Skip to content

Small prime ntt - #173

Merged
odraccir1 merged 11 commits into
masterfrom
ra/small_prime_ntt
Oct 15, 2026
Merged

odraccir1 merged 11 commits into
masterfrom
ra/small_prime_ntt

Conversation

@odraccir1

@odraccir1 odraccir1 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Adds bn254_small_prime_fft_backend, an opt-in polynomial backend that accelerates BN254 Fp12 arithmetic using transforms over 50-bit primes and exact signed CRT reconstruction.

The backend supports multiplication, dedicated squaring, low products, prepared low products, and prepared cyclic remainders. It integrates with the existing polynomial context and divisor context, allowing division and modular arithmetic to reuse transformed operands.

Implementation details:

• Scalar radix-4/radix-2 transforms with cached plans and reusable spectrum buffers.
• Exact FMA-based residue arithmetic using integer-valued doubles, with an integer fallback when the required floating-point conditions are unavailable.
• Explicit coefficient bounds, CRT capacity checks, and transform-size/storage checks.
• Owned prepared spectra that can be reused across compatible backend instances.

Performance

Measured on an AMD EPYC 9454 under KVM, pinned to one CPU, using GCC 15.2 with -O3 -march=native. Inputs are deterministic, dense synthetic BN254 Fp12 polynomials with modulus degree 14,938. Times are medians of five trials after two warmups; setup is measured separately.

Operation : Mixed-radix backend, Small-prime backend, Speedup
Multiplication : 4.235 s , 0.769 s, 5.51×
Squaring: 2.883 s , 0.603 s , 4.78×
Modular multiplication: 8.458 s , 1.621 s, 5.22×
Modular squaring: 7.072 s, 1.454 s, 4.86×

@odraccir1
odraccir1 requested a review from spaceships October 15, 2026 20:47
@odraccir1
odraccir1 merged commit 93857d6 into master Oct 15, 2026
2 checks passed
@odraccir1
odraccir1 deleted the ra/small_prime_ntt branch October 15, 2026 20:48
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