Trait commonware_p2p::crypto::Crypto

source ·
pub trait Crypto:
    Send
    + Sync
    + Clone
    + 'static {
    // Required methods
    fn me(&self) -> PublicKey;
    fn sign(&mut self, dst: &[u8], data: &[u8]) -> Signature;
    fn validate(public_key: &PublicKey) -> bool;
    fn verify(
        dst: &[u8],
        data: &[u8],
        public_key: &PublicKey,
        signature: &Signature,
    ) -> bool;
}
Expand description

Cryptographic operations required by commonware-p2p.

§Warning

Although data provided to this implementation to be signed are expected to be unique to commonware-p2p, it is strongly recommended to prefix any payloads with a unique identifier (dst) to prevent replay attacks.

Required Methods§

source

fn me(&self) -> PublicKey

Returns the public key of the signer.

source

fn sign(&mut self, dst: &[u8], data: &[u8]) -> Signature

Sign the given data (usually an IP).

source

fn validate(public_key: &PublicKey) -> bool

Verify that a public key is well-formatted.

source

fn verify( dst: &[u8], data: &[u8], public_key: &PublicKey, signature: &Signature, ) -> bool

Check that a signature is valid for the given data and public key.

Object Safety§

This trait is not object safe.

Implementors§