Trait Signer

Source
pub trait Signer:
    Send
    + Sync
    + Clone
    + 'static {
    type Signature: Signature;
    type PublicKey: PublicKey<Signature = Self::Signature>;

    // Required methods
    fn public_key(&self) -> Self::PublicKey;
    fn sign(&self, namespace: Option<&[u8]>, msg: &[u8]) -> Self::Signature;
}
Expand description

Produces Signatures over messages that can be verified with a corresponding PublicKey.

Required Associated Types§

Source

type Signature: Signature

The type of Signature produced by this Signer.

Source

type PublicKey: PublicKey<Signature = Self::Signature>

The corresponding PublicKey type.

Required Methods§

Source

fn public_key(&self) -> Self::PublicKey

Returns the PublicKey corresponding to this Signer.

Source

fn sign(&self, namespace: Option<&[u8]>, msg: &[u8]) -> Self::Signature

Sign a message with the given namespace.

The message should not be hashed prior to calling this function. If a particular scheme requires a payload to be hashed before it is signed, it will be done internally.

A namespace should be used to prevent cross-domain attacks (where a signature can be reused in a different context). It must be prepended to the message so that a signature meant for one context cannot be used unexpectedly in another (i.e. signing a message on the network layer can’t accidentally spend funds on the execution layer). See union_unique for details.

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.

Implementors§

Source§

impl Signer for commonware_cryptography::bls12381::PrivateKey

Source§

impl Signer for commonware_cryptography::ed25519::PrivateKey

Source§

impl Signer for commonware_cryptography::secp256r1::PrivateKey