From 300c0c120b7cda4a1667f6eb0930a76819da6fd3 Mon Sep 17 00:00:00 2001 From: arkpar Date: Tue, 4 Oct 2016 22:00:59 +0200 Subject: [PATCH 1/3] v1.3.4 --- Cargo.lock | 82 ++++++++++++++++++++++++++++++---------------- Cargo.toml | 2 +- nsis/installer.nsi | 2 +- util/Cargo.toml | 2 +- 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97b26448d..ac1dee3c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,12 @@ [root] name = "parity" -version = "1.3.3" +version = "1.3.4" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", - "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", + "daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.3.0", "ethcore-dapps 1.3.0", @@ -20,7 +20,7 @@ dependencies = [ "ethcore-logger 1.3.0", "ethcore-rpc 1.3.0", "ethcore-signer 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "ethsync 1.3.0", "fdlimit 0.1.0", "hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -29,13 +29,13 @@ dependencies = [ "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "number_prefix 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.68 (registry+https://github.com/rust-lang/crates.io-index)", - "rpassword 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rpassword 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex 0.36.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "daemonize" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -208,12 +208,13 @@ dependencies = [ [[package]] name = "docopt" -version = "0.6.80" +version = "0.6.86" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.68 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -269,7 +270,7 @@ dependencies = [ "ethcore-ipc 1.3.0", "ethcore-ipc-codegen 1.3.0", "ethcore-ipc-nano 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "ethjson 0.1.0", "ethstore 0.1.0", "evmjit 1.3.0", @@ -293,7 +294,7 @@ version = "1.3.0" dependencies = [ "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 6.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", @@ -335,7 +336,7 @@ name = "ethcore-ipc" version = "1.3.0" dependencies = [ "ethcore-devtools 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -380,7 +381,7 @@ dependencies = [ "ethcore-ipc 1.3.0", "ethcore-ipc-codegen 1.3.0", "ethcore-ipc-nano 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -392,7 +393,7 @@ name = "ethcore-logger" version = "1.3.0" dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "isatty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -407,7 +408,7 @@ dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.3.0", "ethcore-io 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -431,7 +432,7 @@ dependencies = [ "ethcore-devtools 1.3.0", "ethcore-io 1.3.0", "ethcore-ipc 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "ethjson 0.1.0", "ethsync 1.3.0", "json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git?branch=beta)", @@ -454,7 +455,7 @@ dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-io 1.3.0", "ethcore-rpc 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-signer 1.4.0 (git+https://github.com/ethcore/parity-ui.git)", @@ -465,7 +466,7 @@ dependencies = [ [[package]] name = "ethcore-util" -version = "1.3.3" +version = "1.3.4" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -498,7 +499,7 @@ dependencies = [ name = "ethjson" version = "0.1.0" dependencies = [ - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -546,7 +547,7 @@ dependencies = [ "ethcore-ipc-codegen 1.3.0", "ethcore-ipc-nano 1.3.0", "ethcore-network 1.3.0", - "ethcore-util 1.3.3", + "ethcore-util 1.3.4", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1012,7 +1013,7 @@ dependencies = [ [[package]] name = "number_prefix" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1249,7 +1250,7 @@ dependencies = [ [[package]] name = "rpassword" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1375,7 +1376,7 @@ source = "git+https://github.com/carllerche/stable-heap?rev=3c5cd1ca47#3c5cd1ca4 [[package]] name = "strsim" -version = "0.3.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1386,6 +1387,14 @@ dependencies = [ "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syntex_syntax 0.36.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syntex_syntax" version = "0.33.0" @@ -1399,6 +1408,19 @@ dependencies = [ "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syntex_syntax" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "table" version = "0.1.0" @@ -1641,9 +1663,9 @@ dependencies = [ "checksum cookie 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90266f45846f14a1e986c77d1e9c2626b8c342ed806fe60241ec38cc8697b245" "checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc" "checksum ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)" = "" -"checksum daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "271ec51b7e0bee92f0d04601422c73eb76ececf197026711c97ad25038a010cf" +"checksum daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0239832c1b4ca406d5ec73728cf4c7336d25cf85dd32db9e047e9e706ee0e935" "checksum deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1614659040e711785ed8ea24219140654da1729f3ec8a47a9719d041112fe7bf" -"checksum docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4cc0acb4ce0828c6a5a11d47baa432fe885881c27428c3a4e473e454ffe57a76" +"checksum docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9" "checksum elastic-array 0.4.0 (git+https://github.com/ethcore/elastic-array)" = "" "checksum env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aba65b63ffcc17ffacd6cf5aa843da7c5a25e3bd4bbe0b7def8b214e411250e5" "checksum eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)" = "" @@ -1693,7 +1715,7 @@ dependencies = [ "checksum num-rational 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "48cdcc9ff4ae2a8296805ac15af88b3d88ce62128ded0cb74ffb63a587502a84" "checksum num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "51eab148f171aefad295f8cece636fc488b9b392ef544da31ea4b8ef6b9e9c39" "checksum num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "51fedae97a05f7353612fe017ab705a37e6db8f4d67c5c6fe739a9e70d6eed09" -"checksum number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "084d05f4bf60621a9ac9bde941a410df548f4de9545f06e5ee9d3aef4b97cd77" +"checksum number_prefix 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b09f7c223751819881e1b95670d36fb12cdaa89848147f2222f1a2b691d5f0a3" "checksum odds 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "b28c06e81b0f789122d415d6394b5fe849bde8067469f4c2980d3cdc10c78ec1" "checksum parity-dapps 1.4.0 (git+https://github.com/ethcore/parity-ui.git)" = "" "checksum parity-dapps-home 1.4.0 (git+https://github.com/ethcore/parity-ui.git)" = "" @@ -1721,7 +1743,7 @@ dependencies = [ "checksum rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb)" = "" "checksum rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)" = "" "checksum rotor 0.6.3 (git+https://github.com/ethcore/rotor)" = "" -"checksum rpassword 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5d3a99497c5c544e629cc8b359ae5ede321eba5fa8e5a8078f3ced727a976c3f" +"checksum rpassword 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "320da1dfcf5c570a6c07ff60bb7cd4cdc986d2ea89caea139f2247371ab6a1df" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" @@ -1738,9 +1760,11 @@ dependencies = [ "checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2" "checksum spmc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "93bdab61c1a413e591c4d17388ffa859eaff2df27f1e13a5ec8b716700605adf" "checksum stable-heap 0.1.0 (git+https://github.com/carllerche/stable-heap?rev=3c5cd1ca47)" = "" -"checksum strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4d73a2c36a4d095ed1a6df5cbeac159863173447f7a82b3f4757426844ab825" +"checksum strsim 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "50c069df92e4b01425a8bf3576d5d417943a6a7272fbabaf5bd80b1aaa76442e" "checksum syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393b6dd0889df2b064beeea954cfda6bc2571604ac460deeae0fed55a53988af" +"checksum syntex 0.36.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61dc0bbe1e46dcd53ec50d6600e750152c22e0e9352cadbd413e86fb847ae899" "checksum syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44bded3cabafc65c90b663b1071bd2d198a9ab7515e6ce729e4570aaf53c407e" +"checksum syntex_syntax 0.36.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2b92a8c33fad2fa99e14fe499ec17e82b6c6496a7a38a499f33b584ffa1886fa" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281" "checksum termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d9cf598a6d7ce700a4e6a9199da127e6819a61e64b68609683cc9a01b5683a" diff --git a/Cargo.toml b/Cargo.toml index 1e56eff5a..503b5d803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Ethcore client." name = "parity" -version = "1.3.3" +version = "1.3.4" license = "GPL-3.0" authors = ["Ethcore "] build = "build.rs" diff --git a/nsis/installer.nsi b/nsis/installer.nsi index 7ad8f4c7d..282d5f1d3 100644 --- a/nsis/installer.nsi +++ b/nsis/installer.nsi @@ -4,7 +4,7 @@ !define DESCRIPTION "Fast, light, robust Ethereum implementation" !define VERSIONMAJOR 1 !define VERSIONMINOR 3 -!define VERSIONBUILD 3 +!define VERSIONBUILD 4 !addplugindir .\ diff --git a/util/Cargo.toml b/util/Cargo.toml index 795c44bea..c5abd8a1e 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore utility library" homepage = "http://ethcore.io" license = "GPL-3.0" name = "ethcore-util" -version = "1.3.3" +version = "1.3.4" authors = ["Ethcore "] build = "build.rs" From a0b71a9f52657f35623273ba7c2aab8bc94f22dd Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 28 Sep 2016 15:47:52 +0200 Subject: [PATCH 2/3] fixed #2263, geth keys with ciphertext shorter than 32 bytes (#2318) * fixed #2263, geth keys with ciphertext shorter than 32 bytes * replace unwrap with more helpful expect * tests for decrypting short secrets --- ethstore/src/account/safe_account.rs | 11 +++-- ethstore/src/json/bytes.rs | 58 +++++++++++++++++++++++++++ ethstore/src/json/crypto.rs | 6 ++- ethstore/src/json/hash.rs | 14 ++++--- ethstore/src/json/id.rs | 18 +++++---- ethstore/src/json/key_file.rs | 38 +++++++++--------- ethstore/src/json/mod.rs.in | 4 +- ethstore/src/json/presale.rs | 33 +++------------ ethstore/tests/api.rs | 41 +++++++++++++++---- ethstore/tests/res/ciphertext/30.json | 21 ++++++++++ ethstore/tests/res/ciphertext/31.json | 21 ++++++++++ 11 files changed, 193 insertions(+), 72 deletions(-) create mode 100644 ethstore/src/json/bytes.rs create mode 100644 ethstore/tests/res/ciphertext/30.json create mode 100644 ethstore/tests/res/ciphertext/31.json diff --git a/ethstore/src/account/safe_account.rs b/ethstore/src/account/safe_account.rs index 3b3dcf2ee..98d8017d3 100644 --- a/ethstore/src/account/safe_account.rs +++ b/ethstore/src/account/safe_account.rs @@ -23,7 +23,7 @@ use account::{Version, Cipher, Kdf, Aes128Ctr, Pbkdf2, Prf}; #[derive(Debug, PartialEq, Clone)] pub struct Crypto { pub cipher: Cipher, - pub ciphertext: [u8; 32], + pub ciphertext: Vec, pub kdf: Kdf, pub mac: [u8; 32], } @@ -95,7 +95,7 @@ impl Crypto { cipher: Cipher::Aes128Ctr(Aes128Ctr { iv: iv, }), - ciphertext: ciphertext, + ciphertext: ciphertext.to_vec(), kdf: Kdf::Pbkdf2(Pbkdf2 { dklen: crypto::KEY_LENGTH as u32, salt: salt, @@ -107,6 +107,10 @@ impl Crypto { } pub fn secret(&self, password: &str) -> Result { + if self.ciphertext.len() > 32 { + return Err(Error::InvalidSecret); + } + let (derived_left_bits, derived_right_bits) = match self.kdf { Kdf::Pbkdf2(ref params) => crypto::derive_key_iterations(password, ¶ms.salt, params.c), Kdf::Scrypt(ref params) => crypto::derive_key_scrypt(password, ¶ms.salt, params.n, params.p, params.r), @@ -122,7 +126,8 @@ impl Crypto { match self.cipher { Cipher::Aes128Ctr(ref params) => { - crypto::aes::decrypt(&derived_left_bits, ¶ms.iv, &self.ciphertext, &mut *secret) + let from = 32 - self.ciphertext.len(); + crypto::aes::decrypt(&derived_left_bits, ¶ms.iv, &self.ciphertext, &mut (&mut *secret)[from..]) }, } diff --git a/ethstore/src/json/bytes.rs b/ethstore/src/json/bytes.rs new file mode 100644 index 000000000..fd4a3b995 --- /dev/null +++ b/ethstore/src/json/bytes.rs @@ -0,0 +1,58 @@ +use std::{ops, str}; +use serde::{Deserialize, Deserializer, Error, Serialize, Serializer}; +use rustc_serialize::hex::{ToHex, FromHex, FromHexError}; + +#[derive(Debug, PartialEq)] +pub struct Bytes(Vec); + +impl ops::Deref for Bytes { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl Deserialize for Bytes { + fn deserialize(deserializer: &mut D) -> Result + where D: Deserializer + { + let s = try!(String::deserialize(deserializer)); + let data = try!(s.from_hex().map_err(|e| Error::custom(format!("Invalid hex value {}", e)))); + Ok(Bytes(data)) + } +} + +impl Serialize for Bytes { + fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> + where S: Serializer { + serializer.serialize_str(&self.0.to_hex()) + } +} + +impl str::FromStr for Bytes { + type Err = FromHexError; + + fn from_str(s: &str) -> Result { + s.from_hex().map(Bytes) + } +} + +impl From<&'static str> for Bytes { + fn from(s: &'static str) -> Self { + s.parse().expect(&format!("invalid string literal for {}: '{}'", stringify!(Self), s)) + } +} + +impl From> for Bytes { + fn from(v: Vec) -> Self { + Bytes(v) + } +} + +impl From for Vec { + fn from(b: Bytes) -> Self { + b.0 + } +} + diff --git a/ethstore/src/json/crypto.rs b/ethstore/src/json/crypto.rs index 9ff8c1e44..180d1e2d7 100644 --- a/ethstore/src/json/crypto.rs +++ b/ethstore/src/json/crypto.rs @@ -17,12 +17,14 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer, Error}; use serde::de::{Visitor, MapVisitor}; use serde::ser; -use super::{Cipher, CipherSer, CipherSerParams, Kdf, KdfSer, KdfSerParams, H256}; +use super::{Cipher, CipherSer, CipherSerParams, Kdf, KdfSer, KdfSerParams, H256, Bytes}; + +pub type CipherText = Bytes; #[derive(Debug, PartialEq)] pub struct Crypto { pub cipher: Cipher, - pub ciphertext: H256, + pub ciphertext: CipherText, pub kdf: Kdf, pub mac: H256, } diff --git a/ethstore/src/json/hash.rs b/ethstore/src/json/hash.rs index 0079b4f81..25bf51130 100644 --- a/ethstore/src/json/hash.rs +++ b/ethstore/src/json/hash.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::fmt; -use std::ops; -use std::str::FromStr; +use std::{ops, fmt, str}; use rustc_serialize::hex::{FromHex, ToHex}; use serde::{Serialize, Serializer, Deserialize, Deserializer, Error as SerdeError}; use serde::de::Visitor; @@ -65,7 +63,7 @@ macro_rules! impl_hash { type Value = $name; fn visit_str(&mut self, value: &str) -> Result where E: SerdeError { - FromStr::from_str(value).map_err(SerdeError::custom) + value.parse().map_err(SerdeError::custom) } fn visit_string(&mut self, value: String) -> Result where E: SerdeError { @@ -77,7 +75,7 @@ macro_rules! impl_hash { } } - impl FromStr for $name { + impl str::FromStr for $name { type Err = Error; fn from_str(value: &str) -> Result { @@ -92,6 +90,12 @@ macro_rules! impl_hash { } } + impl From<&'static str> for $name { + fn from(s: &'static str) -> Self { + s.parse().expect(&format!("invalid string literal for {}: '{}'", stringify!(Self), s)) + } + } + impl From<[u8; $size]> for $name { fn from(bytes: [u8; $size]) -> Self { $name(bytes) diff --git a/ethstore/src/json/id.rs b/ethstore/src/json/id.rs index 2e896458c..ff282a9f8 100644 --- a/ethstore/src/json/id.rs +++ b/ethstore/src/json/id.rs @@ -15,8 +15,7 @@ // along with Parity. If not, see . //! Universaly unique identifier. -use std::str::FromStr; -use std::fmt; +use std::{fmt, str}; use rustc_serialize::hex::{ToHex, FromHex}; use serde::{Deserialize, Serialize, Deserializer, Serializer, Error as SerdeError}; use serde::de::Visitor; @@ -73,7 +72,7 @@ fn copy_into(from: &str, into: &mut [u8]) -> Result<(), Error> { Ok(()) } -impl FromStr for UUID { +impl str::FromStr for UUID { type Err = Error; fn from_str(s: &str) -> Result { @@ -95,6 +94,12 @@ impl FromStr for UUID { } } +impl From<&'static str> for UUID { + fn from(s: &'static str) -> Self { + s.parse().expect(&format!("invalid string literal for {}: '{}'", stringify!(Self), s)) + } +} + impl Serialize for UUID { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { @@ -116,7 +121,7 @@ impl Visitor for UUIDVisitor { type Value = UUID; fn visit_str(&mut self, value: &str) -> Result where E: SerdeError { - UUID::from_str(value).map_err(SerdeError::custom) + value.parse().map_err(SerdeError::custom) } fn visit_string(&mut self, value: String) -> Result where E: SerdeError { @@ -126,19 +131,18 @@ impl Visitor for UUIDVisitor { #[cfg(test)] mod tests { - use std::str::FromStr; use super::UUID; #[test] fn uuid_from_str() { - let uuid = UUID::from_str("3198bc9c-6672-5ab3-d995-4942343ae5b6").unwrap(); + let uuid: UUID = "3198bc9c-6672-5ab3-d995-4942343ae5b6".into(); assert_eq!(uuid, UUID::from([0x31, 0x98, 0xbc, 0x9c, 0x66, 0x72, 0x5a, 0xb3, 0xd9, 0x95, 0x49, 0x42, 0x34, 0x3a, 0xe5, 0xb6])); } #[test] fn uuid_from_and_to_str() { let from = "3198bc9c-6672-5ab3-d995-4942343ae5b6"; - let uuid = UUID::from_str(from).unwrap(); + let uuid: UUID = from.into(); let to: String = uuid.into(); assert_eq!(from, &to); } diff --git a/ethstore/src/json/key_file.rs b/ethstore/src/json/key_file.rs index 7d970a15c..6e37c7c89 100644 --- a/ethstore/src/json/key_file.rs +++ b/ethstore/src/json/key_file.rs @@ -98,7 +98,7 @@ impl Visitor for KeyFileVisitor { Some(KeyFileField::Version) => { version = Some(try!(visitor.visit_value())); } Some(KeyFileField::Crypto) => { crypto = Some(try!(visitor.visit_value())); } Some(KeyFileField::Address) => { address = Some(try!(visitor.visit_value())); } - Some(KeyFileField::Name) => { name = visitor.visit_value().ok(); } // ignore anyhing that is not a string to be permissive. + Some(KeyFileField::Name) => { name = visitor.visit_value().ok(); } // ignore anyhing that is not a string to be permissive. Some(KeyFileField::Meta) => { meta = visitor.visit_value().ok(); } // ignore anyhing that is not a string to be permissive. None => { break; } } @@ -153,7 +153,7 @@ impl KeyFile { mod tests { use std::str::FromStr; use serde_json; - use json::{KeyFile, UUID, Version, Crypto, Cipher, Aes128Ctr, Kdf, Scrypt, H128, H160, H256}; + use json::{KeyFile, UUID, Version, Crypto, Cipher, Aes128Ctr, Kdf, Scrypt}; #[test] fn basic_keyfile() { @@ -185,20 +185,20 @@ mod tests { let expected = KeyFile { id: UUID::from_str("8777d9f6-7860-4b9b-88b7-0b57ee6b3a73").unwrap(), version: Version::V3, - address: H160::from_str("6edddfc6349aff20bc6467ccf276c5b52487f7a8").unwrap(), + address: "6edddfc6349aff20bc6467ccf276c5b52487f7a8".into(), crypto: Crypto { cipher: Cipher::Aes128Ctr(Aes128Ctr { - iv: H128::from_str("b5a7ec855ec9e2c405371356855fec83").unwrap(), + iv: "b5a7ec855ec9e2c405371356855fec83".into(), }), - ciphertext: H256::from_str("7203da0676d141b138cd7f8e1a4365f59cc1aa6978dc5443f364ca943d7cb4bc").unwrap(), + ciphertext: "7203da0676d141b138cd7f8e1a4365f59cc1aa6978dc5443f364ca943d7cb4bc".into(), kdf: Kdf::Scrypt(Scrypt { n: 262144, dklen: 32, p: 1, r: 8, - salt: H256::from_str("1e8642fdf1f87172492c1412fc62f8db75d796cdfa9c53c3f2b11e44a2a1b209").unwrap(), + salt: "1e8642fdf1f87172492c1412fc62f8db75d796cdfa9c53c3f2b11e44a2a1b209".into(), }), - mac: H256::from_str("46325c5d4e8c991ad2683d525c7854da387138b6ca45068985aa4959fa2b8c8f").unwrap(), + mac: "46325c5d4e8c991ad2683d525c7854da387138b6ca45068985aa4959fa2b8c8f".into(), }, name: Some("Test".to_owned()), meta: Some("{}".to_owned()), @@ -234,22 +234,22 @@ mod tests { }"#; let expected = KeyFile { - id: UUID::from_str("8777d9f6-7860-4b9b-88b7-0b57ee6b3a73").unwrap(), + id: "8777d9f6-7860-4b9b-88b7-0b57ee6b3a73".into(), version: Version::V3, - address: H160::from_str("6edddfc6349aff20bc6467ccf276c5b52487f7a8").unwrap(), + address: "6edddfc6349aff20bc6467ccf276c5b52487f7a8".into(), crypto: Crypto { cipher: Cipher::Aes128Ctr(Aes128Ctr { - iv: H128::from_str("b5a7ec855ec9e2c405371356855fec83").unwrap(), + iv: "b5a7ec855ec9e2c405371356855fec83".into(), }), - ciphertext: H256::from_str("7203da0676d141b138cd7f8e1a4365f59cc1aa6978dc5443f364ca943d7cb4bc").unwrap(), + ciphertext: "7203da0676d141b138cd7f8e1a4365f59cc1aa6978dc5443f364ca943d7cb4bc".into(), kdf: Kdf::Scrypt(Scrypt { n: 262144, dklen: 32, p: 1, r: 8, - salt: H256::from_str("1e8642fdf1f87172492c1412fc62f8db75d796cdfa9c53c3f2b11e44a2a1b209").unwrap(), + salt: "1e8642fdf1f87172492c1412fc62f8db75d796cdfa9c53c3f2b11e44a2a1b209".into(), }), - mac: H256::from_str("46325c5d4e8c991ad2683d525c7854da387138b6ca45068985aa4959fa2b8c8f").unwrap(), + mac: "46325c5d4e8c991ad2683d525c7854da387138b6ca45068985aa4959fa2b8c8f".into(), }, name: None, meta: None, @@ -262,22 +262,22 @@ mod tests { #[test] fn to_and_from_json() { let file = KeyFile { - id: UUID::from_str("8777d9f6-7860-4b9b-88b7-0b57ee6b3a73").unwrap(), + id: "8777d9f6-7860-4b9b-88b7-0b57ee6b3a73".into(), version: Version::V3, - address: H160::from_str("6edddfc6349aff20bc6467ccf276c5b52487f7a8").unwrap(), + address: "6edddfc6349aff20bc6467ccf276c5b52487f7a8".into(), crypto: Crypto { cipher: Cipher::Aes128Ctr(Aes128Ctr { - iv: H128::from_str("b5a7ec855ec9e2c405371356855fec83").unwrap(), + iv: "b5a7ec855ec9e2c405371356855fec83".into(), }), - ciphertext: H256::from_str("7203da0676d141b138cd7f8e1a4365f59cc1aa6978dc5443f364ca943d7cb4bc").unwrap(), + ciphertext: "7203da0676d141b138cd7f8e1a4365f59cc1aa6978dc5443f364ca943d7cb4bc".into(), kdf: Kdf::Scrypt(Scrypt { n: 262144, dklen: 32, p: 1, r: 8, - salt: H256::from_str("1e8642fdf1f87172492c1412fc62f8db75d796cdfa9c53c3f2b11e44a2a1b209").unwrap(), + salt: "1e8642fdf1f87172492c1412fc62f8db75d796cdfa9c53c3f2b11e44a2a1b209".into(), }), - mac: H256::from_str("46325c5d4e8c991ad2683d525c7854da387138b6ca45068985aa4959fa2b8c8f").unwrap(), + mac: "46325c5d4e8c991ad2683d525c7854da387138b6ca45068985aa4959fa2b8c8f".into(), }, name: Some("Test".to_owned()), meta: None, diff --git a/ethstore/src/json/mod.rs.in b/ethstore/src/json/mod.rs.in index 4f9fdbfe3..133d9821e 100644 --- a/ethstore/src/json/mod.rs.in +++ b/ethstore/src/json/mod.rs.in @@ -1,3 +1,4 @@ +mod bytes; mod cipher; mod crypto; mod error; @@ -8,8 +9,9 @@ mod key_file; mod presale; mod version; +pub use self::bytes::Bytes; pub use self::cipher::{Cipher, CipherSer, CipherSerParams, Aes128Ctr}; -pub use self::crypto::Crypto; +pub use self::crypto::{Crypto, CipherText}; pub use self::error::Error; pub use self::hash::{H128, H160, H256}; pub use self::id::UUID; diff --git a/ethstore/src/json/presale.rs b/ethstore/src/json/presale.rs index 77394fcb1..d1cffcb6a 100644 --- a/ethstore/src/json/presale.rs +++ b/ethstore/src/json/presale.rs @@ -1,30 +1,8 @@ use std::io::Read; -use std::ops::Deref; use serde_json; -use serde::{Deserialize, Deserializer, Error}; -use rustc_serialize::hex::FromHex; -use super::{H160}; +use super::{H160, Bytes}; -#[derive(Debug, PartialEq)] -pub struct Encseed(Vec); - -impl Deref for Encseed { - type Target = [u8]; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl Deserialize for Encseed { - fn deserialize(deserializer: &mut D) -> Result - where D: Deserializer - { - let s = try!(String::deserialize(deserializer)); - let data = try!(s.from_hex().map_err(|e| Error::custom(format!("Invalid hex value {}", e)))); - Ok(Encseed(data)) - } -} +pub type Encseed = Bytes; #[derive(Debug, PartialEq, Deserialize)] pub struct PresaleWallet { @@ -43,8 +21,7 @@ impl PresaleWallet { mod tests { use std::str::FromStr; use serde_json; - use rustc_serialize::hex::FromHex; - use json::{PresaleWallet, H160, Encseed}; + use json::{PresaleWallet, H160}; #[test] fn presale_wallet() { @@ -57,7 +34,7 @@ mod tests { } "#; let expected = PresaleWallet { - encseed: Encseed("137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066".from_hex().unwrap()), + encseed: "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066".into(), address: H160::from_str("ede84640d1a1d3e06902048e67aa7db8d52c2ce1").unwrap(), }; @@ -77,7 +54,7 @@ mod tests { } "#; let expected = PresaleWallet { - encseed: Encseed("137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0d".from_hex().unwrap()), + encseed: "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0d".into(), address: H160::from_str("ede84640d1a1d3e06902048e67aa7db8d52c2ce1").unwrap(), }; diff --git a/ethstore/tests/api.rs b/ethstore/tests/api.rs index 83aa04874..e1667607b 100644 --- a/ethstore/tests/api.rs +++ b/ethstore/tests/api.rs @@ -19,9 +19,8 @@ extern crate ethstore; mod util; -use std::str::FromStr; use ethstore::{SecretStore, EthStore}; -use ethstore::ethkey::{Random, Generator, Secret, Address}; +use ethstore::ethkey::{Random, Generator, Secret, KeyPair, verify_address}; use ethstore::dir::DiskDirectory; use util::TransientDir; @@ -103,14 +102,21 @@ fn pat_path() -> &'static str { } } +fn ciphertext_path() -> &'static str { + match ::std::fs::metadata("ethstore") { + Ok(_) => "ethstore/tests/res/ciphertext", + Err(_) => "tests/res/ciphertext", + } +} + #[test] fn secret_store_laod_geth_files() { let dir = DiskDirectory::at(test_path()); let store = EthStore::open(Box::new(dir)).unwrap(); assert_eq!(store.accounts().unwrap(), vec![ - Address::from_str("3f49624084b67849c7b4e805c5988c21a430f9d9").unwrap(), - Address::from_str("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf").unwrap(), - Address::from_str("63121b431a52f8043c16fcf0d1df9cb7b5f66649").unwrap(), + "3f49624084b67849c7b4e805c5988c21a430f9d9".into(), + "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".into(), + "63121b431a52f8043c16fcf0d1df9cb7b5f66649".into(), ]); } @@ -119,9 +125,30 @@ fn secret_store_load_pat_files() { let dir = DiskDirectory::at(pat_path()); let store = EthStore::open(Box::new(dir)).unwrap(); assert_eq!(store.accounts().unwrap(), vec![ - Address::from_str("3f49624084b67849c7b4e805c5988c21a430f9d9").unwrap(), - Address::from_str("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf").unwrap(), + "3f49624084b67849c7b4e805c5988c21a430f9d9".into(), + "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".into(), ]); } +#[test] +fn test_decrypting_files_with_short_ciphertext() { + // 31e9d1e6d844bd3a536800ef8d8be6a9975db509, 30 + let kp1 = KeyPair::from_secret("000081c29e8142bb6a81bef5a92bda7a8328a5c85bb2f9542e76f9b0f94fc018".into()).unwrap(); + // d1e64e5480bfaf733ba7d48712decb8227797a4e , 31 + let kp2 = KeyPair::from_secret("00fa7b3db73dc7dfdf8c5fbdb796d741e4488628c41fc4febd9160a866ba0f35".into()).unwrap(); + let dir = DiskDirectory::at(ciphertext_path()); + let store = EthStore::open(Box::new(dir)).unwrap(); + let accounts = store.accounts().unwrap(); + assert_eq!(accounts, vec![ + "31e9d1e6d844bd3a536800ef8d8be6a9975db509".into(), + "d1e64e5480bfaf733ba7d48712decb8227797a4e".into(), + ]); + let message = Default::default(); + + let s1 = store.sign(&accounts[0], "foo", &message).unwrap(); + let s2 = store.sign(&accounts[1], "foo", &message).unwrap(); + assert!(verify_address(&accounts[0], &s1, &message).unwrap()); + assert!(verify_address(&kp1.address(), &s1, &message).unwrap()); + assert!(verify_address(&kp2.address(), &s2, &message).unwrap()); +} diff --git a/ethstore/tests/res/ciphertext/30.json b/ethstore/tests/res/ciphertext/30.json new file mode 100644 index 000000000..c4f5ad184 --- /dev/null +++ b/ethstore/tests/res/ciphertext/30.json @@ -0,0 +1,21 @@ +{ + "address" : "31e9d1e6d844bd3a536800ef8d8be6a9975db509", + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "3ca92af36ad7c2cd92454c59cea5ef00" + }, + "ciphertext" : "108b7d34f3442fc26ab1ab90ca91476ba6bfa8c00975a49ef9051dc675aa", + "kdf" : "scrypt", + "kdfparams" : { + "dklen" : 32, + "n" : 2, + "r" : 8, + "p" : 1, + "salt" : "d0769e608fb86cda848065642a9c6fa046845c928175662b8e356c77f914cd3b" + }, + "mac" : "75d0e6759f7b3cefa319c3be41680ab6beea7d8328653474bd06706d4cc67420" + }, + "id" : "a37e1559-5955-450d-8075-7b8931b392b2", + "version" : 3 +} diff --git a/ethstore/tests/res/ciphertext/31.json b/ethstore/tests/res/ciphertext/31.json new file mode 100644 index 000000000..9c2612b03 --- /dev/null +++ b/ethstore/tests/res/ciphertext/31.json @@ -0,0 +1,21 @@ +{ + "address" : "d1e64e5480bfaf733ba7d48712decb8227797a4e", + "crypto" : { + "cipher" : "aes-128-ctr", + "cipherparams" : { + "iv" : "e0c41130a323adc1446fc82f724bca2f" + }, + "ciphertext" : "9517cd5bdbe69076f9bf5057248c6c050141e970efa36ce53692d5d59a3984", + "kdf" : "scrypt", + "kdfparams" : { + "dklen" : 32, + "n" : 2, + "r" : 8, + "p" : 1, + "salt" : "711f816911c92d649fb4c84b047915679933555030b3552c1212609b38208c63" + }, + "mac" : "d5e116151c6aa71470e67a7d42c9620c75c4d23229847dcc127794f0732b0db5" + }, + "id" : "fecfc4ce-e956-48fd-953b-30f8b52ed66c", + "version" : 3 +} From ca2bc92dda5edcb7b9c17dd5ff2f8e4eca5a333f Mon Sep 17 00:00:00 2001 From: arkpar Date: Tue, 4 Oct 2016 23:24:16 +0200 Subject: [PATCH 3/3] Fixing tests --- ethstore/tests/api.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ethstore/tests/api.rs b/ethstore/tests/api.rs index e1667607b..ee00be532 100644 --- a/ethstore/tests/api.rs +++ b/ethstore/tests/api.rs @@ -114,9 +114,9 @@ fn secret_store_laod_geth_files() { let dir = DiskDirectory::at(test_path()); let store = EthStore::open(Box::new(dir)).unwrap(); assert_eq!(store.accounts().unwrap(), vec![ - "3f49624084b67849c7b4e805c5988c21a430f9d9".into(), - "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".into(), - "63121b431a52f8043c16fcf0d1df9cb7b5f66649".into(), + "3f49624084b67849c7b4e805c5988c21a430f9d9".parse().unwrap(), + "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".parse().unwrap(), + "63121b431a52f8043c16fcf0d1df9cb7b5f66649".parse().unwrap(), ]); } @@ -125,23 +125,23 @@ fn secret_store_load_pat_files() { let dir = DiskDirectory::at(pat_path()); let store = EthStore::open(Box::new(dir)).unwrap(); assert_eq!(store.accounts().unwrap(), vec![ - "3f49624084b67849c7b4e805c5988c21a430f9d9".into(), - "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".into(), + "3f49624084b67849c7b4e805c5988c21a430f9d9".parse().unwrap(), + "5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".parse().unwrap(), ]); } #[test] fn test_decrypting_files_with_short_ciphertext() { // 31e9d1e6d844bd3a536800ef8d8be6a9975db509, 30 - let kp1 = KeyPair::from_secret("000081c29e8142bb6a81bef5a92bda7a8328a5c85bb2f9542e76f9b0f94fc018".into()).unwrap(); + let kp1 = KeyPair::from_secret("000081c29e8142bb6a81bef5a92bda7a8328a5c85bb2f9542e76f9b0f94fc018".parse().unwrap()).unwrap(); // d1e64e5480bfaf733ba7d48712decb8227797a4e , 31 - let kp2 = KeyPair::from_secret("00fa7b3db73dc7dfdf8c5fbdb796d741e4488628c41fc4febd9160a866ba0f35".into()).unwrap(); + let kp2 = KeyPair::from_secret("00fa7b3db73dc7dfdf8c5fbdb796d741e4488628c41fc4febd9160a866ba0f35".parse().unwrap()).unwrap(); let dir = DiskDirectory::at(ciphertext_path()); let store = EthStore::open(Box::new(dir)).unwrap(); let accounts = store.accounts().unwrap(); assert_eq!(accounts, vec![ - "31e9d1e6d844bd3a536800ef8d8be6a9975db509".into(), - "d1e64e5480bfaf733ba7d48712decb8227797a4e".into(), + "31e9d1e6d844bd3a536800ef8d8be6a9975db509".parse().unwrap(), + "d1e64e5480bfaf733ba7d48712decb8227797a4e".parse().unwrap(), ]); let message = Default::default();