{"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":"python","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,"search_vec":"'0.2.3':53 'addit':66 'applic':35 'bind':2,9,12,73 'blockchain':28,68 'common':25 'compat':63 'crate':18 'cryptograph':17,42 'cryptographi':67 'current':50 'ecosystem':29 'effici':39 'enabl':33 'featur':65 'implement':20 'leverag':37 'librari':48 'like':30 'need':58 'new':60 'occur':56 'polkadot':31,69 'primit':43 'provid':10 'py':7 'py-sr25519-bindings':6 'python':1,11,34,61 'releas':55 'rust':16,47,72 'scheme':24 'schnorrkel':4,15,70 'secur':41 'signatur':23 'sr25519':5,8,22,71 'under':46 'use':26 'version':51,62","created_at":"2026-04-15T18:42:50.048286+00:00","updated_at":"2026-04-16T18:17:53.488463+00:00","problems":[{"fix":"Ensure the package is installed using `pip install py-sr25519-bindings` and that you are importing the correct module: `import sr25519`.","cause":"The `py-sr25519-bindings` package was either not installed correctly, or the Python interpreter cannot find the installed module.","error":"ModuleNotFoundError: No module named 'sr25519'"},{"fix":"Install the Rust toolchain by following instructions on rustup.rs (e.g., `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`). On Windows, ensure you have Visual Studio Build Tools with C++ development workload installed.","cause":"The installation of `py-sr25519-bindings` requires a Rust compiler and potentially C/C++ build tools to compile its underlying Rust dependencies, which are not found on the system.","error":"error: failed to run custom build command for `sr25519-dalek-derive v...` (or similar Rust compilation errors during installation)"},{"fix":"Refer to the `py-sr25519-bindings` documentation or the example usage on its PyPI page to ensure correct function calls and attribute access (e.g., `sr25519.pair_from_seed`, `sr25519.sign`, `sr25519.verify`).","cause":"This error occurs when trying to call a function or access an attribute that does not exist within the `sr25519` module, or there's a mismatch between the expected API and the installed version.","error":"AttributeError: module 'sr25519' has no attribute 'some_function'"},{"fix":"Ensure that the Microsoft Visual C++ Redistributable for Visual Studio is installed. Updating your system and Python environment, or installing the correct build tools (as for Rust compilation issues), can also resolve this.","cause":"This typically occurs on Windows when a dynamically linked library (DLL) required by the Rust-based Python extension cannot be found or loaded, often due to missing C++ redistributables or environment PATH issues.","error":"ImportError: DLL load failed: The specified procedure could not be found."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.2.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/JAMdotTech/py-sr25519","docs":null,"changelog":null,"pypi":"https://pypi.org/project/py-sr25519-bindings/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}