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
sourceimpl<'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
sourceimpl<'a> Signer for AwsSigner<'a>
impl<'a> Signer for AwsSigner<'a>
sourcefn 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
sourcefn 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
sourcefn 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
sourcefn 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
Auto Trait Implementations
impl<'a> !RefUnwindSafe for AwsSigner<'a>
impl<'a> Send for AwsSigner<'a>
impl<'a> Sync for AwsSigner<'a>
impl<'a> Unpin for AwsSigner<'a>
impl<'a> !UnwindSafe for AwsSigner<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more