-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1944 from privacy-scaling-explorations/feature/re…
…base-anon-poll-joining feat: rebase anon poll joining with dev
- Loading branch information
Showing
136 changed files
with
4,671 additions
and
5,368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { BigInt as GraphBN } from "@graphprotocol/graph-ts"; | ||
|
||
export const ONE_BIG_INT = GraphBN.fromU32(1); | ||
export const MESSAGE_TREE_ARITY = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
pragma circom 2.0.0; | ||
|
||
// circomlib import | ||
include "./mux1.circom"; | ||
// zk-kit imports | ||
include "./safe-comparators.circom"; | ||
// local imports | ||
include "../utils/hashers.circom"; | ||
include "../utils/privToPubKey.circom"; | ||
include "../trees/incrementalMerkleTree.circom"; | ||
|
||
template PollJoining(stateTreeDepth) { | ||
// Constants defining the structure and size of state. | ||
var STATE_LEAF_LENGTH = 4; | ||
var STATE_TREE_ARITY = 2; | ||
|
||
// Public key IDs. | ||
var STATE_LEAF_PUB_X_IDX = 0; | ||
var STATE_LEAF_PUB_Y_IDX = 1; | ||
// Voice Credit balance id | ||
var STATE_LEAF_VOICE_CREDIT_BALANCE_IDX = 2; | ||
var N_BITS = 252; | ||
|
||
// User's private key | ||
signal input privKey; | ||
// Poll's private key | ||
signal input pollPrivKey; | ||
// Poll's public key | ||
signal input pollPubKey[2]; | ||
// The state leaf and related path elements. | ||
signal input stateLeaf[STATE_LEAF_LENGTH]; | ||
// Siblings | ||
signal input siblings[stateTreeDepth][STATE_TREE_ARITY - 1]; | ||
// Indices | ||
signal input indices[stateTreeDepth]; | ||
// User's hashed private key | ||
signal input nullifier; | ||
// User's credits for poll joining (might be <= oldCredits) | ||
signal input credits; | ||
// MACI State tree root which proves the user is signed up | ||
signal input stateRoot; | ||
// The actual tree depth (might be <= stateTreeDepth) Used in BinaryMerkleRoot | ||
signal input actualStateTreeDepth; | ||
|
||
var computedNullifier = PoseidonHasher(1)([privKey]); | ||
nullifier === computedNullifier; | ||
|
||
// User private to public key | ||
var derivedPubKey[2] = PrivToPubKey()(privKey); | ||
derivedPubKey[0] === stateLeaf[STATE_LEAF_PUB_X_IDX]; | ||
derivedPubKey[1] === stateLeaf[STATE_LEAF_PUB_Y_IDX]; | ||
|
||
// Poll private to public key | ||
var derivedPollPubKey[2] = PrivToPubKey()(pollPrivKey); | ||
derivedPollPubKey[0] === pollPubKey[0]; | ||
derivedPollPubKey[1] === pollPubKey[1]; | ||
|
||
// Inclusion proof | ||
var stateLeafHash = PoseidonHasher(4)(stateLeaf); | ||
var stateLeafQip = BinaryMerkleRoot(stateTreeDepth)( | ||
stateLeafHash, | ||
actualStateTreeDepth, | ||
indices, | ||
siblings | ||
); | ||
|
||
stateLeafQip === stateRoot; | ||
|
||
// Check credits | ||
var isCreditsValid = SafeLessEqThan(N_BITS)([credits, stateLeaf[STATE_LEAF_VOICE_CREDIT_BALANCE_IDX]]); | ||
isCreditsValid === 1; | ||
|
||
// Check nullifier | ||
var hashedPrivKey = PoseidonHasher(1)([privKey]); | ||
hashedPrivKey === nullifier; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.