A simple circom demo
-
Generate the rank 1 constraint system (r1cs).
circom multiplier2.circom --r1cs --wasm -
Compute the witness.
node generate_witness.js multiplier2.wasm input.json witness.wtns
Using snarkjs we'll prove the circuit through the Groth16 zk-SNARK protocol.
-
Circuit independent.
snarkjs powersoftau new bn128 12 pot12_0000.ptau -vsnarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name="First contribution" -v -
Circuit dependent.
snarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau -v -
Generate zkey.
snarkjs groth16 setup multiplier2.r1cs pot12_final.ptau multiplier2_0000.zkeysnarkjs zkey contribute multiplier2_0000.zkey multiplier2_0001.zkey --name="1st Contributor Name" -v -
Export zkey.
snarkjs zkey export verificationkey multiplier2_0001.zkey verification_key.json -
Generate the proof.
snarkjs groth16 prove multiplier2_0001.zkey witness.wtns proof.json public.json