Repository navigation
Harden ZkeyContributor validation, ctScalarMul, and CI snarkjs interop (ADR-0031) - #120
Conversation
…rkjs interop (ADR-0031)
|
[reviewer1] Changes requested on
One test improvement: the mixed-tool interop test exports the final verification key but only checks whether the generated proof points lie on their curves. Verify the proof against that key and its public input to substantiate the test's end-to-end verification claim. |
|
[reviewer3] Review of head Scope: engineering, cross-backend, CI/build wiring, docs/links. What I verified
Blocking
Non-blocking (P3)
|
|
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 ceremonies, interop tests, or filesystem race tests. |
…tion 10 streaming, UTF-16 name parity, and ceremony docs
|
Addressed all review items from
Verification ( Ready for Round 2 re-review from |
|
[reviewer1] Approved on I ran the contributor, ceremony, streaming import, oracle locator, and bidirectional Groth16/PlonK interop tests from a clean snapshot of this SHA with |
|
[reviewer3] Re-review of head All five points from my review of
Also checked: Section 10 is now streamed (the prior-record byte range is copied mapping-to-mapping, and the transcript hash input is unchanged). The Verification (clean worktree at
Non-blocking follow-ups (optional):
|
Summary
Hardens ZeroJ's Groth16 phase-2 MPC ceremony contributor (
ZkeyContributor/CeremonyCli) under an R3 amendment to ADR-0031, and wires fail-closedsnarkjs@0.7.6CI coverage for all four ceremony and streaming.zkeyinterop suites.Risk classification: R3 (
ZkeyContributorsecret-scalar operations on untrusted.zkeyinputs) + R1/Process (CIsnarkjsinterop wiring).1. Governing ADR-0031 R3 Hardening Amendment (
Proposed)snarkjs@0.7.6/ffjavascript@0.3.1references, exact invariants (S1–S7), measured throughput trade-off (3.57×vs unvalidated variable-timescalarMul), breaking/compatibility notes, milestones, and revision history in docs/adr/0031-groth16-mpc-trusted-setup-ceremony.md.--overwrite, offline/isolated host guidance, and the measured timing estimate.2.
ZkeyContributor&CeremonyCliHardening (S1–S7)k/s):magic, version{1, 2}, 10 unique sections1..10, no OOB/negative/duplicate/unknown sections, zero trailing bytes, protocol1, header length964).n8q == 48,q == FP,n8r == 32,r == FR) and dimension-matched section sizes for sections 3–9.< pMontgomery limb decoding viaMontFp381.fromMontLimbs(no silent.mod(p)reduction) and explicit G2 infinity sentinel ing2FromLem.e(delta1, G2) == e(G1, delta2)and chain continuity check (delta1 == G1at 0 priors,delta1 == lastPrior.deltaAfterfor>= 1priors), plus strict sorted TLV validation on section-10 params.L/Hinfinity semantics:s,k, andk⁻¹routed through ADR-0062JacobianG1BLS381.ctScalarMul/JacobianG2BLS381.ctScalarMul(checkingL/Hpoints on-curve + prime-order subgroup once insidectScalarMuland surfacing worker errors cleanly asIOException).L/H(k⁻¹ · O = O, zero secret leakage), matchingsnarkjs@0.7.6(zkey_new.js:460-466,mpc_applykey.js:44).--nameguard:createLink/ATOMIC_MOVE), cleaning up temp files on any error.--in == --out(including symlinks viaFiles.isSameFile).--outunless explicitoverwrite = true/--overwriteis supplied.--nameon code-point boundaries (<= 64code points and<= 255UTF-8 bytes) to prevent surrogate splits and 1-byte TLV length overflow.3. Fail-Closed
snarkjs@0.7.6CI InteropSnarkjsCliLocatorinzeroj-cryptotestFixtures(excluded from published metadata per ADR-0046) resolvingsnarkjs@0.7.6from-Dzeroj.snarkjs,SNARKJS_BIN,PATH, and common npm directories.-Dzeroj.snarkjsand-PrequireSnarkjsinzeroj-crypto,zeroj-tools, andzeroj-integration-tests.R1csSnarkjsCeremonyRoundTripTest,ZkeyPkStoreImporterTest,ZkeyContributorInteropTest, andCeremonyCliTestto useSnarkjsCliLocatorand fail closed under-PrequireSnarkjs..github/workflows/assurance.yml(snarkjs-interopjob) and uploads all three module test reports.Breaking / Compatibility Notes
ZkeyContributor.contribute(Path, Path, String)now throwsIOExceptionifoutalready exists (previously deletedoutunconditionally). Usecontribute(in, out, name, true)orzeroj-ceremony contribute --overwriteto replace an existing output; in-place--in == --outis always rejected..zkeyinputs (wrong primes, non-canonical coordinates, invalid points, mismatcheddelta1/delta2, broken prior chains) now fail closed..zkeywire format remains 100% bit-compatible withsnarkjs@0.7.6.Verification
./gradlew -PrequireSnarkjs :zeroj-tools:check :zeroj-crypto:check :zeroj-integration-tests:test --tests 'org.zeroj.it.snarkjs.SnarkjsGroth16InteropTest' --stacktrace— PASSED (livesnarkjs@0.7.6verified mixed-tool ceremony transcripts + streaming.zkeyimport + ADR-0046GenerateModuleMetadatacheck + all new offline adversarial tests inZkeyContributorTestandCeremonyCliTest).n = 4,096):19,006 muls/s(scalarMul) vs5,326 muls/s(ctScalarMul,3.57×), recorded in ADR-0031.