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.
pip install py-sr25519-bindingsVerified import paths — ran on the pinned version, not inferred.
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.
Install `bip39` alongside `py-sr25519-bindings` if you need to generate keys from mnemonic phrases: `pip install bip39`.
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.
Ensure the package is installed using `pip install py-sr25519-bindings` and that you are importing the correct module: `import sr25519`.
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.
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`).
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.