Crates.io | py-sr25519-bindings |
lib.rs | py-sr25519-bindings |
version | 0.1.2 |
source | src |
created_at | 2020-08-27 12:45:51.728118 |
updated_at | 2020-08-27 12:45:51.728118 |
description | Python bindings for sr25519 library |
homepage | https://github.com/polkascan/py-sr25519-bindings |
repository | https://github.com/polkascan/py-sr25519-bindings |
max_upload_size | |
id | 281417 |
size | 42,537 |
Python bindings for sr25519 library: https://github.com/w3f/schnorrkel
Reference to https://github.com/LocalCoinSwap/kusama-reference-implementation/tree/improve-trading-tests/bindings and https://gitlab.com/kauriid/schnorrpy/ for the initial work
pip install py-sr25519-bindings
pip install -r requirements.txt
maturin develop
pip install -r requirements.txt
# Build local OS wheelhouse
maturin build
# Build manylinux1 wheelhouse
docker build . --tag polkasource/maturin
docker run --rm -i -v $(pwd):/io polkasource/maturin build
import bip39
import sr25519
message = b"test"
# Get private and public key from seed
seed = bip39.bip39_to_mini_secret('daughter song common combine misery cotton audit morning stuff weasel flee field','')
public_key, private_key = sr25519.pair_from_seed(bytes(seed))
# Generate signature
signature = sr25519.sign(
(public_key, private_key),
message
)
print('Signature', signature.hex())
# Verify message with signature
if sr25519.verify(signature, message, public_key):
print('Verified')
https://github.com/polkascan/py-sr25519-bindings/blob/master/LICENSE