Chore/update eth keystore (#910)
* chore(signers): bump up eth-keystore * doc(signers): update doc for new_keystore * chore: add changelog
This commit is contained in:
parent
a8cdfe60e9
commit
17d5b0ef38
|
@ -140,6 +140,9 @@
|
||||||
|
|
||||||
### Unreleased
|
### Unreleased
|
||||||
|
|
||||||
|
- `eth-keystore-rs` crate updated. Allow an optional name for the to-be-generated
|
||||||
|
keystore file [#910](https://github.com/gakonst/ethers-rs/pull/910)
|
||||||
|
|
||||||
### 0.6.0
|
### 0.6.0
|
||||||
|
|
||||||
- `LocalWallet::new_keystore` now returns a tuple `(LocalWallet, String)`
|
- `LocalWallet::new_keystore` now returns a tuple `(LocalWallet, String)`
|
||||||
|
|
|
@ -172,9 +172,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64ct"
|
name = "base64ct"
|
||||||
version = "1.3.3"
|
version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "874f8444adcb4952a8bc51305c8be95c8ec8237bb0d2e78d2e039f771f8828a0"
|
checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bech32"
|
name = "bech32"
|
||||||
|
@ -417,7 +417,7 @@ checksum = "0a9cf981c7e62b6fb02225592ee7ebf221e0b0b5317984a57a1e9d21af20e317"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aead",
|
"aead",
|
||||||
"cipher",
|
"cipher",
|
||||||
"ctr 0.8.0",
|
"ctr",
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ dependencies = [
|
||||||
"coins-core",
|
"coins-core",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"getrandom 0.2.4",
|
"getrandom 0.2.4",
|
||||||
"hmac",
|
"hmac 0.11.0",
|
||||||
"k256",
|
"k256",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -535,7 +535,7 @@ dependencies = [
|
||||||
"coins-bip32",
|
"coins-bip32",
|
||||||
"getrandom 0.2.4",
|
"getrandom 0.2.4",
|
||||||
"hex",
|
"hex",
|
||||||
"hmac",
|
"hmac 0.11.0",
|
||||||
"pbkdf2 0.8.0",
|
"pbkdf2 0.8.0",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
"sha2 0.9.9",
|
"sha2 0.9.9",
|
||||||
|
@ -559,7 +559,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"sha2 0.9.9",
|
"sha2 0.9.9",
|
||||||
"sha3",
|
"sha3 0.9.1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -850,15 +850,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ctr"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481"
|
|
||||||
dependencies = [
|
|
||||||
"cipher",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctr"
|
name = "ctr"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -944,6 +935,7 @@ dependencies = [
|
||||||
"block-buffer 0.10.0",
|
"block-buffer 0.10.0",
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
"generic-array 0.14.5",
|
"generic-array 0.14.5",
|
||||||
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1071,22 +1063,22 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eth-keystore"
|
name = "eth-keystore"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d47d900a7dea08593d398104f8288e37858b0ad714c8d08cd03fdb86563e6402"
|
checksum = "b9cdd5504a7b6b93c1176b0f4c193218221a927dd38bd1f4a1feb5ddd3ddb7f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"ctr 0.7.0",
|
"ctr",
|
||||||
"digest 0.9.0",
|
"digest 0.10.1",
|
||||||
"hex",
|
"hex",
|
||||||
"hmac",
|
"hmac 0.12.0",
|
||||||
"pbkdf2 0.8.0",
|
"pbkdf2 0.10.0",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
"scrypt",
|
"scrypt",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2 0.9.9",
|
"sha2 0.10.1",
|
||||||
"sha3",
|
"sha3 0.10.0",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
@ -1102,7 +1094,7 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha3",
|
"sha3 0.9.1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"uint",
|
"uint",
|
||||||
]
|
]
|
||||||
|
@ -1766,6 +1758,15 @@ dependencies = [
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hmac"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ddca131f3e7f2ce2df364b57949a9d47915cfbd35e46cfee355ccebbf794d6a2"
|
||||||
|
dependencies = [
|
||||||
|
"digest 0.10.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "home"
|
name = "home"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
|
@ -2001,7 +2002,7 @@ dependencies = [
|
||||||
"elliptic-curve",
|
"elliptic-curve",
|
||||||
"sec1",
|
"sec1",
|
||||||
"sha2 0.9.9",
|
"sha2 0.9.9",
|
||||||
"sha3",
|
"sha3 0.9.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2441,6 +2442,17 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "password-hash"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8"
|
||||||
|
dependencies = [
|
||||||
|
"base64ct",
|
||||||
|
"rand_core 0.6.3",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pbkdf2"
|
name = "pbkdf2"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -2449,8 +2461,8 @@ checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64ct",
|
"base64ct",
|
||||||
"crypto-mac 0.11.1",
|
"crypto-mac 0.11.1",
|
||||||
"hmac",
|
"hmac 0.11.0",
|
||||||
"password-hash",
|
"password-hash 0.2.3",
|
||||||
"sha2 0.9.9",
|
"sha2 0.9.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2463,6 +2475,18 @@ dependencies = [
|
||||||
"crypto-mac 0.11.1",
|
"crypto-mac 0.11.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pbkdf2"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a4628cc3cf953b82edcd3c1388c5715401420ce5524fedbab426bd5aba017434"
|
||||||
|
dependencies = [
|
||||||
|
"digest 0.10.1",
|
||||||
|
"hmac 0.12.0",
|
||||||
|
"password-hash 0.3.2",
|
||||||
|
"sha2 0.10.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -2946,7 +2970,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525"
|
checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint",
|
"crypto-bigint",
|
||||||
"hmac",
|
"hmac 0.11.0",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3076,7 +3100,7 @@ dependencies = [
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"futures",
|
"futures",
|
||||||
"hex",
|
"hex",
|
||||||
"hmac",
|
"hmac 0.11.0",
|
||||||
"http",
|
"http",
|
||||||
"hyper",
|
"hyper",
|
||||||
"log",
|
"log",
|
||||||
|
@ -3140,9 +3164,9 @@ checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "salsa20"
|
name = "salsa20"
|
||||||
version = "0.8.1"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ecbd2eb639fd7cab5804a0837fe373cc2172d15437e804c054a9fb885cb923b0"
|
checksum = "0c0fbb5f676da676c260ba276a8f43a8dc67cf02d1438423aeb1c677a7212686"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cipher",
|
"cipher",
|
||||||
]
|
]
|
||||||
|
@ -3180,16 +3204,15 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scrypt"
|
name = "scrypt"
|
||||||
version = "0.7.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "879588d8f90906e73302547e20fffefdd240eb3e0e744e142321f5d49dea0518"
|
checksum = "e73d6d7c6311ebdbd9184ad6c4447b2f36337e327bda107d3ba9e3c374f9d325"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64ct",
|
"hmac 0.12.0",
|
||||||
"hmac",
|
"password-hash 0.3.2",
|
||||||
"password-hash",
|
"pbkdf2 0.10.0",
|
||||||
"pbkdf2 0.8.0",
|
|
||||||
"salsa20",
|
"salsa20",
|
||||||
"sha2 0.9.9",
|
"sha2 0.10.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3377,6 +3400,17 @@ dependencies = [
|
||||||
"sha2-asm",
|
"sha2-asm",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha2"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"cpufeatures",
|
||||||
|
"digest 0.10.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2-asm"
|
name = "sha2-asm"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
|
@ -3398,6 +3432,16 @@ dependencies = [
|
||||||
"opaque-debug 0.3.0",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha3"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "31f935e31cf406e8c0e96c2815a5516181b7004ae8c5f296293221e9b1e356bd"
|
||||||
|
dependencies = [
|
||||||
|
"digest 0.10.1",
|
||||||
|
"keccak",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
|
@ -4321,7 +4365,7 @@ dependencies = [
|
||||||
"ecdsa",
|
"ecdsa",
|
||||||
"ed25519",
|
"ed25519",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
"hmac",
|
"hmac 0.11.0",
|
||||||
"k256",
|
"k256",
|
||||||
"log",
|
"log",
|
||||||
"p256",
|
"p256",
|
||||||
|
|
|
@ -38,7 +38,7 @@ tracing-futures = { version = "0.2.5", optional = true }
|
||||||
spki = { version = "0.5.4", optional = true }
|
spki = { version = "0.5.4", optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
eth-keystore = { version = "0.3.0" }
|
eth-keystore = { version = "0.4.0" }
|
||||||
home = "0.5.3"
|
home = "0.5.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -64,19 +64,21 @@ impl Clone for Wallet<SigningKey> {
|
||||||
impl Wallet<SigningKey> {
|
impl Wallet<SigningKey> {
|
||||||
/// Creates a new random encrypted JSON with the provided password and stores it in the
|
/// Creates a new random encrypted JSON with the provided password and stores it in the
|
||||||
/// provided directory. Returns a tuple (Wallet, String) of the wallet instance for the
|
/// provided directory. Returns a tuple (Wallet, String) of the wallet instance for the
|
||||||
/// keystore with its random UUID.
|
/// keystore with its random UUID. Accepts an optional name for the keystore file. If `None`,
|
||||||
|
/// the keystore is stored as the stringified UUID.
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn new_keystore<P, R, S>(
|
pub fn new_keystore<P, R, S>(
|
||||||
dir: P,
|
dir: P,
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
password: S,
|
password: S,
|
||||||
|
name: Option<&str>,
|
||||||
) -> Result<(Self, String), WalletError>
|
) -> Result<(Self, String), WalletError>
|
||||||
where
|
where
|
||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
R: Rng + CryptoRng + rand_core::CryptoRng,
|
R: Rng + CryptoRng + rand_core::CryptoRng,
|
||||||
S: AsRef<[u8]>,
|
S: AsRef<[u8]>,
|
||||||
{
|
{
|
||||||
let (secret, uuid) = eth_keystore::new(dir, rng, password)?;
|
let (secret, uuid) = eth_keystore::new(dir, rng, password, name)?;
|
||||||
let signer = SigningKey::from_bytes(secret.as_slice())?;
|
let signer = SigningKey::from_bytes(secret.as_slice())?;
|
||||||
let address = secret_key_to_address(&signer);
|
let address = secret_key_to_address(&signer);
|
||||||
Ok((Self { signer, address, chain_id: 1 }, uuid))
|
Ok((Self { signer, address, chain_id: 1 }, uuid))
|
||||||
|
@ -153,7 +155,8 @@ mod tests {
|
||||||
// create and store a random encrypted JSON keystore in this directory
|
// create and store a random encrypted JSON keystore in this directory
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let (key, uuid) = Wallet::<SigningKey>::new_keystore(&dir, &mut rng, "randpsswd").unwrap();
|
let (key, uuid) =
|
||||||
|
Wallet::<SigningKey>::new_keystore(&dir, &mut rng, "randpsswd", None).unwrap();
|
||||||
|
|
||||||
// sign a message using the above key
|
// sign a message using the above key
|
||||||
let message = "Some data";
|
let message = "Some data";
|
||||||
|
|
Loading…
Reference in New Issue