-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It is awkward to instantiate a SigningKey from its value. #419
Comments
@dmerejkowsky would you mind giving some more details about the raw keypairs you are dealing with, and in particular the environment in which they have been generated in the first place? Are the secret and the public part both available, or only the secret? Thank you. |
The keys have been generated in Javascript (using libsodium-wrapper by the way). The public and private keys are both available. Since I opened the bug we thought more about the problem a bit more and discovered we could just use the lower-lever API in nacl.bindings directly: from nacl.bindings.crypto_sign import crypto_sign, crypot_sign_open, crypto_sign_BYTES
# generate a detached signature:
combined = crypto_sign(message, raw_signing_key)
return combined[:crypto_sign_BYTES]
# check the signature is correct
combined = signature + message
crypto_sign_open(combined, raw_verify_key) So, feel free to close this issue :) |
@dmerejkowsky Thank you very much for following up! The reason for asking whether you were in possession of the verification key or not was to understand if an API requiring both would be enough for your needs. |
As I was stuck on the same problem (Seed != SecretKey) when trying to sign and validate using a private/secret keypair generated in another language I'd like to add my solution hoping that it serves others:
|
Use case:
We have a signing keypair that has been generated by an other program in a different language, and we need to sign and verify messages with them.
The naive way does not work:
That's because the SigningKey constructor expects a seed, not the value:
We have a workaround, though:
We assing the
_signing_key
variable directly:And then we can verify the signature by instantiating a VerifyKey directly:
Of course, this is a bad idea because if you use
signing_key.verify_key
you get the wrong key ...Proposed fix
Maybe we could have something like this instead ?
And then:
Thoughts ?
The text was updated successfully, but these errors were encountered: