Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #37 from paritytech/master
Browse files Browse the repository at this point in the history
merge downstream
  • Loading branch information
5chdn authored Jan 6, 2019
2 parents e92ceb3 + e435407 commit 2bbac44
Show file tree
Hide file tree
Showing 453 changed files with 22,458 additions and 20,047 deletions.
174 changes: 95 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 17 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" }
ethcore = { path = "ethcore", features = ["parity"] }
parity-bytes = "0.1"
common-types = { path = "ethcore/types" }
ethcore-blockchain = { path = "ethcore/blockchain" }
ethcore-db = { path = "ethcore/db" }
ethcore-io = { path = "util/io" }
ethcore-light = { path = "ethcore/light" }
ethcore-logger = { path = "logger" }
Expand All @@ -41,34 +44,32 @@ ethcore-network = { path = "util/network" }
ethcore-private-tx = { path = "ethcore/private-tx" }
ethcore-service = { path = "ethcore/service" }
ethcore-sync = { path = "ethcore/sync" }
ethcore-transaction = { path = "ethcore/transaction" }
ethstore = { path = "accounts/ethstore" }
ethereum-types = "0.4"
node-filter = { path = "ethcore/node_filter" }
ethkey = { path = "ethkey" }
node-filter = { path = "ethcore/node-filter" }
ethkey = { path = "accounts/ethkey" }
rlp = { version = "0.3.0", features = ["ethereum"] }
rpc-cli = { path = "rpc_cli" }
parity-hash-fetch = { path = "hash-fetch" }
cli-signer= { path = "cli-signer" }
parity-hash-fetch = { path = "updater/hash-fetch" }
parity-ipfs-api = { path = "ipfs" }
parity-local-store = { path = "local-store" }
parity-local-store = { path = "miner/local-store" }
parity-runtime = { path = "util/runtime" }
parity-rpc = { path = "rpc" }
parity-rpc-client = { path = "rpc_client" }
parity-updater = { path = "updater" }
parity-version = { path = "util/version" }
parity-whisper = { path = "whisper" }
parity-path = "0.1"
dir = { path = "util/dir" }
panic_hook = { path = "util/panic_hook" }
panic_hook = { path = "util/panic-hook" }
keccak-hash = "0.1"
migration-rocksdb = { path = "util/migration-rocksdb" }
kvdb = "0.1"
kvdb-rocksdb = "0.1.3"
journaldb = { path = "util/journaldb" }
mem = { path = "util/mem" }

ethcore-secretstore = { path = "secret_store", optional = true }
ethcore-secretstore = { path = "secret-store", optional = true }

registrar = { path = "registrar" }
registrar = { path = "util/registrar" }

[build-dependencies]
rustc_version = "0.2"
Expand Down Expand Up @@ -121,19 +122,15 @@ name = "parity"
debug = false

[workspace]
# This should only list projects that are not
# in the dependency tree in any other way
# (i.e. pretty much only standalone CLI tools)
members = [
"accounts/ethkey/cli",
"accounts/ethstore/cli",
"chainspec",
"ethcore/wasm/run",
"ethcore/types",
"ethkey/cli",
"ethstore/cli",
"evmbin",
"miner",
"parity-clib",
"whisper",
"whisper/cli",
"util/triehash-ethereum",
"util/keccak-hasher",
"util/patricia-trie-ethereum",
"util/fastmap",
]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ In addition to the Parity Ethereum client, there are additional tools in this re
- [evmbin](https://github.com/paritytech/parity-ethereum/blob/master/evmbin/) - EVM implementation for Parity Ethereum.
- [ethabi](https://github.com/paritytech/ethabi) - Parity Ethereum function calls encoding.
- [ethstore](https://github.com/paritytech/parity-ethereum/blob/master/ethstore/) - Parity Ethereum key management.
- [ethkey](https://github.com/paritytech/parity-ethereum/blob/master/ethkey/) - Parity Ethereum keys generator.
- [ethstore](https://github.com/paritytech/parity-ethereum/blob/master/accounts/ethstore) - Parity Ethereum key management.
- [ethkey](https://github.com/paritytech/parity-ethereum/blob/master/accounts/ethkey) - Parity Ethereum keys generator.
- [whisper](https://github.com/paritytech/parity-ethereum/blob/master/whisper/) - Implementation of Whisper-v2 PoC.
## Join the chat!
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ethkey/Cargo.toml → accounts/ethkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
ethereum-types = "0.4"
lazy_static = "1.0"
log = "0.4"
mem = { path = "../util/mem" }
memzero = { path = "../../util/memzero" }
parity-wordlist = "1.2"
quick-error = "1.2.2"
rand = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions ethkey/README.md → accounts/ethkey/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ _This project is a part of the Parity Ethereum toolchain._

- [evmbin](https://github.com/paritytech/parity-ethereum/blob/master/evmbin/) - EVM implementation for Parity Ethereum.
- [ethabi](https://github.com/paritytech/ethabi) - Parity Ethereum function calls encoding.
- [ethstore](https://github.com/paritytech/parity-ethereum/blob/master/ethstore/) - Parity Ethereum key management.
- [ethkey](https://github.com/paritytech/parity-ethereum/blob/master/ethkey/) - Parity Ethereum keys generator.
- [ethstore](https://github.com/paritytech/parity-ethereum/blob/master/accounts/ethstore) - Parity Ethereum key management.
- [ethkey](https://github.com/paritytech/parity-ethereum/blob/master/accounts/ethkey) - Parity Ethereum keys generator.
- [whisper](https://github.com/paritytech/parity-ethereum/blob/master/whisper/) - Implementation of Whisper-v2 PoC.
2 changes: 1 addition & 1 deletion ethkey/cli/Cargo.toml → accounts/ethkey/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
docopt = "1.0"
env_logger = "0.5"
ethkey = { path = "../" }
panic_hook = { path = "../../util/panic_hook" }
panic_hook = { path = "../../../util/panic-hook" }
parity-wordlist="1.2"
rustc-hex = "1.0"
serde = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion ethkey/cli/src/main.rs → accounts/ethkey/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn main() {
Ok(ok) => println!("{}", ok),
Err(Error::Docopt(ref e)) => e.exit(),
Err(err) => {
println!("{}", err);
eprintln!("{}", err);
process::exit(1);
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ethkey/src/lib.rs → accounts/ethkey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern crate byteorder;
extern crate edit_distance;
extern crate parity_crypto;
extern crate ethereum_types;
extern crate mem;
extern crate memzero;
extern crate parity_wordlist;
#[macro_use]
extern crate quick_error;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ethkey/src/secret.rs → accounts/ethkey/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_hex::ToHex;
use secp256k1::constants::{SECRET_KEY_SIZE as SECP256K1_SECRET_KEY_SIZE};
use secp256k1::key;
use ethereum_types::H256;
use mem::Memzero;
use memzero::Memzero;
use {Error, SECP256K1};

#[derive(Clone, PartialEq, Eq)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions ethstore/Cargo.toml → accounts/ethstore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethstore"
version = "0.2.0"
version = "0.2.1"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
Expand All @@ -18,7 +18,7 @@ itertools = "0.5"
parking_lot = "0.7"
parity-crypto = "0.2"
ethereum-types = "0.4"
dir = { path = "../util/dir" }
dir = { path = "../../util/dir" }
smallvec = "0.6"
parity-wordlist = "1.0"
tempdir = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions ethstore/README.md → accounts/ethstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,6 @@ _This project is a part of the Parity Ethereum toolchain._

- [evmbin](https://github.com/paritytech/parity-ethereum/blob/master/evmbin/) - EVM implementation for Parity Ethereum.
- [ethabi](https://github.com/paritytech/ethabi) - Parity Ethereum function calls encoding.
- [ethstore](https://github.com/paritytech/parity-ethereum/blob/master/ethstore/) - Parity Ethereum key management.
- [ethkey](https://github.com/paritytech/parity-ethereum/blob/master/ethkey/) - Parity Ethereum keys generator.
- [ethstore](https://github.com/paritytech/parity-ethereum/blob/master/accounts/ethstore) - Parity Ethereum key management.
- [ethkey](https://github.com/paritytech/parity-ethereum/blob/master/accounts/ethkey) - Parity Ethereum keys generator.
- [whisper](https://github.com/paritytech/parity-ethereum/blob/master/whisper/) - Implementation of Whisper-v2 PoC.
7 changes: 4 additions & 3 deletions ethstore/cli/Cargo.toml → accounts/ethstore/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
[package]
name = "ethstore-cli"
version = "0.1.0"
version = "0.1.1"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
docopt = "1.0"
env_logger = "0.5"
num_cpus = "1.6"
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
parking_lot = "0.7"
ethstore = { path = "../" }
dir = { path = '../../util/dir' }
panic_hook = { path = "../../util/panic_hook" }
dir = { path = '../../../util/dir' }
panic_hook = { path = "../../../util/panic-hook" }

[[bin]]
name = "ethstore"
Expand Down
File renamed without changes.
39 changes: 25 additions & 14 deletions ethstore/cli/src/main.rs → accounts/ethstore/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extern crate parking_lot;
extern crate rustc_hex;
extern crate serde;

extern crate env_logger;

#[macro_use]
extern crate serde_derive;

Expand All @@ -45,7 +47,7 @@ Usage:
ethstore insert <secret> <password> [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD]
ethstore change-pwd <address> <old-pwd> <new-pwd> [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD]
ethstore list [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD]
ethstore import [--src DIR] [--dir DIR]
ethstore import [<password>] [--src DIR] [--dir DIR]
ethstore import-wallet <path> <password> [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD]
ethstore find-wallet-pass <path> <password>
ethstore remove <address> <password> [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD]
Expand Down Expand Up @@ -146,30 +148,34 @@ impl fmt::Display for Error {

fn main() {
panic_hook::set_abort();
if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "warn")
}
env_logger::try_init().expect("Logger initialized only once.");

match execute(env::args()) {
Ok(result) => println!("{}", result),
Err(Error::Docopt(ref e)) => e.exit(),
Err(err) => {
println!("{}", err);
eprintln!("{}", err);
process::exit(1);
}
}
}

fn key_dir(location: &str) -> Result<Box<KeyDirectory>, Error> {
let dir: Box<KeyDirectory> = match location {
"geth" => Box::new(RootDiskDirectory::create(dir::geth(false))?),
"geth-test" => Box::new(RootDiskDirectory::create(dir::geth(true))?),
fn key_dir(location: &str, password: Option<Password>) -> Result<Box<KeyDirectory>, Error> {
let dir: RootDiskDirectory = match location {
"geth" => RootDiskDirectory::create(dir::geth(false))?,
"geth-test" => RootDiskDirectory::create(dir::geth(true))?,
path if path.starts_with("parity") => {
let chain = path.split('-').nth(1).unwrap_or("ethereum");
let path = dir::parity(chain);
Box::new(RootDiskDirectory::create(path)?)
RootDiskDirectory::create(path)?
},
path => Box::new(RootDiskDirectory::create(path)?),
path => RootDiskDirectory::create(path)?,
};

Ok(dir)
Ok(Box::new(dir.with_password(password)))
}

fn open_args_vault(store: &EthStore, args: &Args) -> Result<SecretVaultRef, Error> {
Expand Down Expand Up @@ -202,9 +208,9 @@ fn format_vaults(vaults: &[String]) -> String {
}

fn load_password(path: &str) -> Result<Password, Error> {
let mut file = fs::File::open(path).map_err(|e| ethstore::Error::Custom(format!("Error opening password file {}: {}", path, e)))?;
let mut file = fs::File::open(path).map_err(|e| ethstore::Error::Custom(format!("Error opening password file '{}': {}", path, e)))?;
let mut password = String::new();
file.read_to_string(&mut password).map_err(|e| ethstore::Error::Custom(format!("Error reading password file {}: {}", path, e)))?;
file.read_to_string(&mut password).map_err(|e| ethstore::Error::Custom(format!("Error reading password file '{}': {}", path, e)))?;
// drop EOF
let _ = password.pop();
Ok(password.into())
Expand All @@ -214,7 +220,7 @@ fn execute<S, I>(command: I) -> Result<String, Error> where I: IntoIterator<Item
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.argv(command).deserialize())?;

let store = EthStore::open(key_dir(&args.flag_dir)?)?;
let store = EthStore::open(key_dir(&args.flag_dir, None)?)?;

return if args.cmd_insert {
let secret = args.arg_secret.parse().map_err(|_| ethstore::Error::InvalidSecret)?;
Expand All @@ -239,8 +245,13 @@ fn execute<S, I>(command: I) -> Result<String, Error> where I: IntoIterator<Item
.collect();
Ok(format_accounts(&accounts))
} else if args.cmd_import {
let src = key_dir(&args.flag_src)?;
let dst = key_dir(&args.flag_dir)?;
let password = match args.arg_password.as_ref() {
"" => None,
_ => Some(load_password(&args.arg_password)?)
};
let src = key_dir(&args.flag_src, password)?;
let dst = key_dir(&args.flag_dir, None)?;

let accounts = import_accounts(&*src, &*dst)?;
Ok(format_accounts(&accounts))
} else if args.cmd_import_wallet {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ impl Crypto {

// two parts of derived key
// DK = [ DK[0..15] DK[16..31] ] = [derived_left_bits, derived_right_bits]
let (derived_left_bits, derived_right_bits) = crypto::derive_key_iterations(password.as_bytes(), &salt, iterations);
let (derived_left_bits, derived_right_bits) =
crypto::derive_key_iterations(password.as_bytes(), &salt, iterations);

// preallocated (on-stack in case of `Secret`) buffer to hold cipher
// length = length(plain) as we are using CTR-approach
Expand All @@ -104,7 +105,7 @@ impl Crypto {
ciphertext: ciphertext.into_vec(),
kdf: Kdf::Pbkdf2(Pbkdf2 {
dklen: crypto::KEY_LENGTH as u32,
salt: salt,
salt: salt.to_vec(),
c: iterations,
prf: Prf::HmacSha256,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Pbkdf2 {
pub c: u32,
pub dklen: u32,
pub prf: Prf,
pub salt: [u8; 32],
pub salt: Vec<u8>,
}

#[derive(Debug, PartialEq, Clone)]
Expand All @@ -35,7 +35,7 @@ pub struct Scrypt {
pub p: u32,
pub n: u32,
pub r: u32,
pub salt: [u8; 32],
pub salt: Vec<u8>,
}

#[derive(Debug, PartialEq, Clone)]
Expand Down
File renamed without changes.
Loading

0 comments on commit 2bbac44

Please sign in to comment.