24 releases

0.10.0 Feb 19, 2024
0.9.1 Jul 12, 2023
0.8.2 Dec 16, 2022
0.7.1 May 6, 2022
0.1.1 Jul 29, 2020

#4 in #frost

Download history 3470/week @ 2024-06-15 3034/week @ 2024-06-22 2923/week @ 2024-06-29 3070/week @ 2024-07-06 2959/week @ 2024-07-13 2802/week @ 2024-07-20 2563/week @ 2024-07-27 3606/week @ 2024-08-03 2891/week @ 2024-08-10 3370/week @ 2024-08-17 2856/week @ 2024-08-24 2846/week @ 2024-08-31 2550/week @ 2024-09-07 2313/week @ 2024-09-14 2535/week @ 2024-09-21 2308/week @ 2024-09-28

9,978 downloads per month

0BSD license

465KB
8K SLoC

SchnorrFun! crates_badge docs_badge

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.

Use

[dependencies]
schnorr_fun = "0.10"
sha2 = "0.10"

Should use?

This library and secp256kfun are experimental.

Synopsis

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

Features

  • BIP-340 compliant signing and verification
  • Adaptor signatures
  • compatibility with rust-secp256k1's schnorr signature types with libsecp_compat feature.
  • MuSig2 implementation compatible with the spec.
  • WIP FROST implementation
  • Feature flags
    • serde: for serde implementations for signatures
    • bincode: for bincode v2 Encode/Decode implementations
    • libsecp_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

Dependencies

~0.4–2MB
~31K SLoC