Struct ethers_signers::AwsSigner
source · pub struct AwsSigner<'a> { /* private fields */ }
Expand description
An ethers Signer that uses keys held in Amazon AWS KMS.
The AWS Signer passes signing requests to the cloud service. AWS KMS keys
are identified by a UUID, the key_id
.
Because the public key is unknwon, we retrieve it on instantiation of the
signer. This means that the new function is async
and must be called
within some runtime.
ⓘ
use rusoto_core::Client;
use rusoto_kms::{Kms, KmsClient};
user ethers_signers::Signer;
let client = Client::new_with(
EnvironmentProvider::default(),
HttpClient::new().unwrap()
);
let kms_client = KmsClient::new_with_client(client, Region::UsWest1);
let key_id = "...";
let chain_id = 1;
let signer = AwsSigner::new(kms_client, key_id, chain_id).await?;
let sig = signer.sign_message(H256::zero()).await?;
Implementations§
source§impl<'a> AwsSigner<'a>
impl<'a> AwsSigner<'a>
sourcepub async fn new<T>(
kms: &'a KmsClient,
key_id: T,
chain_id: u64
) -> Result<AwsSigner<'a>, AwsSignerError>where
T: AsRef<str>,
pub async fn new<T>(
kms: &'a KmsClient,
key_id: T,
chain_id: u64
) -> Result<AwsSigner<'a>, AwsSignerError>where
T: AsRef<str>,
Instantiate a new signer from an existing KmsClient
and Key ID.
This function retrieves the public key from AWS and calculates the
Etheruem address. It is therefore async
.
sourcepub async fn get_pubkey_for_key<T>(
&self,
key_id: T
) -> Result<VerifyingKey, AwsSignerError>where
T: AsRef<str>,
pub async fn get_pubkey_for_key<T>(
&self,
key_id: T
) -> Result<VerifyingKey, AwsSignerError>where
T: AsRef<str>,
Fetch the pubkey associated with a key id
sourcepub async fn get_pubkey(&self) -> Result<VerifyingKey, AwsSignerError>
pub async fn get_pubkey(&self) -> Result<VerifyingKey, AwsSignerError>
Fetch the pubkey associated with this signer’s key ID
sourcepub async fn sign_digest_with_key<T>(
&self,
key_id: T,
digest: [u8; 32]
) -> Result<KSig, AwsSignerError>where
T: AsRef<str>,
pub async fn sign_digest_with_key<T>(
&self,
key_id: T,
digest: [u8; 32]
) -> Result<KSig, AwsSignerError>where
T: AsRef<str>,
Sign a digest with the key associated with a key id
sourcepub async fn sign_digest(&self, digest: [u8; 32]) -> Result<KSig, AwsSignerError>
pub async fn sign_digest(&self, digest: [u8; 32]) -> Result<KSig, AwsSignerError>
Sign a digest with this signer’s key
Trait Implementations§
source§impl<'a> Signer for AwsSigner<'a>
impl<'a> Signer for AwsSigner<'a>
source§fn with_chain_id<T: Into<u64>>(self, chain_id: T) -> Self
fn with_chain_id<T: Into<u64>>(self, chain_id: T) -> Self
Sets the signer’s chain id
type Error = AwsSignerError
source§fn sign_message<'life0, 'async_trait, S>(
&'life0 self,
message: S
) -> Pin<Box<dyn Future<Output = Result<EthSig, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Send + Sync + AsRef<[u8]>,
'life0: 'async_trait,
Self: 'async_trait,
fn sign_message<'life0, 'async_trait, S>(
&'life0 self,
message: S
) -> Pin<Box<dyn Future<Output = Result<EthSig, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Send + Sync + AsRef<[u8]>,
'life0: 'async_trait,
Self: 'async_trait,
Signs the hash of the provided message after prefixing it
source§fn sign_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 TypedTransaction
) -> Pin<Box<dyn Future<Output = Result<EthSig, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn sign_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 TypedTransaction
) -> Pin<Box<dyn Future<Output = Result<EthSig, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Signs the transaction
source§fn sign_typed_data<'life0, 'life1, 'async_trait, T>(
&'life0 self,
payload: &'life1 T
) -> Pin<Box<dyn Future<Output = Result<EthSig, Self::Error>> + Send + 'async_trait>>where
T: 'async_trait + Eip712 + Send + Sync,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn sign_typed_data<'life0, 'life1, 'async_trait, T>(
&'life0 self,
payload: &'life1 T
) -> Pin<Box<dyn Future<Output = Result<EthSig, Self::Error>> + Send + 'async_trait>>where
T: 'async_trait + Eip712 + Send + Sync,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Encodes and signs the typed data according EIP-712.
Payload must implement Eip712 trait. Read more