Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
cx_mldsa_poly.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2026 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef CX_MLDSA_POLY_H
18#define CX_MLDSA_POLY_H
19
20#include "lcx_mldsa.h"
21
25typedef struct {
26 int32_t coeffs[MLDSA_N];
28
29#define MLDSA_QINV 58728449
30#define MLDSA_MONT (-4186625)
39int32_t MLDSA_POLY_montgomery_reduce(int64_t a);
40
48int32_t MLDSA_POLY_reduce32(int32_t a);
49
57int32_t MLDSA_POLY_caddq(int32_t a);
58
65
72
79void MLDSA_POLY_add(mldsa_poly *a, const mldsa_poly *b);
80
87void MLDSA_POLY_sub(mldsa_poly *a, const mldsa_poly *b);
88
95
102
109
119 const mldsa_poly *a,
120 const mldsa_poly *b,
121 int first);
122
131int MLDSA_POLY_chknorm(const mldsa_poly *a, int32_t B);
132
133#endif /* CX_MLDSA_POLY_H */
void MLDSA_POLY_reduce(mldsa_poly *a)
Applies reduce32 to all coefficients of a polynomial.
int32_t MLDSA_POLY_caddq(int32_t a)
Adds q if input is negative.
int32_t MLDSA_POLY_montgomery_reduce(int64_t a)
Montgomery reduction: given a 64-bit integer, compute a*q^{-1} mod 2^32.
int MLDSA_POLY_chknorm(const mldsa_poly *a, int32_t B)
Checks infinity norm of polynomial against bound B.
void MLDSA_POLY_ntt(mldsa_poly *a)
Forward NTT in place.
int32_t MLDSA_POLY_reduce32(int32_t a)
Reduce coefficient to representative in about (-6283009, 6283009).
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_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_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.
#define MLDSA_N
Definition lcx_mldsa.h:37
ML-DSA (Module-Lattice Digital Signature Algorithm) public API.
Polynomial with MLDSA_N int32_t coefficients.