Page MenuHome GnuPG

libgcrypt | gcry_mpi_ec_mul return a truncated point coordinate
Closed, ResolvedPublic



Debian 11 amd64


CMake project
GCC 10.2.1 x86_64-linux-gnu

Library version

libgcrypt 1.10.1

Compilation options

no-thread no-shared


Certain parameters for elliptic curve multiplication returns an invalid coordinate truncated by one octet.

void gcry_mpi_ec_mul ( gcry mpi point t w , gcry mpi t n , gcry mpi point t u , gcry ctx t ctx )

For example, with:

  • n = "a2f25788c466cf7a9ef8b9eb5c4a61e5e8075f884cd028b2fb5da6cd16c38efe";
  • u.x = "263B07594BD5E827EEB8F780C3A9FFE0055A75525AD6C9A9284E47B7B96AA17A";
  • u.y = "3E796D06072726397ABBF8025B73B1BB860AF7AC131A99906B1B6DF03628C72A";
  • ctx is "brainpoolP256r1";

I get:

  • w.x = "009216B03BFF68210DE107B8F89726F4923A568150D063FA0C2F7F006507C6C239" (length = 67)
  • w.y = "039E2C9AEC146C5799651C42691A3E35E291B6BC45FF079DDA3E70E709BF33" (length = 63)

What should I get

w.y with a length of 65 or 67 characters (depending on the sign)

Step to reproduce


Thank you :)



Event Timeline

Can you please share the expected result with us? Note that Libgcrypt strips leading zeroes except when it is required to keep the value positive.

You are right, w.y should be "00039E2C9AEC146C5799651C42691A3E35E291B6BC45FF079DDA3E70E709BF33".

Is it written somewhere in libgcrypt documentation that leading zeroes are stripped ?

Thank you for your very quick help.

werner claimed this task.

I added a remark to the print function. Thanks for the suggestion.

Your quick support solve my problem, I am thanking you :)
Bye bye