pyca / pyca/pynacl

Signature example

Open
#768 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.2k
Forks
267
Avg merge
42m
Merged PRs (30d)
2

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PyNaCl signing documentation and the from PyNaCl.signing import SigningKey entry point shown in the issue. Verify the documented installation and import steps, then provide a minimum working signature example with enough explanation for a novice; done means the example runs and resolves the reported ModuleNotFoundError confusion.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cryptography, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.