diff --git a/README.md b/README.md index 673134e..7140f49 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,4 @@ A Github action will compile the circuit and generate the first contribution in ``` docker build . --target zk-voceremony -t zk-voceremony docker build . --target zk-voceremony-create -t zk-voceremony-create -``` \ No newline at end of file +```fff diff --git a/ceremony.env b/ceremony.env new file mode 100644 index 0000000..ecc1ac0 --- /dev/null +++ b/ceremony.env @@ -0,0 +1,5 @@ +TARGET_CIRCUIT=./inputs/census.circom +INPUT_PTAU=./inputs/powersOfTau28_hez_final_17.ptau +CEREMONY_BRANCH=ceremony/vocdoni-zkcensus-ceremony +CONTRIBUTIONS_PATH=./contributions +OUTPUT_PATH=./results diff --git a/contributions/CONTRIBUTIONS.md b/contributions/CONTRIBUTIONS.md new file mode 100644 index 0000000..7f209ca --- /dev/null +++ b/contributions/CONTRIBUTIONS.md @@ -0,0 +1,14 @@ +### Global artifacts +- [r1cs](./artifacts/circuit.r1cs) - `1049ddab175ca305100229501083657c7edcb753897d015803004cb333adf5c39686986e45f522c6d8fbc6d816d3f49ff74f23fd45f08aebb72a509cd9c5a16f` +- [wasm](./artifacts/circuit.wasm) - `2ec941c0ba87d8d6fbca11dc720306a90452e154f25b294964e4c4c7009cc94c6b54fbb8e8625d060a8dc3134df13a5d8d8adfa4cacfdc9c3eadf2068a65e3dd` +- [initial ptau](./artifacts/initial.ptau) - `6247a3433948b35fbfae414fa5a9355bfb45f56efa7ab4929e669264a0258976741dfbe3288bfb49828e5df02c2e633df38d2245e30162ae7e3bcca5b8b49345` + +### Contributions +``` +census_initial_contribution.zkey:8540f55c142b3539d032a44012df97ba2d986c8fe67daa1cb47410cd1374224d95540c7cefd8f58d32d987e97935ab29a9a9dc57b800fabe4865106438f15d49 +``` + +### Last contribution +``` + +``` diff --git a/contributions/census.r1cs b/contributions/census.r1cs new file mode 100644 index 0000000..e98937e Binary files /dev/null and b/contributions/census.r1cs differ diff --git a/contributions/census.wasm b/contributions/census.wasm new file mode 100644 index 0000000..f8e17fd Binary files /dev/null and b/contributions/census.wasm differ diff --git a/contributions/census_initial_contribution.zkey b/contributions/census_initial_contribution.zkey new file mode 100644 index 0000000..75c012e --- /dev/null +++ b/contributions/census_initial_contribution.zkey @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14e37cba540c4ae51927c34fcb91e64bdbc915b4cf45564b2acde749a2318de4 +size 55237872 diff --git a/inputs/census.circom b/inputs/census.circom new file mode 100644 index 0000000..fd5ee8a --- /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