11# ZKP Trusted Setup Ceremony Coordinator
22
3+ ** Warning**
4+ Please note that this tool is under development. Please consider it unusable before the first release.
5+
36## Overview
47This utility program allows for performing a Trusted Setup Ceremony in a Multi-Party Computation fashion. It is meant
58to be used by the Coordinator of the ceremony, as well as by the Contributors. In the end, the Coordinator will obtain
69Proving and Verifying Keys, which can be used to generate proofs for the circuit the ceremony was conducted for.
710
11+ ### Online mode
12+
13+ The primary mode of the program. In this mode, the Coordinator runs the ceremony server, which is responsible for
14+ accepting contributions from the Contributors. The Contributors connect to the Coordinator and contribute to the
15+ ceremony.
16+
17+ See help for ` server ` and ` client ` commands for details.
18+
19+ ### Offline mode
20+
21+ In this mode, the Coordinator and the Contributors run the ceremony locally. The Coordinator initializes the ceremony
22+ and generates the initial Phase 2 file. The Coordinator sends the file to the first Contributor. The Contributor
23+ generates their contribution and sends them to the Coordinator in the form of a Phase 2 file. The Coordinator verifies
24+ the contributions and, if the verification is positive, sends it to the next Contributor.
25+
26+ In this mode, sending Phase 2 files must be performed manually by the Coordinator and Contributors.
27+
28+ At the end of the ceremony, the Coordinator will have a list of accepted contributions. The Coordinator can then
29+ perform the final verification and extract the Proving and the Verifying Keys.
30+
31+ See help for ` init ` , ` contrib ` , ` verify ` and ` extract ` commands for details.
32+
33+ ### Snarkjs powers of tau (ptau) -> Phase 1 conversion
34+
35+ The tool can convert a Snarkjs powers of tau file to a Phase 1 file. This step is performed by the Coordinator before
36+ the initialization of the offline mode ceremony, if the Coordinator has a ptau file that they wish to use in the ceremony.
37+
38+ This step is not necessary if the Coordinator already has a Phase 1 file.
39+
840## Constraints
941
1042Gnark version used for implementing the circuit the ceremony will be conducted for must match the Gnark version used
@@ -14,20 +46,57 @@ Your Gnark project must satisfy the following constraints:
1446- Supported curve: BN254
1547- Supported backend: Groth16
1648
49+ ## Prerequisites
50+
51+ These are one-time steps that must be done in order to build the program.
52+
53+ Install [ Go] ( https://go.dev/dl/ ) . Any recent version will do. Look into ` go.mod ` to see the minimum required version.
54+
55+ Install [ Protocol Buffer Compiler] ( https://protobuf.dev/installation/ ) .
56+
57+ Install gRPC for Go:
58+
59+ ``` shell
60+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
61+ ```
62+
63+ ## Build
64+
65+ To build the project, run:
66+ ``` shell
67+ $ go generate ./...
68+ $ go build .
69+ ````
70+
71+ in the project' s root directory.
72+
73+ The test suite can be executed with:
74+ ```shell
75+ $ go test -v ./...
76+ ```
77+
1778## Usage
1879
19- Run the program with ` go run . ` or ` go run <command> <options> ` .
80+ Run the program with:
81+ ```shell
82+ $ go run . <command> <options>
83+
84+ # or, after the program was built
85+ ./trusted-setup <command> <options>
86+ ```
2087
2188Running the program with no arguments lists the available commands. Running the program with the command but without
2289options will display the command' s help.
2390
2491# # Commands
2592
26- ### ` help `
93+ # ## General purpose commands
94+
95+ # ### `help`
2796
2897Print help.
2998
30- ### ` ptau `
99+ # ### `ptau`
31100
32101Convert a Snarkjs powers of tau file to a Phase 1 file. This step is performed by the Coordinator.
33102
@@ -38,9 +107,54 @@ tau file to a Phase 1 file, which can be used to initialize the Phase 2 of the c
38107- ` --ptau` - A Snarkjs powers of tau file,
39108- ` --phase1` - The output Phase 1 file.
40109
41- ### ` init `
110+ # ## Online mode commands
111+
112+ # ### `server`
113+
114+ Start a Ceremony server. This step is performed by the Coordinator.
115+
116+ The server is responsible for orchestrating the ceremony, receiving contributions from the participants and, in the end,
117+ generating Proving and Verifying Keys.
118+
119+ The server is configured with a JSON file. An example configuration is shown below:
120+ ` ` ` json5
121+ {
122+ // A human-readable name for the ceremony that will be sent to contributors.
123+ // Used for identification purposes; can be any reasonably sized string.
124+ " ceremonyName" : " test ceremony" ,
125+ // The IP address on which the server will listen on.
126+ " host" : " 127.0.0.1" ,
127+ // The TCP port on which the server will listen on.
128+ " port" : 7312,
129+ // The path to the R1CS file generated from a Gnark circuit.
130+ " r1cs" : " resources/server.r1cs" ,
131+ // The path to the Phase 1 file (possibly generated from a ptau file - see the ` ptau` command for details).
132+ " phase1" : " resources/server.ph1" ,
133+ }
134+ ` ` `
135+
136+ Coordination of the ceremony is automatic. No action from the Coordinator is required besides starting the server
137+ and stopping it with CTRL+C at any arbitrary moment. At CTRL+C, the server stops accepting new contributions and starts
138+ key extraction from the existing contributions.
139+
140+ - ` --config` - Path to a JSON file containing the server configuration.
141+
142+ # ### `client`
143+
144+ Connect to a Ceremony server and provide contributions. This step is performed by the Contributors.
145+
146+ The client is responsible for connecting to the server and providing contributions. The client is configured with
147+ a host and port of the server. Participation in the ceremony is automatic. No action from the Contributor is required
148+ besides starting the client.
149+
150+ - ` --host` - The IP address of the server,
151+ - ` --port` - The port of the server.
152+
153+ # ## Offline mode commands
154+
155+ # ### `init`
42156
43- Initialize Phase 2 of the ceremony for the given R1CS with a Phase 1 file. This step is performed by the Coordinator.
157+ Initialize Phase 2 of the ceremony for the given R1CS with a Phase 1 file. This step is performed by the Coordinator.
44158
45159This step outputs a Phase 2 file based on the provided R1CS and Phase 1 file. The Coordinator must provide the R1CS file
46160generated from a Gnark circuit and the Phase 1 file either generated in the previous step or from another
@@ -58,7 +172,7 @@ The command outputs a beacon value, which must then be passed as an argument to
58172- ` --phase2` - The output path for the Phase 2 file,
59173- ` --srscommons` - The output path for circuit-independent components of the Groth16 SRS.
60174
61- ### ` contribute `
175+ # ### `contribute`
62176
63177Contribute randomness to Phase 2. This step is performed by all the participants of the ceremony.
64178
@@ -70,7 +184,7 @@ appended to the name.
70184
71185- ` --phase2` - The existing Phase 2 file created in the ` init` step or in the previous run of the ` contribute` step.
72186
73- ### ` verify `
187+ # ### `verify`
74188
75189Verify the last randomness contributed to Phase 2. This step is performed by the Coordinator.
76190
@@ -85,7 +199,7 @@ If the verification is successful, the Coordinator can either:
85199- ` --phase2prev` - A Phase 2 file being an input to the contribution
86200- ` --phase2next` - A Phase 2 file that was contributed to.
87201
88- ### ` extract-keys `
202+ # ### `extract-keys`
89203
90204Extract the Proving and Verifying Keys. This step is performed by the Coordinator.
91205
0 commit comments