#signature-scheme #signature #lamports #threshold-signature

lamport_signature_plus

An implementation of the Lamport one-time signature scheme

2 unstable releases

0.3.0 Apr 17, 2024
0.2.0 Apr 16, 2024

#1863 in Cryptography

29 downloads per month

MIT/Apache

47KB
948 lines

lamport_signature

Crates.io docs.rs GitHub license

lamport_signature_plus is an implementation of the Lamport one-time signature scheme.

Documentation

Documentation is available here.

Usage

use lamport_signature::{VerifyingKey, SigningKey, LamportFixedDigest};
use sha2::Sha256;
use rand::thread_rng;

let mut signing_key = SigningKey::<LamportFixedDigest<Sha256>>::random(thread_rng());
let verifying_key = VerifyingKey::from(&signing_key);

let signature = signing_key.sign(b"Hello, World!").expect("signing failed");

assert!(verifying_key.verify(&signature, b"Hello, World!").is_ok());

This crate supports any hash function that implements the Digest trait from the digest crate or ExtendableOutputFunction. The SigningKey, VerifyingKey, and Signature types are generic over the hash function used.

Threshold Signatures

This crate supports threshold signing by first splitting the SigningKey into shares and creating SignatureShares from each share. The SignatureShares can then be combined into a Signature using the combine method.

use lamport_signature::{VerifyingKey, SigningKey, LamportFixedDigest};
use sha2::Sha256;

let mut rng = rand_chacha::ChaCha8Rng::from_seed(SEED);
let (sk, pk) = generate_keys::<LamportFixedDigest<Sha256>, _>(&mut rng);
let message = b"hello, world!";
let mut shares = sk.split(3, 5, &mut rng).unwrap();
let signatures = shares
    .iter_mut()
    .map(|share| share.sign(message).unwrap())
    .collect::<Vec<_>>();

let res = Signature::combine(&signatures[..3]);
assert!(res.is_ok());
let signature = res.unwrap();
assert!(pk.verify(&signature, message).is_ok());

License

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Dependencies

~5MB
~87K SLoC