Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contribution: from gitibom to 'ceremony/zk-test-ceremony' ceremony #63

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
```fff
5 changes: 5 additions & 0 deletions ceremony.env
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions contributions/CONTRIBUTIONS.md
Original file line number Diff line number Diff line change
@@ -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
```

```
Binary file added contributions/census.r1cs
Binary file not shown.
Binary file added contributions/census.wasm
Binary file not shown.
3 changes: 3 additions & 0 deletions contributions/census_initial_contribution.zkey
Git LFS file not shown
117 changes: 117 additions & 0 deletions inputs/census.circom
Original file line number Diff line number Diff line change
@@ -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<realNLevels; i++) {
sikVerifier.siblings[i] <== sikSiblings[i];
}
sikVerifier.oldKey <== 0;
sikVerifier.oldValue <== 0;
sikVerifier.isOld0 <== 0;
sikVerifier.key <== address;
sikVerifier.value <== sik.out;

component censusVerifier = SMTVerifier(realNLevels);
censusVerifier.enabled <== 1;
censusVerifier.fnc <== 0; // 0 as is to verify inclusion
censusVerifier.root <== censusRoot;
for (var i=0; i<realNLevels; i++) {
censusVerifier.siblings[i] <== censusSiblings[i];
}
censusVerifier.oldKey <== 0;
censusVerifier.oldValue <== 0;
censusVerifier.isOld0 <== 0;
censusVerifier.key <== address;
censusVerifier.value <== availableWeight;

component computedNullifier = Poseidon(4);
computedNullifier.inputs[0] <== signature;
computedNullifier.inputs[1] <== password;
computedNullifier.inputs[2] <== electionId[0];
computedNullifier.inputs[3] <== electionId[1];

component checkNullifier = ForceEqualIfEnabled();
checkNullifier.enabled <== 1;
checkNullifier.in[0] <== computedNullifier.out;
checkNullifier.in[1] <== nullifier;
}

component main { public [ electionId, nullifier, availableWeight, voteHash, sikRoot, censusRoot ] } = ZkFranchiseProofCircuit(160);
3 changes: 3 additions & 0 deletions inputs/powersOfTau28_hez_final_17.ptau
Git LFS file not shown
1 change: 1 addition & 0 deletions newfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fff