Trait diem_sdk::crypto::Signature [−][src]
pub trait Signature: for<'a> TryFrom<&'a [u8], Error = CryptoMaterialError> + Debug + Clone + Eq + Hash + Sealed {
type VerifyingKeyMaterial: VerifyingKey;
type SigningKeyMaterial: SigningKey;
fn verify<T>(
&self,
message: &T,
public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error>
where
T: CryptoHash + Serialize;
fn verify_arbitrary_msg(
&self,
message: &[u8],
public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error>;
fn to_bytes(&self) -> Vec<u8, Global>;
fn batch_verify<T>(
message: &T,
keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self), Global>
) -> Result<(), Error>
where
T: CryptoHash + Serialize,
{ ... }
}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.
Associated Types
The associated verifying key type for this signature.
The associated signing key type for this signature
Required methods
fn verify<T>(
&self,
message: &T,
public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error> where
T: CryptoHash + Serialize,
fn verify<T>(
&self,
message: &T,
public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error> where
T: CryptoHash + Serialize,
Verification for a struct we unabmiguously know how to serialize and that we have a domain separation prefix for.
fn verify_arbitrary_msg(
&self,
message: &[u8],
public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error>
fn verify_arbitrary_msg(
&self,
message: &[u8],
public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error>
Native verification function.
Provided methods
fn batch_verify<T>(
message: &T,
keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self), Global>
) -> Result<(), Error> where
T: CryptoHash + Serialize,
fn batch_verify<T>(
message: &T,
keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self), Global>
) -> Result<(), Error> where
T: CryptoHash + Serialize,
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.