|
| 1 | +# DKG CLI Tool |
| 2 | + |
| 3 | +Command-line tool for Distributed Key Generation (DKG) and key rotation protocols. A DKG process involves a coordinator and a set of participating members. Here we describe the processes for both a fresh DKG and a DKG key rotation. |
| 4 | + |
| 5 | +### Fresh DKG Process |
| 6 | + |
| 7 | +#### Coordinator Runbook |
| 8 | + |
| 9 | +1. Deploy the `seal_committee` package in the Seal repo. Make sure you are on the right network with wallet with enough gas. Find the package ID in output, set it to env var. Share this with members later. |
| 10 | + |
| 11 | +```bash |
| 12 | +NETWORK=testnet |
| 13 | +sui client switch --env $NETWORK |
| 14 | +cd move/committee |
| 15 | +sui client publish |
| 16 | + |
| 17 | +COMMITTEE_PKG=0x4563316d2b647263737bbab1afb32495397bd36eefdcd3b1ca42c3c95ebb2fb3 |
| 18 | +``` |
| 19 | + |
| 20 | +2. Gather all members' addresses. |
| 21 | +3. Initialize the committee onchain. Notify members: |
| 22 | + |
| 23 | +- Committee package ID |
| 24 | +- Created committee object ID |
| 25 | + |
| 26 | +Then announce phase 1. |
| 27 | + |
| 28 | +```bash |
| 29 | +THRESHOLD=2 # Replace this with your threshold. |
| 30 | +ADDRESS_0=0x0636157e9d013585ff473b3b378499ac2f1d207ed07d70e2cd815711725bca9d # Replace these with the members' addresses. |
| 31 | +ADDRESS_1=0xe6a37ff5cd968b6a666fb033d85eabc674449f44f9fc2b600e55e27354211ed6 |
| 32 | +ADDRESS_2=0x223762117ab21a439f0f3f3b0577e838b8b26a37d9a1723a4be311243f4461b9 |
| 33 | + |
| 34 | +sui client call --package $COMMITTEE_PKG --module seal_committee \ |
| 35 | + --function init_committee \ |
| 36 | + --args $THRESHOLD "[\"$ADDRESS_0\", \"$ADDRESS_1\", \"$ADDRESS_2\"]" |
| 37 | + |
| 38 | +# Find the created committee object in output and share this with members. |
| 39 | +COMMITTEE_ID=0x210f1a2157d76e5c32a5e585ae3733b51105d553dc17f67457132af5e2dae7a5 |
| 40 | +``` |
| 41 | + |
| 42 | +4. Watch the onchain state until all members registered. Check the committee object state members on Explorer containing entries of all members' addresses. |
| 43 | +5. Notify all members to run phase 2. |
| 44 | +6. Watch the offchain storage until all members upload their messages. |
| 45 | +7. Notify all members to run phase 3. |
| 46 | +8. Monitor the committee for finalized state when all members approves. |
| 47 | + |
| 48 | +#### Member Runbook |
| 49 | + |
| 50 | +1. Share with the coordinator its address. This is the wallet used for the rest of the onchain commands. |
| 51 | +2. Receive from coordinator the committee package ID and committee ID. Verify its parameters (members addresses and threshold) on Sui Explorer. Set environment variables. |
| 52 | + |
| 53 | +```bash |
| 54 | +COMMITTEE_PKG=0x4563316d2b647263737bbab1afb32495397bd36eefdcd3b1ca42c3c95ebb2fb3 |
| 55 | +COMMITTEE_ID=0x210f1a2157d76e5c32a5e585ae3733b51105d553dc17f67457132af5e2dae7a5 |
| 56 | +``` |
| 57 | + |
| 58 | +3. Wait for the coordinator to announce phase 1. Run the CLI below to generate keys locally and register the public keys onchain. Notify the coordinator when finished. |
| 59 | + |
| 60 | +```bash |
| 61 | +# A file `.dkg.key` containing sensitive private keys is created locally. Keep it secure till DKG is completed. |
| 62 | +cargo run --bin dkg-cli generate-keys |
| 63 | + |
| 64 | +export DKG_ENC_PK=$(jq -r '.enc_pk' .dkg.key) |
| 65 | +export DKG_SIGNING_PK=$(jq -r '.signing_pk' .dkg.key) |
| 66 | + |
| 67 | +# Register onchain. |
| 68 | +sui client switch --env $NETWORK |
| 69 | +YOUR_SERVER_URL="replace your url here" |
| 70 | +MY_ADDRESS=$ADDRESS_0 # Replace your address here. |
| 71 | + |
| 72 | +sui client switch --address $MY_ADDRESS |
| 73 | +sui client call --package $COMMITTEE_PKG --module seal_committee \ |
| 74 | + --function register \ |
| 75 | + --args $COMMITTEE_ID x"$DKG_ENC_PK" x"$DKG_SIGNING_PK" "$YOUR_SERVER_URL" |
| 76 | +``` |
| 77 | + |
| 78 | +4. Wait for the coordinator to announce phase 2. Initialize the DKG state locally, create your message and upload it to offchain storage. |
| 79 | + |
| 80 | +```bash |
| 81 | +# The `/dkg-state` directory is created, containing sensitive private keys. Keep it secure till DKG is completed. |
| 82 | +cargo run --bin dkg-cli init --my-address $MY_ADDRESS --committee-id $COMMITTEE_ID --network $NETWORK |
| 83 | +``` |
| 84 | + |
| 85 | +5. TODO: Wait for the coordinator to announce phase 3. Process all messages locally and propose the committee onchain. |
| 86 | + |
| 87 | +### Key Rotation Process |
| 88 | + |
| 89 | +A key rotation process is needed when a committee wants to rotate a portion of its members. The contuning members (in both current and next committee) must meet the threshold of the current committee. |
| 90 | + |
| 91 | +#### Coordinator Runbook |
| 92 | + |
| 93 | +1. Gather all members' addresses for the next committee, including continuing members and new members. |
| 94 | + |
| 95 | +2. Initialize the next committee onchain with the current committee object ID. Notify members the next committee object ID and announce phase 1. |
| 96 | + |
| 97 | +```bash |
| 98 | +THRESHOLD=3 # Replace with the new threshold. |
| 99 | +ADDRESS_3=0x2aaadc85d1013bde04e7bff32aceaa03201627e43e3e3dd0b30521486b5c34cb # Replace with your members' addresses |
| 100 | +ADDRESS_4=0x8b4a608c002d969d29f1dd84bc8ac13e6c2481d6de45718e606cfc4450723ec2 |
| 101 | +CURRENT_COMMITTEE_ID=0x210f1a2157d76e5c32a5e585ae3733b51105d553dc17f67457132af5e2dae7a5 # Replace with the current committee ID. |
| 102 | + |
| 103 | +sui client call --package $COMMITTEE_PKG --module seal_committee \ |
| 104 | + --function init_rotation \ |
| 105 | + --args $CURRENT_COMMITTEE_ID $THRESHOLD "[\"$ADDRESS_1\", \"$ADDRESS_0\", \"$ADDRESS_3\", \"$ADDRESS_4\"]" |
| 106 | + |
| 107 | +# Find the created next committee object in output and share this with members. |
| 108 | +COMMITTEE_ID=0x15c4b9560ffd4922b3de98ea48cca427a376236fea86828944b3eb7e8719f856 |
| 109 | +``` |
| 110 | + |
| 111 | +4. Watch the onchain state until all members registered. |
| 112 | +5. Notify all members to run phase 2. |
| 113 | +6. Watch the offchain storage until all members upload their messages. |
| 114 | +7. Notify all members to run phase 3. |
| 115 | +8. Monitor the committee for finalized state when all members approves. |
| 116 | + |
| 117 | +#### Member Runbook |
| 118 | + |
| 119 | +1. Share with the coordinator its address. This is the wallet used for the rest of the onchain commands. |
| 120 | +2. Receive from coordinator the next committee ID. Verify its parameters (members addresses, threshold, the current committee ID) on Sui Explorer. Set environment variable. |
| 121 | + |
| 122 | +```bash |
| 123 | +# next committee ID |
| 124 | +COMMITTEE_ID=0x210f1a2157d76e5c32a5e585ae3733b51105d553dc17f67457132af5e2dae7a5 |
| 125 | +``` |
| 126 | + |
| 127 | +3. Wait for the coordinator to announce phase 1. Run the CLI below to generate keys locally and register the public keys onchain. Make sure you are on the right network with wallet with enough gas. |
| 128 | + |
| 129 | +```bash |
| 130 | +# A file `.dkg.key` containing sensitive private keys is created locally. Keep it secure till DKG is completed. |
| 131 | +cargo run --bin dkg-cli generate-keys |
| 132 | + |
| 133 | +export DKG_ENC_PK=$(jq -r '.enc_pk' .dkg.key) |
| 134 | +export DKG_SIGNING_PK=$(jq -r '.signing_pk' .dkg.key) |
| 135 | + |
| 136 | +# Register onchain. |
| 137 | +sui client switch --env $NETWORK |
| 138 | +YOUR_SERVER_URL="replace your url here" |
| 139 | +MY_ADDRESS=$ADDRESS_0 # Replace your address here. |
| 140 | + |
| 141 | +sui client switch --address $MY_ADDRESS |
| 142 | +sui client call --package $COMMITTEE_PKG --module seal_committee \ |
| 143 | + --function register \ |
| 144 | + --args $COMMITTEE_ID x"$DKG_ENC_PK" x"$DKG_SIGNING_PK" "$YOUR_SERVER_URL" |
| 145 | +``` |
| 146 | + |
| 147 | +4. Wait for the coordinator to announce phase 2. |
| 148 | + |
| 149 | +a. For continuing members, run the CLI below to initialize the local state, create your message and upload it to offchain storage. Must provide `--old-share` arg. |
| 150 | + |
| 151 | +```bash |
| 152 | +cargo run --bin dkg-cli init --my-address $MY_ADDRESS --old-share $DKG_OLD_SHARE --committee-id $COMMITTEE_ID --network $NETWORK |
| 153 | +``` |
| 154 | + |
| 155 | +b. For new members, run the CLI below that initialize the local state. Do not provide old share. |
| 156 | + |
| 157 | +```bash |
| 158 | +cargo run --bin dkg-cli init --my-address $MY_ADDRESS --committee-id $COMMITTEE_ID --network $NETWORK |
| 159 | +``` |
| 160 | + |
| 161 | +5. TODO: Wait for the coordinator to announce phase 3. Process all messages locally and propose the committee onchain. |
0 commit comments