Crates.io | schnorr_fun |
lib.rs | schnorr_fun |
version | 0.10.0 |
source | src |
created_at | 2020-07-29 07:46:51.197323 |
updated_at | 2024-02-19 03:01:20.308324 |
description | BIP340 Schnorr signatures based on secp256kfun |
homepage | https://github.com/LLFourn/secp256kfun/tree/master/schnorr_fun |
repository | https://github.com/LLFourn/secp256kfun |
max_upload_size | |
id | 270848 |
size | 202,349 |
Generate and verify Schnorr signatures on secp256k1. Built on secp256kfun.
Schnorr signatures were introduced (and patented until 2008) by their namesake in Efficient Signature Generation by Smart Cards. This implementation is based on the BIP-340 specification, but is flexible enough to be used as a general purpose Schnorr signature scheme.
[dependencies]
schnorr_fun = "0.10"
sha2 = "0.10"
This library and secp256kfun are experimental.
use schnorr_fun::{
fun::{marker::*, Scalar, nonce},
Schnorr,
Message
};
use sha2::Sha256;
use rand::rngs::ThreadRng;
// Use synthetic nonces
let nonce_gen = nonce::Synthetic::<Sha256, nonce::GlobalRng<ThreadRng>>::default();
let schnorr = Schnorr::<Sha256, _>::new(nonce_gen.clone());
// Generate your public/private key-pair
let keypair = schnorr.new_keypair(Scalar::random(&mut rand::thread_rng()));
// Sign a variable length message
let message = Message::<Public>::plain("the-times-of-london", b"Chancellor on brink of second bailout for banks");
// Sign the message with our keypair
let signature = schnorr.sign(&keypair, message);
// Get the verifier's key
let verification_key = keypair.public_key();
// Check it's valid 🍿
assert!(schnorr.verify(&verification_key, message, &signature));
rust-secp256k1
's schnorr signature types with libsecp_compat
feature.serde
: for serde implementations for signaturesbincode
: for bincode
v2 Encode
/Decode
implementationslibsecp_compat
: for From
implementations between rust-secp256k1
's Schnorr signatures.proptest
to enable secp256kfun/proptest
.share_backup
to enable bech32 backups of FROST secret shares