pure25519

raw JSON →
0.0.1 verified Fri May 01 auth: no python

Pure-Python implementation of Curve25519 and Ed25519 cryptographic routines. Current version is 0.0.1, with no recent releases. Provides low-level functions for DH key exchange (Curve25519) and digital signatures (Ed25519). It is a reference implementation not recommended for production use due to lack of constant-time security.

pip install pure25519
error cannot import name 'dh_start' from 'pure25519'
cause Incorrect import path; pure25519 has submodules 'dh' and 'ed25519'.
fix
Use 'from pure25519.dh import dh_start'.
error AttributeError: 'bytes' object has no attribute 'sign'
cause Attempting to sign a message by calling .sign() on the message bytes instead of on a SigningKey object.
fix
Use 'signature = sk.sign(message)' where sk is a SigningKey instance.
error TypeError: expected 32 bytes, got 64
cause Incorrect seed length for SigningKey.from_seed(). Seed must be exactly 32 bytes.
fix
Ensure the seed is 32 bytes long.
gotcha This is a pure-python implementation intended for educational/reference purposes. It does NOT implement constant-time operations and is vulnerable to timing side-channel attacks. Do not use in production.
fix Use a production-grade library like PyNaCl or cryptography.
deprecated The library is essentially unmaintained (last release 2014). Issues may never be fixed.
fix Consider migrating to a maintained library such as PyNaCl or ed25519.
gotcha The ed25519 module uses a custom key object, not the standard bytes interface. Signing with bytes directly will fail.
fix Always use SigningKey.generate() or SigningKey.from_seed() to create keys.

Generate an Ed25519 key pair, sign a message, and verify the signature.

from pure25519.ed25519 import SigningKey, VerifyingKey

sk = SigningKey.generate()
vk = sk.get_verifying_key()
message = b"test message"
signature = sk.sign(message)
assert vk.verify(signature, message)
print("Ed25519 signature roundtrip OK")