Repository navigation
ADR-0068: DSL soundness, PlonK scaling, MPF canonicality & gadget hardening - #125
Conversation
…ty & gadget hardening
|
[reviewer1] Changes requested on
|
|
Initial automated review · Aster Hi @satran004, thanks for the PR! 🙏 This is an automatic first check by an AI reviewer. It does not replace maintainer review and may be wrong. Reviewed commit: Issues found:
Not tested: Code and tests were read only; I did not run the build, circuit tests, or proof interoperability tests. |
|
[reviewer3] Review of head What I verified
Non-blocking (P3)
|
|
[reviewer3] Follow-up: the full |
…k signal ownership
|
Addressed all four Round 1 findings from
Verification
|
|
[reviewer1] Changes requested on One blocking redaction gap remains. In All 15 selected tests passed on this head with zero skips, including SRS snapshot isolation, gadget ownership, input validation and live snarkjs PlonK interoperability. |
|
[reviewer3] Re-review of head Scope: engineering, cross-backend, compatibility and docs. What I verified
Blocking
Non-blocking (P3)
Everything else in round 2 looks correct to me. Once item 1 is fixed or narrowed, I'll approve. |
…te srsG1 prefix in ADR-0068
|
Addressed all remaining review comments in commit
Verification
Ready for final approval. |
|
[reviewer1] Approved All eight selected tests passed with zero skips on this head, including the redaction regression, SRS snapshot isolation and live snarkjs PlonK interoperability. My earlier findings on this PR are closed. |
|
[reviewer3] Re-review of head Scope: engineering, cross-backend, compatibility and docs. What I verified
No remaining findings from me. |
Summary
Implements ADR-0068 (
Proposed, Risk R2) — circuit DSL soundness, PlonK BLS12-381 scaling & batched SRS consistency, Poseidon MPF canonical< Frkey-path conformance, witness validation, and standard-library gadget hardening:ZkUInt.sub252-bit cap &MAX_SAFE_BITSdocumentation:ZkUInt.subatmax(bits, other.bits) < 253(<= 252), closing BN254 253-bit subtraction underflow wrap-around (2^(bits+1) <= r).CircuitAPIImpl.MAX_SAFE_BITSto distinguish decomposition uniqueness (2^bits < p, 253 bits on BN254) from difference-underflow safety (2^(bits+1) <= p, 252 bits on BN254).SrsConsistencyBLS381):PlonKProverBLS381.cosetEval, linearpowFr(switched to binary square-and-multiply),zetaN(switched tologNsquarings), andPlonKSetupBLS381(omegaPowsprecomputation).PtauImporterBLS381andPlonKSetupBLS381with a singleSecureRandom-challenged batched RLC two-pairing check (SrsConsistencyBLS381), plus a snapshot-verifiedWeakHashMapfast path that avoids redundant verification on unmodified importedSRSinstances while catching any post-import array mutation.CircuitAPI.{xor,and,or,not,fromBinary}booleanity & width guards:oneWire, exact constants0/1,isZero/isEqual, and outputs ofxor/and/or/not) inCircuitAPIImpl.booleanWires.assertBooleanon operands ofxor,and,or, andnot(zero extra rows for proven booleans; eliminates redundantAssertBooleanrows in circuits such as Jubjub subgroup checks and JMTinsert-different-leaf), and boundedfromBinaryto1 <= bits.length <= 253with non-null checks.R1CSConstraintSystem.verifyWitness:WitnessCalculator(calculate,calculateFlat,calculateFlatChunked) to reject null maps, unknown input keys, multi-value lists, null elements, and non-canonical values (< 0or>= p) without silent modular reduction.BOOL/BITS:{0,1},BYTES:[0,255],UINT(bits):[0, 2^bits),FIELD: canonical[0, p)) toZkInputMapand generatedInputssetters /calculateWitness.R1CSConstraintSystem.verifyWitness(instance and static overloads).forRemoval = true), legacy-gated (LegacyCurvePolicy.requireLegacyBn254Enabled()), and hardenedGroth16Prover.validateWitness(wire-0, canonical BN254 scalars, bounds) while preserving the public method surface.< Frkey-path constraint &Step.forkvalidation:ZkMpf.requireKeyPath(andZkMpfProofleaf key paths) to be strictly less thanFieldConfig.BLS12_381.prime(), matchingPoseidonMpfHash.digestToNibblesanddocs/merkle/poseidon-authenticated-state-v1.mdinvariant Review: Groth16 + PlonK end-to-end — findings & public-testnet readiness gates (ADR-0025) #8.skip,neighborNibble in [0, 15], and every fork prefix bytein [0, 15]inPoseidonMpfCodec.Step.fork.docs/merkle/poseidon-authenticated-state-v1.mdand ADR-0068.@ProveZkBoolownership:Binary.rotateLeftandSignalBinary.rotateLeft, and guardedBinary.shiftRightagainstn < 0andi + noverflow.RangeCheckwith honest< 2^nBitssemantics and deprecatedAliasCheck(forRemoval = true) with corrected Javadoc.PoseidonN.Objects.requireNonNull+__zeroj.requireSignal(__zerojResult.signal())before.assertTrue()on non-void@Provereturns inCircuitAnnotationProcessor.Verification
snarkjs@0.7.6.ptau -> setup -> prove -> verifyinterop tests passed.ZkUIntSubAndInputMapHardeningTest,CircuitDslHardeningTest,GadgetHardeningTest,PlonKSrsAndScalingTest,Groth16ProverValidateWitnessTest,ZkMpfCanonicalKeyPathAndForkTest, plus expanded tests inCircuitAnnotationProcessorTestandPoseidonMpfOperationWitnessTest.