hash_based_signatures/signature.rs
1pub mod basic_lamport;
2pub mod q_indexed_signature;
3pub mod stateless_merkle;
4pub mod winternitz;
5
6pub type HashType = [u8; 32];
7
8/// A generic trait that describes a signature scheme.
9///
10/// The general workflow is:
11/// - Instantiating a signature scheme generates a new key pair.
12/// Concrete instantiations have to provide their own way of instantiating
13/// themselves.
14/// - The public key is exposed via `public_key()`
15/// - Messages can be signed using `sign()`
16/// - Signatures can be verified using `verify()`
17pub trait SignatureScheme<PK, M, SIG> {
18 /// Returns a copy of the public key
19 fn public_key(&self) -> PK;
20
21 /// Signs a message
22 fn sign(&mut self, message: M) -> SIG;
23
24 /// Verifies a signature.
25 /// Note that this function does not require need `self`, hence does not need
26 /// an instance of the signature scheme.
27 /// This is because an instance of a signature scheme contains the signing key
28 /// which is typically not available for the verifier.
29 fn verify(pk: PK, message: M, signature: &SIG) -> bool;
30}