{"id":6784,"library":"py-sr25519-bindings","title":"Python Bindings for Schnorrkel (sr25519)","description":"py-sr25519-bindings provides Python bindings for the `schnorrkel` RUST cryptographic crate, which implements the sr25519 signature scheme commonly used in blockchain ecosystems like Polkadot. It enables Python applications to leverage the efficient and secure cryptographic primitives from the underlying Rust library. The current version is 0.2.3, with releases occurring as needed for new Python version compatibility and feature additions.","status":"active","version":"0.2.3","language":"en","source_language":"en","source_url":"https://github.com/JAMdotTech/py-sr25519","tags":["cryptography","blockchain","polkadot","schnorrkel","sr25519","rust","bindings"],"install":[{"cmd":"pip install py-sr25519-bindings","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for the common use case of generating sr25519 keys from BIP-39 mnemonics, as shown in the quickstart examples.","package":"bip39","optional":true}],"imports":[{"symbol":"sr25519","correct":"import sr25519"}],"quickstart":{"code":"import sr25519\nimport bip39 # This library is a suggested optional dependency for key generation.\n\nmessage = b\"test_message\"\n\n# Get private and public key from a BIP-39 seed\n# Note: bip39 is an external dependency not automatically installed with py-sr25519-bindings\nseed_phrase = 'daughter song common combine misery cotton audit morning stuff weasel flee field'\nseed = bip39.bip39_to_mini_secret(seed_phrase, '')\npublic_key, private_key = sr25519.pair_from_seed(bytes(seed))\n\nprint(f\"Public Key: {public_key.hex()}\")\nprint(f\"Private Key (seed): {private_key.hex()}\")\n\n# Generate signature\nsignature = sr25519.sign((public_key, private_key), message)\nprint(f\"Signature: {signature.hex()}\")\n\n# Verify message with signature\nis_verified = sr25519.verify(signature, message, public_key)\nif is_verified:\n    print('Signature Verified: True')\nelse:\n    print('Signature Verified: False')","lang":"python","description":"This quickstart demonstrates how to generate a key pair from a BIP-39 mnemonic phrase (requiring the optional `bip39` library), sign a message, and verify the signature using the `sr25519` module. It illustrates the core functionality for cryptographic operations."},"warnings":[{"fix":"Install `bip39` alongside `py-sr25519-bindings` if you need to generate keys from mnemonic phrases: `pip install bip39`.","message":"The quickstart examples and many practical use cases rely on the `bip39` Python library for generating sr25519 key pairs from mnemonic phrases. This library is not a direct dependency of `py-sr25519-bindings` and must be installed separately.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use the latest version of `py-sr25519-bindings` to ensure the broadest Python version support. Check the PyPI page or GitHub releases for explicit compatibility notes if encountering issues with newer Python interpreters.","message":"Explicit compatibility with newer Python versions (e.g., 3.10, 3.12, 3.13, 3.14) is frequently added in specific releases. Users on newer or less common Python versions should verify the latest `py-sr25519-bindings` release supports their interpreter version to avoid compatibility issues.","severity":"gotcha","affected_versions":"<0.2.3"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}