-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from alloy-rs/aws_signer
feat(wallets): aws signer
- Loading branch information
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! Example showing how to use the AWS KMS signer. | ||
use alloy::signers::{aws::AwsSigner, Signer}; | ||
use aws_config::BehaviorVersion; | ||
use eyre::Result; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let Ok(key_id) = std::env::var("AWS_KEY_ID") else { | ||
return Ok(()); | ||
}; | ||
let config = aws_config::load_defaults(BehaviorVersion::latest()).await; | ||
let client = aws_sdk_kms::Client::new(&config); | ||
|
||
let signer = AwsSigner::new(client, key_id, Some(1)).await.unwrap(); | ||
|
||
let message = "Hello, world!"; | ||
|
||
let sig = signer.sign_message(message.as_bytes()).await.unwrap(); | ||
assert_eq!(sig.recover_address_from_msg(message).unwrap(), signer.address()); | ||
|
||
Ok(()) | ||
} |