Skip to content

Add AVX2 optimizations for ML-DSA NTT operations#3

Open
mdcornu wants to merge 3 commits intomasterfrom
ml_dsa_ntt
Open

Add AVX2 optimizations for ML-DSA NTT operations#3
mdcornu wants to merge 3 commits intomasterfrom
ml_dsa_ntt

Conversation

@mdcornu
Copy link
Owner

@mdcornu mdcornu commented Feb 17, 2026

  • Add AVX2 implementations for NTT, inverse NTT, and NTT multiplication
  • Add ML-DSA NTT runtime AVX2 check to select optimal implementation
Checklist
  • documentation is added or updated
  • tests are added or updated

@mdcornu mdcornu force-pushed the ml_dsa_ntt branch 3 times, most recently from 7fd35f2 to 7d850a5 Compare February 24, 2026 10:36
This commit introduces AVX2-vectorized assembly implementations of the
Number Theoretic Transform (NTT) operations used in ML-DSA (FIPS 204).
These optimizations improve performance of ML-DSA key generation,
signing, and verification operations on x86_64 platforms
with AVX2 support.

The implementation adds the following functions:
- ml_dsa_poly_ntt_avx2: Forward NTT transformation
- ml_dsa_poly_ntt_inverse_avx2: Inverse NTT transformation
- ml_dsa_poly_ntt_mult_avx2: NTT-domain polynomial multiplication

Key implementation details:
- Uses YMM registers to process 8 32-bit coefficients in parallel
- Employs Montgomery reduction for modular arithmetic
- Implements NTT butterfly operations across multiple transform levels
- Includes dedicated zeta table for INTT to reduce cycles
- Runtime capability check via ml_dsa_ntt_avx2_capable() using
  OPENSSL_ia32cap_P to detect AVX2 support

The C code in ml_dsa_ntt.c is updated to dispatch to AVX2 implementations
at runtime when available, with automatic fallback to the portable C
implementation on platforms without AVX2 support.

Build system changes:
- Added GENERATE rule for ml_dsa_ntt-x86_64.s from Perl assembly
- Conditional assembly inclusion based on target architecture
- Works with both libcrypto and FIPS provider builds

Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
Signed-off-by: Tomasz Kantecki <tomasz.kantecki@intel.com>
Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant