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;
}
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

Get the 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.

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§

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

Source§

impl Signer<P256> for SigningKey

Source§

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

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§

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

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<PublicKey: Clone + Send + Sync>, S: Signer<C>,

Source§

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