Coder Social home page Coder Social logo

squirrel-nation / py-sr25519-bindings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polkascan/py-sr25519-bindings

0.0 1.0 0.0 38 KB

Python bindings for the RUST implementation of the sr25519 cryptography library

License: Apache License 2.0

Dockerfile 0.18% Shell 0.68% Rust 87.67% Python 11.46%

py-sr25519-bindings's Introduction

py-sr25519-bindings

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

Documentation

https://docs.rs/py-sr25519-bindings

Installation

Install from PyPI

pip install py-sr25519-bindings

Compile for local development

pip install -r requirements.txt
maturin develop

Build wheelhouses

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

Usage

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')

License

https://github.com/polkascan/py-sr25519-bindings/blob/master/LICENSE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.