Skip to content

Accelerate small-prime CRT reconstruction and BN254 export - #175

Merged
odraccir1 merged 1 commit into
masterfrom
ra/small_prime_ntt_CRT_export
Oct 16, 2026
Merged

odraccir1 merged 1 commit into
masterfrom
ra/small_prime_ntt_CRT_export

Conversation

@odraccir1

@odraccir1 odraccir1 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@odraccir1 odraccir1 changed the title CRT reconstruction and BN254 export Accelerate small-prime CRT reconstruction and BN254 export Oct 16, 2026
@odraccir1
odraccir1 requested a review from spaceships October 16, 2026 04:29
@odraccir1
odraccir1 merged commit a2a9a13 into master Oct 16, 2026
2 of 3 checks passed
@odraccir1
odraccir1 deleted the ra/small_prime_ntt_CRT_export branch October 16, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant