summaryrefslogtreecommitdiffstats
path: root/vendor/signature/src/prehash_signature.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/signature/src/prehash_signature.rs')
-rw-r--r--vendor/signature/src/prehash_signature.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/signature/src/prehash_signature.rs b/vendor/signature/src/prehash_signature.rs
new file mode 100644
index 000000000..d9a86456d
--- /dev/null
+++ b/vendor/signature/src/prehash_signature.rs
@@ -0,0 +1,31 @@
+//! `PrehashSignature` trait.
+
+/// For intra-doc link resolution.
+#[allow(unused_imports)]
+use crate::{
+ signer::{DigestSigner, Signer},
+ verifier::{DigestVerifier, Verifier},
+};
+
+/// Marker trait for `Signature` types computable as `𝐒(𝐇(𝒎))`
+/// i.e. ones which prehash a message to be signed as `𝐇(𝒎)`
+///
+/// Where:
+///
+/// - `𝐒`: signature algorithm
+/// - `𝐇`: hash (a.k.a. digest) function
+/// - `𝒎`: message
+///
+/// This approach is relatively common in signature schemes based on the
+/// [Fiat-Shamir heuristic].
+///
+/// For signature types that implement this trait, when the `derive` crate
+/// feature is enabled a custom derive for [`Signer`] is available for any
+/// types that impl [`DigestSigner`], and likewise for deriving [`Verifier`] for
+/// types which impl [`DigestVerifier`].
+///
+/// [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic
+pub trait PrehashSignature {
+ /// Preferred `Digest` algorithm to use when computing this signature type.
+ type Digest: digest::Digest;
+}