|
| 1 | +# adkg-cli |
| 2 | +CLI tool used to prepare and execute asynchronous distributed key generation ceremonies using the ADKG described in [Practical Asynchronous Distributed Key Generation](https://eprint.iacr.org/2021/1591.pdf) by Das et al. |
| 3 | + |
| 4 | +A ceremony is a three steps process: creation of a scheme specification, long-term key generation, and the execution of the ADKG. |
| 5 | + |
| 6 | +## Networking |
| 7 | +The ADKG relies on libp2p to exchange messages between the various nodes. |
| 8 | +The current implementation requires all nodes to use tcp communication, the traffic is secured using [Noise](https://docs.libp2p.io/concepts/secure-comm/noise/), and multiplexed with [Yamux](https://docs.libp2p.io/concepts/multiplex/yamux/). |
| 9 | +The node must allow incoming traffic on its libp2p tcp port, and tcp outbound traffic must be allowed to the rest of the nodes. |
| 10 | + |
| 11 | +## Specifying a scheme |
| 12 | +A scheme is used to describe an instance of the ADKG. |
| 13 | +It contains various parameters, such as the curve, the number of parties and the malicious threshold. |
| 14 | +Here is an example of a scheme specification used in the context of `dcipher`: |
| 15 | +```toml |
| 16 | +app_name = "dcipher" |
| 17 | +curve_id = "Bn254G1" |
| 18 | +hash_id = "Keccak256" |
| 19 | +adkg_version = "v0.1" |
| 20 | +adkg_scheme_name = "DYX20-Bn254G1-Keccak256" |
| 21 | +generator_g = "qB3/U8RDVn4aF2tUTlmeDQbV0PvHJ8IB0QL/k1Z+5WI=" |
| 22 | +generator_h = "gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE=" |
| 23 | +``` |
| 24 | + |
| 25 | +The `new-scheme` command can be used to obtain a scheme specification as follows: |
| 26 | +```bash |
| 27 | +adkg-cli new-scheme --app-name dcipher --scheme-out scheme.toml |
| 28 | +``` |
| 29 | + |
| 30 | +By default, we use the `DYX20-Bn254G1-Keccak256` scheme. |
| 31 | +This represents the aforementioned ADKG, using the bn254 curve on group G1. |
| 32 | +In this configuration, the long-term public keys use a deterministic generator, `H`, obtained by hashing `ADKG_GENERATOR_G` with the DST `ADKG-%adkg_version%-%app_name%_BN254G1_XMD:KECCAK-256_SVDW_RO_GENERATORS_` using [rfc9380](https://datatracker.ietf.org/doc/html/rfc9380). |
| 33 | +The public key after the ADKG, however, are output with respect to the standard generator of bn254, the point `(1, 2)`. |
| 34 | + |
| 35 | +It is preferable that a single participant executes the `new-scheme` command, and sends the generated file to the rest of the participants. |
| 36 | + |
| 37 | +## Generating long-term keys |
| 38 | +With the scheme in hand, the next step consists of generating long-term keys that can be used to execute multiple instances of the ADKG. |
| 39 | +We require the generation of two keypairs, an elliptic curve keypair `(sk, [sk] H)`, and an ed25519 libp2p keypair. |
| 40 | + |
| 41 | +The former is used for the ADKG, while the latter to authenticate and encrypt network communications. |
| 42 | + |
| 43 | +The `generate` command is used as follows and requires a `scheme.toml` file: |
| 44 | +```bash |
| 45 | +adkg-cli generate --scheme scheme.toml --priv-out adkg.priv --pub-out adkg.pub |
| 46 | +``` |
| 47 | + |
| 48 | +The command writes the private key material to the `adkg.priv` file, and the public key material to `adkg.pub`. |
| 49 | +Only the public key material must be forwarded to the rest of the participants. |
| 50 | +As explained above, `adkg.pub` contains two different values: |
| 51 | +```toml |
| 52 | +adkg_pk = "6xBXHRXOlmPcfV2LqeEKEDAOGOoAH2pIYBnuG/h1w8s=" |
| 53 | +peer_id = "12D3KooWRLzVJSS2EYpc9Tm4BfV5HEdXc8DiKvQkFqWhEwXcJ8eP" |
| 54 | +``` |
| 55 | + |
| 56 | +Once the public key material of each of the participant has been gather, a group configuration in the following format must be built and sent to the participants: |
| 57 | +```toml |
| 58 | +n = 7 |
| 59 | +t = 2 |
| 60 | +start_time = "2025-07-24T16:25:30Z" |
| 61 | + |
| 62 | +[[nodes]] |
| 63 | +id = 1 |
| 64 | +multiaddr = "/ip4/127.0.0.1/tcp/9991" |
| 65 | +adkg_pk = "71zT8Vib8vHG3vX2cktMyFl5VngXFi8RLOkIw9a5ulI=" |
| 66 | +peer_id = "12D3KooWMSH17hbmMBSbEtCeyYBkFT7phd6PVaA2fdxakaTAuXMx" |
| 67 | + |
| 68 | +[[nodes]] |
| 69 | +id = 2 |
| 70 | +multiaddr = "/dns4/my.domain.com/tcp/1005" |
| 71 | +adkg_pk = "354LSCLd/rCf8bX/vN+nWNfO2G2ZoLs/v054IAgiDFk=" |
| 72 | +peer_id = "12D3KooWMAADWEWNMFCNBadQfNFLeHHcYeZr9tNJBekY4opdCzDM" |
| 73 | + |
| 74 | +[...] |
| 75 | + |
| 76 | +[[nodes]] |
| 77 | +id = 7 |
| 78 | +multiaddr = "/ip4/127.0.0.1/tcp/7777" |
| 79 | +adkg_pk = "7dpgwvtWiLAw/TweCrzBeRuWahRbxqMwACwiiulYkfA=" |
| 80 | +peer_id = "12D3KooWGjQdQ6B3LazUw2EVbhakN3P5931e1UV76vJUNoV73Dd4" |
| 81 | +``` |
| 82 | + |
| 83 | +This file contains the group configuration, which includes the number of parties (`n`), a threshold (`t`), and an agreed upon starting time, alongside a list of nodes. |
| 84 | + |
| 85 | +Note that we use the malicious threshold here, i.e., the maximum number of parties that may be malicious. |
| 86 | +The reconstruction threshold, i.e., the number of partials required to obtain a threshold signature, is obtained by adding one. |
| 87 | + |
| 88 | +Each node is specified by its unique identifier, its public key material, and a libp2p multiaddress that can be used to communicate with the node. |
| 89 | + |
| 90 | +Once this group file has been obtained and save, we can proceed to the final step. |
| 91 | + |
| 92 | +## Executing the ADKG |
| 93 | +Finally, to execute the ADKG, we must gather various piece of information: |
| 94 | + - the scheme configuration file (`scheme.toml`) |
| 95 | + - the long-term private key file (`adkg.priv`) |
| 96 | + - the node's identifier (`1`) |
| 97 | + - the group configuration (`group.toml`) |
| 98 | + - the libp2p listen address (`/ip4/0.0.0.0/tcp/7777`) |
| 99 | + |
| 100 | +With those details, we can use the `run` command as follows: |
| 101 | +```bash |
| 102 | +adkg-cli run \ |
| 103 | + --scheme ./scheme.toml \ |
| 104 | + --group ./group.toml \ |
| 105 | + --priv adkg.priv \ |
| 106 | + --id 1 \ |
| 107 | + --listen-address "/ip4/0.0.0.0/tcp/7777" \ |
| 108 | + --priv-out adkg.ceremony.priv \ |
| 109 | + --pub-out adkg.ceremony.pub |
| 110 | +``` |
| 111 | + |
| 112 | +Notice that we also include two output files used to store the private and public output of the ADKG. |
0 commit comments