diff --git a/devtools/keypair/README.md b/devtools/keypair/README.md new file mode 100644 index 000000000..87e3a9c38 --- /dev/null +++ b/devtools/keypair/README.md @@ -0,0 +1,57 @@ +# Axon Keypair Generator + +This is a simple tool to generate keypair used for Axon. + +## Usage + +### Generate Keypair + +```bash +cd devtools/keypair & cargo run -- -n number_of_keypair_to_generate -p path_to_save_private_keys +``` +Example Output: + +```bash +$ cargo run -- -n 1 +{ + "keypairs": [ + { + "index": 0, + "net_private_key": "0x0000000000000000000000000000000000000000000000000000000000000000", + "public_key": "0x020044def250d1d27c0f7c0eeee6c8b964756d5ad7936fcefaf3f086245ddb9c9c", + "address": "0x83fec4b12b26a70195ccabb67ce0cd692856eaf1", + "peer_id": "QmbZEzvonMiPiioRpYeVWxngjN42FHC3EHXjeo2C7o2NDZ", + "bls_private_key": "0x1111111111111111111111111111111111111111111111111111111111111111", + "bls_public_key": "0x81ca54f01e3b433c209ae1d165e6362669e13170f89712dbc52c3572901d025ecc206a43c4b25f58388189f74587a7d" + } + ] +} +``` + +The arguments are described in the following table: + +| name | short | default value | +|--|--|--| +| number | n | 4 | +| private-key-path | p | current_path/private-binary/ | + +### Update Config and Spec File + +Firstly, update the `validator_list` in [chain-spec](../chain/specs/single_node/chain-spec.toml) file. Replace the `bls_pub_key`, `pub_key` and `address` with the value generated by the keypair generator.For example: + +```toml +[[params.verifier_list]] +bls_pub_key = "0x81ca54f01e3b433c209ae1d165e6362669e13170f89712dbc52c3572901d025ecc206a43c4b25f58388189f74587a7d" +pub_key = "0x020044def250d1d27c0f7c0eeee6c8b964756d5ad7936fcefaf3f086245ddb9c9c" +address = "0x83fec4b12b26a70195ccabb67ce0cd692856eaf1" +propose_weight = 1 +vote_weight = 1 +``` + +Then, update the `bootstraps` in [config](../chain/config.toml) file. Fill the generated `peer_id` to the `multi_address` For example: + +```toml +[[network.bootstraps]] +multi_address = "/ip4/127.0.0.1/tcp/8001/p2p/QmbZEzvonMiPiioRpYeVWxngjN42FHC3EHXjeo2C7o2NDZ" +``` +Finally, set the `net_privkey_file` and `bls_privkey_file` with the generated private key file path in [config](../chain/config.toml) file. diff --git a/devtools/keypair/src/keypair.yml b/devtools/keypair/src/keypair.yml index 2681ef65a..08736ef54 100644 --- a/devtools/keypair/src/keypair.yml +++ b/devtools/keypair/src/keypair.yml @@ -10,7 +10,7 @@ args: long: number default_value: "4" - - binary-path: + - private-key-path: help: The path to save net and bls private key binary short: p long: path diff --git a/devtools/keypair/src/main.rs b/devtools/keypair/src/main.rs index eb00946b0..b00eee442 100644 --- a/devtools/keypair/src/main.rs +++ b/devtools/keypair/src/main.rs @@ -23,6 +23,7 @@ struct Keypair { #[derive(Default, Serialize, Debug)] struct Output { + #[serde(skip)] pub common_ref: String, pub keypairs: Vec, } @@ -32,7 +33,7 @@ pub fn main() { let yml = load_yaml!("keypair.yml"); let m = App::from(yml).get_matches(); let number = value_t!(m, "number", usize).unwrap(); - let path = value_t!(m, "binary-path", String).unwrap(); + let path = value_t!(m, "private-key-path", String).unwrap(); let path = PathBuf::from(path); let _ = fs::create_dir(path.clone());