pub trait Signature:
for<'a> TryFrom<&'a [u8], Error = CryptoMaterialError>
+ Sized
+ Debug
+ Clone
+ Eq
+ Hash
+ Sealed {
type VerifyingKeyMaterial: VerifyingKey<SignatureMaterial = Self>;
type SigningKeyMaterial: SigningKey<SignatureMaterial = Self>;
// Required methods
fn verify<T: CryptoHash + Serialize>(
&self,
message: &T,
public_key: &Self::VerifyingKeyMaterial,
) -> Result<()>;
fn verify_arbitrary_msg(
&self,
message: &[u8],
public_key: &Self::VerifyingKeyMaterial,
) -> Result<()>;
// Provided method
fn batch_verify<T: CryptoHash + Serialize>(
message: &T,
keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self)>,
) -> Result<()> { ... }
}
Expand description
A type family for signature material that knows which public key type is needed to verify it, and given such a public key, knows how to verify.
This trait simply requires an association to some type of the
PublicKey
family of which we are the SignatureMaterial
.
This trait has a requirement on a pub(crate)
marker trait meant to
specifically limit its implementations to the present crate.
It should be possible to write a generic signature function that
checks signature material passed as &[u8]
and only returns Ok when
that material de-serializes to a signature of the expected concrete
scheme. This would be done as an extension trait of
Signature
.
Required Associated Types§
Sourcetype VerifyingKeyMaterial: VerifyingKey<SignatureMaterial = Self>
type VerifyingKeyMaterial: VerifyingKey<SignatureMaterial = Self>
The associated verifying key type for this signature.
Sourcetype SigningKeyMaterial: SigningKey<SignatureMaterial = Self>
type SigningKeyMaterial: SigningKey<SignatureMaterial = Self>
The associated signing key type for this signature
Required Methods§
Sourcefn verify<T: CryptoHash + Serialize>(
&self,
message: &T,
public_key: &Self::VerifyingKeyMaterial,
) -> Result<()>
fn verify<T: CryptoHash + Serialize>( &self, message: &T, public_key: &Self::VerifyingKeyMaterial, ) -> Result<()>
Verification for a struct we unabmiguously know how to serialize and that we have a domain separation prefix for.
Sourcefn verify_arbitrary_msg(
&self,
message: &[u8],
public_key: &Self::VerifyingKeyMaterial,
) -> Result<()>
fn verify_arbitrary_msg( &self, message: &[u8], public_key: &Self::VerifyingKeyMaterial, ) -> Result<()>
Native verification function.
Provided Methods§
Sourcefn batch_verify<T: CryptoHash + Serialize>(
message: &T,
keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self)>,
) -> Result<()>
fn batch_verify<T: CryptoHash + Serialize>( message: &T, keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self)>, ) -> Result<()>
The implementer can override a batch verification implementation that by default iterates over each signature. More efficient implementations exist and should be implemented for many schemes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.