{"id":8459,"library":"py-ed25519-zebra-bindings","title":"Py-ed25519-zebra-bindings","description":"Python bindings for the `ed25519-zebra` Rust crate, providing high-performance cryptographic operations for Ed25519 digital signatures. It's currently at version 1.3.0 and has a moderate release cadence, driven by updates to the underlying Rust dependencies and Python version support, ensuring compatibility and performance.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/polkascan/py-ed25519-zebra-bindings","tags":["cryptography","ed25519","signatures","rust","bindings"],"install":[{"cmd":"pip install py-ed25519-zebra-bindings","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"generate_keypair","correct":"from ed25519_zebra import generate_keypair"},{"symbol":"sign","correct":"from ed25519_zebra import sign"},{"symbol":"verify","correct":"from ed25519_zebra import verify"},{"symbol":"PublicKey","correct":"from ed25519_zebra import PublicKey"},{"symbol":"SecretKey","correct":"from ed25519_zebra import SecretKey"},{"symbol":"ed_public_from_secret","correct":"from ed25519_zebra import ed_public_from_secret"}],"quickstart":{"code":"from ed25519_zebra import generate_keypair, sign, verify, PublicKey, SecretKey, ed_public_from_secret\n\n# Generate a new keypair\nsecret_key, public_key = generate_keypair()\nprint(f\"Secret Key: {secret_key.to_bytes().hex()}\")\nprint(f\"Public Key: {public_key.to_bytes().hex()}\")\n\n# Message to sign (must be bytes)\nmessage = b\"This is a test message to be signed.\"\n\n# Sign the message\nsignature = sign(secret_key, message)\nprint(f\"Signature: {signature.to_bytes().hex()}\")\n\n# Verify the signature\nis_valid = verify(public_key, signature, message)\nprint(f\"Signature valid: {is_valid}\")\n\n# Example of converting bytes to key objects\npublic_key_bytes = public_key.to_bytes()\nsecret_key_bytes = secret_key.to_bytes()\n\nreconstructed_public_key = PublicKey.from_bytes(public_key_bytes)\nreconstructed_secret_key = SecretKey.from_bytes(secret_key_bytes)\n\nprint(f\"Reconstructed Public Key Matches: {reconstructed_public_key == public_key}\")\nprint(f\"Reconstructed Secret Key Matches: {reconstructed_secret_key == secret_key}\")\n\n# Derived public key from secret (available from v1.1.0+)\nderived_public_key = ed_public_from_secret(secret_key)\nprint(f\"Derived Public Key from Secret Matches: {derived_public_key == public_key}\")","lang":"python","description":"This example demonstrates how to generate an Ed25519 keypair, sign a message with the secret key, and then verify the signature using the public key. It also shows how to convert keys to and from byte representations and derive the public key from a secret key."},"warnings":[{"fix":"Always ensure messages are `bytes` (e.g., `b\"your_message\"`) and use `SecretKey.from_bytes()` or `PublicKey.from_bytes()` when loading keys from raw bytes.","message":"Type Mismatches for Cryptographic Operations. Functions like `sign` and `verify` expect byte strings (`bytes`) for messages and specific key/signature objects (`SecretKey`, `PublicKey`, `Signature`). Passing regular `str` objects or incorrect types will lead to `TypeError`.","severity":"gotcha","affected_versions":"All"},{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Minimum Python Version. The library requires Python 3.9 or higher. Attempting to install or run on older Python versions will result in installation failures or runtime errors.","severity":"breaking","affected_versions":"All versions >= 1.0.0"},{"fix":"Ensure Rust and Cargo are installed (e.g., `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`) or switch to a platform/Python version with available wheels.","message":"Source Compilation Requirements. If pre-built wheels are not available for your specific OS/architecture/Python version, `pip` will attempt to build the library from source, which requires a Rust toolchain (Rust compiler, Cargo).","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your `py-ed25519-zebra-bindings` version is 1.1.0 or newer if you need to use `ed_public_from_secret`.","message":"New Functions in Newer Versions. The `ed_public_from_secret` function was added in v1.1.0. Attempting to use this function in versions prior to 1.1.0 will result in an `AttributeError`.","severity":"breaking","affected_versions":"< 1.1.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure correct installation and import: `pip install py-ed25519-zebra-bindings` then `from ed25519_zebra import ...`.","cause":"The package `py-ed25519-zebra-bindings` was installed, but the Python module it provides is named `ed25519_zebra`. Or the package was not installed at all.","error":"ModuleNotFoundError: No module named 'ed25519_zebra'"},{"fix":"Encode your string to bytes, e.g., `message.encode('utf-8')` or use a byte literal `b\"my message\"`.","cause":"Cryptographic functions within `ed25519_zebra` require messages to be `bytes`, not `str`.","error":"TypeError: argument 'message': 'str' object cannot be converted to 'bytes'"},{"fix":"Check PyPI for available wheels (`https://pypi.org/project/py-ed25519-zebra-bindings/#files`). If none, ensure you have a Rust toolchain installed to build from source, or use a supported Python version/platform. Alternatively, you might see `error: can't find Rust compiler` if a source build is attempted without Rust.","cause":"No pre-built wheels are available for your specific Python version and/or operating system/architecture. This often happens on less common platforms or with very new Python versions before wheels are released.","error":"ERROR: Could not find a version that satisfies the requirement py-ed25519-zebra-bindings (from versions: none)"}]}