Crates.io | lamport_signature_plus |
lib.rs | lamport_signature_plus |
version | 0.3.0 |
source | src |
created_at | 2024-04-16 18:27:19.692329 |
updated_at | 2024-04-17 16:34:12.449373 |
description | An implementation of the Lamport one-time signature scheme. |
homepage | |
repository | https://github.com/mikelodder7/lamport_signature_plus |
max_upload_size | |
id | 1210510 |
size | 70,861 |
lamport_signature
lamport_signature_plus is an implementation of the Lamport one-time signature scheme.
Documentation is available here.
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.
This crate supports threshold signing by first splitting the SigningKey
into shares and creating
SignatureShare
s from each share. The SignatureShare
s 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());
Licensed under either of
at your option.
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.