Trait Signer

Source
pub trait Signer: Send + Sync {
    // Required methods
    fn sign<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SigningError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn public_key(&self) -> &[u8] ;
    fn algorithm(&self) -> Algorithm;

    // Provided methods
    fn sign_payload<'life0, 'life1, 'async_trait>(
        &'life0 self,
        payload: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Signature, SigningError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn sign_request<'life0, 'async_trait, P>(
        &'life0 self,
        data: P,
    ) -> Pin<Box<dyn Future<Output = Result<SignedRequest<P>, SigningError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             P: 'async_trait + Message,
             Self: 'async_trait { ... }
    fn endorse<'life0, 'life1, 'async_trait>(
        &'life0 self,
        contract: &'life1 mut Contract,
        ledger_id: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), SigningError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

A trait repersenting a service or key that can sign a message

Typically this trait would be implemented by a key pair (like in KeyPair), an HSM, or some secure service like Vault

Required Methods§

Source

fn sign<'life0, 'life1, 'async_trait>( &'life0 self, msg: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SigningError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Signs the passed message, and returns the signature.

Source

fn public_key(&self) -> &[u8]

Returns the public key associated with the signer

Source

fn algorithm(&self) -> Algorithm

Returns the signing algorithm used by the signer

Provided Methods§

Source

fn sign_payload<'life0, 'life1, 'async_trait>( &'life0 self, payload: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Signature, SigningError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Signs the payload, and returns a signature structure containing the algorithm, public-key, and signature

Source

fn sign_request<'life0, 'async_trait, P>( &'life0 self, data: P, ) -> Pin<Box<dyn Future<Output = Result<SignedRequest<P>, SigningError>> + Send + 'async_trait>>
where 'life0: 'async_trait, P: 'async_trait + Message, Self: 'async_trait,

Signs a Message and returns a SignedRequest

Source

fn endorse<'life0, 'life1, 'async_trait>( &'life0 self, contract: &'life1 mut Contract, ledger_id: String, ) -> Pin<Box<dyn Future<Output = Result<(), SigningError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Adds an endorsement signatured to a sdk::Contract

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§