Skip to content
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

Signature example #768

Open
davejakenic opened this issue Jul 24, 2022 · 1 comment
Open

Signature example #768

davejakenic opened this issue Jul 24, 2022 · 1 comment

Comments

@davejakenic
Copy link

Hi,

I found the following non-deterministic ed25519 signature code in a deprecated library.

import ed25519

privKey, pubKey = ed25519.create_keypair()
print("Private key (32 bytes):", privKey.to_ascii(encoding='hex'))
print("Public key (32 bytes): ", pubKey.to_ascii(encoding='hex'))

msg = b'Message for Ed25519 signing'
signature = privKey.sign(msg, encoding='hex')
print("Signature (64 bytes):", signature)

try:
    pubKey.verify(signature, msg, encoding='hex')
    print("The signature is valid.")
except:
    print("Invalid signature!")

I then pip installed PyNaCl successfully.
I then followed your documentation, from where I got

from PyNaCl.signing import SigningKey
# Generate a new random signing key
signing_key = SigningKey.generate()
# Sign a message with the signing key
signed = signing_key.sign(b"Attack at Dawn")
# Obtain the verify key for a given signing key
verify_key = signing_key.verify_key
# Serialize the verify key to send it to a third party
verify_key_bytes = verify_key.encode()

with either PyNaCl or nacl or NaCl (I tried them all). The result is:

> python .\example_signature_edwards.py
Traceback (most recent call last):
  File "C:\Users\UserName\Desktop\NewPyEnv\example_signature_edwards.py", line 1, in <module>
    from PyNaCl.signing import SigningKey
ModuleNotFoundError: No module named 'PyNaCl'

Can you provide a minimum working example?
I apologize in advance for my apparent inability to get smart of these documentations that I find all around.
Some are uselessly elaborate without giving an actual working example and others are too short, still without giving an actual working example; and again others give working examples that are impossible to understand for someone with a novice math crypto background. Who is the audience?

@alex
Copy link
Member

alex commented Jul 24, 2022

The library is imported as nacl, not PyNaCl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants