Skip to content

Commit 4a98037

Browse files
vincentvbhmkannwischer
authored andcommitted
map to canonical
1 parent 40f33ea commit 4a98037

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

crypto_kem/ml-kem-512/m4fspeed/poly.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ void poly_tobytes(unsigned char *r, poly *a) {
366366
int i;
367367
uint16_t t0, t1;
368368

369+
poly_reduce(a);
369370
poly_reduce(a);
370371

371372
for (i = 0; i < KYBER_N / 2; i++) {

crypto_kem/ml-kem-512/m4fstack/poly.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ void poly_tobytes(unsigned char *r, poly *a) {
366366
int i;
367367
uint16_t t0, t1;
368368

369+
poly_reduce(a);
369370
poly_reduce(a);
370371

371372
for (i = 0; i < KYBER_N / 2; i++) {

crypto_kem/ml-kem-768/m4fspeed/poly.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void poly_packcompress(unsigned char *r, poly *a, int i) {
142142
d0 >>= 31;
143143
t[k] = d0 & 0x7ff;
144144
}
145-
145+
146146

147147
r[352*i+11*j+ 0] = t[0] & 0xff;
148148
r[352*i+11*j+ 1] = (t[0] >> 8) | ((t[1] & 0x1f) << 3);
@@ -366,6 +366,7 @@ void poly_tobytes(unsigned char *r, poly *a) {
366366
int i;
367367
uint16_t t0, t1;
368368

369+
poly_reduce(a);
369370
poly_reduce(a);
370371

371372
for (i = 0; i < KYBER_N / 2; i++) {
@@ -465,7 +466,7 @@ void poly_noise(poly *r, const unsigned char *seed, unsigned char nonce, int add
465466
* Using strategy of better accumulation (initial step).
466467
* Arguments: - const poly *a: pointer to input polynomial
467468
* - const poly *b: pointer to input polynomial
468-
* - const poly *a_prime: pointer to a pre-multiplied by zetas
469+
* - const poly *a_prime: pointer to a pre-multiplied by zetas
469470
* - int32_t *r_tmp: array for accumulating unreduced results
470471
**************************************************/
471472
extern void basemul_asm_opt_16_32(int32_t *, const int16_t *, const int16_t *, const int16_t *);
@@ -481,7 +482,7 @@ void poly_basemul_opt_16_32(int32_t *r_tmp, const poly *a, const poly *b, const
481482
* Using strategy of better accumulation.
482483
* Arguments: - const poly *a: pointer to input polynomial
483484
* - const poly *b: pointer to input polynomial
484-
* - const poly *a_prime: pointer to a pre-multiplied by zetas
485+
* - const poly *a_prime: pointer to a pre-multiplied by zetas
485486
* - int32_t *r_tmp: array for accumulating unreduced results
486487
**************************************************/
487488
extern void basemul_asm_acc_opt_32_32(int32_t *, const int16_t *, const int16_t *, const int16_t *);
@@ -497,7 +498,7 @@ void poly_basemul_acc_opt_32_32(int32_t *r_tmp, const poly *a, const poly *b, co
497498
* Using strategy of better accumulation (final step).
498499
* Arguments: - const poly *a: pointer to input polynomial
499500
* - const poly *b: pointer to input polynomial
500-
* - const poly *a_prime: pointer to a pre-multiplied by zetas
501+
* - const poly *a_prime: pointer to a pre-multiplied by zetas
501502
* - poly *r: pointer to output polynomial
502503
* - int32_t *r_tmp: array for accumulating unreduced results
503504
**************************************************/

crypto_kem/ml-kem-768/m4fstack/poly.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void poly_packcompress(unsigned char *r, poly *a, int i) {
142142
d0 >>= 31;
143143
t[k] = d0 & 0x7ff;
144144
}
145-
145+
146146

147147
r[352*i+11*j+ 0] = t[0] & 0xff;
148148
r[352*i+11*j+ 1] = (t[0] >> 8) | ((t[1] & 0x1f) << 3);
@@ -366,6 +366,7 @@ void poly_tobytes(unsigned char *r, poly *a) {
366366
int i;
367367
uint16_t t0, t1;
368368

369+
poly_reduce(a);
369370
poly_reduce(a);
370371

371372
for (i = 0; i < KYBER_N / 2; i++) {

0 commit comments

Comments
 (0)