Registry / auth-security / py-sr25519-bindings

py-sr25519-bindings

JSON →
library0.2.3pypypi✓ verified 88d ago

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-bindings
INSTALL
IMPORT
SIG · PY-SR25519-BINDING
P
py-sr25519-bindings
auth-securitypythonv0.2.3
Install
1.6s avg
Import
—
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sr25519
✓ import sr25519

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.

import sr25519 import bip39 # This library is a suggested optional dependency for key generation. message = b"test_message" # Get private and public key from a BIP-39 seed # Note: bip39 is an external dependency not automatically installed with py-sr25519-bindings seed_phrase = 'daughter song common combine misery cotton audit morning stuff weasel flee field' seed = bip39.bip39_to_mini_secret(seed_phrase, '') public_key, private_key = sr25519.pair_from_seed(bytes(seed)) print(f"Public Key: {public_key.hex()}") print(f"Private Key (seed): {private_key.hex()}") # Generate signature signature = sr25519.sign((public_key, private_key), message) print(f"Signature: {signature.hex()}") # Verify message with signature is_verified = sr25519.verify(signature, message, public_key) if is_verified: print('Signature Verified: True') else: print('Signature Verified: False')
Debug
Known issues
gotchaThe 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.
fix
Install `bip39` alongside `py-sr25519-bindings` if you need to generate keys from mnemonic phrases: `pip install bip39`.
affects: All versions
gotchaExplicit 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.
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.
affects: <0.2.3
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'sr25519'
The `py-sr25519-bindings` package was either not installed correctly, or the Python interpreter cannot find the installed module.
fix
Ensure the package is installed using `pip install py-sr25519-bindings` and that you are importing the correct module: `import sr25519`.
error: failed to run custom build command for `sr25519-dalek-derive v...` (or similar Rust compilation errors during installation)
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.
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.
AttributeError: module 'sr25519' has no attribute 'some_function'
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.
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`).
ImportError: DLL load failed: The specified procedure could not be found.
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.
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.
Upgrade
Version history
0.2.3latest on PyPI · released Nov 20, 2025
Audit
Dependencies
bip39optionalRequired for the common use case of generating sr25519 keys from BIP-39 mnemonics, as shown in the quickstart examples.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
py-sr25519-bindings — pip install py-sr25519-bindings · libregistry