2 个版本
0.1.2 | 2020年11月15日 |
---|---|
0.1.1 | 2020年8月28日 |
#2102 in 加密
12KB
112 行
py-ed25519-bindings
ed25519-dalek RUST 包的 Python 绑定
文档
https://docs.rs/py-ed25519-bindings
安装
从 PyPI 安装
pip install py-ed25519-bindings
为本地开发编译
pip install -r requirements.txt
maturin develop
构建 wheelhouse
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 ed25519
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','')
private_key, public_key = ed25519.ed_from_seed(bytes(seed))
# Generate signature
signature = ed25519.ed_sign(public_key, private_key, message)
print(signature.hex())
# Verify message with signature
if ed25519.ed_verify(signature, message, public_key):
print('Verified')
许可证
https://github.com/polkascan/py-ed25519-bindings/blob/master/LICENSE
依赖项
~7MB
~133K SLoC