From fbb8375db5d9e46b7ae39e5d6ddff312242444e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Men=C3=A9ndez?= Date: Wed, 15 Nov 2023 10:37:09 +0100 Subject: [PATCH] Initialize ceremony --- ceremony.env | 5 ++ inputs/census.circom | 117 +++++++++++++++++++++++++++++++++++++++++++ inputs/input.ptau | 3 ++ 3 files changed, 125 insertions(+) create mode 100644 ceremony.env create mode 100644 inputs/census.circom create mode 100644 inputs/input.ptau diff --git a/ceremony.env b/ceremony.env new file mode 100644 index 0000000..d241055 --- /dev/null +++ b/ceremony.env @@ -0,0 +1,5 @@ +TARGET_CIRCUIT=./inputs/census.circom +INPUT_PTAU=./inputs/input.ptau +CEREMONY_BRANCH=ceremony/new-test +CONTRIBUTIONS_PATH=./contributions +OUTPUT_PATH=./results diff --git a/inputs/census.circom b/inputs/census.circom new file mode 100644 index 0000000..bd6e53a --- /dev/null +++ b/inputs/census.circom @@ -0,0 +1,117 @@ +pragma circom 2.1.2; + +include "/node_modules/circomlib/circuits/poseidon.circom"; +include "/node_modules/circomlib/circuits/comparators.circom"; +include "/node_modules/circomlib/circuits/smt/smtverifier.circom"; + +/** + ┌───────────┐ + ┌────────────────────▶lessOrEqual├──────────┐ + (pub) voteWeight───────┘ └─────▲─────┘ │ + │ │ + (priv) availableWeight─┬────────────────────────────────┘ │ + │ │ ┌────┐ + │ └───▶│ └┐ + │ ┌────────────────────┐ ┌──────▶│ └┐ + │ ┌────▶key │ │ │ ├─ + └──│────▶value │ │ ┌──▶│ ┌┘ + │ │ SMTVerifier├─────────────────┘ ┌────▶│ ┌┘ + (pub) censusRoot────│────▶root │ │ │ └────┘ + ┌──│────▶siblings │ │ │ + (priv) censusSiblings─┘ │ └────────────────────┘ │ │ + │ ┌────────────────────┐ │ │ + │ ┌─────────────────▶key │ │ │ + │ │ ┌─▶value │ │ │ + │ │ │ │ SMTVerifier├──│─┘ + (pub) sikRoot────│─────────────────────▶root │ │ + │ ┌─────────────────▶siblings │ │ + (priv) sikSiblings────│───┘ │ └────────────────────┘ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + (priv) address────┼───┘ ┌────────────┐│ │ + ├────▶│ ││ │ + (priv) password────│────▶│ Hash ├┘ │ + ┌──│────▶│ │ │ + (priv) signature─┤ │ └────────────┘ │ + │ │ │ + │ │ ┌────────────┐ │ + │ └────▶│ │ │ + └───────▶│ Hash ├──────────┐ │ + ┌────▶│ │ │ │ + │ └────────────┘ │ │ + (pub) electionId────┘ │ │ + ┌─────▼─────┐ │ + (pub) nullifier────────────────────────────▶ equal ├─────────┘ + └───────────┘ +*/ + +template ZkFranchiseProofCircuit (nLevels) { + var realNLevels = nLevels+1; + signal input electionId[2]; + signal input nullifier; + signal input availableWeight; + // voteHash is not operated inside the circuit, assuming that in + // Circom an input that is not used will be included in the constraints + // system and in the witness + signal input voteHash[2]; + signal input sikRoot; + signal input censusRoot; + + signal input address; + signal input password; + signal input signature; + + signal input voteWeight; + signal input censusSiblings[realNLevels]; + signal input sikSiblings[realNLevels]; + + component checkWeight = LessEqThan(252); + checkWeight.in[0] <== voteWeight; + checkWeight.in[1] <== availableWeight; + checkWeight.out === 1; + + component sik = Poseidon(3); + sik.inputs[0] <== address; + sik.inputs[1] <== password; + sik.inputs[2] <== signature; + + component sikVerifier = SMTVerifier(realNLevels); + sikVerifier.enabled <== 1; + sikVerifier.fnc <== 0; // 0 as is to verify inclusion + sikVerifier.root <== sikRoot; + for (var i=0; i