Repository navigation
Accelerate small-prime CRT reconstruction and BN254 export - #175
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CRT reconstruction created temporary multiprecision products for every cofactor contribution, while wide BN254 exports could fall back to general division. This change reduces both costs while preserving exact signed reconstruction and coefficient-bound checks.
• Fuse cofactor multiplication and accumulation using only the required limbs.
• Fold reconstructed magnitudes at bit 384 using cached 2^384 mod p, keeping export within the existing Barrett reducer’s fast range.
• Process residue normalization and inverse weighting four lanes at a time with the existing AVX2/FMA kernel, retaining scalar tails and integer fallback.
Native x86 benchmark results against the SIMD baseline (06d04c0 → be42799):
Operation Before After Time reduction
Modular multiplication 1,067.7 ms 849.6 ms 20.4%
Modular squaring 984.3 ms 766.4 ms 22.1%
Multiplication 521.0 ms 416.1 ms 20.1%
Squaring 438.8 ms 332.7 ms 24.2%
Measured on AMD EPYC 9454 with GCC 15.2, -O3 -DNDEBUG -march=native, degree 14,938, one pinned CPU, two warmups, and five measured trials. Figures are median operation times excluding setup. Inputs and source hashes were verified; all eight measured operations improved.