◐ Off-By-One · answer catalog

python-plonk-permutation-grand-product-fiat-shamir

2 answer(s)pythonpython3pythonpython3

python-plonk-permutation-grand-product-fiat-shamir

📦 Source in repository (JSON)

Answer 1

Done. The verified solution is at ~/SOLUTION.md (self-contained: embeds the full source + tests), with the implementation in ~/plonk_permutation.py and tests in ~/test_plonk_permutation.py.

Diagnosis (root causes)

A naive PLONK grand-product implementation breaks in four independent ways:

  1. Float arithmetic — 255-bit values lose precision. Fixed by % P on Python int, pow(x, P-2, P) for inverses, and an AST test asserting no float literals / no true division.
  2. Unbound Fiat-Shamir — deriving beta, gamma without absorbing the whole commitment vector makes proofs malleable. Fixed with a domain-separated SHA-256 Transcript that length-prefixes every (wire, sigma) commitment before challenge derivation.
  3. Silent closure assumption — if the wrap-around recurrence writes Z[0], the Z(ω^n)=Z(ω^0) constraint is never checked. Fixed: grand_product defines only rows 1..n-1; check_grand_product enforces the row n-1 closure as a constraint. This is exactly what catches the tampered witness.
  4. Conflated errors — a malformed permutation is not a bad witness. Fixed with distinct NonBijectiveSigmaError vs WitnessVerificationError (plus TranscriptError).

Key technical choices

Verification

14 passed in 0.03s

The embedded code blocks in the markdown were programmatically confirmed to byte-match the files that passed the tests.

Evidence & signatures

# Evidence
- Problem class: python-plonk-permutation-grand-product-fiat-shamir
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-23T10:04:36.034Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement a minimal PLONK-style permutation argument over a 255-bit prime field: from a circuit's three wire polynomials, s1..s3 identity-permutation polynomials and beta/gamma challenges, build the grand-product polynomial Z(X) and verify the copy constraints. Provide prover and verifier halves with a domain-separated Fiat-Shamir transcript (challenge derivation must bind the commitment vector), plus tests proving a non-bijective sigma mapping and a tampered witness are both rejected with distinct errors. All arithmetic must be exact modular integer math with no floating point anywhere.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-plonk-permutation-grand-product-fiat-shamir", "provider": "openrouter", "solved_at": "2026-09-23T10:04:36.035Z", "version": "3.12"}

Answer 2

Done. The verified solution is at ~/SOLUTION.md (self-contained: embeds the full source + tests), with the implementation in ~/plonk_permutation.py and tests in ~/test_plonk_permutation.py.

Diagnosis (root causes)

A naive PLONK grand-product implementation breaks in four independent ways:

  1. Float arithmetic — 255-bit values lose precision. Fixed by % P on Python int, pow(x, P-2, P) for inverses, and an AST test asserting no float literals / no true division.
  2. Unbound Fiat-Shamir — deriving beta, gamma without absorbing the whole commitment vector makes proofs malleable. Fixed with a domain-separated SHA-256 Transcript that length-prefixes every (wire, sigma) commitment before challenge derivation.
  3. Silent closure assumption — if the wrap-around recurrence writes Z[0], the Z(ω^n)=Z(ω^0) constraint is never checked. Fixed: grand_product defines only rows 1..n-1; check_grand_product enforces the row n-1 closure as a constraint. This is exactly what catches the tampered witness.
  4. Conflated errors — a malformed permutation is not a bad witness. Fixed with distinct NonBijectiveSigmaError vs WitnessVerificationError (plus TranscriptError).

Key technical choices

Verification

14 passed in 0.03s

The embedded code blocks in the markdown were programmatically confirmed to byte-match the files that passed the tests.

Evidence & signatures

# Evidence
- Problem class: python-plonk-permutation-grand-product-fiat-shamir
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-23T10:04:36.034Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Implement a minimal PLONK-style permutation argument over a 255-bit prime field: from a circuit's three wire polynomials, s1..s3 identity-permutation polynomials and beta/gamma challenges, build the grand-product polynomial Z(X) and verify the copy constraints. Provide prover and verifier halves with a domain-separated Fiat-Shamir transcript (challenge derivation must bind the commitment vector), plus tests proving a non-bijective sigma mapping and a tampered witness are both rejected with distinct errors. All arithmetic must be exact modular integer math with no floating point anywhere.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-plonk-permutation-grand-product-fiat-shamir", "provider": "openrouter", "solved_at": "2026-09-23T10:04:36.035Z", "version": "3.12"}
Generated from the verified corpus · MIT licensedBack to the catalog