Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
feat(signers): replace rusoto with aws-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Aug 10, 2023
1 parent 5145992 commit 9ff2477
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 202 deletions.
16 changes: 9 additions & 7 deletions ethers-core/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use hex;

use crate::types::{Address, Bytes, ParseI256Error, H256, I256, U256};
use ethabi::ethereum_types::FromDecStrErr;
use k256::ecdsa::SigningKey;
use k256::ecdsa::{SigningKey, VerifyingKey};
use std::{
collections::HashMap,
convert::{TryFrom, TryInto},
Expand Down Expand Up @@ -390,17 +390,19 @@ pub fn get_create2_address_from_hash(
Address::from(bytes)
}

/// Converts a K256 SigningKey to an Ethereum Address
/// Converts a K256 [SigningKey] to an Ethereum address.
#[inline]
pub fn secret_key_to_address(secret_key: &SigningKey) -> Address {
let public_key = secret_key.verifying_key();
public_key_to_address(secret_key.verifying_key())
}

/// Converts a K256 [VerifyingKey] to an Ethereum address.
pub fn public_key_to_address(public_key: &VerifyingKey) -> Address {
let public_key = public_key.to_encoded_point(/* compress = */ false);
let public_key = public_key.as_bytes();
debug_assert_eq!(public_key[0], 0x04);
let hash = keccak256(&public_key[1..]);

let mut bytes = [0u8; 20];
bytes.copy_from_slice(&hash[12..]);
Address::from(bytes)
Address::from_slice(&hash[12..])
}

/// Encodes an Ethereum address to its [EIP-55] checksum.
Expand Down
9 changes: 6 additions & 3 deletions ethers-signers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ futures-util = { workspace = true, optional = true }
futures-executor = { workspace = true, optional = true }

# aws
rusoto_core = { version = "0.48.0", default-features = false, optional = true }
rusoto_kms = { version = "0.48.0", default-features = false, optional = true }
aws-config = { version = "0.56", default-features = false, optional = true }
aws-smithy-runtime-api = { version = "0.56", default-features = false, features = [
"client",
], optional = true }
aws-sdk-kms = { version = "0.29", default-features = false, optional = true }
spki = { workspace = true, optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down Expand Up @@ -80,5 +83,5 @@ optimism = ["ethers-core/optimism"]

ledger = ["coins-ledger", "futures", "semver"]
trezor = ["trezor-client", "futures", "semver", "home"]
aws = ["rusoto_core/rustls", "rusoto_kms/rustls", "spki"]
aws = ["aws-config", "aws-sdk-kms", "aws-smithy-runtime-api", "spki"]
yubi = ["yubihsm"]
Loading

0 comments on commit 9ff2477

Please sign in to comment.