[−][src]Trait web3::signing::Key
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:
- https://github.com/graphprotocol/solidity-bindgen/blob/master/solidity-bindgen/src/secrets.rs
- or https://crates.io/crates/zeroize if you care enough about your secrets to be used securely.
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>
&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.