EIP-2335: Keystore (#1071)

* Add test to understand flow of key storage

* First commit

* Committing to save trait stuff

* Working naive design

* Add keystore struct

* Move keystore files into their own module

* Add serde (de)serialize_with magic

* Add keystore test

* Fix tests

* Add comments and minor fixes

* Pass optional params to `to_keystore` function

* Add `path` field to keystore

* Add function to read Keystore from file

* Add test vectors and fix Version serialization

* Checksum params is empty object

* Add public key to Keystore

* Add function for saving keystore into file

* Deleted account_manager main.rs

* Move keystore module to validator_client

* Add save_keystore method to validator_directory

* Add load_keystore function. Minor refactorings

* Fixed dependencies

* Address some review comments

* Add Password newtype; derive Zeroize

* Fix test

* Move keystore into own crate

* Remove padding

* Add error enum, zeroize more things

* Fix comment

* Add keystore builder

* Remove keystore stuff from val client

* Add more tests, comments

* Add more comments, test vectors

* Progress on improving JSON validation

* More JSON verification

* Start moving JSON into own mod

* Remove old code

* Add more tests, reader/writers

* Tidy

* Move keystore into own file

* Move more logic into keystore file

* Tidy

* Tidy

* Allow for odd-character hex

* Add more json missing field checks

* Use scrypt by default

* Tidy, address comments

* Test path and uuid in vectors

* Fix comment

* Add checks for kdf params

* Enforce empty kdf message

* Expose json_keystore mod

* Split out encrypt/decrypt

* Replace some password usage with slice

* Expose PlainText struct

* Expose consts, remove Password

* Expose SALT_SIZE

* Move dbg assert statement

* Fix dodgy json test

* Protect against n == 1

* Return error if n is not power of 2

* Add dklen checks

* Add note about panics

Co-authored-by: pawan <pawandhananjay@gmail.com>
This commit is contained in:
Paul Hauner
2020-05-11 17:45:06 +10:00
committed by GitHub
parent 294d007f64
commit f30271ee9e
16 changed files with 2500 additions and 5 deletions

71
Cargo.lock generated
View File

@@ -1296,6 +1296,23 @@ dependencies = [
"serde_yaml",
]
[[package]]
name = "eth2_keystore"
version = "0.1.0"
dependencies = [
"bls",
"eth2_ssz",
"hex 0.3.2",
"rand 0.7.3",
"rust-crypto",
"serde",
"serde_json",
"serde_repr",
"tempfile",
"uuid 0.8.1",
"zeroize 1.1.0",
]
[[package]]
name = "eth2_ssz"
version = "0.1.2"
@@ -3550,7 +3567,7 @@ dependencies = [
"tokio-threadpool",
"tokio-timer 0.2.13",
"url 1.7.2",
"uuid",
"uuid 0.7.4",
"winreg",
]
@@ -3650,6 +3667,19 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "rust-crypto"
version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a"
dependencies = [
"gcc",
"libc",
"rand 0.3.23",
"rustc-serialize",
"time",
]
[[package]]
name = "rustc-demangle"
version = "0.1.16"
@@ -3662,6 +3692,12 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6"
[[package]]
name = "rustc-serialize"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
[[package]]
name = "rustc_version"
version = "0.2.3"
@@ -4199,9 +4235,9 @@ dependencies = [
name = "state_transition_vectors"
version = "0.1.0"
dependencies = [
"eth2_ssz 0.1.2",
"state_processing 0.2.0",
"types 0.2.0",
"eth2_ssz",
"state_processing",
"types",
]
[[package]]
@@ -4983,6 +5019,16 @@ dependencies = [
"rand 0.6.5",
]
[[package]]
name = "uuid"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11"
dependencies = [
"rand 0.7.3",
"serde",
]
[[package]]
name = "validator_client"
version = "0.2.0"
@@ -5424,7 +5470,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e68403b858b6af538b11614e62dfe9ab2facba9f13a0cafb974855cfb495ec95"
dependencies = [
"zeroize_derive",
"zeroize_derive 0.1.0",
]
[[package]]
@@ -5432,6 +5478,9 @@ name = "zeroize"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8"
dependencies = [
"zeroize_derive 1.0.0",
]
[[package]]
name = "zeroize_derive"
@@ -5443,3 +5492,15 @@ dependencies = [
"quote 0.6.13",
"syn 0.15.44",
]
[[package]]
name = "zeroize_derive"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2"
dependencies = [
"proc-macro2 1.0.12",
"quote 1.0.4",
"syn 1.0.19",
"synstructure",
]