Compile the LogicGate() circuit and verify it.
pragma circom 2.0.0;
template LogicGate () {
signal input a;
signal input b;
signal x;
signal y;
signal output Q;
component andGate = AND();
component orGate = OR();
component notGate = NOT();
// circuit logic
andGate.a <== a;
andGate.b <== b;
notGate.in <== b;
x <== andGate.out;
y <== notGate.out;
orGate.a <== x;
orGate.b <== y;
Q <== orGate.out;
}
template AND() {
signal input a;
signal input b;
signal output out;
out <== a*b;
}
template NOT() {
signal input in;
signal output out;
out <== 1 + in - 2*in;
}
template OR() {
signal input a;
signal input b;
signal output out;
out <== a + b - a*b;
}
component main = LogicGate();
npm i
npx hardhat circom
This will generate the out file with circuit intermediaries and geneate the MultiplierVerifier.sol contract
npx hardhat run scripts/deploy.ts
npx hardhat run scripts/deploy.ts --network mumbai
This script does 4 things
- Deploys the MultiplierVerifier.sol contract
- Generates a proof from circuit intermediaries with
generateProof()
- Generates calldata with
generateCallData()
- Calls
verifyProof()
on the verifier contract with calldata
With two commands you can compile a ZKP, generate a proof, deploy a verifier, and verify the proof 🎉
This project was developed by Uttam Kumar.
This project is licensed under the MIT License.