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

type VerifyingKeyMaterial: VerifyingKey[src]

Expand description

The associated verifying key type for this signature.

type SigningKeyMaterial: SigningKey[src]

Expand description

The associated signing key type for this signature

Loading content...

Required methods

fn verify<T>(
    &self,
    message: &T,
    public_key: &Self::VerifyingKeyMaterial
) -> Result<(), Error> where
    T: CryptoHash + Serialize
[src]

Expand description

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>
[src]

Expand description

Native verification function.

fn to_bytes(&self) -> Vec<u8, Global>[src]

Expand description

Convert the signature into a byte representation.

Loading content...

Provided methods

fn batch_verify<T>(
    message: &T,
    keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self), Global>
) -> Result<(), Error> where
    T: CryptoHash + Serialize
[src]

Expand description

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.

Loading content...

Implementors

impl Signature for Ed25519Signature[src]

pub fn verify<T>(
    &self,
    message: &T,
    public_key: &Ed25519PublicKey
) -> Result<(), Error> where
    T: CryptoHash + Serialize
[src]

Verifies that the provided signature is valid for the provided message, according to the RFC8032 algorithm. This strict verification performs the recommended check of 5.1.7 §3, on top of the required RFC8032 verifications.

pub fn verify_arbitrary_msg(
    &self,
    message: &[u8],
    public_key: &Ed25519PublicKey
) -> Result<(), Error>
[src]

Checks that self is valid for an arbitrary &u8 message using public_key. Outside of this crate, this particular function should only be used for native signature verification in move

type VerifyingKeyMaterial = Ed25519PublicKey

type SigningKeyMaterial = Ed25519PrivateKey

pub fn to_bytes(&self) -> Vec<u8, Global>[src]

impl Signature for MultiEd25519Signature[src]

pub fn verify_arbitrary_msg(
    &self,
    message: &[u8],
    public_key: &MultiEd25519PublicKey
) -> Result<(), Error>
[src]

Checks that self is valid for an arbitrary &u8 message using public_key. Outside of this crate, this particular function should only be used for native signature verification in Move.

type VerifyingKeyMaterial = MultiEd25519PublicKey

type SigningKeyMaterial = MultiEd25519PrivateKey

pub fn verify<T>(
    &self,
    message: &T,
    public_key: &MultiEd25519PublicKey
) -> Result<(), Error> where
    T: CryptoHash + Serialize
[src]

pub fn to_bytes(&self) -> Vec<u8, Global>[src]

Loading content...