121
121
/* contracts, so it is "inlined for proof" by CBMC */
122
122
/* This allows CBMC to keep track of the ranges of the */
123
123
/* modified coefficients in the calling functions. */
124
- static INLINE void ct_butterfly (int16_t r [MLKEM_N ], const int coeff1_index ,
125
- const int coeff2_index , const int16_t zeta )
124
+ static INLINE void ct_butterfly (int16_t r [MLKEM_N ], const unsigned coeff1_index ,
125
+ const unsigned coeff2_index , const int16_t zeta )
126
126
{
127
127
int16_t t1 = r [coeff1_index ];
128
128
int16_t t2 = fqmul (r [coeff2_index ], zeta );
@@ -166,14 +166,14 @@ __contract__(
166
166
{
167
167
/* 8 coeffifient indexes, starting at element j */
168
168
/* and increasing in strides of 32 */
169
- const int ci0 = j ;
170
- const int ci1 = ci0 + 32 ;
171
- const int ci2 = ci0 + 64 ;
172
- const int ci3 = ci0 + 96 ;
173
- const int ci4 = ci0 + 128 ;
174
- const int ci5 = ci0 + 160 ;
175
- const int ci6 = ci0 + 192 ;
176
- const int ci7 = ci0 + 224 ;
169
+ const unsigned ci0 = j ;
170
+ const unsigned ci1 = ci0 + 32 ;
171
+ const unsigned ci2 = ci0 + 64 ;
172
+ const unsigned ci3 = ci0 + 96 ;
173
+ const unsigned ci4 = ci0 + 128 ;
174
+ const unsigned ci5 = ci0 + 160 ;
175
+ const unsigned ci6 = ci0 + 192 ;
176
+ const unsigned ci7 = ci0 + 224 ;
177
177
178
178
/* Layer 1 */
179
179
ct_butterfly (r , ci0 , ci4 , l1zeta1 );
@@ -226,10 +226,10 @@ __contract__(
226
226
{
227
227
/* 4 coeffifient indexes, starting at element j + start */
228
228
/* and increasing in strides of 8 */
229
- const int ci1 = j + start ;
230
- const int ci2 = ci1 + 8 ;
231
- const int ci3 = ci1 + 16 ;
232
- const int ci4 = ci1 + 24 ;
229
+ const unsigned ci1 = j + start ;
230
+ const unsigned ci2 = ci1 + 8 ;
231
+ const unsigned ci3 = ci1 + 16 ;
232
+ const unsigned ci4 = ci1 + 24 ;
233
233
234
234
/* Layer 4 */
235
235
ct_butterfly (r , ci1 , ci3 , z1 );
@@ -286,8 +286,8 @@ __contract__(
286
286
invariant (array_abs_bound (r , start + 4 , start + j + 4 , NTT_BOUND7 ))
287
287
invariant (array_abs_bound (r , start + j + 4 , MLKEM_N , NTT_BOUND6 )))
288
288
{
289
- const int ci1 = j + start ;
290
- const int ci2 = ci1 + 4 ;
289
+ const unsigned ci1 = j + start ;
290
+ const unsigned ci2 = ci1 + 4 ;
291
291
292
292
ct_butterfly (r , ci1 , ci2 , zeta );
293
293
}
@@ -325,10 +325,10 @@ __contract__(
325
325
ensures (array_abs_bound (r , start + 4 , MLKEM_N , NTT_BOUND7 )))
326
326
{
327
327
const int32_t zeta = (int32_t )layer7_zetas [zeta_index ];
328
- const unsigned int ci0 = start ;
329
- const unsigned int ci1 = ci0 + 1 ;
330
- const unsigned int ci2 = ci0 + 2 ;
331
- const unsigned int ci3 = ci0 + 3 ;
328
+ const unsigned ci0 = start ;
329
+ const unsigned ci1 = ci0 + 1 ;
330
+ const unsigned ci2 = ci0 + 2 ;
331
+ const unsigned ci3 = ci0 + 3 ;
332
332
333
333
ct_butterfly (r , ci0 , ci2 , zeta );
334
334
ct_butterfly (r , ci1 , ci3 , zeta );
@@ -457,8 +457,8 @@ void poly_ntt(poly *p)
457
457
/* Like ct_butterfly(), this functions is inlined */
458
458
/* for both compilation and proof. */
459
459
static INLINE void gs_butterfly_reduce (int16_t r [MLKEM_N ],
460
- const int coeff1_index ,
461
- const int coeff2_index ,
460
+ const unsigned coeff1_index ,
461
+ const unsigned coeff2_index ,
462
462
const int16_t zeta )
463
463
{
464
464
const int16_t t1 = r [coeff1_index ];
@@ -470,8 +470,8 @@ static INLINE void gs_butterfly_reduce(int16_t r[MLKEM_N],
470
470
/* As gs_butterfly_reduce(), but does not reduce the */
471
471
/* coefficient denoted by coeff1_index */
472
472
static INLINE void gs_butterfly_defer (int16_t r [MLKEM_N ],
473
- const int coeff1_index ,
474
- const int coeff2_index ,
473
+ const unsigned coeff1_index ,
474
+ const unsigned coeff2_index ,
475
475
const int16_t zeta )
476
476
{
477
477
const int16_t t1 = r [coeff1_index ];
@@ -495,10 +495,10 @@ __contract__(
495
495
)
496
496
{
497
497
const int32_t zeta = (int32_t )layer7_zetas [zeta_index ];
498
- const int ci0 = start ;
499
- const int ci1 = ci0 + 1 ;
500
- const int ci2 = ci0 + 2 ;
501
- const int ci3 = ci0 + 3 ;
498
+ const unsigned ci0 = start ;
499
+ const unsigned ci1 = ci0 + 1 ;
500
+ const unsigned ci2 = ci0 + 2 ;
501
+ const unsigned ci3 = ci0 + 3 ;
502
502
503
503
/* Invert and reduce all coefficients here the first time they */
504
504
/* are read. This is efficient, and also means we can accept */
@@ -547,14 +547,14 @@ __contract__(
547
547
)
548
548
{
549
549
const int32_t zeta = (int32_t )layer6_zetas [zeta_index ];
550
- const int ci0 = start ;
551
- const int ci1 = ci0 + 1 ;
552
- const int ci2 = ci0 + 2 ;
553
- const int ci3 = ci0 + 3 ;
554
- const int ci4 = ci0 + 4 ;
555
- const int ci5 = ci0 + 5 ;
556
- const int ci6 = ci0 + 6 ;
557
- const int ci7 = ci0 + 7 ;
550
+ const unsigned ci0 = start ;
551
+ const unsigned ci1 = ci0 + 1 ;
552
+ const unsigned ci2 = ci0 + 2 ;
553
+ const unsigned ci3 = ci0 + 3 ;
554
+ const unsigned ci4 = ci0 + 4 ;
555
+ const unsigned ci5 = ci0 + 5 ;
556
+ const unsigned ci6 = ci0 + 6 ;
557
+ const unsigned ci7 = ci0 + 7 ;
558
558
559
559
/* Defer reduction of coefficients 0, 1, 2, and 3 here so they */
560
560
/* are bounded to NTT_BOUND2 after Layer6 */
@@ -618,10 +618,10 @@ __contract__(
618
618
invariant (array_abs_bound (r , start + 24 , start + j + 24 , NTT_BOUND1 ))
619
619
invariant (array_abs_bound (r , start + j + 24 , MLKEM_N , NTT_BOUND2 )))
620
620
{
621
- const int ci0 = j + start ;
622
- const int ci8 = ci0 + 8 ;
623
- const int ci16 = ci0 + 16 ;
624
- const int ci24 = ci0 + 24 ;
621
+ const unsigned ci0 = j + start ;
622
+ const unsigned ci8 = ci0 + 8 ;
623
+ const unsigned ci16 = ci0 + 16 ;
624
+ const unsigned ci24 = ci0 + 24 ;
625
625
626
626
/* Layer 5 - Defer reduction of coeffs 0 and 16 here */
627
627
gs_butterfly_defer (r , ci0 , ci8 , l5zeta2 );
@@ -675,14 +675,14 @@ __contract__(
675
675
invariant (array_abs_bound (r , j + 96 , 128 , NTT_BOUND1 ))
676
676
invariant (array_abs_bound (r , 128 , MLKEM_N , NTT_BOUND1 )))
677
677
{
678
- const int ci0 = j + 0 ;
679
- const int ci32 = j + 32 ;
680
- const int ci64 = j + 64 ;
681
- const int ci96 = j + 96 ;
682
- const int ci128 = j + 128 ;
683
- const int ci160 = j + 160 ;
684
- const int ci192 = j + 192 ;
685
- const int ci224 = j + 224 ;
678
+ const unsigned ci0 = j + 0 ;
679
+ const unsigned ci32 = j + 32 ;
680
+ const unsigned ci64 = j + 64 ;
681
+ const unsigned ci96 = j + 96 ;
682
+ const unsigned ci128 = j + 128 ;
683
+ const unsigned ci160 = j + 160 ;
684
+ const unsigned ci192 = j + 192 ;
685
+ const unsigned ci224 = j + 224 ;
686
686
687
687
/* Layer 3 */
688
688
gs_butterfly_defer (r , ci0 , ci32 , l3zeta7 );
0 commit comments