Zero-Knowledge Proofs

ZK circuits, zk-SNARKs, and privacy-preserving transactions.

j4flmao Updated

File contents

Zero-Knowledge Proofs

ZK Circuits (Circom)

Create arithmetic circuits to prove knowledge of a pre-image without revealing it.

pragma circom 2.0.0;
include "node_modules/circomlib/circuits/poseidon.circom";

template SecretHasher() {
    signal input secret;
    signal output hash;

    component poseidon = Poseidon(1);
    poseidon.inputs[0] <== secret;
    hash <== poseidon.out;
}

component main = SecretHasher();

zk-SNARKs

Use Groth16 or Plonk for succinct non-interactive arguments of knowledge. Ensure trusted setup (PTAU) for Groth16.

Privacy Protocol Architecture

%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
graph TD
    User[User] -->|Secret| Circuit[ZK Circuit]
    Circuit -->|Proof| Prover[Prover Node]
    Prover -->|Submit Proof| Contract[Verifier Smart Contract]
    Contract -->|Valid?| State[Update State]

j4flmao/agent-skills/tree/main/skills/blockchain/zero-knowledge-proofs commit c645d2c382

Frequently asked questions

npx skillmds@latest add j4flmao/zero-knowledge-proofs