Closed fgimenez closed 1 year ago
The PrivateKey
and PublicKey
objects correspond to curve25519, which is birationally equivalent to the ed25519 curve, but is not the same. You want to use SigningKey
and VerifyKey
in nacl.signing
.
from nacl.public import PrivateKey
from nacl.encoding import HexEncoder
sign_key = SigningKey(bytes.fromhex('a4421cf8f5594287e6cbc47e6a465d9ba70e20ed28199c8712d59665bb95fdda'))
verify_key = sign_key.verify_key
print('sign key: ' + sign_key.encode(HexEncoder).decode('utf-8'))
print('verify key: ' + verify_key.encode(HexEncoder).decode('utf-8'))
This should give you the value you expect.
Awesome, thank you so much @reaperhulk! :heart:
I have the following code:
this gives me:
but other the libraries (like the rust version used in libp2p) or online tools like https://cyphr.me/ed25519_applet/ed.html#?msg_encoding=Text&msg_type=Msg&key_encoding=Hex give me
C737701E24FE1A3449A54F4CA86626B55D0D87CD6546D315F02611D538E5C63C
as the public key corresponding to the same private key, I've checked and this is the public key in compressed Edwards Y format.So, is it possible to obtain this format of the public key using pynacl?
Thanks!