Skip to content

Commit

Permalink
docs(docs): update installation docs and cli walkthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 authored and samajammin committed Feb 26, 2024
1 parent c1c30fd commit 5af5267
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 42 deletions.
30 changes: 15 additions & 15 deletions website/versioned_docs/version-v1.x/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ node build/ts/index.js genMaciKeyPair
Example output:

```bash
[✓] Public key: macipk.1e03ee6ec5ee1d0dd9bcc5c91c10df8f2e37e134d9737a0239b361cd2809ae9e
[✓] Private key: macisk.a87fbc475cf8e42231a6dd487b41ccc935e7d2de08565f1ba6ecd7464694b85e
[✓] Public key: macipk.78e716652dfd1cc8f5fb0b45f656b493135edba5447cfc5e68c2f568d22e7193
[✓] Private key: macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8
```

If you already have a MACI private key in serialized form, you can generate its corresponding public key using the following command:

```bash
node build/ts/index.js genMaciPubKey -sk macisk.a87fbc475cf8e42231a6dd487b41ccc935e7d2de08565f1ba6ecd7464694b85e
node build/ts/index.js genMaciPubKey -sk macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8
```

Example output:

```
[✓] Public key: macipk.1e03ee6ec5ee1d0dd9bcc5c91c10df8f2e37e134d9737a0239b361cd2809ae9e
[✓] Public key: macipk.78e716652dfd1cc8f5fb0b45f656b493135edba5447cfc5e68c2f568d22e7193
```

### Coordinator: Deploy VkRegistry
Expand Down Expand Up @@ -157,7 +157,7 @@ Example usage:

```bash
node ./build/ts/index.js deployPoll \
-pk macipk.c974f4f168b79727ac98bfd53a65ea0b4e45dc2552fe73df9f8b51ebb0930330 \
-pk macipk.78e716652dfd1cc8f5fb0b45f656b493135edba5447cfc5e68c2f568d22e7193 \
-t 300 -i 1 -m 2 -b 1 -v 2
```

Expand All @@ -177,7 +177,7 @@ Example usage:

```bash
node ./build/ts/index.js signup \
-p macipk.c974f4f168b79727ac98bfd53a65ea0b4e45dc2552fe73df9f8b51ebb0930330
-p macisk.1a5103582662c0ada112bc5aac9202fbe51de84aa249989cbbbf9569eff19697
```

Example output:
Expand All @@ -193,8 +193,8 @@ Example usage:

```bash
node build/ts/index.js publish \
-p macipk.c974f4f168b79727ac98bfd53a65ea0b4e45dc2552fe73df9f8b51ebb0930330 \
-sk macisk.2ae4f199bf3925a2407f7c775c9261f351ab861d8e9ecbb84622bdd3f6d41b08 \
-p macisk.1a5103582662c0ada112bc5aac9202fbe51de84aa249989cbbbf9569eff19697 \
-sk macipk.a3c6a51848e96cf7b635931f450f61de4f907fbdcaaaadeaa1ac6b8a0ae1481c \
-i 1 -v 0 -w 9 -n 1 -o 0
```

Expand Down Expand Up @@ -268,7 +268,7 @@ Example usage to generate the state locally from the smart contracts events:
node build/ts/index.js genLocalState \
--poll-id 0 \
--output localState.json \
--privkey macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
--privkey macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8 \
--blocks-per-batch 50
```

Expand All @@ -287,7 +287,7 @@ Example usage:

```bash
node build/ts/index.js genProofs -x 0x89962fa216d39fCcaaC11e1e462340d80ab6Cf4D \
-sk macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
-sk macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8 \
-o 0 \
-t tally.json \
-f proofs \
Expand All @@ -302,7 +302,7 @@ node build/ts/index.js genProofs -x 0x89962fa216d39fCcaaC11e1e462340d80ab6Cf4D \

```bash
node build/ts/index.js genProofs \
-sk macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
-sk macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8 \
-o 0 \
-t tally.json \
-f proofs \
Expand All @@ -317,7 +317,7 @@ node build/ts/index.js genProofs \

```bash
node build/ts/index.js genProofs \
-sk macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
-sk macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8 \
-o 0 \
-t tally.json \
-f proofs \
Expand Down Expand Up @@ -351,7 +351,7 @@ Example usage to generate the proofs locally from the local state file created w

```bash
node build/ts/index.js genProofs \
--privkey macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
--privkey macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8 \
--poll-id 0 \
--rapidsnark ~/rapidsnark/build/prover \
--process-witnessgen ./zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test_cpp/ProcessMessages_10-2-1-2_test \
Expand All @@ -367,7 +367,7 @@ node build/ts/index.js genProofs \

```bash
node build/ts/index.js genProofs \
--privkey macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \
--privkey macisk.16b5a5b7fff5537f515a0b03e364cab43d7cce861cdba9fe5a1fff2b667f86d8 \
--poll-id 0 \
--process-zkey ./zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test.0.zkey \
--tally-zkey ./zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test.0.zkey \
Expand Down Expand Up @@ -506,7 +506,7 @@ Output:
### Coordinator: Deploy poll

```bash
node ./build/index.js deployPoll \
node ./build/ts/index.js deployPoll \
-pk macipk.c974f4f168b79727ac98bfd53a65ea0b4e45dc2552fe73df9f8b51ebb0930330 \
-t 1000 -i 1 -m 2 -b 1 -v 2
```
Expand Down
72 changes: 45 additions & 27 deletions website/versioned_docs/version-v1.x/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,23 @@ pnpm i && \
pnpm run build
```

#### On intel chips
#### On Intel chips (no ARM64)

Install dependencies to compile the c++ witness generator:
Install dependencies:

```bash
sudo apt-get install libgmp-dev nlohmann-json3-dev nasm g++
```

> Note that on an ARM macbook you won't need the above. However, you will not be able to compile the c++ witness generator.
:::info
Remember that if on a ARM64 chip, you will not be able to compile the c++ witness generator and thus use rapidsnark. Please follow instructions for WASM artifacts, in case you decide to recompile artifacts.
:::

### Configure circomkit
### Decide whether you need to compile new circuits or use the test ones

If you are going to be making any changes to the circom circuits, then the following will apply to you. Otherwise, you can skip to the [Download `.zkey` files](#download-zkey-files-if-you-would-like-to-use-the-default-parameters-or-the-trusted-setup-artifacts) section.

#### Configure circomkit

Edit `circuits/circom/circuits` to include the circuits you would like to compile. This comes already configured with the three main circuits and with testing parameters:

Expand All @@ -81,12 +87,24 @@ Edit `circuits/circom/circuits` to include the circuits you would like to compil
"params": [10, 2, 1, 2],
"pubs": ["inputHash"]
},
"ProcessMessagesNonQv_10-2-1-2_test": {
"file": "processMessagesNonQv",
"template": "ProcessMessagesNonQv",
"params": [10, 2, 1, 2],
"pubs": ["inputHash"]
},
"TallyVotes_10-1-2_test": {
"file": "tallyVotes",
"template": "TallyVotes",
"params": [10, 1, 2],
"pubs": ["inputHash"]
},
"TallyVotesNonQv_10-1-2_test": {
"file": "tallyVotesNonQv",
"template": "TallyVotesNonQv",
"params": [10, 1, 2],
"pubs": ["inputHash"]
},
"SubsidyPerBatch_10-1-2_test": {
"file": "subsidy",
"template": "SubsidyPerBatch",
Expand All @@ -96,29 +114,6 @@ Edit `circuits/circom/circuits` to include the circuits you would like to compil
}
```

### Download `.zkey` files (if you would like to use the default parameters or the trusted setup artifacts)

MACI has two main zk-SNARK circuits (plus an optional Subsidy circuit). Each circuit is parameterised. There should one
`.zkey` file for each circuit and set of parameters.

Unless you wish to generate a fresh set of `.zkey` files, you should obtain
them from someone who has performed a multi-party trusted setup for said
circuits. For more details on which artifacts have undergone a trusted setup, please refer to the [Trusted Setup](/docs/trusted-setup) page.

Note the locations of the `.zkey` files as the CLI requires them as command-line flags.

**Download test artifacts**

```bash
pnpm download:test-zkeys
```

**Download ceremony artifacts**

```bash
pnpm download:ceremony-zkeys
```

### Generate `.zkey` files

If you wish to generate `.zkey` files from scratch, first navigate to `circuits/circom`
Expand Down Expand Up @@ -152,3 +147,26 @@ pnpm setup:zkeys
> ^~~~~~~~~~~~~~~~~~~
> 1 error generated.
> ```
### Download `.zkey` files (if you would like to use the default parameters or the trusted setup artifacts)
MACI has two main zk-SNARK circuits (plus an optional Subsidy circuit). Each circuit is parameterised. There should one
`.zkey` file for each circuit and set of parameters.
Unless you wish to generate a fresh set of `.zkey` files, you should obtain
them from someone who has performed a multi-party trusted setup for said
circuits. For more details on which artifacts have undergone a trusted setup, please refer to the [Trusted Setup](/docs/trusted-setup) page.
Note the locations of the `.zkey` files as the CLI requires them as command-line flags.
**Download test artifacts**
```bash
pnpm download:test-zkeys
```
**Download ceremony artifacts**

```bash
pnpm download:ceremony-zkeys
```

0 comments on commit 5af5267

Please sign in to comment.