-
Notifications
You must be signed in to change notification settings - Fork 0
[New Circuit] KV Membership circuit #1
base: main
Are you sure you want to change the base?
Conversation
const pubKey = ec.keyFromPrivate(privKey.toString("hex")).getPublic(); | ||
|
||
const hashPubKey = poseidon.hash([pubKey.x.toString("hex"), pubKey.y.toString("hex")]); | ||
const hashSecret = poseidon.hash([secret, BigInt(0)]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could maybe leave a comment here or in the circuit about why padding is necessary
const SECP256K1_N = new BN( | ||
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", | ||
16 | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do? just curiousity, i see it used down below, assuming something related to the curve math
let serialized = new Uint8Array( | ||
32 + 1 + this.msgHash.byteLength + circuitPubInput.byteLength | ||
); | ||
|
||
serialized.set(bigIntToBytes(this.r, 32), 0); | ||
serialized.set(bigIntToBytes(this.rV, 1), 32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could potentially make vars like:
const rLength = 32;
const rVLength = 1;
let serialized = new Uint8Array(
rLength + rVLength + this.msgHash.byteLength + circuitPubInput.byteLength
);
serialized.set(bigIntToBytes(this.r, rLength), 0);
serialized.set(bigIntToBytes(this.rV, rVLength), rLength);
...
Just to make it clear what each padding is for (but this is extremely minor)
name: string; | ||
version: string; | ||
chainId: number; | ||
// verifyingContract: PrefixedHex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this get added later?
packages/lib/package.json
Outdated
"snarkjs": "^0.5.0", | ||
"ethers": "5", | ||
"snarkjs": "^0.5.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Da-Colon -- snarkjs is included twice here
Summary
This pull request introduces a new zk-SNARK circuit called
KVMembership
that serves multiple purposes such as nullifier check, Merkle proof verification, and statement value validation. The circuit is implemented in Circom and leverages multiple components fromcircomlib
as well as custom components likeEfficientECDSA
andPoseidon
. Unit tests have been added to ensure the prove and verify functions of the circuit work as expected.Features
Dependencies
Installation and Testing
Pre-requisites
circom
installed as its missing the README instructions. circomInstallation
Switch to the appropriate Node.js version by running the following command:
Follow the README instructions for setting up the environment and dependencies.
Testing
Run the test suite with the following command: