Skip to content

Commit

Permalink
Cleanup the name from ethkey/ethstore to cfxkey/cfxstore to avoid con…
Browse files Browse the repository at this point in the history
…fusion, add checks for address type in CLI and RPC (#1036)

* Add a check for the address first four bits when perform transaction at RPC

* change ethkey to cfxkey

* change ethstore to cfxstore

* more cleanup of eth to cfx

* update python test scripts
  • Loading branch information
fanlong committed Mar 13, 2020
1 parent 5ac7597 commit 4f65eb5
Show file tree
Hide file tree
Showing 103 changed files with 521 additions and 434 deletions.
256 changes: 163 additions & 93 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Expand Up @@ -16,8 +16,8 @@ parking_lot = "0.10"
panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git" }
app_dirs = { git = "https://github.com/paritytech/app-dirs-rs" }
dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git" }
ethstore = { path = "accounts/ethstore" }
ethcore-accounts = { path = "accounts" }
cfxstore = { path = "accounts/cfxstore" }
cfxcore-accounts = { path = "accounts" }
home = "0.5.0"
rpassword = "4.0.1"
io = { path = "util/io" }
Expand Down Expand Up @@ -48,7 +48,7 @@ cfx-types = { path = "cfx_types" }
threadpool = "1.7"
futures = "0.1.29"
docopt = "1.0"
ethkey = { path = "accounts/ethkey" }
cfxkey = { path = "accounts/cfxkey" }
parity-wordlist = "1.3.0"
rustc-hex = "2.0.1"
env_logger = "0.5"
Expand Down Expand Up @@ -78,8 +78,8 @@ name = "cfx-gen-dot"
path = "tools/cfx-gen-dot/main.rs"

[[bin]]
name = "ethkey"
path = "accounts/ethkey/cli/src/main.rs"
name = "cfxkey"
path = "accounts/cfxkey/cli/src/main.rs"

[[bin]]
name = "tg_config_gen"
Expand Down
12 changes: 6 additions & 6 deletions accounts/Cargo.toml
@@ -1,15 +1,15 @@
[package]
description = "Parity Ethereum Account Management"
homepage = "http://parity.io"
description = "Conflux Account Management"
homepage = "http://conflux-chain.org"
license = "GPL-3.0"
name = "ethcore-accounts"
name = "cfxcore-accounts"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
authors = ["Conflux Foundation"]
edition = "2018"

[dependencies]
ethkey = { path = "ethkey" }
ethstore = { path = "ethstore" }
cfxkey = { path = "cfxkey" }
cfxstore = { path = "cfxstore" }
log = "0.4"
parking_lot = "0.10"
serde = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions accounts/ethkey/Cargo.toml → accounts/cfxkey/Cargo.toml
@@ -1,8 +1,8 @@
[package]
description = "Conflux Keys Generator"
name = "ethkey"
name = "cfxkey"
version = "0.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
authors = ["Conflux Foundation"]

[dependencies]
edit-distance = "2.0"
Expand Down
70 changes: 31 additions & 39 deletions accounts/ethkey/README.md → accounts/cfxkey/README.md
@@ -1,22 +1,23 @@
## ethkey-cli
## cfxkey-cli

Parity Ethereum keys generator.
Conflux keys generator. It is built on top of the counterpart of Parity Ethereum. Note that Conflux
address scheme is different from Ethereum. You cannot directly import Ethereum key files into Conflux.

### Usage

```
Parity Ethereum Keys Generator.
Copyright 2015-2019 Parity Technologies (UK) Ltd.
Conflux Keys Generator.
Copyright 2020 Conflux Foundation
Usage:
ethkey info <secret-or-phrase> [options]
ethkey generate random [options]
ethkey generate prefix <prefix> [options]
ethkey sign <secret> <message>
ethkey verify public <public> <signature> <message>
ethkey verify address <address> <signature> <message>
ethkey recover <address> <known-phrase>
ethkey [-h | --help]
cfxkey info <secret-or-phrase> [options]
cfxkey generate random [options]
cfxkey generate prefix <prefix> [options]
cfxkey sign <secret> <message>
cfxkey verify public <public> <signature> <message>
cfxkey verify address <address> <signature> <message>
cfxkey recover <address> <known-phrase>
cfxkey [-h | --help]
Options:
-h, --help Display this message and exit.
Expand All @@ -39,10 +40,10 @@ Commands:
#### `info <secret>`
*Display info about private key.*

- `<secret>` - ethereum secret, 32 bytes long
- `<secret>` - conflux secret, 32 bytes long

```
ethkey info 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55
cfxkey info 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55
```

```
Expand All @@ -60,7 +61,7 @@ address: 26d1ec50b4e62c1d1a40d16e7cacc6a6580757d5
- `<phrase>` - Parity recovery phrase, 12 words

```
ethkey info --brain "this is sparta"
cfxkey info --brain "this is sparta"
```

```
Expand All @@ -77,7 +78,7 @@ address: 006e27b6a72e1f34c626762f3c4761547aff1421
*Generate new keypair randomly.*

```
ethkey generate random
cfxkey generate random
```

```
Expand All @@ -92,7 +93,7 @@ address: a8fa5dd30a87bb9e3288d604eb74949c515ab66e
*Generate new keypair with recovery phrase randomly.*

```
ethkey generate random --brain
cfxkey generate random --brain
```

```
Expand All @@ -111,7 +112,7 @@ address: 00cf3711cbd3a1512570639280758118ba0b2bcb
- `<prefix>` - desired address prefix, 0 - 32 bytes long.

```
ethkey generate prefix ff
cfxkey generate prefix ff
```

```
Expand All @@ -128,7 +129,7 @@ address: fff7e25dff2aa60f61f9d98130c8646a01f31649
- `<prefix>` - desired address prefix, 0 - 32 bytes long.

```
ethkey generate prefix --brain 00cf
cfxkey generate prefix --brain 00cf
```

```
Expand All @@ -143,11 +144,11 @@ address: 00cf3711cbd3a1512570639280758118ba0b2bcb
#### `sign <secret> <message>`
*Sign a message with a secret.*

- `<secret>` - ethereum secret, 32 bytes long
- `<secret>` - conflux secret, 32 bytes long
- `<message>` - message to sign, 32 bytes long

```
ethkey sign 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55 bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987
cfxkey sign 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55 bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987
```

```
Expand All @@ -159,12 +160,12 @@ c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8
#### `verify public <public> <signature> <message>`
*Verify the signature.*

- `<public>` - ethereum public, 64 bytes long
- `<public>` - conflux public, 64 bytes long
- `<signature>` - message signature, 65 bytes long
- `<message>` - message, 32 bytes long

```
ethkey verify public 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124 c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200 bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987
cfxkey verify public 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124 c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200 bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987
```

```
Expand All @@ -176,12 +177,12 @@ true
#### `verify address <address> <signature> <message>`
*Verify the signature.*

- `<address>` - ethereum address, 20 bytes long
- `<address>` - conflux address, 20 bytes long
- `<signature>` - message signature, 65 bytes long
- `<message>` - message, 32 bytes long

```
ethkey verify address 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124 c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200 bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987
cfxkey verify address 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124 c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200 bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987
```

```
Expand All @@ -193,29 +194,20 @@ true
#### `recover <address> <known-phrase>`
*Try to recover an account given expected address and partial (too short or with invalid words) recovery phrase.*

- `<address>` - ethereum address, 20 bytes long
- `<address>` - conflux address, 20 bytes long
- `<known-phrase>` - known phrase, can be in a form of `thwarting * creamer`

```
RUST_LOG="info" ethkey recover "00cf3711cbd3a1512570639280758118ba0b2bcb" "thwarting scandal creamer nuzzle asparagus blast crouch trusting anytime elixir frenzied octag"
RUST_LOG="info" cfxkey recover "00cf3711cbd3a1512570639280758118ba0b2bcb" "thwarting scandal creamer nuzzle asparagus blast crouch trusting anytime elixir frenzied octag"
```

```
INFO:ethkey::brain_recover: Invalid word 'octag', looking for potential substitutions.
INFO:ethkey::brain_recover: Closest words: ["ocean", "octagon", "octane", "outage", "tag", "acting", "acts", "aorta", "cage", "chug"]
INFO:ethkey::brain_recover: Starting to test 7776 possible combinations.
INFO:cfxkey::brain_recover: Invalid word 'octag', looking for potential substitutions.
INFO:cfxkey::brain_recover: Closest words: ["ocean", "octagon", "octane", "outage", "tag", "acting", "acts", "aorta", "cage", "chug"]
INFO:cfxkey::brain_recover: Starting to test 7776 possible combinations.
thwarting scandal creamer nuzzle asparagus blast crouch trusting anytime elixir frenzied octagon
secret: 001ce488d50d2f7579dc190c4655f32918d505cee3de63bddc7101bc91c0c2f0
public: 4e19a5fdae82596e1485c69b687c9cc52b5078e5b0668ef3ce8543cd90e712cb00df822489bc1f1dcb3623538a54476c7b3def44e1a51dc174e86448b63f42d0
address: 00cf3711cbd3a1512570639280758118ba0b2bcb
```

## Parity Ethereum toolchain
_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/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/whisper) - Implementation of Whisper-v2 PoC.
@@ -1,13 +1,13 @@
[package]
description = "Parity Ethereum Keys Generator CLI"
name = "ethkey-cli"
name = "ctxkey-cli"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
docopt = "1.0"
env_logger = "0.5"
ethkey = { path = "../" }
cfxkey = { path = "../" }
panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git" }
parity-wordlist="1.2"
rustc-hex = "1.0"
Expand All @@ -16,6 +16,6 @@ serde_derive = "1.0"
threadpool = "1.7"

[[bin]]
name = "ethkey"
name = "cfxkey"
path = "src/main.rs"
doc = false
44 changes: 24 additions & 20 deletions accounts/ethkey/cli/src/main.rs → accounts/cfxkey/cli/src/main.rs
@@ -1,3 +1,7 @@
// Copyright 2020 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/

// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.

Expand All @@ -14,9 +18,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

extern crate cfxkey;
extern crate docopt;
extern crate env_logger;
extern crate ethkey;
extern crate panic_hook;
extern crate parity_wordlist;
extern crate rustc_hex;
Expand All @@ -28,26 +32,26 @@ extern crate serde_derive;

use std::{env, fmt, io, num::ParseIntError, process, sync};

use docopt::Docopt;
use ethkey::{
use cfxkey::{
brain_recover, sign, verify_address, verify_public, Brain, BrainPrefix,
Error as EthkeyError, Generator, KeyPair, Prefix, Random,
};
use docopt::Docopt;
use rustc_hex::{FromHex, FromHexError};

const USAGE: &str = r#"
Parity Ethereum keys generator.
Copyright 2015-2019 Parity Technologies (UK) Ltd.
Usage:
ethkey info <secret-or-phrase> [options]
ethkey generate random [options]
ethkey generate prefix <prefix> [options]
ethkey sign <secret> <message>
ethkey verify public <public> <signature> <message>
ethkey verify address <address> <signature> <message>
ethkey recover <address> <known-phrase>
ethkey [-h | --help]
cfxkey info <secret-or-phrase> [options]
cfxkey generate random [options]
cfxkey generate prefix <prefix> [options]
cfxkey sign <secret> <message>
cfxkey verify public <public> <signature> <message>
cfxkey verify address <address> <signature> <message>
cfxkey recover <address> <known-phrase>
cfxkey [-h | --help]
Options:
-h, --help Display this message and exit.
Expand Down Expand Up @@ -375,7 +379,7 @@ mod tests {
#[test]
fn info() {
let command = vec![
"ethkey",
"cfxkey",
"info",
"17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55",
]
Expand All @@ -392,7 +396,7 @@ address: 16d1ec50b4e62c1d1a40d16e7cacc6a6580757d5".to_owned();

#[test]
fn brain() {
let command = vec!["ethkey", "info", "--brain", "this is sparta"]
let command = vec!["cfxkey", "info", "--brain", "this is sparta"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
Expand All @@ -409,7 +413,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();
#[test]
fn secret() {
let command =
vec!["ethkey", "info", "--brain", "this is sparta", "--secret"]
vec!["cfxkey", "info", "--brain", "this is sparta", "--secret"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
Expand All @@ -423,7 +427,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();
#[test]
fn public() {
let command =
vec!["ethkey", "info", "--brain", "this is sparta", "--public"]
vec!["cfxkey", "info", "--brain", "this is sparta", "--public"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
Expand All @@ -435,7 +439,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();
#[test]
fn address() {
let command =
vec!["ethkey", "info", "-b", "this is sparta", "--address"]
vec!["cfxkey", "info", "-b", "this is sparta", "--address"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
Expand All @@ -447,7 +451,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();
#[test]
fn sign() {
let command = vec![
"ethkey",
"cfxkey",
"sign",
"17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55",
"bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987",
Expand All @@ -462,7 +466,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();

#[test]
fn verify_valid_public() {
let command = vec!["ethkey", "verify", "public", "689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987"]
let command = vec!["cfxkey", "verify", "public", "689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
Expand All @@ -473,7 +477,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();

#[test]
fn verify_valid_address() {
let command = vec!["ethkey", "verify", "address", "16d1ec50b4e62c1d1a40d16e7cacc6a6580757d5", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987"]
let command = vec!["cfxkey", "verify", "address", "16d1ec50b4e62c1d1a40d16e7cacc6a6580757d5", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
Expand All @@ -484,7 +488,7 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned();

#[test]
fn verify_invalid() {
let command = vec!["ethkey", "verify", "public", "689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec986"]
let command = vec!["cfxkey", "verify", "public", "689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec986"]
.into_iter()
.map(Into::into)
.collect::<Vec<String>>();
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.
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.

0 comments on commit 4f65eb5

Please sign in to comment.