Trusted Setup: Multi-Party Phase-2 Ceremony
Tukar's proving keys are Groth16 over BN254, which needs a two-phase trusted setup.
- Phase 1 (universal): the real Hermez
powersOfTau28_hez_final_14ceremony. It is already multi-party, and reproducibly waste-free (snarkjs zkey verifybinds every deployed key to it). Nothing to redo here. - Phase 2 (per-circuit): the deployed keys are now the output of a multi-party
phase-2 ceremony (3 independent contributions + a public random beacon). The seven
browser-shipped
frontend/circuit/*_final.zkeyare byte-identical toceremony/<circuit>/*_final.zkeyand the on-chain verifiers embed the matching VKs. All eight circuits (transfer, compliance, disclosure, merkleUpdate, thresholdDisclosure, aggregateDisclosure, rangeDisclosure, and reserves) have a committed transcript atceremony/<circuit>/TRANSCRIPT.txt. The reserves circuit is proved off the browser path, so its key ships with the reserves tooling rather than infrontend/circuit/; its phase-1 is the larger HermezpowersOfTau28_hez_final_15, matching its 21471 constraints. Production wants multiple independent contributors so that as long as one is honest, the toxic waste is unrecoverable; the demo ran all rounds on one machine to prove the process, so the one-honest-party guarantee holds fully only with genuinely independent parties.
This repo ships that runnable multi-party phase-2 ceremony.
Run it
bash scripts/ceremony-phase2.sh compliance # or: npm run ceremony
It performs, into ceremony/<circuit>/ (the deployed circuits/build/*_final.zkey
are left untouched, so the live verifier contracts keep matching):
groth16 setupto make the initial phase-2 zkey from the circuit r1cs + Hermez phase-1- 3 independent contributions (
zkey contribute), each adding secret entropy - a public random beacon (
zkey beacon), a final round nobody can bias zkey verifyagainst the r1cs + Hermez ptau →ZKey Ok!- exports the verification key and writes
TRANSCRIPT.txt
Verified output for the compliance circuit is committed at
ceremony/compliance/TRANSCRIPT.txt and
ceremony/compliance/compliance_vk.json
(the large .zkey files are regenerable and git-ignored).
Real multi-party (production)
Running all rounds on one machine demonstrates the process; the security guarantee holds only when each contribution comes from an independent party. In production:
- Coordinator runs step 1, publishes
${circuit}_0000.zkey. - Contributor k downloads
${circuit}_000(k-1).zkey, runssnarkjs zkey contributeon their own machine with their own secret entropy, publishes${circuit}_000k.zkeyand their attestation (contribution hash), and destroys the entropy. - After N contributors, the coordinator applies the public beacon (e.g. a future
Bitcoin/Stellar block hash) and runs
zkey verify. - Everyone checks their contribution hash appears in the transcript.
Promoting a ceremony key to production
The verification key is embedded in the deployed verifier contracts, so adopting a new phase-2 key means rebuilding + redeploying the affected verifier (and re-pointing the pool if its id changes):
- Copy
ceremony/<circuit>/<circuit>_final.zkey→circuits/build/<circuit>_final.zkeyand re-exportfrontend/circuit/<circuit>_final.zkey+ the vk. - Rebuild the verifier WASM with the new vk (
scripts/wsl-build-verifier.sh) and deploy it; updatedeployments/testnet.json. - Re-run the soundness suites (
npm run test:negative,test:proving,test:asp).
Because this changes live contract ids, it is deliberately a separate step, not part of the demo build.