Skip to content

Commit

Permalink
docs: add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoImin committed Dec 6, 2023
1 parent e633e06 commit 632507a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
57 changes: 57 additions & 0 deletions devtools/keypair/README.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion devtools/keypair/src/keypair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion devtools/keypair/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Keypair {

#[derive(Default, Serialize, Debug)]
struct Output {
#[serde(skip)]
pub common_ref: String,
pub keypairs: Vec<Keypair>,
}
Expand All @@ -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());

Expand Down

0 comments on commit 632507a

Please sign in to comment.