Skip to content

Add Groth16Hybrid algorithm (5): SHA-256 key hash + Poseidon MAC#32

Merged
sweis merged 1 commit intomainfrom
claude/symmetric-key-proofs-lgsxG
Feb 27, 2026
Merged

Add Groth16Hybrid algorithm (5): SHA-256 key hash + Poseidon MAC#32
sweis merged 1 commit intomainfrom
claude/symmetric-key-proofs-lgsxG

Conversation

@sweis
Copy link
Copy Markdown
Owner

@sweis sweis commented Feb 27, 2026

New SNARK circuit variant for when the verifier only knows SHA-256(K) (e.g., from existing HMAC key infrastructure). The circuit proves:

  1. SHA-256(K) == key_hash (in-circuit SHA-256, ~26K constraints)
  2. Poseidon(K_fr, payload_hash) == mac (in-circuit Poseidon)

Changes across all layers:

  • types.rs: Groth16Hybrid = 5 algorithm variant
  • snark.rs: HybridKeyProofCircuit with SHA-256 key hash gadget + Poseidon MAC, le_bytes_to_fpvar helper, setup_hybrid/prove_hybrid/ verify_hybrid functions
  • sign.rs: sign_groth16_hybrid(), compute_sha256_full_key_hash()
  • verify.rs: verify_groth16_hybrid()
  • keys.rs, serialize.rs: algorithm 5 in all match arms
  • main.rs: "groth16-hybrid" in generate-key, snark-setup (with -a flag), sign, verify; SNARK VK verify dispatches on token algorithm

142 tests pass (125 unit + 4 reference + 13 test vectors). Hybrid tests use run_with_large_stack(64MB) for SHA-256 circuit.

https://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM

New SNARK circuit variant for when the verifier only knows SHA-256(K)
(e.g., from existing HMAC key infrastructure). The circuit proves:
  1. SHA-256(K) == key_hash  (in-circuit SHA-256, ~26K constraints)
  2. Poseidon(K_fr, payload_hash) == mac  (in-circuit Poseidon)

Changes across all layers:
- types.rs: Groth16Hybrid = 5 algorithm variant
- snark.rs: HybridKeyProofCircuit with SHA-256 key hash gadget +
  Poseidon MAC, le_bytes_to_fpvar helper, setup_hybrid/prove_hybrid/
  verify_hybrid functions
- sign.rs: sign_groth16_hybrid(), compute_sha256_full_key_hash()
- verify.rs: verify_groth16_hybrid()
- keys.rs, serialize.rs: algorithm 5 in all match arms
- main.rs: "groth16-hybrid" in generate-key, snark-setup (with -a flag),
  sign, verify; SNARK VK verify dispatches on token algorithm

142 tests pass (125 unit + 4 reference + 13 test vectors).
Hybrid tests use run_with_large_stack(64MB) for SHA-256 circuit.

https://claude.ai/code/session_01LJyL1uYXD1JHMq8Q3v7shM
@sweis sweis merged commit a2678b8 into main Feb 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants