perf(zkatdlog): optimize IPA prover using native gnark-crypto arithmetic - #2154
perf(zkatdlog): optimize IPA prover using native gnark-crypto arithmetic#2154SurbhiAgarwal1 wants to merge 6 commits into
Conversation
aca7240 to
d4f768b
Compare
Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
d4f768b to
4b48652
Compare
|
Hi @adecaro and @AkramBitar , I have updated the PR branch (
Could you please trigger/re-run the CI workflows and let me know if any further changes are needed? Thanks! |
|
Thanks a lot for submitting this PR! Regards, |
|
Could you please help to review this PR? Thanks a lot, |
|
Thanks for this, @SurbhiAgarwal1, the native-arithmetic port of the inner-product/MSM prep looks good and follows the existing GnarkFr[T] pattern correctly. |
Thanks a lot for your support. Regards, |
|
Hi @neetance and @AkramBitar, Here are the benchmark numbers for the native gnark-crypto arithmetic path:
Please see the attached terminal benchmark output below for complete details. Thanks! |
|
Hi @SurbhiAgarwal1, Thanks a lot for running the benchmarks! I assume these are the results after the fix. It would be great if we could also have the benchmark numbers from before and after the changes, so we can make a complete comparison and see the overall impact of this PR, as @neetance mentioned above. Thanks a million, |
|
Hello @SurbhiAgarwal1 Any update on that PR? Regards, |
|
Hi @AkramBitar, apologies for the delay. I’ve been busy with some other work and haven’t been able to get back to this yet. I’ll work on the before-and-after benchmark comparison and update the PR within the next 2–3 days. Thanks for your patience! |
|
@SurbhiAgarwal1 |
|
Hello @SurbhiAgarwal1 I am wondering if you had the chance to work in this PR benchmarks as described above? Regards, |
|
Hi @AkramBitar and @neetance, Here are the Before (Baseline) benchmark results for the generic mathlib Inner Product Argument (IPA) prover before applying the native Standard Generic IPA Prover
Please see the attached terminal screenshot below for the raw
|
|
Thank you for the fix and for the updated benchmark results! I am wondering if we can compare the results directly, since the before-fix and after-fix results seem to be from different tests/workloads. After-fix tests: BN254 Native IPA Prover Before-fix test: A single benchmark with execution time, memory allocation, and allocation count So I think we would need the same test/benchmark configuration before and after the fix to accurately measure the impact of the fix (same as after fix IPA tests). Thanks again for the work on this! Akram |
|
Hi @AkramBitar and @neetance, Apologies for the delay! Here are the before/after results using Environment: Windows, amd64, 13th Gen Intel Core i5-13450HX
BN254 shows a clear improvement: -12.5% time, -15.3% memory, -9.2% allocations. BLS12-381 shows no regression — memory and allocs are essentially identical (0% difference). During investigation I found the native IPA path was hurting BLS12-381 due to
The range proof native path for BLS12-381 in |
|
Thanks a million for the effort that you put in this PR. I appreciate it a lot. Could you please have a look at the result, maybe it is worth to run this branch on our performance env. or to check how much improvement we gained in the PR benchmark workflow? Regards, |
- Restore tampered_C and tampered_D subtests in TestNativeRPTamperedProofRejected; both are required security regression tests - Add clarifying comment in nativeIPAReduce explaining that the updated com is never hashed and does not affect the Fiat-Shamir transcript; the folding is required only for the verifier algebraic consistency check - Fix misleading godoc on ComputeSVector: BatchInverse is still called once to compute challenge inverses up front; the butterfly avoids a second BatchInverse pass over the full s/sInv output vectors Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
Benchmarking showed the native gnark-crypto path for BLS12-381 yields no speedup and more allocations due to BigInt conversion overhead from 48-byte field elements. Restrict nativeIPAReduce dispatch to BN254 only. Also: - Remove unused bls12381fr import - Add DisableNativeIPA flag for benchmark comparison (used by BenchmarkCompareIPAProver in ipa_native_test.go) Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
Effi-S correctly identified that the com update inside the prover's reduce loop is dead computation: the updated com is never hashed (x is derived solely from Hash(L[i], R[i])) and is never returned. The verifier reconstructs the commitment independently from LArray and RArray without relying on the prover's com accumulation. Remove the xSquare/xSquareInv/CPrime/com block from both: - nativeIPAReduce in ipa_native.go - the generic mathlib reduce loop in ipa.go Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
Restore the security regression test for F-09: verifies that a proof with foreign (C, D) from another honest proof is rejected by the native verifier, confirming the z-challenge binding finding does not translate into an exploitable forgery. Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
|
@AkramBitar @SurbhiAgarwal1 |





Description
This PR introduces native gnark-crypto field arithmetic for the Inner Product Argument (IPA) prover to eliminate the allocation overhead of the generic mathlib wrapper in tight reduction loops. Supersedes #1912.
As discussed in #1432 and the parent performance epic (#954), the core curve layer heavily relies on mathlib interface allocations, which becomes a bottleneck during Bulletproof/IPA proof generation.
Changes Made
ipa_native.gocontainingnativeIPAReduceto execute round reductions natively.ipaProver.reduceto dynamically dispatch execution based on the underlying curve viamath.DispatchCurve(BLS12-381 and BN254).math.GnarkFr[T]) for in-place scalar computations.Related Issues
Type of Change
Testing Done
make unit-tests)