user3531900
user3531900

Reputation: 321

Generate 33 bytes public key for curve25519 in python

Using Java's spongycastle, i am able to generate curve25519 private keys(32 bytes) and public keys(33 bytes).

Similarly for Python, i am using Nacl library for curve25519 but here public key generated is of 32 bytes only. The one byte of y co-ordinate is missing in public key.

from nacl.public import PrivateKey
import binascii

privKey = PrivateKey.generate()
pubKey = privKey.public_key

print("privKey:", binascii.hexlify(bytes(privKey)))
print("pubKey: ", binascii.hexlify(bytes(pubKey)))

any suggestion why Nacl library is not compressing the public key ?

Upvotes: 1

Views: 830

Answers (1)

nil
nil

Reputation: 11

spongycastle(Java) and PyNacl(Python) are totally two different libraries.

PyNacl(Python) and LazySodiumJava(Java) derive from C library libsodium, they can only generate 32bit key.

I think maybe you could look for other Python packages, which is consistent with spongycastle(Java).

Upvotes: 0

Related Questions