lamport_signature_plus

Crates.iolamport_signature_plus
lib.rslamport_signature_plus
version0.3.0
sourcesrc
created_at2024-04-16 18:27:19.692329
updated_at2024-04-17 16:34:12.449373
descriptionAn implementation of the Lamport one-time signature scheme.
homepage
repositoryhttps://github.com/mikelodder7/lamport_signature_plus
max_upload_size
id1210510
size70,861
Michael Lodder (mikelodder7)

documentation

https://docs.rs/lamport_signature_plus

README

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.

Commit count: 23

cargo fmt