LPsLux Proposals
Q-Chain
LP-4074

lp-4074-poly-mul-lattice-polynomial-multiplication


lp: 4074 title: poly_mul — Lattice Polynomial Multiplication description: Polynomial multiplication in the negacyclic ring Z_q[X]/(X^N + 1), the shared arithmetic core under ML-KEM, ML-DSA, TFHE and Pulsar author: Lux Core Team (@luxfi) discussions-to: https://github.com/luxfi/lps/discussions status: Final implementation-rust: none implementation-cpp: partial implementation-go: shipped type: Standards Track category: Core tags: [lattice, polynomial, ntt, arithmetic, ml-kem, ml-dsa, tfhe]

  • lp-4076
  • lp-4040

Abstract

Polynomial multiplication in R_q = Z_q[X] / (X^N + 1) — the negacyclic cyclotomic ring. Every lattice scheme in the corpus multiplies polynomials in this ring, so this is one kernel with four consumers: ML-KEM (LP-4600), ML-DSA (LP-4400), TFHE (LP-4655) and Pulsar (LP-4450).

Specification

Parameters

Negacyclic ring R_q = Z_q / (X^N + 1) for power-of-two N, with the modulus set by the consuming scheme:

Schemeq
ML-KEM3329
ML-DSA8,380,417
TFHE2^64
Pulsarscheme-specific

Multiplication goes through the NTT when N | (q − 1)/2 — that is the condition for a negacyclic root of unity to exist in F_q. When it does not, there is no NTT to take.

Algorithm

forward NTT(a), NTT(b)  →  pointwise multiply  →  inverse NTT

with two fallbacks:

  • Schoolbook for small N (≤ 64), where O(N²) with a tight inner loop beats three transforms.
  • Karatsuba as an intermediate for N whose modulus is not NTT-friendly.

Known-answer tests

Per-scheme vectors derived from upstream PQClean (mldsa, mlkem); TFHE cross-checked against lattigo ring.NTT. crypto/poly_mul/test/kat_*.json.

Implementation

Go canonical

luxfi/crypto/poly_mul — {schoolbook,ntt}.go.

C++ CPU canonical

luxcpp/crypto/poly_mul/cpp/poly_mul.{hpp,cpp}, depending on luxcpp/crypto/ntt. C-ABI at poly_mul_capi.h, shipped as libpoly_mul.a.

GPU kernels

Metal, CUDA and WGSL kernels fuse NTT + pointwise + inverse NTT into a single dispatch under the lattice dispatcher — the three-transform sequence is exactly the fusion the four-kernel template (LP-4040) asks for, since the intermediate NTT-domain buffers never need to leave the device.

One thread per (batch index, output coefficient). Measured crossover on M1 Max (median of 11 runs) — the batch size at which the GPU path beats the CPU:

NBatch threshold
64≈ 2048
128≈ 1024
256≈ 256
512≈ 128
1024≈ 64

The threshold falls as N grows, which is the expected shape: bigger transforms give the dispatch more to amortize over.

Determinism

CPU↔GPU byte-equality over N = 100 random multiplications across every per-scheme (N, q) configuration: PASS.

Test oracles

PQClean reference (pqcrystals-{mldsa,mlkem}/poly) and lattigo ring.NTT, both vendored test-only.

Security Considerations

  1. Modular reduction uses Barrett or Montgomery form and is constant-time on the NTT path.
  2. The TFHE q = 2^64 path reduces by machine-word truncation, which is trivially constant-time.
  3. Side-channel posture is inherited from the consuming scheme. This kernel does not add a leak the scheme did not already have to reason about.

References

  • Longa, Naehrig, "Speeding up the Number-Theoretic Transform for Faster Ideal Lattice-Based Cryptography" (2016)
  • FIPS 203 (ML-KEM) §4.3
  • FIPS 204 (ML-DSA) §7

Copyright (C) 2024-2026, Lux Industries Inc. All rights reserved.

Licensed under the MIT License.