Skip to main content

Signer

Trait Signer 

Source
pub trait Signer<C: Curve>: Sync + Send {
    type Error: Debug + Display;

    // Required methods
    fn public_key(&self) -> C::PublicKey;
    fn sign(
        &self,
        msg: &[u8],
    ) -> impl Future<Output = Result<C::Signature, Self::Error>> + Send;

    // Provided method
    fn cache_public_key(self) -> CachePublicKey<C, Self>
       where Self: Sized { ... }
}
Expand description

A signer capable of producing signatures for a specific Curve.

Required Associated Types§

Source

type Error: Debug + Display

An error that can occur during signing.

Required Methods§

Source

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

Public key of the signer

Source

fn sign( &self, msg: &[u8], ) -> impl Future<Output = Result<C::Signature, Self::Error>> + Send

Sign a given message and return a signature.

NOTE: implementations MAY require msg to be prehash (i.e. output of cryptographic hash function) of a fixed length and return an error otherwise. Check corresponding docs before using.

Provided Methods§

Source

fn cache_public_key(self) -> CachePublicKey<C, Self>
where Self: Sized,

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.

Implementations on Foreign Types§

Source§

impl Signer<Ed25519> for SigningKey

Source§

type Error = Infallible

Source§

fn public_key(&self) -> <Ed25519 as Curve>::PublicKey

Source§

async fn sign( &self, msg: &[u8], ) -> Result<<Ed25519 as Curve>::Signature, Self::Error>

Source§

impl Signer<P256> for SigningKey

Source§

async fn sign( &self, prehash: &[u8], ) -> Result<<P256 as Curve>::Signature, Self::Error>

Sign 32-byte prehash (i.e. output of cryptographic hash function).

If given prehash is of different length, an error will be returned.

Source§

type Error = Error

Source§

fn public_key(&self) -> <P256 as Curve>::PublicKey

Source§

impl Signer<Secp256k1> for SigningKey

Source§

async fn sign( &self, prehash: &[u8], ) -> Result<<Secp256k1 as Curve>::Signature, Self::Error>

Sign 32-byte prehash (i.e. output of cryptographic hash function).

If given prehash is of different length, an error will be returned.

Source§

type Error = Error

Source§

fn public_key(&self) -> <Secp256k1 as Curve>::PublicKey

Source§

impl<T: Signer<C> + ?Sized, C: Curve> Signer<C> for &T

Source§

type Error = <T as Signer<C>>::Error

Source§

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

Source§

fn sign( &self, msg: &[u8], ) -> impl Future<Output = Result<C::Signature, Self::Error>> + Send

Source§

impl<T: Signer<C> + ?Sized, C: Curve> Signer<C> for &mut T

Source§

type Error = <T as Signer<C>>::Error

Source§

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

Source§

fn sign( &self, msg: &[u8], ) -> impl Future<Output = Result<C::Signature, Self::Error>> + Send

Source§

impl<T: Signer<C> + ?Sized, C: Curve> Signer<C> for Box<T>

Source§

type Error = <T as Signer<C>>::Error

Source§

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

Source§

fn sign( &self, msg: &[u8], ) -> impl Future<Output = Result<C::Signature, Self::Error>> + Send

Source§

impl<T: Signer<C> + ?Sized, C: Curve> Signer<C> for Arc<T>

Source§

type Error = <T as Signer<C>>::Error

Source§

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

Source§

fn sign( &self, msg: &[u8], ) -> impl Future<Output = Result<C::Signature, Self::Error>> + Send

Implementors§

Source§

impl<C, S> Signer<C> for CachePublicKey<C, S>
where C: Curve, C::PublicKey: Clone + Send + Sync, S: Signer<C>,

Source§

type Error = <S as Signer<C>>::Error