ZK circuit definitions for the IAM Protocol. Proves that the Hamming distance between two Poseidon-committed Temporal Fingerprints is below a threshold, without revealing either fingerprint.
iam_hamming.circom — Main Groth16 circuit (BN254). ~1,996 constraints.
Proves three things:
Poseidon(pack(ft_new), salt_new) == commitment_newPoseidon(pack(ft_prev), salt_prev) == commitment_prevHammingDistance(ft_new, ft_prev) < threshold
Public inputs: commitment_new, commitment_prev, threshold
Private witnesses: ft_new[256], ft_prev[256], salt_new, salt_prev
# Prerequisites: circom (cargo install --git https://github.com/iden3/circom.git), Node.js >= 20
npm install
./scripts/setup.sh # Download ptau, compile, trusted setup, export VK
npm test # Run circuit tests (7 tests)# Generate a test proof (requires setup.sh to have been run)
npx snarkjs groth16 fullprove <input.json> build/iam_hamming_js/iam_hamming.wasm build/iam_hamming_final.zkey proof.json public.jsonkeys/verification_key.json — snarkjs format, committed to the repo.
keys/verifying_key.rs — Rust format for groth16-solana, used by protocol-core/iam-verifier.
MIT