1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* SPDX-License-Identifier: MIT
*
* Rivide Post-Quantum Cryptography Library
* Copyright (C) 2026 Moh. Ananda Firmansyah Putra
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*/
/**
* @file kem_poly.c
* @brief ML-KEM polynomial arithmetic (add, sub, reduce, tomont, csubq, polyvec ops).
*
* Implements coefficient-wise polynomial vector arithmetic and inner products for ML-KEM.
*/
/**
* @brief Add two polynomials coefficient-wise: r = a + b.
*
* @param[out] r Output polynomial buffer.
* @param[in] a First operand polynomial.
* @param[in] b Second operand polynomial.
*/
void
/**
* @brief Subtract two polynomials coefficient-wise: r = a - b.
*
* @param[out] r Output polynomial buffer.
* @param[in] a First operand polynomial.
* @param[in] b Second operand polynomial.
*/
void
/**
* @brief Reduce all polynomial coefficients using Barrett reduction.
*
* @param[in,out] p Polynomial to reduce in-place.
*/
void
/**
* @brief Multiply all polynomial coefficients by Montgomery factor R.
*
* @param[in,out] p Polynomial to scale in-place.
*/
void
/**
* @brief Conditionally subtract q from all polynomial coefficients.
*
* @param[in,out] p Polynomial to normalize in-place.
*/
void
/**
* @brief Transform all polynomials in a vector into the NTT domain in-place.
*
* @param[in,out] v Polynomial vector to transform.
* @param[in] k Module rank.
*/
void
/**
* @brief Pointwise multiplication and accumulation of two polynomial vectors: r = <a, b>.
*
* @param[out] r Output accumulated polynomial.
* @param[in] a First polynomial vector.
* @param[in] b Second polynomial vector.
* @param[in] k Module rank.
*/
void