signature/prehash_signature.rs
1//! `PrehashSignature` trait.
2
3/// For intra-doc link resolution.
4#[allow(unused_imports)]
5use crate::{
6 signer::{DigestSigner, Signer},
7 verifier::{DigestVerifier, Verifier},
8};
9
10/// Marker trait for `Signature` types computable as `𝐒(𝐇(𝒎))`
11/// i.e. ones which prehash a message to be signed as `𝐇(𝒎)`
12///
13/// Where:
14///
15/// - `𝐒`: signature algorithm
16/// - `𝐇`: hash (a.k.a. digest) function
17/// - `𝒎`: message
18///
19/// This approach is relatively common in signature schemes based on the
20/// [Fiat-Shamir heuristic].
21///
22/// For signature types that implement this trait, when the `derive` crate
23/// feature is enabled a custom derive for [`Signer`] is available for any
24/// types that impl [`DigestSigner`], and likewise for deriving [`Verifier`] for
25/// types which impl [`DigestVerifier`].
26///
27/// [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic
28pub trait PrehashSignature {
29 /// Preferred `Digest` algorithm to use when computing this signature type.
30 type Digest: digest::Digest;
31}