pyca / pynacl

Python binding to the Networking and Cryptography (NaCl) library
https://pynacl.readthedocs.io/
Apache License 2.0
1.06k stars 233 forks source link

Why is there a 32 byte signing key for ed25519? #708

Closed mr-pandabear closed 2 years ago

mr-pandabear commented 2 years ago

I'm trying to write some python code that is one to one with a C++ codebase using the following Ed25519 library: https://github.com/orlp/ed25519

My understanding is that Ed25519 uses a 64byte private key and 32byte public key, however when using pynacl and running the following code I get two keys each of 32 bytes:

    # Generate a new random signing key
    signing_key = SigningKey.generate()
    verify_key = signing_key.verify_key

    # Serialize the verify key to send it to a third party
    verify_key_hex = verify_key.encode(encoder=HexEncoder)
    signing_key_hex = signing_key.encode(encoder=HexEncoder)

    print(str(verify_key_hex, encoding='utf8').upper())
    print(str(signing_key_hex, encoding='utf8').upper())

Is there a way I can get the full 64 bytes of the signing key?

reaperhulk commented 2 years ago

The value you're obtaining is the seed. In the library you've linked you can create the public/private pair from the seed with ed25519_create_keypair.