|
Embedded SDK
Embedded SDK
|
ML-DSA polynomial arithmetic (FIPS 204). More...
#include "cx_mldsa_poly.h"
Go to the source code of this file.
Functions | |
| int32_t | MLDSA_POLY_montgomery_reduce (int64_t a) |
| Montgomery reduction: given a 64-bit integer, compute a*q^{-1} mod 2^32. | |
| int32_t | MLDSA_POLY_reduce32 (int32_t a) |
| Reduce coefficient to representative in about (-6283009, 6283009). | |
| int32_t | MLDSA_POLY_caddq (int32_t a) |
| Adds q if input is negative. | |
| void | MLDSA_POLY_reduce (mldsa_poly *a) |
| Applies reduce32 to all coefficients of a polynomial. | |
| void | MLDSA_POLY_caddq_all (mldsa_poly *a) |
| Applies caddq to all coefficients of a polynomial. | |
| void | MLDSA_POLY_add (mldsa_poly *a, const mldsa_poly *b) |
| Adds polynomial b to polynomial a in place. | |
| void | MLDSA_POLY_sub (mldsa_poly *a, const mldsa_poly *b) |
| Subtracts polynomial b from polynomial a in place. | |
| void | MLDSA_POLY_shiftl (mldsa_poly *a) |
| Shifts all coefficients left by D bits. | |
| void | MLDSA_POLY_ntt (mldsa_poly *a) |
| Forward NTT in place. | |
| void | MLDSA_POLY_invntt_tomont (mldsa_poly *a) |
| Inverse NTT and multiply by Montgomery factor. | |
| void | MLDSA_POLY_pointwise_montgomery (mldsa_poly *c, const mldsa_poly *a, const mldsa_poly *b, int first) |
| Pointwise multiplication (Montgomery) with accumulation. | |
| int | MLDSA_POLY_chknorm (const mldsa_poly *a, int32_t B) |
| Checks infinity norm of polynomial against bound B. | |
Variables | |
| static const int32_t | mldsa_zetas [MLDSA_N] |
ML-DSA polynomial arithmetic (FIPS 204).
Implements NTT, inverse NTT, Montgomery reduction, pointwise multiplication, and related polynomial operations for the ML-DSA ring Z_q[X]/(X^256+1).
Definition in file cx_mldsa_poly.c.
| void MLDSA_POLY_add | ( | mldsa_poly * | a, |
| const mldsa_poly * | b | ||
| ) |
Adds polynomial b to polynomial a in place.
| [in,out] | a | Accumulator polynomial. |
| [in] | b | Polynomial to add. |
Definition at line 104 of file cx_mldsa_poly.c.
| int32_t MLDSA_POLY_caddq | ( | int32_t | a | ) |
Adds q if input is negative.
| [in] | a | Input coefficient in (-q, q). |
Definition at line 84 of file cx_mldsa_poly.c.
| void MLDSA_POLY_caddq_all | ( | mldsa_poly * | a | ) |
Applies caddq to all coefficients of a polynomial.
| [in,out] | a | Polynomial to make positive. |
Definition at line 97 of file cx_mldsa_poly.c.
| int MLDSA_POLY_chknorm | ( | const mldsa_poly * | a, |
| int32_t | B | ||
| ) |
Checks infinity norm of polynomial against bound B.
| [in] | a | Polynomial. |
| [in] | B | Norm bound. |
Definition at line 179 of file cx_mldsa_poly.c.
| void MLDSA_POLY_invntt_tomont | ( | mldsa_poly * | a | ) |
Inverse NTT and multiply by Montgomery factor.
| [in,out] | a | Polynomial to inverse-transform. |
Definition at line 141 of file cx_mldsa_poly.c.
| int32_t MLDSA_POLY_montgomery_reduce | ( | int64_t | a | ) |
Montgomery reduction: given a 64-bit integer, compute a*q^{-1} mod 2^32.
| [in] | a | 64-bit input. |
Definition at line 68 of file cx_mldsa_poly.c.
| void MLDSA_POLY_ntt | ( | mldsa_poly * | a | ) |
Forward NTT in place.
| [in,out] | a | Polynomial to transform. |
Definition at line 125 of file cx_mldsa_poly.c.
| void MLDSA_POLY_pointwise_montgomery | ( | mldsa_poly * | c, |
| const mldsa_poly * | a, | ||
| const mldsa_poly * | b, | ||
| int | first | ||
| ) |
Pointwise multiplication (Montgomery) with accumulation.
| [in,out] | c | Accumulator polynomial. |
| [in] | a | First input polynomial. |
| [in] | b | Second input polynomial. |
| [in] | first | If non-zero, overwrite c; otherwise accumulate. |
Definition at line 163 of file cx_mldsa_poly.c.
| void MLDSA_POLY_reduce | ( | mldsa_poly * | a | ) |
Applies reduce32 to all coefficients of a polynomial.
| [in,out] | a | Polynomial to reduce. |
Definition at line 90 of file cx_mldsa_poly.c.
| int32_t MLDSA_POLY_reduce32 | ( | int32_t | a | ) |
Reduce coefficient to representative in about (-6283009, 6283009).
| [in] | a | Input coefficient. |
Definition at line 76 of file cx_mldsa_poly.c.
| void MLDSA_POLY_shiftl | ( | mldsa_poly * | a | ) |
Shifts all coefficients left by D bits.
| [in,out] | a | Polynomial to shift. |
Definition at line 118 of file cx_mldsa_poly.c.
| void MLDSA_POLY_sub | ( | mldsa_poly * | a, |
| const mldsa_poly * | b | ||
| ) |
Subtracts polynomial b from polynomial a in place.
| [in,out] | a | Accumulator polynomial. |
| [in] | b | Polynomial to subtract. |
Definition at line 111 of file cx_mldsa_poly.c.
|
static |
Definition at line 27 of file cx_mldsa_poly.c.