Build a custom circuit
Bring your own circom circuit and verify its proofs through the zkHelios program.
1. Write the circuit
circom
pragma circom 2.1.6;
template Membership(depth) {
signal input leaf;
signal input path[depth];
signal input root; // public
signal output ok;
// ... Merkle inclusion constraints ...
}
component main { public [root] } = Membership(20);2. Compile + trusted setup
bash
circom membership.circom --r1cs --wasm
snarkjs groth16 setup membership.r1cs pot.ptau membership_0.zkey
snarkjs zkey contribute membership_0.zkey membership_final.zkey
snarkjs zkey export verificationkey membership_final.zkey vkey.json3. Register the circuit on-chain
An admin registers the verifying key so the program can verify proofs for it:
ts
await zk.admin.registerCircuit({
name: "membership_v1",
proofType: "membership",
verifyingKey: vkeyToBytes(vkey),
publicInputCount: 1,
});The verifying key is consensus-critical. Only register keys from a circuit you have audited and whose trusted setup you trust.
4. Prove with it
ts
const proof = await zk.proveCustom({
circuit: "membership_v1",
inputs: { leaf, path, root },
});
await zk.submitProof(proof);