[][src]Trait web3::signing::Key

pub trait Key {
    fn sign(
        &self,
        message: &[u8],
        chain_id: Option<u64>
    ) -> Result<Signature, SigningError>;
fn address(&self) -> Address; }

A trait representing ethereum-compatible key with signing capabilities.

The purpose of this trait is to prevent leaking secp256k1::SecretKey struct in stack or memory. To use secret keys securely, they should be wrapped in a struct that prevents leaving copies in memory (both when it's moved or dropped). Please take a look at:

If it's enough to pass a reference to SecretKey (lifetimes) than you can use SecretKeyRef wrapper.

Required methods

fn sign(
    &self,
    message: &[u8],
    chain_id: Option<u64>
) -> Result<Signature, SigningError>

Sign given message and include chain-id replay protection.

When a chain ID is provided, the Signature's V-value will have chain relay protection added (as per EIP-155). Otherwise, the V-value will be in 'Electrum' notation.

fn address(&self) -> Address

Get public address that this key represents.

Loading content...

Implementors

impl<T: Deref<Target = SecretKey>> Key for T[src]

Loading content...