Coverage Report

Created: 2025-08-27 07:03

/src/dropbear/src/libcrux_mlkem768_sha3.h
Line
Count
Source (jump to first uncovered line)
1
/*  $OpenBSD$ */
2
3
/* Extracted from libcrux revision 84c5d87b3092c59294345aa269ceefe0eb97cc35 */
4
5
/*
6
 * MIT License
7
 *
8
 * Copyright (c) 2024 Cryspen
9
 *
10
 * Permission is hereby granted, free of charge, to any person obtaining a copy
11
 * of this software and associated documentation files (the "Software"), to deal
12
 * in the Software without restriction, including without limitation the rights
13
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
 * copies of the Software, and to permit persons to whom the Software is
15
 * furnished to do so, subject to the following conditions:
16
 *
17
 * The above copyright notice and this permission notice shall be included in all
18
 * copies or substantial portions of the Software.
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
 * SOFTWARE.
27
 */
28
29
#if !defined(__GNUC__) || (__GNUC__ < 2)
30
# define __attribute__(x)
31
#endif
32
#define KRML_MUSTINLINE inline
33
#define KRML_NOINLINE __attribute__((noinline, unused))
34
#define KRML_HOST_EPRINTF(...)
35
0
#define KRML_HOST_EXIT(x) dropbear_exit("mlkem")
36
37
/* from libcrux/libcrux-ml-kem/cg/eurydice_glue.h */
38
/*
39
 * SPDX-FileCopyrightText: 2024 Eurydice Contributors
40
 * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com>
41
 *
42
 * SPDX-License-Identifier: MIT or Apache-2.0
43
 */
44
45
#pragma once
46
47
#if defined(__cplusplus)
48
extern "C" {
49
#endif
50
51
52
53
// SLICES, ARRAYS, ETC.
54
55
// The MSVC C++ compiler does not support compound literals.
56
// This CLITERAL is used to turn `(type){...}` into `type{...}` when using a C++
57
// compiler.
58
#if defined(__cplusplus)
59
#define CLITERAL(type) type
60
#else
61
0
#define CLITERAL(type) (type)
62
#endif
63
64
// We represent a slice as a pair of an (untyped) pointer, along with the length
65
// of the slice, i.e. the number of elements in the slice (this is NOT the
66
// number of bytes). This design choice has two important consequences.
67
// - if you need to use `ptr`, you MUST cast it to a proper type *before*
68
// performing pointer
69
//   arithmetic on it (remember that C desugars pointer arithmetic based on the
70
//   type of the address)
71
// - if you need to use `len` for a C style function (e.g. memcpy, memcmp), you
72
// need to multiply it
73
//   by sizeof t, where t is the type of the elements.
74
//
75
// Empty slices have `len == 0` and `ptr` always needs to be valid pointer that
76
// is not NULL (otherwise the construction in EURYDICE_SLICE computes `NULL +
77
// start`).
78
typedef struct {
79
  void *ptr;
80
  size_t len;
81
} Eurydice_slice;
82
83
// Helper macro to create a slice out of a pointer x, a start index in x
84
// (included), and an end index in x (excluded). The argument x must be suitably
85
// cast to something that can decay (see remark above about how pointer
86
// arithmetic works in C), meaning either pointer or array type.
87
#define EURYDICE_SLICE(x, start, end) \
88
0
  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
89
0
#define EURYDICE_SLICE_LEN(s, _) s.len
90
// This macro is a pain because in case the dereferenced element type is an
91
// array, you cannot simply write `t x` as it would yield `int[4] x` instead,
92
// which is NOT correct C syntax, so we add a dedicated phase in Eurydice that
93
// adds an extra argument to this macro at the last minute so that we have the
94
// correct type of *pointers* to elements.
95
0
#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
96
#define Eurydice_slice_subslice(s, r, t, _) \
97
  EURYDICE_SLICE((t *)s.ptr, r.start, r.end)
98
// Variant for when the start and end indices are statically known (i.e., the
99
// range argument `r` is a literal).
100
#define Eurydice_slice_subslice2(s, start, end, t) \
101
0
  EURYDICE_SLICE((t *)s.ptr, start, end)
102
#define Eurydice_slice_subslice_to(s, subslice_end_pos, t, _) \
103
0
  EURYDICE_SLICE((t *)s.ptr, 0, subslice_end_pos)
104
#define Eurydice_slice_subslice_from(s, subslice_start_pos, t, _) \
105
0
  EURYDICE_SLICE((t *)s.ptr, subslice_start_pos, s.len)
106
#define Eurydice_array_to_slice(end, x, t) \
107
0
  EURYDICE_SLICE(x, 0,                     \
108
0
                 end) /* x is already at an array type, no need for cast */
109
#define Eurydice_array_to_subslice(_arraylen, x, r, t, _) \
110
  EURYDICE_SLICE((t *)x, r.start, r.end)
111
// Same as above, variant for when start and end are statically known
112
#define Eurydice_array_to_subslice2(x, start, end, t) \
113
0
  EURYDICE_SLICE((t *)x, start, end)
114
#define Eurydice_array_to_subslice_to(_size, x, r, t, _range_t) \
115
  EURYDICE_SLICE((t *)x, 0, r)
116
#define Eurydice_array_to_subslice_from(size, x, r, t, _range_t) \
117
0
  EURYDICE_SLICE((t *)x, r, size)
118
0
#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
119
#define Eurydice_slice_copy(dst, src, t) \
120
0
  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
121
#define core_array___Array_T__N__23__as_slice(len_, ptr_, t, _ret_t) \
122
  ((Eurydice_slice){.ptr = ptr_, .len = len_})
123
124
#define core_array___core__clone__Clone_for__Array_T__N___20__clone( \
125
    len, src, dst, elem_type, _ret_t)                                \
126
  (memcpy(dst, src, len * sizeof(elem_type)))
127
#define TryFromSliceError uint8_t
128
129
#define Eurydice_array_eq(sz, a1, a2, t, _) \
130
  (memcmp(a1, a2, sz * sizeof(t)) == 0)
131
#define core_array_equality___core__cmp__PartialEq__Array_U__N___for__Array_T__N____eq( \
132
    sz, a1, a2, t, _, _ret_t)                                                           \
133
  Eurydice_array_eq(sz, a1, a2, t, _)
134
#define core_array_equality___core__cmp__PartialEq__0___Slice_U____for__Array_T__N___3__eq( \
135
    sz, a1, a2, t, _, _ret_t)                                                               \
136
  Eurydice_array_eq(sz, a1, ((a2)->ptr), t, _)
137
138
#define Eurydice_slice_split_at(slice, mid, element_type, ret_t) \
139
0
  (CLITERAL(ret_t){                                              \
140
0
      .fst = EURYDICE_SLICE((element_type *)slice.ptr, 0, mid),  \
141
0
      .snd = EURYDICE_SLICE((element_type *)slice.ptr, mid, slice.len)})
142
#define Eurydice_slice_split_at_mut(slice, mid, element_type, ret_t) \
143
0
  (CLITERAL(ret_t){                                                  \
144
0
      .fst = {.ptr = slice.ptr, .len = mid},                         \
145
0
      .snd = {.ptr = (char *)slice.ptr + mid * sizeof(element_type), \
146
0
              .len = slice.len - mid}})
147
148
// Conversion of slice to an array, rewritten (by Eurydice) to name the
149
// destination array, since arrays are not values in C.
150
// N.B.: see note in karamel/lib/Inlining.ml if you change this.
151
#define Eurydice_slice_to_array2(dst, src, _, t_arr)                      \
152
0
  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
153
0
                           sizeof(t_arr))
154
155
static inline void Eurydice_slice_to_array3(uint8_t *dst_tag, char *dst_ok,
156
0
                                            Eurydice_slice src, size_t sz) {
157
0
  *dst_tag = 0;
158
0
  memcpy(dst_ok, src.ptr, sz);
159
0
}
160
161
// CORE STUFF (conversions, endianness, ...)
162
163
0
static inline void core_num__u64_9__to_le_bytes(uint64_t v, uint8_t buf[8]) {
164
0
  v = htole64(v);
165
0
  memcpy(buf, &v, sizeof(v));
166
0
}
167
0
static inline uint64_t core_num__u64_9__from_le_bytes(uint8_t buf[8]) {
168
0
  uint64_t v;
169
0
  memcpy(&v, buf, sizeof(v));
170
0
  return le64toh(v);
171
0
}
172
173
0
static inline uint32_t core_num__u32_8__from_le_bytes(uint8_t buf[4]) {
174
0
  uint32_t v;
175
0
  memcpy(&v, buf, sizeof(v));
176
0
  return le32toh(v);
177
0
}
178
179
0
static inline uint32_t core_num__u8_6__count_ones(uint8_t x0) {
180
0
#ifdef _MSC_VER
181
0
  return __popcnt(x0);
182
0
#else
183
0
  return __builtin_popcount(x0);
184
0
#endif
185
0
}
186
187
// unsigned overflow wraparound semantics in C
188
0
static inline uint16_t core_num__u16_7__wrapping_add(uint16_t x, uint16_t y) {
189
0
  return x + y;
190
0
}
191
0
static inline uint8_t core_num__u8_6__wrapping_sub(uint8_t x, uint8_t y) {
192
0
  return x - y;
193
0
}
194
195
// ITERATORS
196
197
#define Eurydice_range_iter_next(iter_ptr, t, ret_t) \
198
0
  (((iter_ptr)->start == (iter_ptr)->end)            \
199
0
       ? (CLITERAL(ret_t){.tag = None})              \
200
0
       : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
201
202
#define core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next \
203
0
  Eurydice_range_iter_next
204
205
// See note in karamel/lib/Inlining.ml if you change this
206
0
#define Eurydice_into_iter(x, t, _ret_t) (x)
207
#define core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter \
208
0
  Eurydice_into_iter
209
210
#if defined(__cplusplus)
211
}
212
#endif
213
214
/* from libcrux/libcrux-ml-kem/cg/libcrux_core.h */
215
/*
216
 * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com>
217
 *
218
 * SPDX-License-Identifier: MIT or Apache-2.0
219
 *
220
 * This code was generated with the following revisions:
221
 * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4
222
 * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb
223
 * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908
224
 * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty
225
 * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee
226
 */
227
228
#ifndef __libcrux_core_H
229
#define __libcrux_core_H
230
231
#if defined(__cplusplus)
232
extern "C" {
233
#endif
234
235
236
/**
237
A monomorphic instance of core.ops.range.Range
238
with types size_t
239
240
*/
241
typedef struct core_ops_range_Range_b3_s {
242
  size_t start;
243
  size_t end;
244
} core_ops_range_Range_b3;
245
246
0
#define Ok 0
247
#define Err 1
248
249
typedef uint8_t Result_86_tags;
250
251
0
#define None 0
252
0
#define Some 1
253
254
typedef uint8_t Option_ef_tags;
255
256
/**
257
A monomorphic instance of core.option.Option
258
with types size_t
259
260
*/
261
typedef struct Option_b3_s {
262
  Option_ef_tags tag;
263
  size_t f0;
264
} Option_b3;
265
266
static inline uint16_t core_num__u16_7__wrapping_add(uint16_t x0, uint16_t x1);
267
268
0
#define CORE_NUM__U32_8__BITS (32U)
269
270
static inline uint64_t core_num__u64_9__from_le_bytes(uint8_t x0[8U]);
271
272
static inline void core_num__u64_9__to_le_bytes(uint64_t x0, uint8_t x1[8U]);
273
274
static inline uint32_t core_num__u8_6__count_ones(uint8_t x0);
275
276
static inline uint8_t core_num__u8_6__wrapping_sub(uint8_t x0, uint8_t x1);
277
278
0
#define LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE ((size_t)32U)
279
280
#define LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT ((size_t)12U)
281
282
0
#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
283
284
#define LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT \
285
0
  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)12U)
286
287
#define LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT \
288
0
  (LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U)
289
290
0
#define LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE ((size_t)32U)
291
292
0
#define LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE ((size_t)32U)
293
294
typedef struct libcrux_ml_kem_utils_extraction_helper_Keypair768_s {
295
  uint8_t fst[1152U];
296
  uint8_t snd[1184U];
297
} libcrux_ml_kem_utils_extraction_helper_Keypair768;
298
299
/**
300
A monomorphic instance of core.result.Result
301
with types uint8_t[24size_t], core_array_TryFromSliceError
302
303
*/
304
typedef struct Result_6f_s {
305
  Result_86_tags tag;
306
  union {
307
    uint8_t case_Ok[24U];
308
    TryFromSliceError case_Err;
309
  } val;
310
} Result_6f;
311
312
/**
313
This function found in impl {core::result::Result<T, E>}
314
*/
315
/**
316
A monomorphic instance of core.result.unwrap_41
317
with types uint8_t[24size_t], core_array_TryFromSliceError
318
319
*/
320
0
static inline void unwrap_41_1c(Result_6f self, uint8_t ret[24U]) {
321
0
  if (self.tag == Ok) {
322
0
    uint8_t f0[24U];
323
0
    memcpy(f0, self.val.case_Ok, (size_t)24U * sizeof(uint8_t));
324
0
    memcpy(ret, f0, (size_t)24U * sizeof(uint8_t));
325
0
  } else {
326
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
327
0
                      "unwrap not Ok");
328
0
    KRML_HOST_EXIT(255U);
329
0
  }
330
0
}
331
332
/**
333
A monomorphic instance of core.result.Result
334
with types uint8_t[20size_t], core_array_TryFromSliceError
335
336
*/
337
typedef struct Result_7a_s {
338
  Result_86_tags tag;
339
  union {
340
    uint8_t case_Ok[20U];
341
    TryFromSliceError case_Err;
342
  } val;
343
} Result_7a;
344
345
/**
346
This function found in impl {core::result::Result<T, E>}
347
*/
348
/**
349
A monomorphic instance of core.result.unwrap_41
350
with types uint8_t[20size_t], core_array_TryFromSliceError
351
352
*/
353
0
static inline void unwrap_41_34(Result_7a self, uint8_t ret[20U]) {
354
0
  if (self.tag == Ok) {
355
0
    uint8_t f0[20U];
356
0
    memcpy(f0, self.val.case_Ok, (size_t)20U * sizeof(uint8_t));
357
0
    memcpy(ret, f0, (size_t)20U * sizeof(uint8_t));
358
0
  } else {
359
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
360
0
                      "unwrap not Ok");
361
0
    KRML_HOST_EXIT(255U);
362
0
  }
363
0
}
364
365
/**
366
A monomorphic instance of core.result.Result
367
with types uint8_t[10size_t], core_array_TryFromSliceError
368
369
*/
370
typedef struct Result_cd_s {
371
  Result_86_tags tag;
372
  union {
373
    uint8_t case_Ok[10U];
374
    TryFromSliceError case_Err;
375
  } val;
376
} Result_cd;
377
378
/**
379
This function found in impl {core::result::Result<T, E>}
380
*/
381
/**
382
A monomorphic instance of core.result.unwrap_41
383
with types uint8_t[10size_t], core_array_TryFromSliceError
384
385
*/
386
0
static inline void unwrap_41_e8(Result_cd self, uint8_t ret[10U]) {
387
0
  if (self.tag == Ok) {
388
0
    uint8_t f0[10U];
389
0
    memcpy(f0, self.val.case_Ok, (size_t)10U * sizeof(uint8_t));
390
0
    memcpy(ret, f0, (size_t)10U * sizeof(uint8_t));
391
0
  } else {
392
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
393
0
                      "unwrap not Ok");
394
0
    KRML_HOST_EXIT(255U);
395
0
  }
396
0
}
397
398
typedef struct Eurydice_slice_uint8_t_4size_t__x2_s {
399
  Eurydice_slice fst[4U];
400
  Eurydice_slice snd[4U];
401
} Eurydice_slice_uint8_t_4size_t__x2;
402
403
typedef struct libcrux_ml_kem_mlkem768_MlKem768Ciphertext_s {
404
  uint8_t value[1088U];
405
} libcrux_ml_kem_mlkem768_MlKem768Ciphertext;
406
407
/**
408
 A reference to the raw byte slice.
409
*/
410
/**
411
This function found in impl {libcrux_ml_kem::types::MlKemCiphertext<SIZE>#6}
412
*/
413
/**
414
A monomorphic instance of libcrux_ml_kem.types.as_slice_d4
415
with const generics
416
- SIZE= 1088
417
*/
418
static inline uint8_t *libcrux_ml_kem_types_as_slice_d4_1d(
419
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *self) {
420
0
  return self->value;
421
0
}
422
423
/**
424
A monomorphic instance of libcrux_ml_kem.types.MlKemPublicKey
425
with const generics
426
- $1184size_t
427
*/
428
typedef struct libcrux_ml_kem_types_MlKemPublicKey_15_s {
429
  uint8_t value[1184U];
430
} libcrux_ml_kem_types_MlKemPublicKey_15;
431
432
/**
433
This function found in impl {(core::convert::From<@Array<u8, SIZE>> for
434
libcrux_ml_kem::types::MlKemPublicKey<SIZE>)#14}
435
*/
436
/**
437
A monomorphic instance of libcrux_ml_kem.types.from_b6
438
with const generics
439
- SIZE= 1184
440
*/
441
static inline libcrux_ml_kem_types_MlKemPublicKey_15
442
0
libcrux_ml_kem_types_from_b6_da(uint8_t value[1184U]) {
443
  /* Passing arrays by value in Rust generates a copy in C */
444
0
  uint8_t copy_of_value[1184U];
445
0
  memcpy(copy_of_value, value, (size_t)1184U * sizeof(uint8_t));
446
0
  libcrux_ml_kem_types_MlKemPublicKey_15 lit;
447
0
  memcpy(lit.value, copy_of_value, (size_t)1184U * sizeof(uint8_t));
448
0
  return lit;
449
0
}
450
451
/**
452
A monomorphic instance of libcrux_ml_kem.types.MlKemPrivateKey
453
with const generics
454
- $2400size_t
455
*/
456
typedef struct libcrux_ml_kem_types_MlKemPrivateKey_55_s {
457
  uint8_t value[2400U];
458
} libcrux_ml_kem_types_MlKemPrivateKey_55;
459
460
typedef struct libcrux_ml_kem_mlkem768_MlKem768KeyPair_s {
461
  libcrux_ml_kem_types_MlKemPrivateKey_55 sk;
462
  libcrux_ml_kem_types_MlKemPublicKey_15 pk;
463
} libcrux_ml_kem_mlkem768_MlKem768KeyPair;
464
465
/**
466
 Create a new [`MlKemKeyPair`] from the secret and public key.
467
*/
468
/**
469
This function found in impl
470
{libcrux_ml_kem::types::MlKemKeyPair<PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE>}
471
*/
472
/**
473
A monomorphic instance of libcrux_ml_kem.types.from_17
474
with const generics
475
- PRIVATE_KEY_SIZE= 2400
476
- PUBLIC_KEY_SIZE= 1184
477
*/
478
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
479
libcrux_ml_kem_types_from_17_35(libcrux_ml_kem_types_MlKemPrivateKey_55 sk,
480
0
                                libcrux_ml_kem_types_MlKemPublicKey_15 pk) {
481
0
  return (
482
0
      CLITERAL(libcrux_ml_kem_mlkem768_MlKem768KeyPair){.sk = sk, .pk = pk});
483
0
}
484
485
/**
486
This function found in impl {(core::convert::From<@Array<u8, SIZE>> for
487
libcrux_ml_kem::types::MlKemPrivateKey<SIZE>)#8}
488
*/
489
/**
490
A monomorphic instance of libcrux_ml_kem.types.from_05
491
with const generics
492
- SIZE= 2400
493
*/
494
static inline libcrux_ml_kem_types_MlKemPrivateKey_55
495
0
libcrux_ml_kem_types_from_05_f2(uint8_t value[2400U]) {
496
  /* Passing arrays by value in Rust generates a copy in C */
497
0
  uint8_t copy_of_value[2400U];
498
0
  memcpy(copy_of_value, value, (size_t)2400U * sizeof(uint8_t));
499
0
  libcrux_ml_kem_types_MlKemPrivateKey_55 lit;
500
0
  memcpy(lit.value, copy_of_value, (size_t)2400U * sizeof(uint8_t));
501
0
  return lit;
502
0
}
503
504
/**
505
A monomorphic instance of core.result.Result
506
with types uint8_t[32size_t], core_array_TryFromSliceError
507
508
*/
509
typedef struct Result_00_s {
510
  Result_86_tags tag;
511
  union {
512
    uint8_t case_Ok[32U];
513
    TryFromSliceError case_Err;
514
  } val;
515
} Result_00;
516
517
/**
518
This function found in impl {core::result::Result<T, E>}
519
*/
520
/**
521
A monomorphic instance of core.result.unwrap_41
522
with types uint8_t[32size_t], core_array_TryFromSliceError
523
524
*/
525
0
static inline void unwrap_41_83(Result_00 self, uint8_t ret[32U]) {
526
0
  if (self.tag == Ok) {
527
0
    uint8_t f0[32U];
528
0
    memcpy(f0, self.val.case_Ok, (size_t)32U * sizeof(uint8_t));
529
0
    memcpy(ret, f0, (size_t)32U * sizeof(uint8_t));
530
0
  } else {
531
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
532
0
                      "unwrap not Ok");
533
0
    KRML_HOST_EXIT(255U);
534
0
  }
535
0
}
536
537
/**
538
A monomorphic instance of K.
539
with types libcrux_ml_kem_types_MlKemCiphertext[[$1088size_t]],
540
uint8_t[32size_t]
541
542
*/
543
typedef struct tuple_3c_s {
544
  libcrux_ml_kem_mlkem768_MlKem768Ciphertext fst;
545
  uint8_t snd[32U];
546
} tuple_3c;
547
548
/**
549
This function found in impl {(core::convert::From<@Array<u8, SIZE>> for
550
libcrux_ml_kem::types::MlKemCiphertext<SIZE>)#2}
551
*/
552
/**
553
A monomorphic instance of libcrux_ml_kem.types.from_01
554
with const generics
555
- SIZE= 1088
556
*/
557
static inline libcrux_ml_kem_mlkem768_MlKem768Ciphertext
558
0
libcrux_ml_kem_types_from_01_9f(uint8_t value[1088U]) {
559
  /* Passing arrays by value in Rust generates a copy in C */
560
0
  uint8_t copy_of_value[1088U];
561
0
  memcpy(copy_of_value, value, (size_t)1088U * sizeof(uint8_t));
562
0
  libcrux_ml_kem_mlkem768_MlKem768Ciphertext lit;
563
0
  memcpy(lit.value, copy_of_value, (size_t)1088U * sizeof(uint8_t));
564
0
  return lit;
565
0
}
566
567
/**
568
 A reference to the raw byte slice.
569
*/
570
/**
571
This function found in impl {libcrux_ml_kem::types::MlKemPublicKey<SIZE>#18}
572
*/
573
/**
574
A monomorphic instance of libcrux_ml_kem.types.as_slice_cb
575
with const generics
576
- SIZE= 1184
577
*/
578
static inline uint8_t *libcrux_ml_kem_types_as_slice_cb_50(
579
0
    libcrux_ml_kem_types_MlKemPublicKey_15 *self) {
580
0
  return self->value;
581
0
}
582
583
/**
584
 Pad the `slice` with `0`s at the end.
585
*/
586
/**
587
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
588
with const generics
589
- LEN= 33
590
*/
591
static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea2(
592
0
    Eurydice_slice slice, uint8_t ret[33U]) {
593
0
  uint8_t out[33U] = {0U};
594
0
  uint8_t *uu____0 = out;
595
0
  Eurydice_slice_copy(
596
0
      Eurydice_array_to_subslice2(uu____0, (size_t)0U,
597
0
                                  Eurydice_slice_len(slice, uint8_t), uint8_t),
598
0
      slice, uint8_t);
599
0
  memcpy(ret, out, (size_t)33U * sizeof(uint8_t));
600
0
}
601
602
/**
603
 Pad the `slice` with `0`s at the end.
604
*/
605
/**
606
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
607
with const generics
608
- LEN= 34
609
*/
610
static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea1(
611
0
    Eurydice_slice slice, uint8_t ret[34U]) {
612
0
  uint8_t out[34U] = {0U};
613
0
  uint8_t *uu____0 = out;
614
0
  Eurydice_slice_copy(
615
0
      Eurydice_array_to_subslice2(uu____0, (size_t)0U,
616
0
                                  Eurydice_slice_len(slice, uint8_t), uint8_t),
617
0
      slice, uint8_t);
618
0
  memcpy(ret, out, (size_t)34U * sizeof(uint8_t));
619
0
}
620
621
/**
622
This function found in impl {(core::convert::AsRef<@Slice<u8>> for
623
libcrux_ml_kem::types::MlKemCiphertext<SIZE>)#1}
624
*/
625
/**
626
A monomorphic instance of libcrux_ml_kem.types.as_ref_00
627
with const generics
628
- SIZE= 1088
629
*/
630
static inline Eurydice_slice libcrux_ml_kem_types_as_ref_00_24(
631
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *self) {
632
0
  return Eurydice_array_to_slice((size_t)1088U, self->value, uint8_t);
633
0
}
634
635
/**
636
 Pad the `slice` with `0`s at the end.
637
*/
638
/**
639
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
640
with const generics
641
- LEN= 1120
642
*/
643
static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea0(
644
0
    Eurydice_slice slice, uint8_t ret[1120U]) {
645
0
  uint8_t out[1120U] = {0U};
646
0
  uint8_t *uu____0 = out;
647
0
  Eurydice_slice_copy(
648
0
      Eurydice_array_to_subslice2(uu____0, (size_t)0U,
649
0
                                  Eurydice_slice_len(slice, uint8_t), uint8_t),
650
0
      slice, uint8_t);
651
0
  memcpy(ret, out, (size_t)1120U * sizeof(uint8_t));
652
0
}
653
654
/**
655
 Pad the `slice` with `0`s at the end.
656
*/
657
/**
658
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
659
with const generics
660
- LEN= 64
661
*/
662
static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea(
663
0
    Eurydice_slice slice, uint8_t ret[64U]) {
664
0
  uint8_t out[64U] = {0U};
665
0
  uint8_t *uu____0 = out;
666
0
  Eurydice_slice_copy(
667
0
      Eurydice_array_to_subslice2(uu____0, (size_t)0U,
668
0
                                  Eurydice_slice_len(slice, uint8_t), uint8_t),
669
0
      slice, uint8_t);
670
0
  memcpy(ret, out, (size_t)64U * sizeof(uint8_t));
671
0
}
672
673
/**
674
A monomorphic instance of core.result.Result
675
with types int16_t[16size_t], core_array_TryFromSliceError
676
677
*/
678
typedef struct Result_c0_s {
679
  Result_86_tags tag;
680
  union {
681
    int16_t case_Ok[16U];
682
    TryFromSliceError case_Err;
683
  } val;
684
} Result_c0;
685
686
/**
687
This function found in impl {core::result::Result<T, E>}
688
*/
689
/**
690
A monomorphic instance of core.result.unwrap_41
691
with types int16_t[16size_t], core_array_TryFromSliceError
692
693
*/
694
0
static inline void unwrap_41_f9(Result_c0 self, int16_t ret[16U]) {
695
0
  if (self.tag == Ok) {
696
0
    int16_t f0[16U];
697
0
    memcpy(f0, self.val.case_Ok, (size_t)16U * sizeof(int16_t));
698
0
    memcpy(ret, f0, (size_t)16U * sizeof(int16_t));
699
0
  } else {
700
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
701
0
                      "unwrap not Ok");
702
0
    KRML_HOST_EXIT(255U);
703
0
  }
704
0
}
705
706
/**
707
A monomorphic instance of core.result.Result
708
with types uint8_t[8size_t], core_array_TryFromSliceError
709
710
*/
711
typedef struct Result_56_s {
712
  Result_86_tags tag;
713
  union {
714
    uint8_t case_Ok[8U];
715
    TryFromSliceError case_Err;
716
  } val;
717
} Result_56;
718
719
/**
720
This function found in impl {core::result::Result<T, E>}
721
*/
722
/**
723
A monomorphic instance of core.result.unwrap_41
724
with types uint8_t[8size_t], core_array_TryFromSliceError
725
726
*/
727
0
static inline void unwrap_41_ac(Result_56 self, uint8_t ret[8U]) {
728
0
  if (self.tag == Ok) {
729
0
    uint8_t f0[8U];
730
0
    memcpy(f0, self.val.case_Ok, (size_t)8U * sizeof(uint8_t));
731
0
    memcpy(ret, f0, (size_t)8U * sizeof(uint8_t));
732
0
  } else {
733
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
734
0
                      "unwrap not Ok");
735
0
    KRML_HOST_EXIT(255U);
736
0
  }
737
0
}
738
739
typedef struct Eurydice_slice_uint8_t_x2_s {
740
  Eurydice_slice fst;
741
  Eurydice_slice snd;
742
} Eurydice_slice_uint8_t_x2;
743
744
typedef struct Eurydice_slice_uint8_t_1size_t__x2_s {
745
  Eurydice_slice fst[1U];
746
  Eurydice_slice snd[1U];
747
} Eurydice_slice_uint8_t_1size_t__x2;
748
749
#if defined(__cplusplus)
750
}
751
#endif
752
753
#define __libcrux_core_H_DEFINED
754
#endif
755
756
/* from libcrux/libcrux-ml-kem/cg/libcrux_ct_ops.h */
757
/*
758
 * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com>
759
 *
760
 * SPDX-License-Identifier: MIT or Apache-2.0
761
 *
762
 * This code was generated with the following revisions:
763
 * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4
764
 * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb
765
 * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908
766
 * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty
767
 * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee
768
 */
769
770
#ifndef __libcrux_ct_ops_H
771
#define __libcrux_ct_ops_H
772
773
#if defined(__cplusplus)
774
extern "C" {
775
#endif
776
777
778
/**
779
 Return 1 if `value` is not zero and 0 otherwise.
780
*/
781
0
static inline uint8_t libcrux_ml_kem_constant_time_ops_inz(uint8_t value) {
782
0
  uint16_t value0 = (uint16_t)value;
783
0
  uint16_t result = (((uint32_t)value0 |
784
0
                      (uint32_t)core_num__u16_7__wrapping_add(~value0, 1U)) &
785
0
                     0xFFFFU) >>
786
0
                        8U &
787
0
                    1U;
788
0
  return (uint8_t)result;
789
0
}
790
791
static KRML_NOINLINE uint8_t
792
0
libcrux_ml_kem_constant_time_ops_is_non_zero(uint8_t value) {
793
0
  return libcrux_ml_kem_constant_time_ops_inz(value);
794
0
}
795
796
/**
797
 Return 1 if the bytes of `lhs` and `rhs` do not exactly
798
 match and 0 otherwise.
799
*/
800
static inline uint8_t libcrux_ml_kem_constant_time_ops_compare(
801
0
    Eurydice_slice lhs, Eurydice_slice rhs) {
802
0
  uint8_t r = 0U;
803
0
  for (size_t i = (size_t)0U; i < Eurydice_slice_len(lhs, uint8_t); i++) {
804
0
    size_t i0 = i;
805
0
    r = (uint32_t)r |
806
0
        ((uint32_t)Eurydice_slice_index(lhs, i0, uint8_t, uint8_t *) ^
807
0
         (uint32_t)Eurydice_slice_index(rhs, i0, uint8_t, uint8_t *));
808
0
  }
809
0
  return libcrux_ml_kem_constant_time_ops_is_non_zero(r);
810
0
}
811
812
static KRML_NOINLINE uint8_t
813
libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(
814
0
    Eurydice_slice lhs, Eurydice_slice rhs) {
815
0
  return libcrux_ml_kem_constant_time_ops_compare(lhs, rhs);
816
0
}
817
818
/**
819
 If `selector` is not zero, return the bytes in `rhs`; return the bytes in
820
 `lhs` otherwise.
821
*/
822
static inline void libcrux_ml_kem_constant_time_ops_select_ct(
823
    Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector,
824
0
    uint8_t ret[32U]) {
825
0
  uint8_t mask = core_num__u8_6__wrapping_sub(
826
0
      libcrux_ml_kem_constant_time_ops_is_non_zero(selector), 1U);
827
0
  uint8_t out[32U] = {0U};
828
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE;
829
0
       i++) {
830
0
    size_t i0 = i;
831
0
    out[i0] = ((uint32_t)Eurydice_slice_index(lhs, i0, uint8_t, uint8_t *) &
832
0
               (uint32_t)mask) |
833
0
              ((uint32_t)Eurydice_slice_index(rhs, i0, uint8_t, uint8_t *) &
834
0
               (uint32_t)~mask);
835
0
  }
836
0
  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
837
0
}
838
839
static KRML_NOINLINE void
840
libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(
841
    Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector,
842
0
    uint8_t ret[32U]) {
843
0
  libcrux_ml_kem_constant_time_ops_select_ct(lhs, rhs, selector, ret);
844
0
}
845
846
static inline void
847
libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time(
848
    Eurydice_slice lhs_c, Eurydice_slice rhs_c, Eurydice_slice lhs_s,
849
0
    Eurydice_slice rhs_s, uint8_t ret[32U]) {
850
0
  uint8_t selector =
851
0
      libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(
852
0
          lhs_c, rhs_c);
853
0
  uint8_t ret0[32U];
854
0
  libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(
855
0
      lhs_s, rhs_s, selector, ret0);
856
0
  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
857
0
}
858
859
#if defined(__cplusplus)
860
}
861
#endif
862
863
#define __libcrux_ct_ops_H_DEFINED
864
#endif
865
866
/* from libcrux/libcrux-ml-kem/cg/libcrux_sha3_portable.h */
867
/*
868
 * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com>
869
 *
870
 * SPDX-License-Identifier: MIT or Apache-2.0
871
 *
872
 * This code was generated with the following revisions:
873
 * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4
874
 * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb
875
 * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908
876
 * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty
877
 * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee
878
 */
879
880
#ifndef __libcrux_sha3_portable_H
881
#define __libcrux_sha3_portable_H
882
883
#if defined(__cplusplus)
884
extern "C" {
885
#endif
886
887
888
static const uint64_t libcrux_sha3_generic_keccak_ROUNDCONSTANTS[24U] = {
889
    1ULL,
890
    32898ULL,
891
    9223372036854808714ULL,
892
    9223372039002292224ULL,
893
    32907ULL,
894
    2147483649ULL,
895
    9223372039002292353ULL,
896
    9223372036854808585ULL,
897
    138ULL,
898
    136ULL,
899
    2147516425ULL,
900
    2147483658ULL,
901
    2147516555ULL,
902
    9223372036854775947ULL,
903
    9223372036854808713ULL,
904
    9223372036854808579ULL,
905
    9223372036854808578ULL,
906
    9223372036854775936ULL,
907
    32778ULL,
908
    9223372039002259466ULL,
909
    9223372039002292353ULL,
910
    9223372036854808704ULL,
911
    2147483649ULL,
912
    9223372039002292232ULL};
913
914
/**
915
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
916
usize> for u64)}
917
*/
918
0
static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_zero_5a(void) {
919
0
  return 0ULL;
920
0
}
921
922
static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak__veor5q_u64(
923
0
    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
924
0
  uint64_t ab = a ^ b;
925
0
  uint64_t cd = c ^ d;
926
0
  uint64_t abcd = ab ^ cd;
927
0
  return abcd ^ e;
928
0
}
929
930
/**
931
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
932
usize> for u64)}
933
*/
934
static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_xor5_5a(
935
0
    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
936
0
  return libcrux_sha3_portable_keccak__veor5q_u64(a, b, c, d, e);
937
0
}
938
939
/**
940
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
941
with const generics
942
- LEFT= 1
943
- RIGHT= 63
944
*/
945
static KRML_MUSTINLINE uint64_t
946
0
libcrux_sha3_portable_keccak_rotate_left_cb(uint64_t x) {
947
0
  return x << (uint32_t)(int32_t)1 | x >> (uint32_t)(int32_t)63;
948
0
}
949
950
static KRML_MUSTINLINE uint64_t
951
0
libcrux_sha3_portable_keccak__vrax1q_u64(uint64_t a, uint64_t b) {
952
0
  uint64_t uu____0 = a;
953
0
  return uu____0 ^ libcrux_sha3_portable_keccak_rotate_left_cb(b);
954
0
}
955
956
/**
957
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
958
usize> for u64)}
959
*/
960
static KRML_MUSTINLINE uint64_t
961
0
libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(uint64_t a, uint64_t b) {
962
0
  return libcrux_sha3_portable_keccak__vrax1q_u64(a, b);
963
0
}
964
965
static KRML_MUSTINLINE uint64_t
966
0
libcrux_sha3_portable_keccak__vbcaxq_u64(uint64_t a, uint64_t b, uint64_t c) {
967
0
  return a ^ (b & ~c);
968
0
}
969
970
/**
971
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
972
usize> for u64)}
973
*/
974
static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_and_not_xor_5a(
975
0
    uint64_t a, uint64_t b, uint64_t c) {
976
0
  return libcrux_sha3_portable_keccak__vbcaxq_u64(a, b, c);
977
0
}
978
979
static KRML_MUSTINLINE uint64_t
980
0
libcrux_sha3_portable_keccak__veorq_n_u64(uint64_t a, uint64_t c) {
981
0
  return a ^ c;
982
0
}
983
984
/**
985
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
986
usize> for u64)}
987
*/
988
static KRML_MUSTINLINE uint64_t
989
0
libcrux_sha3_portable_keccak_xor_constant_5a(uint64_t a, uint64_t c) {
990
0
  return libcrux_sha3_portable_keccak__veorq_n_u64(a, c);
991
0
}
992
993
/**
994
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
995
usize> for u64)}
996
*/
997
static KRML_MUSTINLINE uint64_t
998
0
libcrux_sha3_portable_keccak_xor_5a(uint64_t a, uint64_t b) {
999
0
  return a ^ b;
1000
0
}
1001
1002
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_slice_1(
1003
0
    Eurydice_slice a[1U], size_t start, size_t len, Eurydice_slice ret[1U]) {
1004
0
  ret[0U] = Eurydice_slice_subslice2(a[0U], start, start + len, uint8_t);
1005
0
}
1006
1007
/**
1008
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1009
usize> for u64)}
1010
*/
1011
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_slice_n_5a(
1012
0
    Eurydice_slice a[1U], size_t start, size_t len, Eurydice_slice ret[1U]) {
1013
  /* Passing arrays by value in Rust generates a copy in C */
1014
0
  Eurydice_slice copy_of_a[1U];
1015
0
  memcpy(copy_of_a, a, (size_t)1U * sizeof(Eurydice_slice));
1016
0
  Eurydice_slice ret0[1U];
1017
0
  libcrux_sha3_portable_keccak_slice_1(copy_of_a, start, len, ret0);
1018
0
  memcpy(ret, ret0, (size_t)1U * sizeof(Eurydice_slice));
1019
0
}
1020
1021
static KRML_MUSTINLINE Eurydice_slice_uint8_t_1size_t__x2
1022
libcrux_sha3_portable_keccak_split_at_mut_1(Eurydice_slice out[1U],
1023
0
                                            size_t mid) {
1024
0
  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at_mut(
1025
0
      out[0U], mid, uint8_t, Eurydice_slice_uint8_t_x2);
1026
0
  Eurydice_slice out00 = uu____0.fst;
1027
0
  Eurydice_slice out01 = uu____0.snd;
1028
0
  Eurydice_slice_uint8_t_1size_t__x2 lit;
1029
0
  lit.fst[0U] = out00;
1030
0
  lit.snd[0U] = out01;
1031
0
  return lit;
1032
0
}
1033
1034
/**
1035
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1036
usize> for u64)}
1037
*/
1038
static KRML_MUSTINLINE Eurydice_slice_uint8_t_1size_t__x2
1039
libcrux_sha3_portable_keccak_split_at_mut_n_5a(Eurydice_slice a[1U],
1040
0
                                               size_t mid) {
1041
0
  return libcrux_sha3_portable_keccak_split_at_mut_1(a, mid);
1042
0
}
1043
1044
/**
1045
A monomorphic instance of libcrux_sha3.generic_keccak.KeccakState
1046
with types uint64_t
1047
with const generics
1048
- $1size_t
1049
*/
1050
typedef struct libcrux_sha3_generic_keccak_KeccakState_48_s {
1051
  uint64_t st[5U][5U];
1052
} libcrux_sha3_generic_keccak_KeccakState_48;
1053
1054
/**
1055
 Create a new Shake128 x4 state.
1056
*/
1057
/**
1058
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T,
1059
N>[TraitClause@0]#1}
1060
*/
1061
/**
1062
A monomorphic instance of libcrux_sha3.generic_keccak.new_1e
1063
with types uint64_t
1064
with const generics
1065
- N= 1
1066
*/
1067
static KRML_MUSTINLINE libcrux_sha3_generic_keccak_KeccakState_48
1068
0
libcrux_sha3_generic_keccak_new_1e_f4(void) {
1069
0
  libcrux_sha3_generic_keccak_KeccakState_48 lit;
1070
0
  lit.st[0U][0U] = libcrux_sha3_portable_keccak_zero_5a();
1071
0
  lit.st[0U][1U] = libcrux_sha3_portable_keccak_zero_5a();
1072
0
  lit.st[0U][2U] = libcrux_sha3_portable_keccak_zero_5a();
1073
0
  lit.st[0U][3U] = libcrux_sha3_portable_keccak_zero_5a();
1074
0
  lit.st[0U][4U] = libcrux_sha3_portable_keccak_zero_5a();
1075
0
  lit.st[1U][0U] = libcrux_sha3_portable_keccak_zero_5a();
1076
0
  lit.st[1U][1U] = libcrux_sha3_portable_keccak_zero_5a();
1077
0
  lit.st[1U][2U] = libcrux_sha3_portable_keccak_zero_5a();
1078
0
  lit.st[1U][3U] = libcrux_sha3_portable_keccak_zero_5a();
1079
0
  lit.st[1U][4U] = libcrux_sha3_portable_keccak_zero_5a();
1080
0
  lit.st[2U][0U] = libcrux_sha3_portable_keccak_zero_5a();
1081
0
  lit.st[2U][1U] = libcrux_sha3_portable_keccak_zero_5a();
1082
0
  lit.st[2U][2U] = libcrux_sha3_portable_keccak_zero_5a();
1083
0
  lit.st[2U][3U] = libcrux_sha3_portable_keccak_zero_5a();
1084
0
  lit.st[2U][4U] = libcrux_sha3_portable_keccak_zero_5a();
1085
0
  lit.st[3U][0U] = libcrux_sha3_portable_keccak_zero_5a();
1086
0
  lit.st[3U][1U] = libcrux_sha3_portable_keccak_zero_5a();
1087
0
  lit.st[3U][2U] = libcrux_sha3_portable_keccak_zero_5a();
1088
0
  lit.st[3U][3U] = libcrux_sha3_portable_keccak_zero_5a();
1089
0
  lit.st[3U][4U] = libcrux_sha3_portable_keccak_zero_5a();
1090
0
  lit.st[4U][0U] = libcrux_sha3_portable_keccak_zero_5a();
1091
0
  lit.st[4U][1U] = libcrux_sha3_portable_keccak_zero_5a();
1092
0
  lit.st[4U][2U] = libcrux_sha3_portable_keccak_zero_5a();
1093
0
  lit.st[4U][3U] = libcrux_sha3_portable_keccak_zero_5a();
1094
0
  lit.st[4U][4U] = libcrux_sha3_portable_keccak_zero_5a();
1095
0
  return lit;
1096
0
}
1097
1098
/**
1099
A monomorphic instance of libcrux_sha3.portable_keccak.load_block
1100
with const generics
1101
- RATE= 72
1102
*/
1103
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c(
1104
0
    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
1105
0
  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
1106
0
    size_t i0 = i;
1107
0
    uint8_t uu____0[8U];
1108
0
    Result_56 dst;
1109
0
    Eurydice_slice_to_array2(
1110
0
        &dst,
1111
0
        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
1112
0
                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
1113
0
        Eurydice_slice, uint8_t[8U]);
1114
0
    unwrap_41_ac(dst, uu____0);
1115
0
    size_t uu____1 = i0 / (size_t)5U;
1116
0
    size_t uu____2 = i0 % (size_t)5U;
1117
0
    s[uu____1][uu____2] =
1118
0
        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
1119
0
  }
1120
0
}
1121
1122
/**
1123
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1124
usize> for u64)}
1125
*/
1126
/**
1127
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a
1128
with const generics
1129
- RATE= 72
1130
*/
1131
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b8(
1132
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
1133
0
  uint64_t(*uu____0)[5U] = a;
1134
  /* Passing arrays by value in Rust generates a copy in C */
1135
0
  Eurydice_slice copy_of_b[1U];
1136
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice));
1137
0
  libcrux_sha3_portable_keccak_load_block_2c(uu____0, copy_of_b);
1138
0
}
1139
1140
/**
1141
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1142
with const generics
1143
- LEFT= 36
1144
- RIGHT= 28
1145
*/
1146
static KRML_MUSTINLINE uint64_t
1147
0
libcrux_sha3_portable_keccak_rotate_left_cb0(uint64_t x) {
1148
0
  return x << (uint32_t)(int32_t)36 | x >> (uint32_t)(int32_t)28;
1149
0
}
1150
1151
/**
1152
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1153
with const generics
1154
- LEFT= 36
1155
- RIGHT= 28
1156
*/
1157
static KRML_MUSTINLINE uint64_t
1158
0
libcrux_sha3_portable_keccak__vxarq_u64_42(uint64_t a, uint64_t b) {
1159
0
  uint64_t ab = a ^ b;
1160
0
  return libcrux_sha3_portable_keccak_rotate_left_cb0(ab);
1161
0
}
1162
1163
/**
1164
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1165
usize> for u64)}
1166
*/
1167
/**
1168
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1169
with const generics
1170
- LEFT= 36
1171
- RIGHT= 28
1172
*/
1173
static KRML_MUSTINLINE uint64_t
1174
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb(uint64_t a, uint64_t b) {
1175
0
  return libcrux_sha3_portable_keccak__vxarq_u64_42(a, b);
1176
0
}
1177
1178
/**
1179
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1180
with const generics
1181
- LEFT= 3
1182
- RIGHT= 61
1183
*/
1184
static KRML_MUSTINLINE uint64_t
1185
0
libcrux_sha3_portable_keccak_rotate_left_cb1(uint64_t x) {
1186
0
  return x << (uint32_t)(int32_t)3 | x >> (uint32_t)(int32_t)61;
1187
0
}
1188
1189
/**
1190
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1191
with const generics
1192
- LEFT= 3
1193
- RIGHT= 61
1194
*/
1195
static KRML_MUSTINLINE uint64_t
1196
0
libcrux_sha3_portable_keccak__vxarq_u64_420(uint64_t a, uint64_t b) {
1197
0
  uint64_t ab = a ^ b;
1198
0
  return libcrux_sha3_portable_keccak_rotate_left_cb1(ab);
1199
0
}
1200
1201
/**
1202
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1203
usize> for u64)}
1204
*/
1205
/**
1206
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1207
with const generics
1208
- LEFT= 3
1209
- RIGHT= 61
1210
*/
1211
static KRML_MUSTINLINE uint64_t
1212
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0(uint64_t a, uint64_t b) {
1213
0
  return libcrux_sha3_portable_keccak__vxarq_u64_420(a, b);
1214
0
}
1215
1216
/**
1217
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1218
with const generics
1219
- LEFT= 41
1220
- RIGHT= 23
1221
*/
1222
static KRML_MUSTINLINE uint64_t
1223
0
libcrux_sha3_portable_keccak_rotate_left_cb2(uint64_t x) {
1224
0
  return x << (uint32_t)(int32_t)41 | x >> (uint32_t)(int32_t)23;
1225
0
}
1226
1227
/**
1228
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1229
with const generics
1230
- LEFT= 41
1231
- RIGHT= 23
1232
*/
1233
static KRML_MUSTINLINE uint64_t
1234
0
libcrux_sha3_portable_keccak__vxarq_u64_421(uint64_t a, uint64_t b) {
1235
0
  uint64_t ab = a ^ b;
1236
0
  return libcrux_sha3_portable_keccak_rotate_left_cb2(ab);
1237
0
}
1238
1239
/**
1240
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1241
usize> for u64)}
1242
*/
1243
/**
1244
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1245
with const generics
1246
- LEFT= 41
1247
- RIGHT= 23
1248
*/
1249
static KRML_MUSTINLINE uint64_t
1250
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1(uint64_t a, uint64_t b) {
1251
0
  return libcrux_sha3_portable_keccak__vxarq_u64_421(a, b);
1252
0
}
1253
1254
/**
1255
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1256
with const generics
1257
- LEFT= 18
1258
- RIGHT= 46
1259
*/
1260
static KRML_MUSTINLINE uint64_t
1261
0
libcrux_sha3_portable_keccak_rotate_left_cb3(uint64_t x) {
1262
0
  return x << (uint32_t)(int32_t)18 | x >> (uint32_t)(int32_t)46;
1263
0
}
1264
1265
/**
1266
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1267
with const generics
1268
- LEFT= 18
1269
- RIGHT= 46
1270
*/
1271
static KRML_MUSTINLINE uint64_t
1272
0
libcrux_sha3_portable_keccak__vxarq_u64_422(uint64_t a, uint64_t b) {
1273
0
  uint64_t ab = a ^ b;
1274
0
  return libcrux_sha3_portable_keccak_rotate_left_cb3(ab);
1275
0
}
1276
1277
/**
1278
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1279
usize> for u64)}
1280
*/
1281
/**
1282
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1283
with const generics
1284
- LEFT= 18
1285
- RIGHT= 46
1286
*/
1287
static KRML_MUSTINLINE uint64_t
1288
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2(uint64_t a, uint64_t b) {
1289
0
  return libcrux_sha3_portable_keccak__vxarq_u64_422(a, b);
1290
0
}
1291
1292
/**
1293
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1294
with const generics
1295
- LEFT= 1
1296
- RIGHT= 63
1297
*/
1298
static KRML_MUSTINLINE uint64_t
1299
0
libcrux_sha3_portable_keccak__vxarq_u64_423(uint64_t a, uint64_t b) {
1300
0
  uint64_t ab = a ^ b;
1301
0
  return libcrux_sha3_portable_keccak_rotate_left_cb(ab);
1302
0
}
1303
1304
/**
1305
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1306
usize> for u64)}
1307
*/
1308
/**
1309
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1310
with const generics
1311
- LEFT= 1
1312
- RIGHT= 63
1313
*/
1314
static KRML_MUSTINLINE uint64_t
1315
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3(uint64_t a, uint64_t b) {
1316
0
  return libcrux_sha3_portable_keccak__vxarq_u64_423(a, b);
1317
0
}
1318
1319
/**
1320
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1321
with const generics
1322
- LEFT= 44
1323
- RIGHT= 20
1324
*/
1325
static KRML_MUSTINLINE uint64_t
1326
0
libcrux_sha3_portable_keccak_rotate_left_cb4(uint64_t x) {
1327
0
  return x << (uint32_t)(int32_t)44 | x >> (uint32_t)(int32_t)20;
1328
0
}
1329
1330
/**
1331
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1332
with const generics
1333
- LEFT= 44
1334
- RIGHT= 20
1335
*/
1336
static KRML_MUSTINLINE uint64_t
1337
0
libcrux_sha3_portable_keccak__vxarq_u64_424(uint64_t a, uint64_t b) {
1338
0
  uint64_t ab = a ^ b;
1339
0
  return libcrux_sha3_portable_keccak_rotate_left_cb4(ab);
1340
0
}
1341
1342
/**
1343
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1344
usize> for u64)}
1345
*/
1346
/**
1347
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1348
with const generics
1349
- LEFT= 44
1350
- RIGHT= 20
1351
*/
1352
static KRML_MUSTINLINE uint64_t
1353
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4(uint64_t a, uint64_t b) {
1354
0
  return libcrux_sha3_portable_keccak__vxarq_u64_424(a, b);
1355
0
}
1356
1357
/**
1358
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1359
with const generics
1360
- LEFT= 10
1361
- RIGHT= 54
1362
*/
1363
static KRML_MUSTINLINE uint64_t
1364
0
libcrux_sha3_portable_keccak_rotate_left_cb5(uint64_t x) {
1365
0
  return x << (uint32_t)(int32_t)10 | x >> (uint32_t)(int32_t)54;
1366
0
}
1367
1368
/**
1369
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1370
with const generics
1371
- LEFT= 10
1372
- RIGHT= 54
1373
*/
1374
static KRML_MUSTINLINE uint64_t
1375
0
libcrux_sha3_portable_keccak__vxarq_u64_425(uint64_t a, uint64_t b) {
1376
0
  uint64_t ab = a ^ b;
1377
0
  return libcrux_sha3_portable_keccak_rotate_left_cb5(ab);
1378
0
}
1379
1380
/**
1381
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1382
usize> for u64)}
1383
*/
1384
/**
1385
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1386
with const generics
1387
- LEFT= 10
1388
- RIGHT= 54
1389
*/
1390
static KRML_MUSTINLINE uint64_t
1391
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5(uint64_t a, uint64_t b) {
1392
0
  return libcrux_sha3_portable_keccak__vxarq_u64_425(a, b);
1393
0
}
1394
1395
/**
1396
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1397
with const generics
1398
- LEFT= 45
1399
- RIGHT= 19
1400
*/
1401
static KRML_MUSTINLINE uint64_t
1402
0
libcrux_sha3_portable_keccak_rotate_left_cb6(uint64_t x) {
1403
0
  return x << (uint32_t)(int32_t)45 | x >> (uint32_t)(int32_t)19;
1404
0
}
1405
1406
/**
1407
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1408
with const generics
1409
- LEFT= 45
1410
- RIGHT= 19
1411
*/
1412
static KRML_MUSTINLINE uint64_t
1413
0
libcrux_sha3_portable_keccak__vxarq_u64_426(uint64_t a, uint64_t b) {
1414
0
  uint64_t ab = a ^ b;
1415
0
  return libcrux_sha3_portable_keccak_rotate_left_cb6(ab);
1416
0
}
1417
1418
/**
1419
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1420
usize> for u64)}
1421
*/
1422
/**
1423
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1424
with const generics
1425
- LEFT= 45
1426
- RIGHT= 19
1427
*/
1428
static KRML_MUSTINLINE uint64_t
1429
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6(uint64_t a, uint64_t b) {
1430
0
  return libcrux_sha3_portable_keccak__vxarq_u64_426(a, b);
1431
0
}
1432
1433
/**
1434
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1435
with const generics
1436
- LEFT= 2
1437
- RIGHT= 62
1438
*/
1439
static KRML_MUSTINLINE uint64_t
1440
0
libcrux_sha3_portable_keccak_rotate_left_cb7(uint64_t x) {
1441
0
  return x << (uint32_t)(int32_t)2 | x >> (uint32_t)(int32_t)62;
1442
0
}
1443
1444
/**
1445
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1446
with const generics
1447
- LEFT= 2
1448
- RIGHT= 62
1449
*/
1450
static KRML_MUSTINLINE uint64_t
1451
0
libcrux_sha3_portable_keccak__vxarq_u64_427(uint64_t a, uint64_t b) {
1452
0
  uint64_t ab = a ^ b;
1453
0
  return libcrux_sha3_portable_keccak_rotate_left_cb7(ab);
1454
0
}
1455
1456
/**
1457
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1458
usize> for u64)}
1459
*/
1460
/**
1461
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1462
with const generics
1463
- LEFT= 2
1464
- RIGHT= 62
1465
*/
1466
static KRML_MUSTINLINE uint64_t
1467
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7(uint64_t a, uint64_t b) {
1468
0
  return libcrux_sha3_portable_keccak__vxarq_u64_427(a, b);
1469
0
}
1470
1471
/**
1472
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1473
with const generics
1474
- LEFT= 62
1475
- RIGHT= 2
1476
*/
1477
static KRML_MUSTINLINE uint64_t
1478
0
libcrux_sha3_portable_keccak_rotate_left_cb8(uint64_t x) {
1479
0
  return x << (uint32_t)(int32_t)62 | x >> (uint32_t)(int32_t)2;
1480
0
}
1481
1482
/**
1483
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1484
with const generics
1485
- LEFT= 62
1486
- RIGHT= 2
1487
*/
1488
static KRML_MUSTINLINE uint64_t
1489
0
libcrux_sha3_portable_keccak__vxarq_u64_428(uint64_t a, uint64_t b) {
1490
0
  uint64_t ab = a ^ b;
1491
0
  return libcrux_sha3_portable_keccak_rotate_left_cb8(ab);
1492
0
}
1493
1494
/**
1495
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1496
usize> for u64)}
1497
*/
1498
/**
1499
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1500
with const generics
1501
- LEFT= 62
1502
- RIGHT= 2
1503
*/
1504
static KRML_MUSTINLINE uint64_t
1505
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8(uint64_t a, uint64_t b) {
1506
0
  return libcrux_sha3_portable_keccak__vxarq_u64_428(a, b);
1507
0
}
1508
1509
/**
1510
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1511
with const generics
1512
- LEFT= 6
1513
- RIGHT= 58
1514
*/
1515
static KRML_MUSTINLINE uint64_t
1516
0
libcrux_sha3_portable_keccak_rotate_left_cb9(uint64_t x) {
1517
0
  return x << (uint32_t)(int32_t)6 | x >> (uint32_t)(int32_t)58;
1518
0
}
1519
1520
/**
1521
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1522
with const generics
1523
- LEFT= 6
1524
- RIGHT= 58
1525
*/
1526
static KRML_MUSTINLINE uint64_t
1527
0
libcrux_sha3_portable_keccak__vxarq_u64_429(uint64_t a, uint64_t b) {
1528
0
  uint64_t ab = a ^ b;
1529
0
  return libcrux_sha3_portable_keccak_rotate_left_cb9(ab);
1530
0
}
1531
1532
/**
1533
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1534
usize> for u64)}
1535
*/
1536
/**
1537
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1538
with const generics
1539
- LEFT= 6
1540
- RIGHT= 58
1541
*/
1542
static KRML_MUSTINLINE uint64_t
1543
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9(uint64_t a, uint64_t b) {
1544
0
  return libcrux_sha3_portable_keccak__vxarq_u64_429(a, b);
1545
0
}
1546
1547
/**
1548
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1549
with const generics
1550
- LEFT= 43
1551
- RIGHT= 21
1552
*/
1553
static KRML_MUSTINLINE uint64_t
1554
0
libcrux_sha3_portable_keccak_rotate_left_cb10(uint64_t x) {
1555
0
  return x << (uint32_t)(int32_t)43 | x >> (uint32_t)(int32_t)21;
1556
0
}
1557
1558
/**
1559
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1560
with const generics
1561
- LEFT= 43
1562
- RIGHT= 21
1563
*/
1564
static KRML_MUSTINLINE uint64_t
1565
0
libcrux_sha3_portable_keccak__vxarq_u64_4210(uint64_t a, uint64_t b) {
1566
0
  uint64_t ab = a ^ b;
1567
0
  return libcrux_sha3_portable_keccak_rotate_left_cb10(ab);
1568
0
}
1569
1570
/**
1571
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1572
usize> for u64)}
1573
*/
1574
/**
1575
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1576
with const generics
1577
- LEFT= 43
1578
- RIGHT= 21
1579
*/
1580
static KRML_MUSTINLINE uint64_t
1581
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10(uint64_t a, uint64_t b) {
1582
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4210(a, b);
1583
0
}
1584
1585
/**
1586
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1587
with const generics
1588
- LEFT= 15
1589
- RIGHT= 49
1590
*/
1591
static KRML_MUSTINLINE uint64_t
1592
0
libcrux_sha3_portable_keccak_rotate_left_cb11(uint64_t x) {
1593
0
  return x << (uint32_t)(int32_t)15 | x >> (uint32_t)(int32_t)49;
1594
0
}
1595
1596
/**
1597
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1598
with const generics
1599
- LEFT= 15
1600
- RIGHT= 49
1601
*/
1602
static KRML_MUSTINLINE uint64_t
1603
0
libcrux_sha3_portable_keccak__vxarq_u64_4211(uint64_t a, uint64_t b) {
1604
0
  uint64_t ab = a ^ b;
1605
0
  return libcrux_sha3_portable_keccak_rotate_left_cb11(ab);
1606
0
}
1607
1608
/**
1609
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1610
usize> for u64)}
1611
*/
1612
/**
1613
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1614
with const generics
1615
- LEFT= 15
1616
- RIGHT= 49
1617
*/
1618
static KRML_MUSTINLINE uint64_t
1619
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11(uint64_t a, uint64_t b) {
1620
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4211(a, b);
1621
0
}
1622
1623
/**
1624
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1625
with const generics
1626
- LEFT= 61
1627
- RIGHT= 3
1628
*/
1629
static KRML_MUSTINLINE uint64_t
1630
0
libcrux_sha3_portable_keccak_rotate_left_cb12(uint64_t x) {
1631
0
  return x << (uint32_t)(int32_t)61 | x >> (uint32_t)(int32_t)3;
1632
0
}
1633
1634
/**
1635
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1636
with const generics
1637
- LEFT= 61
1638
- RIGHT= 3
1639
*/
1640
static KRML_MUSTINLINE uint64_t
1641
0
libcrux_sha3_portable_keccak__vxarq_u64_4212(uint64_t a, uint64_t b) {
1642
0
  uint64_t ab = a ^ b;
1643
0
  return libcrux_sha3_portable_keccak_rotate_left_cb12(ab);
1644
0
}
1645
1646
/**
1647
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1648
usize> for u64)}
1649
*/
1650
/**
1651
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1652
with const generics
1653
- LEFT= 61
1654
- RIGHT= 3
1655
*/
1656
static KRML_MUSTINLINE uint64_t
1657
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12(uint64_t a, uint64_t b) {
1658
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4212(a, b);
1659
0
}
1660
1661
/**
1662
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1663
with const generics
1664
- LEFT= 28
1665
- RIGHT= 36
1666
*/
1667
static KRML_MUSTINLINE uint64_t
1668
0
libcrux_sha3_portable_keccak_rotate_left_cb13(uint64_t x) {
1669
0
  return x << (uint32_t)(int32_t)28 | x >> (uint32_t)(int32_t)36;
1670
0
}
1671
1672
/**
1673
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1674
with const generics
1675
- LEFT= 28
1676
- RIGHT= 36
1677
*/
1678
static KRML_MUSTINLINE uint64_t
1679
0
libcrux_sha3_portable_keccak__vxarq_u64_4213(uint64_t a, uint64_t b) {
1680
0
  uint64_t ab = a ^ b;
1681
0
  return libcrux_sha3_portable_keccak_rotate_left_cb13(ab);
1682
0
}
1683
1684
/**
1685
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1686
usize> for u64)}
1687
*/
1688
/**
1689
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1690
with const generics
1691
- LEFT= 28
1692
- RIGHT= 36
1693
*/
1694
static KRML_MUSTINLINE uint64_t
1695
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13(uint64_t a, uint64_t b) {
1696
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4213(a, b);
1697
0
}
1698
1699
/**
1700
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1701
with const generics
1702
- LEFT= 55
1703
- RIGHT= 9
1704
*/
1705
static KRML_MUSTINLINE uint64_t
1706
0
libcrux_sha3_portable_keccak_rotate_left_cb14(uint64_t x) {
1707
0
  return x << (uint32_t)(int32_t)55 | x >> (uint32_t)(int32_t)9;
1708
0
}
1709
1710
/**
1711
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1712
with const generics
1713
- LEFT= 55
1714
- RIGHT= 9
1715
*/
1716
static KRML_MUSTINLINE uint64_t
1717
0
libcrux_sha3_portable_keccak__vxarq_u64_4214(uint64_t a, uint64_t b) {
1718
0
  uint64_t ab = a ^ b;
1719
0
  return libcrux_sha3_portable_keccak_rotate_left_cb14(ab);
1720
0
}
1721
1722
/**
1723
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1724
usize> for u64)}
1725
*/
1726
/**
1727
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1728
with const generics
1729
- LEFT= 55
1730
- RIGHT= 9
1731
*/
1732
static KRML_MUSTINLINE uint64_t
1733
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14(uint64_t a, uint64_t b) {
1734
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4214(a, b);
1735
0
}
1736
1737
/**
1738
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1739
with const generics
1740
- LEFT= 25
1741
- RIGHT= 39
1742
*/
1743
static KRML_MUSTINLINE uint64_t
1744
0
libcrux_sha3_portable_keccak_rotate_left_cb15(uint64_t x) {
1745
0
  return x << (uint32_t)(int32_t)25 | x >> (uint32_t)(int32_t)39;
1746
0
}
1747
1748
/**
1749
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1750
with const generics
1751
- LEFT= 25
1752
- RIGHT= 39
1753
*/
1754
static KRML_MUSTINLINE uint64_t
1755
0
libcrux_sha3_portable_keccak__vxarq_u64_4215(uint64_t a, uint64_t b) {
1756
0
  uint64_t ab = a ^ b;
1757
0
  return libcrux_sha3_portable_keccak_rotate_left_cb15(ab);
1758
0
}
1759
1760
/**
1761
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1762
usize> for u64)}
1763
*/
1764
/**
1765
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1766
with const generics
1767
- LEFT= 25
1768
- RIGHT= 39
1769
*/
1770
static KRML_MUSTINLINE uint64_t
1771
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15(uint64_t a, uint64_t b) {
1772
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4215(a, b);
1773
0
}
1774
1775
/**
1776
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1777
with const generics
1778
- LEFT= 21
1779
- RIGHT= 43
1780
*/
1781
static KRML_MUSTINLINE uint64_t
1782
0
libcrux_sha3_portable_keccak_rotate_left_cb16(uint64_t x) {
1783
0
  return x << (uint32_t)(int32_t)21 | x >> (uint32_t)(int32_t)43;
1784
0
}
1785
1786
/**
1787
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1788
with const generics
1789
- LEFT= 21
1790
- RIGHT= 43
1791
*/
1792
static KRML_MUSTINLINE uint64_t
1793
0
libcrux_sha3_portable_keccak__vxarq_u64_4216(uint64_t a, uint64_t b) {
1794
0
  uint64_t ab = a ^ b;
1795
0
  return libcrux_sha3_portable_keccak_rotate_left_cb16(ab);
1796
0
}
1797
1798
/**
1799
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1800
usize> for u64)}
1801
*/
1802
/**
1803
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1804
with const generics
1805
- LEFT= 21
1806
- RIGHT= 43
1807
*/
1808
static KRML_MUSTINLINE uint64_t
1809
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16(uint64_t a, uint64_t b) {
1810
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4216(a, b);
1811
0
}
1812
1813
/**
1814
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1815
with const generics
1816
- LEFT= 56
1817
- RIGHT= 8
1818
*/
1819
static KRML_MUSTINLINE uint64_t
1820
0
libcrux_sha3_portable_keccak_rotate_left_cb17(uint64_t x) {
1821
0
  return x << (uint32_t)(int32_t)56 | x >> (uint32_t)(int32_t)8;
1822
0
}
1823
1824
/**
1825
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1826
with const generics
1827
- LEFT= 56
1828
- RIGHT= 8
1829
*/
1830
static KRML_MUSTINLINE uint64_t
1831
0
libcrux_sha3_portable_keccak__vxarq_u64_4217(uint64_t a, uint64_t b) {
1832
0
  uint64_t ab = a ^ b;
1833
0
  return libcrux_sha3_portable_keccak_rotate_left_cb17(ab);
1834
0
}
1835
1836
/**
1837
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1838
usize> for u64)}
1839
*/
1840
/**
1841
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1842
with const generics
1843
- LEFT= 56
1844
- RIGHT= 8
1845
*/
1846
static KRML_MUSTINLINE uint64_t
1847
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17(uint64_t a, uint64_t b) {
1848
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4217(a, b);
1849
0
}
1850
1851
/**
1852
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1853
with const generics
1854
- LEFT= 27
1855
- RIGHT= 37
1856
*/
1857
static KRML_MUSTINLINE uint64_t
1858
0
libcrux_sha3_portable_keccak_rotate_left_cb18(uint64_t x) {
1859
0
  return x << (uint32_t)(int32_t)27 | x >> (uint32_t)(int32_t)37;
1860
0
}
1861
1862
/**
1863
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1864
with const generics
1865
- LEFT= 27
1866
- RIGHT= 37
1867
*/
1868
static KRML_MUSTINLINE uint64_t
1869
0
libcrux_sha3_portable_keccak__vxarq_u64_4218(uint64_t a, uint64_t b) {
1870
0
  uint64_t ab = a ^ b;
1871
0
  return libcrux_sha3_portable_keccak_rotate_left_cb18(ab);
1872
0
}
1873
1874
/**
1875
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1876
usize> for u64)}
1877
*/
1878
/**
1879
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1880
with const generics
1881
- LEFT= 27
1882
- RIGHT= 37
1883
*/
1884
static KRML_MUSTINLINE uint64_t
1885
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18(uint64_t a, uint64_t b) {
1886
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4218(a, b);
1887
0
}
1888
1889
/**
1890
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1891
with const generics
1892
- LEFT= 20
1893
- RIGHT= 44
1894
*/
1895
static KRML_MUSTINLINE uint64_t
1896
0
libcrux_sha3_portable_keccak_rotate_left_cb19(uint64_t x) {
1897
0
  return x << (uint32_t)(int32_t)20 | x >> (uint32_t)(int32_t)44;
1898
0
}
1899
1900
/**
1901
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1902
with const generics
1903
- LEFT= 20
1904
- RIGHT= 44
1905
*/
1906
static KRML_MUSTINLINE uint64_t
1907
0
libcrux_sha3_portable_keccak__vxarq_u64_4219(uint64_t a, uint64_t b) {
1908
0
  uint64_t ab = a ^ b;
1909
0
  return libcrux_sha3_portable_keccak_rotate_left_cb19(ab);
1910
0
}
1911
1912
/**
1913
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1914
usize> for u64)}
1915
*/
1916
/**
1917
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1918
with const generics
1919
- LEFT= 20
1920
- RIGHT= 44
1921
*/
1922
static KRML_MUSTINLINE uint64_t
1923
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19(uint64_t a, uint64_t b) {
1924
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4219(a, b);
1925
0
}
1926
1927
/**
1928
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1929
with const generics
1930
- LEFT= 39
1931
- RIGHT= 25
1932
*/
1933
static KRML_MUSTINLINE uint64_t
1934
0
libcrux_sha3_portable_keccak_rotate_left_cb20(uint64_t x) {
1935
0
  return x << (uint32_t)(int32_t)39 | x >> (uint32_t)(int32_t)25;
1936
0
}
1937
1938
/**
1939
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1940
with const generics
1941
- LEFT= 39
1942
- RIGHT= 25
1943
*/
1944
static KRML_MUSTINLINE uint64_t
1945
0
libcrux_sha3_portable_keccak__vxarq_u64_4220(uint64_t a, uint64_t b) {
1946
0
  uint64_t ab = a ^ b;
1947
0
  return libcrux_sha3_portable_keccak_rotate_left_cb20(ab);
1948
0
}
1949
1950
/**
1951
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1952
usize> for u64)}
1953
*/
1954
/**
1955
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1956
with const generics
1957
- LEFT= 39
1958
- RIGHT= 25
1959
*/
1960
static KRML_MUSTINLINE uint64_t
1961
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20(uint64_t a, uint64_t b) {
1962
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4220(a, b);
1963
0
}
1964
1965
/**
1966
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
1967
with const generics
1968
- LEFT= 8
1969
- RIGHT= 56
1970
*/
1971
static KRML_MUSTINLINE uint64_t
1972
0
libcrux_sha3_portable_keccak_rotate_left_cb21(uint64_t x) {
1973
0
  return x << (uint32_t)(int32_t)8 | x >> (uint32_t)(int32_t)56;
1974
0
}
1975
1976
/**
1977
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
1978
with const generics
1979
- LEFT= 8
1980
- RIGHT= 56
1981
*/
1982
static KRML_MUSTINLINE uint64_t
1983
0
libcrux_sha3_portable_keccak__vxarq_u64_4221(uint64_t a, uint64_t b) {
1984
0
  uint64_t ab = a ^ b;
1985
0
  return libcrux_sha3_portable_keccak_rotate_left_cb21(ab);
1986
0
}
1987
1988
/**
1989
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
1990
usize> for u64)}
1991
*/
1992
/**
1993
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
1994
with const generics
1995
- LEFT= 8
1996
- RIGHT= 56
1997
*/
1998
static KRML_MUSTINLINE uint64_t
1999
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21(uint64_t a, uint64_t b) {
2000
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4221(a, b);
2001
0
}
2002
2003
/**
2004
A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left
2005
with const generics
2006
- LEFT= 14
2007
- RIGHT= 50
2008
*/
2009
static KRML_MUSTINLINE uint64_t
2010
0
libcrux_sha3_portable_keccak_rotate_left_cb22(uint64_t x) {
2011
0
  return x << (uint32_t)(int32_t)14 | x >> (uint32_t)(int32_t)50;
2012
0
}
2013
2014
/**
2015
A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64
2016
with const generics
2017
- LEFT= 14
2018
- RIGHT= 50
2019
*/
2020
static KRML_MUSTINLINE uint64_t
2021
0
libcrux_sha3_portable_keccak__vxarq_u64_4222(uint64_t a, uint64_t b) {
2022
0
  uint64_t ab = a ^ b;
2023
0
  return libcrux_sha3_portable_keccak_rotate_left_cb22(ab);
2024
0
}
2025
2026
/**
2027
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2028
usize> for u64)}
2029
*/
2030
/**
2031
A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a
2032
with const generics
2033
- LEFT= 14
2034
- RIGHT= 50
2035
*/
2036
static KRML_MUSTINLINE uint64_t
2037
0
libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22(uint64_t a, uint64_t b) {
2038
0
  return libcrux_sha3_portable_keccak__vxarq_u64_4222(a, b);
2039
0
}
2040
2041
/**
2042
A monomorphic instance of libcrux_sha3.generic_keccak.theta_rho
2043
with types uint64_t
2044
with const generics
2045
- N= 1
2046
*/
2047
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_theta_rho_16(
2048
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
2049
0
  uint64_t c[5U] = {
2050
0
      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][0U], s->st[1U][0U],
2051
0
                                           s->st[2U][0U], s->st[3U][0U],
2052
0
                                           s->st[4U][0U]),
2053
0
      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][1U], s->st[1U][1U],
2054
0
                                           s->st[2U][1U], s->st[3U][1U],
2055
0
                                           s->st[4U][1U]),
2056
0
      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][2U], s->st[1U][2U],
2057
0
                                           s->st[2U][2U], s->st[3U][2U],
2058
0
                                           s->st[4U][2U]),
2059
0
      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][3U], s->st[1U][3U],
2060
0
                                           s->st[2U][3U], s->st[3U][3U],
2061
0
                                           s->st[4U][3U]),
2062
0
      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][4U], s->st[1U][4U],
2063
0
                                           s->st[2U][4U], s->st[3U][4U],
2064
0
                                           s->st[4U][4U])};
2065
0
  uint64_t uu____0 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
2066
0
      c[((size_t)0U + (size_t)4U) % (size_t)5U],
2067
0
      c[((size_t)0U + (size_t)1U) % (size_t)5U]);
2068
0
  uint64_t uu____1 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
2069
0
      c[((size_t)1U + (size_t)4U) % (size_t)5U],
2070
0
      c[((size_t)1U + (size_t)1U) % (size_t)5U]);
2071
0
  uint64_t uu____2 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
2072
0
      c[((size_t)2U + (size_t)4U) % (size_t)5U],
2073
0
      c[((size_t)2U + (size_t)1U) % (size_t)5U]);
2074
0
  uint64_t uu____3 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
2075
0
      c[((size_t)3U + (size_t)4U) % (size_t)5U],
2076
0
      c[((size_t)3U + (size_t)1U) % (size_t)5U]);
2077
0
  uint64_t t[5U] = {uu____0, uu____1, uu____2, uu____3,
2078
0
                    libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
2079
0
                        c[((size_t)4U + (size_t)4U) % (size_t)5U],
2080
0
                        c[((size_t)4U + (size_t)1U) % (size_t)5U])};
2081
0
  s->st[0U][0U] = libcrux_sha3_portable_keccak_xor_5a(s->st[0U][0U], t[0U]);
2082
0
  s->st[1U][0U] =
2083
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb(s->st[1U][0U], t[0U]);
2084
0
  s->st[2U][0U] =
2085
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0(s->st[2U][0U], t[0U]);
2086
0
  s->st[3U][0U] =
2087
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1(s->st[3U][0U], t[0U]);
2088
0
  s->st[4U][0U] =
2089
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2(s->st[4U][0U], t[0U]);
2090
0
  s->st[0U][1U] =
2091
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3(s->st[0U][1U], t[1U]);
2092
0
  s->st[1U][1U] =
2093
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4(s->st[1U][1U], t[1U]);
2094
0
  s->st[2U][1U] =
2095
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5(s->st[2U][1U], t[1U]);
2096
0
  s->st[3U][1U] =
2097
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6(s->st[3U][1U], t[1U]);
2098
0
  s->st[4U][1U] =
2099
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7(s->st[4U][1U], t[1U]);
2100
0
  s->st[0U][2U] =
2101
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8(s->st[0U][2U], t[2U]);
2102
0
  s->st[1U][2U] =
2103
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9(s->st[1U][2U], t[2U]);
2104
0
  s->st[2U][2U] =
2105
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10(s->st[2U][2U], t[2U]);
2106
0
  s->st[3U][2U] =
2107
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11(s->st[3U][2U], t[2U]);
2108
0
  s->st[4U][2U] =
2109
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12(s->st[4U][2U], t[2U]);
2110
0
  s->st[0U][3U] =
2111
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13(s->st[0U][3U], t[3U]);
2112
0
  s->st[1U][3U] =
2113
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14(s->st[1U][3U], t[3U]);
2114
0
  s->st[2U][3U] =
2115
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15(s->st[2U][3U], t[3U]);
2116
0
  s->st[3U][3U] =
2117
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16(s->st[3U][3U], t[3U]);
2118
0
  s->st[4U][3U] =
2119
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17(s->st[4U][3U], t[3U]);
2120
0
  s->st[0U][4U] =
2121
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18(s->st[0U][4U], t[4U]);
2122
0
  s->st[1U][4U] =
2123
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19(s->st[1U][4U], t[4U]);
2124
0
  s->st[2U][4U] =
2125
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20(s->st[2U][4U], t[4U]);
2126
0
  s->st[3U][4U] =
2127
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21(s->st[3U][4U], t[4U]);
2128
0
  uint64_t uu____27 =
2129
0
      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22(s->st[4U][4U], t[4U]);
2130
0
  s->st[4U][4U] = uu____27;
2131
0
}
2132
2133
/**
2134
A monomorphic instance of libcrux_sha3.generic_keccak.pi
2135
with types uint64_t
2136
with const generics
2137
- N= 1
2138
*/
2139
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_pi_1d(
2140
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
2141
0
  uint64_t old[5U][5U];
2142
0
  memcpy(old, s->st, (size_t)5U * sizeof(uint64_t[5U]));
2143
0
  s->st[0U][1U] = old[1U][1U];
2144
0
  s->st[0U][2U] = old[2U][2U];
2145
0
  s->st[0U][3U] = old[3U][3U];
2146
0
  s->st[0U][4U] = old[4U][4U];
2147
0
  s->st[1U][0U] = old[0U][3U];
2148
0
  s->st[1U][1U] = old[1U][4U];
2149
0
  s->st[1U][2U] = old[2U][0U];
2150
0
  s->st[1U][3U] = old[3U][1U];
2151
0
  s->st[1U][4U] = old[4U][2U];
2152
0
  s->st[2U][0U] = old[0U][1U];
2153
0
  s->st[2U][1U] = old[1U][2U];
2154
0
  s->st[2U][2U] = old[2U][3U];
2155
0
  s->st[2U][3U] = old[3U][4U];
2156
0
  s->st[2U][4U] = old[4U][0U];
2157
0
  s->st[3U][0U] = old[0U][4U];
2158
0
  s->st[3U][1U] = old[1U][0U];
2159
0
  s->st[3U][2U] = old[2U][1U];
2160
0
  s->st[3U][3U] = old[3U][2U];
2161
0
  s->st[3U][4U] = old[4U][3U];
2162
0
  s->st[4U][0U] = old[0U][2U];
2163
0
  s->st[4U][1U] = old[1U][3U];
2164
0
  s->st[4U][2U] = old[2U][4U];
2165
0
  s->st[4U][3U] = old[3U][0U];
2166
0
  s->st[4U][4U] = old[4U][1U];
2167
0
}
2168
2169
/**
2170
A monomorphic instance of libcrux_sha3.generic_keccak.chi
2171
with types uint64_t
2172
with const generics
2173
- N= 1
2174
*/
2175
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_chi_12(
2176
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
2177
0
  uint64_t old[5U][5U];
2178
0
  memcpy(old, s->st, (size_t)5U * sizeof(uint64_t[5U]));
2179
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)5U; i0++) {
2180
0
    size_t i1 = i0;
2181
0
    for (size_t i = (size_t)0U; i < (size_t)5U; i++) {
2182
0
      size_t j = i;
2183
0
      s->st[i1][j] = libcrux_sha3_portable_keccak_and_not_xor_5a(
2184
0
          s->st[i1][j], old[i1][(j + (size_t)2U) % (size_t)5U],
2185
0
          old[i1][(j + (size_t)1U) % (size_t)5U]);
2186
0
    }
2187
0
  }
2188
0
}
2189
2190
/**
2191
A monomorphic instance of libcrux_sha3.generic_keccak.iota
2192
with types uint64_t
2193
with const generics
2194
- N= 1
2195
*/
2196
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_iota_62(
2197
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, size_t i) {
2198
0
  s->st[0U][0U] = libcrux_sha3_portable_keccak_xor_constant_5a(
2199
0
      s->st[0U][0U], libcrux_sha3_generic_keccak_ROUNDCONSTANTS[i]);
2200
0
}
2201
2202
/**
2203
A monomorphic instance of libcrux_sha3.generic_keccak.keccakf1600
2204
with types uint64_t
2205
with const generics
2206
- N= 1
2207
*/
2208
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccakf1600_21(
2209
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
2210
0
  for (size_t i = (size_t)0U; i < (size_t)24U; i++) {
2211
0
    size_t i0 = i;
2212
0
    libcrux_sha3_generic_keccak_theta_rho_16(s);
2213
0
    libcrux_sha3_generic_keccak_pi_1d(s);
2214
0
    libcrux_sha3_generic_keccak_chi_12(s);
2215
0
    libcrux_sha3_generic_keccak_iota_62(s, i0);
2216
0
  }
2217
0
}
2218
2219
/**
2220
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block
2221
with types uint64_t
2222
with const generics
2223
- N= 1
2224
- RATE= 72
2225
*/
2226
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df(
2227
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) {
2228
0
  uint64_t(*uu____0)[5U] = s->st;
2229
0
  Eurydice_slice uu____1[1U];
2230
0
  memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice));
2231
0
  libcrux_sha3_portable_keccak_load_block_5a_b8(uu____0, uu____1);
2232
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2233
0
}
2234
2235
/**
2236
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full
2237
with const generics
2238
- RATE= 72
2239
*/
2240
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df(
2241
0
    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
2242
0
  Eurydice_slice buf[1U] = {
2243
0
      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
2244
0
  libcrux_sha3_portable_keccak_load_block_2c(s, buf);
2245
0
}
2246
2247
/**
2248
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2249
usize> for u64)}
2250
*/
2251
/**
2252
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a
2253
with const generics
2254
- RATE= 72
2255
*/
2256
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d2(
2257
0
    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
2258
0
  uint64_t(*uu____0)[5U] = a;
2259
  /* Passing arrays by value in Rust generates a copy in C */
2260
0
  uint8_t copy_of_b[1U][200U];
2261
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
2262
0
  libcrux_sha3_portable_keccak_load_block_full_df(uu____0, copy_of_b);
2263
0
}
2264
2265
/**
2266
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final
2267
with types uint64_t
2268
with const generics
2269
- N= 1
2270
- RATE= 72
2271
- DELIM= 6
2272
*/
2273
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c7(
2274
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
2275
0
  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
2276
0
  uint8_t blocks[1U][200U] = {{0U}};
2277
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2278
0
    size_t i0 = i;
2279
0
    if (last_len > (size_t)0U) {
2280
0
      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
2281
0
          blocks[i0], (size_t)0U, last_len, uint8_t);
2282
0
      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
2283
0
    }
2284
0
    blocks[i0][last_len] = 6U;
2285
0
    size_t uu____1 = i0;
2286
0
    size_t uu____2 = (size_t)72U - (size_t)1U;
2287
0
    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
2288
0
  }
2289
0
  uint64_t(*uu____3)[5U] = s->st;
2290
0
  uint8_t uu____4[1U][200U];
2291
0
  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
2292
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d2(uu____3, uu____4);
2293
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2294
0
}
2295
2296
/**
2297
A monomorphic instance of libcrux_sha3.portable_keccak.store_block
2298
with const generics
2299
- RATE= 72
2300
*/
2301
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_58(
2302
0
    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
2303
0
  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
2304
0
    size_t i0 = i;
2305
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
2306
0
        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
2307
0
    uint8_t ret[8U];
2308
0
    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
2309
0
    Eurydice_slice_copy(
2310
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
2311
0
  }
2312
0
}
2313
2314
/**
2315
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full
2316
with const generics
2317
- RATE= 72
2318
*/
2319
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d(
2320
0
    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
2321
0
  uint8_t out[200U] = {0U};
2322
0
  Eurydice_slice buf[1U] = {
2323
0
      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
2324
0
  libcrux_sha3_portable_keccak_store_block_58(s, buf);
2325
  /* Passing arrays by value in Rust generates a copy in C */
2326
0
  uint8_t copy_of_out[200U];
2327
0
  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
2328
0
  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
2329
0
}
2330
2331
/**
2332
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2333
usize> for u64)}
2334
*/
2335
/**
2336
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a
2337
with const generics
2338
- RATE= 72
2339
*/
2340
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_5a_29(
2341
0
    uint64_t (*a)[5U], uint8_t ret[1U][200U]) {
2342
0
  libcrux_sha3_portable_keccak_store_block_full_2d(a, ret);
2343
0
}
2344
2345
/**
2346
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last
2347
with types uint64_t
2348
with const generics
2349
- N= 1
2350
- RATE= 72
2351
*/
2352
static KRML_MUSTINLINE void
2353
libcrux_sha3_generic_keccak_squeeze_first_and_last_c5(
2354
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
2355
0
  uint8_t b[1U][200U];
2356
0
  libcrux_sha3_portable_keccak_store_block_full_5a_29(s->st, b);
2357
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2358
0
    size_t i0 = i;
2359
0
    Eurydice_slice uu____0 = out[i0];
2360
0
    uint8_t *uu____1 = b[i0];
2361
0
    core_ops_range_Range_b3 lit;
2362
0
    lit.start = (size_t)0U;
2363
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
2364
0
    Eurydice_slice_copy(
2365
0
        uu____0,
2366
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
2367
0
                                   core_ops_range_Range_b3),
2368
0
        uint8_t);
2369
0
  }
2370
0
}
2371
2372
/**
2373
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2374
usize> for u64)}
2375
*/
2376
/**
2377
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a
2378
with const generics
2379
- RATE= 72
2380
*/
2381
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_59(
2382
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
2383
0
  libcrux_sha3_portable_keccak_store_block_58(a, b);
2384
0
}
2385
2386
/**
2387
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block
2388
with types uint64_t
2389
with const generics
2390
- N= 1
2391
- RATE= 72
2392
*/
2393
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_84(
2394
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
2395
0
  libcrux_sha3_portable_keccak_store_block_5a_59(s->st, out);
2396
0
}
2397
2398
/**
2399
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block
2400
with types uint64_t
2401
with const generics
2402
- N= 1
2403
- RATE= 72
2404
*/
2405
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc(
2406
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
2407
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2408
0
  libcrux_sha3_portable_keccak_store_block_5a_59(s->st, out);
2409
0
}
2410
2411
/**
2412
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last
2413
with types uint64_t
2414
with const generics
2415
- N= 1
2416
- RATE= 72
2417
*/
2418
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf(
2419
0
    libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) {
2420
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&s);
2421
0
  uint8_t b[1U][200U];
2422
0
  libcrux_sha3_portable_keccak_store_block_full_5a_29(s.st, b);
2423
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2424
0
    size_t i0 = i;
2425
0
    Eurydice_slice uu____0 = out[i0];
2426
0
    uint8_t *uu____1 = b[i0];
2427
0
    core_ops_range_Range_b3 lit;
2428
0
    lit.start = (size_t)0U;
2429
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
2430
0
    Eurydice_slice_copy(
2431
0
        uu____0,
2432
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
2433
0
                                   core_ops_range_Range_b3),
2434
0
        uint8_t);
2435
0
  }
2436
0
}
2437
2438
/**
2439
A monomorphic instance of libcrux_sha3.generic_keccak.keccak
2440
with types uint64_t
2441
with const generics
2442
- N= 1
2443
- RATE= 72
2444
- DELIM= 6
2445
*/
2446
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e9(
2447
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
2448
0
  libcrux_sha3_generic_keccak_KeccakState_48 s =
2449
0
      libcrux_sha3_generic_keccak_new_1e_f4();
2450
0
  for (size_t i = (size_t)0U;
2451
0
       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)72U; i++) {
2452
0
    size_t i0 = i;
2453
0
    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
2454
    /* Passing arrays by value in Rust generates a copy in C */
2455
0
    Eurydice_slice copy_of_data[1U];
2456
0
    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2457
0
    Eurydice_slice ret[1U];
2458
0
    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)72U,
2459
0
                                            (size_t)72U, ret);
2460
0
    libcrux_sha3_generic_keccak_absorb_block_df(uu____0, ret);
2461
0
  }
2462
0
  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)72U;
2463
0
  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
2464
  /* Passing arrays by value in Rust generates a copy in C */
2465
0
  Eurydice_slice copy_of_data[1U];
2466
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2467
0
  Eurydice_slice ret[1U];
2468
0
  libcrux_sha3_portable_keccak_slice_n_5a(
2469
0
      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
2470
0
  libcrux_sha3_generic_keccak_absorb_final_c7(uu____2, ret);
2471
0
  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
2472
0
  size_t blocks = outlen / (size_t)72U;
2473
0
  size_t last = outlen - outlen % (size_t)72U;
2474
0
  if (blocks == (size_t)0U) {
2475
0
    libcrux_sha3_generic_keccak_squeeze_first_and_last_c5(&s, out);
2476
0
  } else {
2477
0
    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
2478
0
        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)72U);
2479
0
    Eurydice_slice o0[1U];
2480
0
    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
2481
0
    Eurydice_slice o1[1U];
2482
0
    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
2483
0
    libcrux_sha3_generic_keccak_squeeze_first_block_84(&s, o0);
2484
0
    core_ops_range_Range_b3 iter =
2485
0
        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
2486
0
            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
2487
0
                                               .end = blocks}),
2488
0
            core_ops_range_Range_b3, core_ops_range_Range_b3);
2489
0
    while (true) {
2490
0
      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
2491
0
              &iter, size_t, Option_b3)
2492
0
              .tag == None) {
2493
0
        break;
2494
0
      } else {
2495
0
        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
2496
0
            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)72U);
2497
0
        Eurydice_slice o[1U];
2498
0
        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
2499
0
        Eurydice_slice orest[1U];
2500
0
        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
2501
0
        libcrux_sha3_generic_keccak_squeeze_next_block_fc(&s, o);
2502
0
        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
2503
0
      }
2504
0
    }
2505
0
    if (last < outlen) {
2506
0
      libcrux_sha3_generic_keccak_squeeze_last_cf(s, o1);
2507
0
    }
2508
0
  }
2509
0
}
2510
2511
/**
2512
A monomorphic instance of libcrux_sha3.portable.keccakx1
2513
with const generics
2514
- RATE= 72
2515
- DELIM= 6
2516
*/
2517
static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce(
2518
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
2519
  /* Passing arrays by value in Rust generates a copy in C */
2520
0
  Eurydice_slice copy_of_data[1U];
2521
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2522
0
  libcrux_sha3_generic_keccak_keccak_e9(copy_of_data, out);
2523
0
}
2524
2525
/**
2526
 A portable SHA3 512 implementation.
2527
*/
2528
static KRML_MUSTINLINE void libcrux_sha3_portable_sha512(Eurydice_slice digest,
2529
0
                                                         Eurydice_slice data) {
2530
0
  Eurydice_slice buf0[1U] = {data};
2531
0
  Eurydice_slice buf[1U] = {digest};
2532
0
  libcrux_sha3_portable_keccakx1_ce(buf0, buf);
2533
0
}
2534
2535
/**
2536
A monomorphic instance of libcrux_sha3.portable_keccak.load_block
2537
with const generics
2538
- RATE= 136
2539
*/
2540
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c0(
2541
0
    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
2542
0
  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
2543
0
    size_t i0 = i;
2544
0
    uint8_t uu____0[8U];
2545
0
    Result_56 dst;
2546
0
    Eurydice_slice_to_array2(
2547
0
        &dst,
2548
0
        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
2549
0
                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
2550
0
        Eurydice_slice, uint8_t[8U]);
2551
0
    unwrap_41_ac(dst, uu____0);
2552
0
    size_t uu____1 = i0 / (size_t)5U;
2553
0
    size_t uu____2 = i0 % (size_t)5U;
2554
0
    s[uu____1][uu____2] =
2555
0
        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
2556
0
  }
2557
0
}
2558
2559
/**
2560
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2561
usize> for u64)}
2562
*/
2563
/**
2564
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a
2565
with const generics
2566
- RATE= 136
2567
*/
2568
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b80(
2569
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
2570
0
  uint64_t(*uu____0)[5U] = a;
2571
  /* Passing arrays by value in Rust generates a copy in C */
2572
0
  Eurydice_slice copy_of_b[1U];
2573
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice));
2574
0
  libcrux_sha3_portable_keccak_load_block_2c0(uu____0, copy_of_b);
2575
0
}
2576
2577
/**
2578
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block
2579
with types uint64_t
2580
with const generics
2581
- N= 1
2582
- RATE= 136
2583
*/
2584
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df0(
2585
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) {
2586
0
  uint64_t(*uu____0)[5U] = s->st;
2587
0
  Eurydice_slice uu____1[1U];
2588
0
  memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice));
2589
0
  libcrux_sha3_portable_keccak_load_block_5a_b80(uu____0, uu____1);
2590
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2591
0
}
2592
2593
/**
2594
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full
2595
with const generics
2596
- RATE= 136
2597
*/
2598
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df0(
2599
0
    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
2600
0
  Eurydice_slice buf[1U] = {
2601
0
      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
2602
0
  libcrux_sha3_portable_keccak_load_block_2c0(s, buf);
2603
0
}
2604
2605
/**
2606
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2607
usize> for u64)}
2608
*/
2609
/**
2610
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a
2611
with const generics
2612
- RATE= 136
2613
*/
2614
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d20(
2615
0
    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
2616
0
  uint64_t(*uu____0)[5U] = a;
2617
  /* Passing arrays by value in Rust generates a copy in C */
2618
0
  uint8_t copy_of_b[1U][200U];
2619
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
2620
0
  libcrux_sha3_portable_keccak_load_block_full_df0(uu____0, copy_of_b);
2621
0
}
2622
2623
/**
2624
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final
2625
with types uint64_t
2626
with const generics
2627
- N= 1
2628
- RATE= 136
2629
- DELIM= 6
2630
*/
2631
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c70(
2632
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
2633
0
  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
2634
0
  uint8_t blocks[1U][200U] = {{0U}};
2635
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2636
0
    size_t i0 = i;
2637
0
    if (last_len > (size_t)0U) {
2638
0
      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
2639
0
          blocks[i0], (size_t)0U, last_len, uint8_t);
2640
0
      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
2641
0
    }
2642
0
    blocks[i0][last_len] = 6U;
2643
0
    size_t uu____1 = i0;
2644
0
    size_t uu____2 = (size_t)136U - (size_t)1U;
2645
0
    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
2646
0
  }
2647
0
  uint64_t(*uu____3)[5U] = s->st;
2648
0
  uint8_t uu____4[1U][200U];
2649
0
  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
2650
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____3, uu____4);
2651
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2652
0
}
2653
2654
/**
2655
A monomorphic instance of libcrux_sha3.portable_keccak.store_block
2656
with const generics
2657
- RATE= 136
2658
*/
2659
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_580(
2660
0
    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
2661
0
  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
2662
0
    size_t i0 = i;
2663
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
2664
0
        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
2665
0
    uint8_t ret[8U];
2666
0
    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
2667
0
    Eurydice_slice_copy(
2668
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
2669
0
  }
2670
0
}
2671
2672
/**
2673
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full
2674
with const generics
2675
- RATE= 136
2676
*/
2677
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d0(
2678
0
    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
2679
0
  uint8_t out[200U] = {0U};
2680
0
  Eurydice_slice buf[1U] = {
2681
0
      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
2682
0
  libcrux_sha3_portable_keccak_store_block_580(s, buf);
2683
  /* Passing arrays by value in Rust generates a copy in C */
2684
0
  uint8_t copy_of_out[200U];
2685
0
  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
2686
0
  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
2687
0
}
2688
2689
/**
2690
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2691
usize> for u64)}
2692
*/
2693
/**
2694
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a
2695
with const generics
2696
- RATE= 136
2697
*/
2698
static KRML_MUSTINLINE void
2699
libcrux_sha3_portable_keccak_store_block_full_5a_290(uint64_t (*a)[5U],
2700
0
                                                     uint8_t ret[1U][200U]) {
2701
0
  libcrux_sha3_portable_keccak_store_block_full_2d0(a, ret);
2702
0
}
2703
2704
/**
2705
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last
2706
with types uint64_t
2707
with const generics
2708
- N= 1
2709
- RATE= 136
2710
*/
2711
static KRML_MUSTINLINE void
2712
libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(
2713
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
2714
0
  uint8_t b[1U][200U];
2715
0
  libcrux_sha3_portable_keccak_store_block_full_5a_290(s->st, b);
2716
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2717
0
    size_t i0 = i;
2718
0
    Eurydice_slice uu____0 = out[i0];
2719
0
    uint8_t *uu____1 = b[i0];
2720
0
    core_ops_range_Range_b3 lit;
2721
0
    lit.start = (size_t)0U;
2722
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
2723
0
    Eurydice_slice_copy(
2724
0
        uu____0,
2725
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
2726
0
                                   core_ops_range_Range_b3),
2727
0
        uint8_t);
2728
0
  }
2729
0
}
2730
2731
/**
2732
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
2733
usize> for u64)}
2734
*/
2735
/**
2736
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a
2737
with const generics
2738
- RATE= 136
2739
*/
2740
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_590(
2741
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
2742
0
  libcrux_sha3_portable_keccak_store_block_580(a, b);
2743
0
}
2744
2745
/**
2746
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block
2747
with types uint64_t
2748
with const generics
2749
- N= 1
2750
- RATE= 136
2751
*/
2752
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_840(
2753
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
2754
0
  libcrux_sha3_portable_keccak_store_block_5a_590(s->st, out);
2755
0
}
2756
2757
/**
2758
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block
2759
with types uint64_t
2760
with const generics
2761
- N= 1
2762
- RATE= 136
2763
*/
2764
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc0(
2765
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
2766
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2767
0
  libcrux_sha3_portable_keccak_store_block_5a_590(s->st, out);
2768
0
}
2769
2770
/**
2771
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last
2772
with types uint64_t
2773
with const generics
2774
- N= 1
2775
- RATE= 136
2776
*/
2777
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf0(
2778
0
    libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) {
2779
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&s);
2780
0
  uint8_t b[1U][200U];
2781
0
  libcrux_sha3_portable_keccak_store_block_full_5a_290(s.st, b);
2782
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2783
0
    size_t i0 = i;
2784
0
    Eurydice_slice uu____0 = out[i0];
2785
0
    uint8_t *uu____1 = b[i0];
2786
0
    core_ops_range_Range_b3 lit;
2787
0
    lit.start = (size_t)0U;
2788
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
2789
0
    Eurydice_slice_copy(
2790
0
        uu____0,
2791
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
2792
0
                                   core_ops_range_Range_b3),
2793
0
        uint8_t);
2794
0
  }
2795
0
}
2796
2797
/**
2798
A monomorphic instance of libcrux_sha3.generic_keccak.keccak
2799
with types uint64_t
2800
with const generics
2801
- N= 1
2802
- RATE= 136
2803
- DELIM= 6
2804
*/
2805
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e90(
2806
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
2807
0
  libcrux_sha3_generic_keccak_KeccakState_48 s =
2808
0
      libcrux_sha3_generic_keccak_new_1e_f4();
2809
0
  for (size_t i = (size_t)0U;
2810
0
       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)136U; i++) {
2811
0
    size_t i0 = i;
2812
0
    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
2813
    /* Passing arrays by value in Rust generates a copy in C */
2814
0
    Eurydice_slice copy_of_data[1U];
2815
0
    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2816
0
    Eurydice_slice ret[1U];
2817
0
    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)136U,
2818
0
                                            (size_t)136U, ret);
2819
0
    libcrux_sha3_generic_keccak_absorb_block_df0(uu____0, ret);
2820
0
  }
2821
0
  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)136U;
2822
0
  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
2823
  /* Passing arrays by value in Rust generates a copy in C */
2824
0
  Eurydice_slice copy_of_data[1U];
2825
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2826
0
  Eurydice_slice ret[1U];
2827
0
  libcrux_sha3_portable_keccak_slice_n_5a(
2828
0
      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
2829
0
  libcrux_sha3_generic_keccak_absorb_final_c70(uu____2, ret);
2830
0
  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
2831
0
  size_t blocks = outlen / (size_t)136U;
2832
0
  size_t last = outlen - outlen % (size_t)136U;
2833
0
  if (blocks == (size_t)0U) {
2834
0
    libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(&s, out);
2835
0
  } else {
2836
0
    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
2837
0
        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)136U);
2838
0
    Eurydice_slice o0[1U];
2839
0
    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
2840
0
    Eurydice_slice o1[1U];
2841
0
    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
2842
0
    libcrux_sha3_generic_keccak_squeeze_first_block_840(&s, o0);
2843
0
    core_ops_range_Range_b3 iter =
2844
0
        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
2845
0
            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
2846
0
                                               .end = blocks}),
2847
0
            core_ops_range_Range_b3, core_ops_range_Range_b3);
2848
0
    while (true) {
2849
0
      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
2850
0
              &iter, size_t, Option_b3)
2851
0
              .tag == None) {
2852
0
        break;
2853
0
      } else {
2854
0
        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
2855
0
            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)136U);
2856
0
        Eurydice_slice o[1U];
2857
0
        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
2858
0
        Eurydice_slice orest[1U];
2859
0
        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
2860
0
        libcrux_sha3_generic_keccak_squeeze_next_block_fc0(&s, o);
2861
0
        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
2862
0
      }
2863
0
    }
2864
0
    if (last < outlen) {
2865
0
      libcrux_sha3_generic_keccak_squeeze_last_cf0(s, o1);
2866
0
    }
2867
0
  }
2868
0
}
2869
2870
/**
2871
A monomorphic instance of libcrux_sha3.portable.keccakx1
2872
with const generics
2873
- RATE= 136
2874
- DELIM= 6
2875
*/
2876
static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce0(
2877
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
2878
  /* Passing arrays by value in Rust generates a copy in C */
2879
0
  Eurydice_slice copy_of_data[1U];
2880
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2881
0
  libcrux_sha3_generic_keccak_keccak_e90(copy_of_data, out);
2882
0
}
2883
2884
/**
2885
 A portable SHA3 256 implementation.
2886
*/
2887
static KRML_MUSTINLINE void libcrux_sha3_portable_sha256(Eurydice_slice digest,
2888
0
                                                         Eurydice_slice data) {
2889
0
  Eurydice_slice buf0[1U] = {data};
2890
0
  Eurydice_slice buf[1U] = {digest};
2891
0
  libcrux_sha3_portable_keccakx1_ce0(buf0, buf);
2892
0
}
2893
2894
/**
2895
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final
2896
with types uint64_t
2897
with const generics
2898
- N= 1
2899
- RATE= 136
2900
- DELIM= 31
2901
*/
2902
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c71(
2903
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
2904
0
  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
2905
0
  uint8_t blocks[1U][200U] = {{0U}};
2906
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
2907
0
    size_t i0 = i;
2908
0
    if (last_len > (size_t)0U) {
2909
0
      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
2910
0
          blocks[i0], (size_t)0U, last_len, uint8_t);
2911
0
      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
2912
0
    }
2913
0
    blocks[i0][last_len] = 31U;
2914
0
    size_t uu____1 = i0;
2915
0
    size_t uu____2 = (size_t)136U - (size_t)1U;
2916
0
    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
2917
0
  }
2918
0
  uint64_t(*uu____3)[5U] = s->st;
2919
0
  uint8_t uu____4[1U][200U];
2920
0
  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
2921
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____3, uu____4);
2922
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
2923
0
}
2924
2925
/**
2926
A monomorphic instance of libcrux_sha3.generic_keccak.keccak
2927
with types uint64_t
2928
with const generics
2929
- N= 1
2930
- RATE= 136
2931
- DELIM= 31
2932
*/
2933
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e91(
2934
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
2935
0
  libcrux_sha3_generic_keccak_KeccakState_48 s =
2936
0
      libcrux_sha3_generic_keccak_new_1e_f4();
2937
0
  for (size_t i = (size_t)0U;
2938
0
       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)136U; i++) {
2939
0
    size_t i0 = i;
2940
0
    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
2941
    /* Passing arrays by value in Rust generates a copy in C */
2942
0
    Eurydice_slice copy_of_data[1U];
2943
0
    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2944
0
    Eurydice_slice ret[1U];
2945
0
    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)136U,
2946
0
                                            (size_t)136U, ret);
2947
0
    libcrux_sha3_generic_keccak_absorb_block_df0(uu____0, ret);
2948
0
  }
2949
0
  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)136U;
2950
0
  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
2951
  /* Passing arrays by value in Rust generates a copy in C */
2952
0
  Eurydice_slice copy_of_data[1U];
2953
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
2954
0
  Eurydice_slice ret[1U];
2955
0
  libcrux_sha3_portable_keccak_slice_n_5a(
2956
0
      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
2957
0
  libcrux_sha3_generic_keccak_absorb_final_c71(uu____2, ret);
2958
0
  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
2959
0
  size_t blocks = outlen / (size_t)136U;
2960
0
  size_t last = outlen - outlen % (size_t)136U;
2961
0
  if (blocks == (size_t)0U) {
2962
0
    libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(&s, out);
2963
0
  } else {
2964
0
    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
2965
0
        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)136U);
2966
0
    Eurydice_slice o0[1U];
2967
0
    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
2968
0
    Eurydice_slice o1[1U];
2969
0
    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
2970
0
    libcrux_sha3_generic_keccak_squeeze_first_block_840(&s, o0);
2971
0
    core_ops_range_Range_b3 iter =
2972
0
        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
2973
0
            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
2974
0
                                               .end = blocks}),
2975
0
            core_ops_range_Range_b3, core_ops_range_Range_b3);
2976
0
    while (true) {
2977
0
      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
2978
0
              &iter, size_t, Option_b3)
2979
0
              .tag == None) {
2980
0
        break;
2981
0
      } else {
2982
0
        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
2983
0
            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)136U);
2984
0
        Eurydice_slice o[1U];
2985
0
        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
2986
0
        Eurydice_slice orest[1U];
2987
0
        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
2988
0
        libcrux_sha3_generic_keccak_squeeze_next_block_fc0(&s, o);
2989
0
        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
2990
0
      }
2991
0
    }
2992
0
    if (last < outlen) {
2993
0
      libcrux_sha3_generic_keccak_squeeze_last_cf0(s, o1);
2994
0
    }
2995
0
  }
2996
0
}
2997
2998
/**
2999
A monomorphic instance of libcrux_sha3.portable.keccakx1
3000
with const generics
3001
- RATE= 136
3002
- DELIM= 31
3003
*/
3004
static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce1(
3005
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
3006
  /* Passing arrays by value in Rust generates a copy in C */
3007
0
  Eurydice_slice copy_of_data[1U];
3008
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3009
0
  libcrux_sha3_generic_keccak_keccak_e91(copy_of_data, out);
3010
0
}
3011
3012
/**
3013
 A portable SHAKE256 implementation.
3014
*/
3015
static KRML_MUSTINLINE void libcrux_sha3_portable_shake256(
3016
0
    Eurydice_slice digest, Eurydice_slice data) {
3017
0
  Eurydice_slice buf0[1U] = {data};
3018
0
  Eurydice_slice buf[1U] = {digest};
3019
0
  libcrux_sha3_portable_keccakx1_ce1(buf0, buf);
3020
0
}
3021
3022
typedef libcrux_sha3_generic_keccak_KeccakState_48
3023
    libcrux_sha3_portable_KeccakState;
3024
3025
/**
3026
 Create a new SHAKE-128 state object.
3027
*/
3028
static KRML_MUSTINLINE libcrux_sha3_generic_keccak_KeccakState_48
3029
0
libcrux_sha3_portable_incremental_shake128_init(void) {
3030
0
  return libcrux_sha3_generic_keccak_new_1e_f4();
3031
0
}
3032
3033
/**
3034
A monomorphic instance of libcrux_sha3.portable_keccak.load_block
3035
with const generics
3036
- RATE= 168
3037
*/
3038
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c1(
3039
0
    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
3040
0
  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
3041
0
    size_t i0 = i;
3042
0
    uint8_t uu____0[8U];
3043
0
    Result_56 dst;
3044
0
    Eurydice_slice_to_array2(
3045
0
        &dst,
3046
0
        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
3047
0
                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
3048
0
        Eurydice_slice, uint8_t[8U]);
3049
0
    unwrap_41_ac(dst, uu____0);
3050
0
    size_t uu____1 = i0 / (size_t)5U;
3051
0
    size_t uu____2 = i0 % (size_t)5U;
3052
0
    s[uu____1][uu____2] =
3053
0
        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
3054
0
  }
3055
0
}
3056
3057
/**
3058
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full
3059
with const generics
3060
- RATE= 168
3061
*/
3062
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df1(
3063
0
    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
3064
0
  Eurydice_slice buf[1U] = {
3065
0
      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
3066
0
  libcrux_sha3_portable_keccak_load_block_2c1(s, buf);
3067
0
}
3068
3069
/**
3070
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3071
usize> for u64)}
3072
*/
3073
/**
3074
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a
3075
with const generics
3076
- RATE= 168
3077
*/
3078
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d21(
3079
0
    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
3080
0
  uint64_t(*uu____0)[5U] = a;
3081
  /* Passing arrays by value in Rust generates a copy in C */
3082
0
  uint8_t copy_of_b[1U][200U];
3083
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
3084
0
  libcrux_sha3_portable_keccak_load_block_full_df1(uu____0, copy_of_b);
3085
0
}
3086
3087
/**
3088
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final
3089
with types uint64_t
3090
with const generics
3091
- N= 1
3092
- RATE= 168
3093
- DELIM= 31
3094
*/
3095
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c72(
3096
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
3097
0
  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
3098
0
  uint8_t blocks[1U][200U] = {{0U}};
3099
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3100
0
    size_t i0 = i;
3101
0
    if (last_len > (size_t)0U) {
3102
0
      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
3103
0
          blocks[i0], (size_t)0U, last_len, uint8_t);
3104
0
      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
3105
0
    }
3106
0
    blocks[i0][last_len] = 31U;
3107
0
    size_t uu____1 = i0;
3108
0
    size_t uu____2 = (size_t)168U - (size_t)1U;
3109
0
    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
3110
0
  }
3111
0
  uint64_t(*uu____3)[5U] = s->st;
3112
0
  uint8_t uu____4[1U][200U];
3113
0
  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
3114
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d21(uu____3, uu____4);
3115
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3116
0
}
3117
3118
/**
3119
 Absorb
3120
*/
3121
static KRML_MUSTINLINE void
3122
libcrux_sha3_portable_incremental_shake128_absorb_final(
3123
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice data0) {
3124
0
  Eurydice_slice buf[1U] = {data0};
3125
0
  libcrux_sha3_generic_keccak_absorb_final_c72(s, buf);
3126
0
}
3127
3128
/**
3129
A monomorphic instance of libcrux_sha3.portable_keccak.store_block
3130
with const generics
3131
- RATE= 168
3132
*/
3133
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_581(
3134
0
    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
3135
0
  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
3136
0
    size_t i0 = i;
3137
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
3138
0
        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
3139
0
    uint8_t ret[8U];
3140
0
    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
3141
0
    Eurydice_slice_copy(
3142
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
3143
0
  }
3144
0
}
3145
3146
/**
3147
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3148
usize> for u64)}
3149
*/
3150
/**
3151
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a
3152
with const generics
3153
- RATE= 168
3154
*/
3155
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_591(
3156
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
3157
0
  libcrux_sha3_portable_keccak_store_block_581(a, b);
3158
0
}
3159
3160
/**
3161
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block
3162
with types uint64_t
3163
with const generics
3164
- N= 1
3165
- RATE= 168
3166
*/
3167
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc1(
3168
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3169
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3170
0
  libcrux_sha3_portable_keccak_store_block_5a_591(s->st, out);
3171
0
}
3172
3173
/**
3174
 Squeeze another block
3175
*/
3176
static KRML_MUSTINLINE void
3177
libcrux_sha3_portable_incremental_shake128_squeeze_next_block(
3178
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) {
3179
0
  Eurydice_slice buf[1U] = {out0};
3180
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, buf);
3181
0
}
3182
3183
/**
3184
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block
3185
with types uint64_t
3186
with const generics
3187
- N= 1
3188
- RATE= 168
3189
*/
3190
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_841(
3191
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3192
0
  libcrux_sha3_portable_keccak_store_block_5a_591(s->st, out);
3193
0
}
3194
3195
/**
3196
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_three_blocks
3197
with types uint64_t
3198
with const generics
3199
- N= 1
3200
- RATE= 168
3201
*/
3202
static KRML_MUSTINLINE void
3203
libcrux_sha3_generic_keccak_squeeze_first_three_blocks_cc(
3204
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3205
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____0 =
3206
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U);
3207
0
  Eurydice_slice o0[1U];
3208
0
  memcpy(o0, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice));
3209
0
  Eurydice_slice o10[1U];
3210
0
  memcpy(o10, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice));
3211
0
  libcrux_sha3_generic_keccak_squeeze_first_block_841(s, o0);
3212
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____1 =
3213
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(o10, (size_t)168U);
3214
0
  Eurydice_slice o1[1U];
3215
0
  memcpy(o1, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice));
3216
0
  Eurydice_slice o2[1U];
3217
0
  memcpy(o2, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice));
3218
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o1);
3219
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o2);
3220
0
}
3221
3222
/**
3223
 Squeeze three blocks
3224
*/
3225
static KRML_MUSTINLINE void
3226
libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(
3227
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) {
3228
0
  Eurydice_slice buf[1U] = {out0};
3229
0
  libcrux_sha3_generic_keccak_squeeze_first_three_blocks_cc(s, buf);
3230
0
}
3231
3232
#define libcrux_sha3_Sha224 0
3233
#define libcrux_sha3_Sha256 1
3234
#define libcrux_sha3_Sha384 2
3235
#define libcrux_sha3_Sha512 3
3236
3237
typedef uint8_t libcrux_sha3_Algorithm;
3238
3239
/**
3240
 Returns the output size of a digest.
3241
*/
3242
0
static inline size_t libcrux_sha3_digest_size(libcrux_sha3_Algorithm mode) {
3243
0
  size_t uu____0;
3244
0
  switch (mode) {
3245
0
    case libcrux_sha3_Sha224: {
3246
0
      uu____0 = (size_t)28U;
3247
0
      break;
3248
0
    }
3249
0
    case libcrux_sha3_Sha256: {
3250
0
      uu____0 = (size_t)32U;
3251
0
      break;
3252
0
    }
3253
0
    case libcrux_sha3_Sha384: {
3254
0
      uu____0 = (size_t)48U;
3255
0
      break;
3256
0
    }
3257
0
    case libcrux_sha3_Sha512: {
3258
0
      uu____0 = (size_t)64U;
3259
0
      break;
3260
0
    }
3261
0
    default: {
3262
0
      KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__,
3263
0
                        __LINE__);
3264
0
      KRML_HOST_EXIT(253U);
3265
0
    }
3266
0
  }
3267
0
  return uu____0;
3268
0
}
3269
3270
/**
3271
A monomorphic instance of libcrux_sha3.portable_keccak.load_block
3272
with const generics
3273
- RATE= 144
3274
*/
3275
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c2(
3276
0
    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
3277
0
  for (size_t i = (size_t)0U; i < (size_t)144U / (size_t)8U; i++) {
3278
0
    size_t i0 = i;
3279
0
    uint8_t uu____0[8U];
3280
0
    Result_56 dst;
3281
0
    Eurydice_slice_to_array2(
3282
0
        &dst,
3283
0
        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
3284
0
                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
3285
0
        Eurydice_slice, uint8_t[8U]);
3286
0
    unwrap_41_ac(dst, uu____0);
3287
0
    size_t uu____1 = i0 / (size_t)5U;
3288
0
    size_t uu____2 = i0 % (size_t)5U;
3289
0
    s[uu____1][uu____2] =
3290
0
        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
3291
0
  }
3292
0
}
3293
3294
/**
3295
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3296
usize> for u64)}
3297
*/
3298
/**
3299
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a
3300
with const generics
3301
- RATE= 144
3302
*/
3303
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b81(
3304
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
3305
0
  uint64_t(*uu____0)[5U] = a;
3306
0
  /* Passing arrays by value in Rust generates a copy in C */
3307
0
  Eurydice_slice copy_of_b[1U];
3308
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice));
3309
0
  libcrux_sha3_portable_keccak_load_block_2c2(uu____0, copy_of_b);
3310
0
}
3311
3312
/**
3313
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block
3314
with types uint64_t
3315
with const generics
3316
- N= 1
3317
- RATE= 144
3318
*/
3319
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df1(
3320
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) {
3321
0
  uint64_t(*uu____0)[5U] = s->st;
3322
0
  Eurydice_slice uu____1[1U];
3323
0
  memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice));
3324
0
  libcrux_sha3_portable_keccak_load_block_5a_b81(uu____0, uu____1);
3325
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3326
0
}
3327
3328
/**
3329
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full
3330
with const generics
3331
- RATE= 144
3332
*/
3333
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df2(
3334
0
    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
3335
0
  Eurydice_slice buf[1U] = {
3336
0
      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
3337
0
  libcrux_sha3_portable_keccak_load_block_2c2(s, buf);
3338
0
}
3339
3340
/**
3341
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3342
usize> for u64)}
3343
*/
3344
/**
3345
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a
3346
with const generics
3347
- RATE= 144
3348
*/
3349
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d22(
3350
0
    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
3351
0
  uint64_t(*uu____0)[5U] = a;
3352
0
  /* Passing arrays by value in Rust generates a copy in C */
3353
0
  uint8_t copy_of_b[1U][200U];
3354
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
3355
0
  libcrux_sha3_portable_keccak_load_block_full_df2(uu____0, copy_of_b);
3356
0
}
3357
3358
/**
3359
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final
3360
with types uint64_t
3361
with const generics
3362
- N= 1
3363
- RATE= 144
3364
- DELIM= 6
3365
*/
3366
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c73(
3367
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
3368
0
  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
3369
0
  uint8_t blocks[1U][200U] = {{0U}};
3370
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3371
0
    size_t i0 = i;
3372
0
    if (last_len > (size_t)0U) {
3373
0
      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
3374
0
          blocks[i0], (size_t)0U, last_len, uint8_t);
3375
0
      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
3376
0
    }
3377
0
    blocks[i0][last_len] = 6U;
3378
0
    size_t uu____1 = i0;
3379
0
    size_t uu____2 = (size_t)144U - (size_t)1U;
3380
0
    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
3381
0
  }
3382
0
  uint64_t(*uu____3)[5U] = s->st;
3383
0
  uint8_t uu____4[1U][200U];
3384
0
  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
3385
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d22(uu____3, uu____4);
3386
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3387
0
}
3388
3389
/**
3390
A monomorphic instance of libcrux_sha3.portable_keccak.store_block
3391
with const generics
3392
- RATE= 144
3393
*/
3394
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_582(
3395
0
    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
3396
0
  for (size_t i = (size_t)0U; i < (size_t)144U / (size_t)8U; i++) {
3397
0
    size_t i0 = i;
3398
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
3399
0
        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
3400
0
    uint8_t ret[8U];
3401
0
    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
3402
0
    Eurydice_slice_copy(
3403
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
3404
0
  }
3405
0
}
3406
3407
/**
3408
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full
3409
with const generics
3410
- RATE= 144
3411
*/
3412
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d1(
3413
0
    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
3414
0
  uint8_t out[200U] = {0U};
3415
0
  Eurydice_slice buf[1U] = {
3416
0
      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
3417
0
  libcrux_sha3_portable_keccak_store_block_582(s, buf);
3418
0
  /* Passing arrays by value in Rust generates a copy in C */
3419
0
  uint8_t copy_of_out[200U];
3420
0
  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
3421
0
  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
3422
0
}
3423
3424
/**
3425
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3426
usize> for u64)}
3427
*/
3428
/**
3429
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a
3430
with const generics
3431
- RATE= 144
3432
*/
3433
static KRML_MUSTINLINE void
3434
libcrux_sha3_portable_keccak_store_block_full_5a_291(uint64_t (*a)[5U],
3435
0
                                                     uint8_t ret[1U][200U]) {
3436
0
  libcrux_sha3_portable_keccak_store_block_full_2d1(a, ret);
3437
0
}
3438
3439
/**
3440
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last
3441
with types uint64_t
3442
with const generics
3443
- N= 1
3444
- RATE= 144
3445
*/
3446
static KRML_MUSTINLINE void
3447
libcrux_sha3_generic_keccak_squeeze_first_and_last_c51(
3448
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3449
0
  uint8_t b[1U][200U];
3450
0
  libcrux_sha3_portable_keccak_store_block_full_5a_291(s->st, b);
3451
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3452
0
    size_t i0 = i;
3453
0
    Eurydice_slice uu____0 = out[i0];
3454
0
    uint8_t *uu____1 = b[i0];
3455
0
    core_ops_range_Range_b3 lit;
3456
0
    lit.start = (size_t)0U;
3457
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
3458
0
    Eurydice_slice_copy(
3459
0
        uu____0,
3460
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
3461
0
                                   core_ops_range_Range_b3),
3462
0
        uint8_t);
3463
0
  }
3464
0
}
3465
3466
/**
3467
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3468
usize> for u64)}
3469
*/
3470
/**
3471
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a
3472
with const generics
3473
- RATE= 144
3474
*/
3475
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_592(
3476
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
3477
0
  libcrux_sha3_portable_keccak_store_block_582(a, b);
3478
0
}
3479
3480
/**
3481
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block
3482
with types uint64_t
3483
with const generics
3484
- N= 1
3485
- RATE= 144
3486
*/
3487
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_842(
3488
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3489
0
  libcrux_sha3_portable_keccak_store_block_5a_592(s->st, out);
3490
0
}
3491
3492
/**
3493
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block
3494
with types uint64_t
3495
with const generics
3496
- N= 1
3497
- RATE= 144
3498
*/
3499
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc2(
3500
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3501
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3502
0
  libcrux_sha3_portable_keccak_store_block_5a_592(s->st, out);
3503
0
}
3504
3505
/**
3506
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last
3507
with types uint64_t
3508
with const generics
3509
- N= 1
3510
- RATE= 144
3511
*/
3512
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf1(
3513
0
    libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) {
3514
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&s);
3515
0
  uint8_t b[1U][200U];
3516
0
  libcrux_sha3_portable_keccak_store_block_full_5a_291(s.st, b);
3517
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3518
0
    size_t i0 = i;
3519
0
    Eurydice_slice uu____0 = out[i0];
3520
0
    uint8_t *uu____1 = b[i0];
3521
0
    core_ops_range_Range_b3 lit;
3522
0
    lit.start = (size_t)0U;
3523
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
3524
0
    Eurydice_slice_copy(
3525
0
        uu____0,
3526
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
3527
0
                                   core_ops_range_Range_b3),
3528
0
        uint8_t);
3529
0
  }
3530
0
}
3531
3532
/**
3533
A monomorphic instance of libcrux_sha3.generic_keccak.keccak
3534
with types uint64_t
3535
with const generics
3536
- N= 1
3537
- RATE= 144
3538
- DELIM= 6
3539
*/
3540
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e92(
3541
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
3542
0
  libcrux_sha3_generic_keccak_KeccakState_48 s =
3543
0
      libcrux_sha3_generic_keccak_new_1e_f4();
3544
0
  for (size_t i = (size_t)0U;
3545
0
       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)144U; i++) {
3546
0
    size_t i0 = i;
3547
0
    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
3548
0
    /* Passing arrays by value in Rust generates a copy in C */
3549
0
    Eurydice_slice copy_of_data[1U];
3550
0
    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3551
0
    Eurydice_slice ret[1U];
3552
0
    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)144U,
3553
0
                                            (size_t)144U, ret);
3554
0
    libcrux_sha3_generic_keccak_absorb_block_df1(uu____0, ret);
3555
0
  }
3556
0
  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)144U;
3557
0
  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
3558
0
  /* Passing arrays by value in Rust generates a copy in C */
3559
0
  Eurydice_slice copy_of_data[1U];
3560
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3561
0
  Eurydice_slice ret[1U];
3562
0
  libcrux_sha3_portable_keccak_slice_n_5a(
3563
0
      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
3564
0
  libcrux_sha3_generic_keccak_absorb_final_c73(uu____2, ret);
3565
0
  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
3566
0
  size_t blocks = outlen / (size_t)144U;
3567
0
  size_t last = outlen - outlen % (size_t)144U;
3568
0
  if (blocks == (size_t)0U) {
3569
0
    libcrux_sha3_generic_keccak_squeeze_first_and_last_c51(&s, out);
3570
0
  } else {
3571
0
    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
3572
0
        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)144U);
3573
0
    Eurydice_slice o0[1U];
3574
0
    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
3575
0
    Eurydice_slice o1[1U];
3576
0
    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
3577
0
    libcrux_sha3_generic_keccak_squeeze_first_block_842(&s, o0);
3578
0
    core_ops_range_Range_b3 iter =
3579
0
        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
3580
0
            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
3581
0
                                               .end = blocks}),
3582
0
            core_ops_range_Range_b3, core_ops_range_Range_b3);
3583
0
    while (true) {
3584
0
      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
3585
0
              &iter, size_t, Option_b3)
3586
0
              .tag == None) {
3587
0
        break;
3588
0
      } else {
3589
0
        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
3590
0
            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)144U);
3591
0
        Eurydice_slice o[1U];
3592
0
        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
3593
0
        Eurydice_slice orest[1U];
3594
0
        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
3595
0
        libcrux_sha3_generic_keccak_squeeze_next_block_fc2(&s, o);
3596
0
        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
3597
0
      }
3598
0
    }
3599
0
    if (last < outlen) {
3600
0
      libcrux_sha3_generic_keccak_squeeze_last_cf1(s, o1);
3601
0
    }
3602
0
  }
3603
0
}
3604
3605
/**
3606
A monomorphic instance of libcrux_sha3.portable.keccakx1
3607
with const generics
3608
- RATE= 144
3609
- DELIM= 6
3610
*/
3611
static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce2(
3612
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
3613
0
  /* Passing arrays by value in Rust generates a copy in C */
3614
0
  Eurydice_slice copy_of_data[1U];
3615
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3616
0
  libcrux_sha3_generic_keccak_keccak_e92(copy_of_data, out);
3617
0
}
3618
3619
/**
3620
 A portable SHA3 224 implementation.
3621
*/
3622
static KRML_MUSTINLINE void libcrux_sha3_portable_sha224(Eurydice_slice digest,
3623
0
                                                         Eurydice_slice data) {
3624
0
  Eurydice_slice buf0[1U] = {data};
3625
0
  Eurydice_slice buf[1U] = {digest};
3626
0
  libcrux_sha3_portable_keccakx1_ce2(buf0, buf);
3627
0
}
3628
3629
/**
3630
A monomorphic instance of libcrux_sha3.portable_keccak.load_block
3631
with const generics
3632
- RATE= 104
3633
*/
3634
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c3(
3635
0
    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
3636
0
  for (size_t i = (size_t)0U; i < (size_t)104U / (size_t)8U; i++) {
3637
0
    size_t i0 = i;
3638
0
    uint8_t uu____0[8U];
3639
0
    Result_56 dst;
3640
0
    Eurydice_slice_to_array2(
3641
0
        &dst,
3642
0
        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
3643
0
                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
3644
0
        Eurydice_slice, uint8_t[8U]);
3645
0
    unwrap_41_ac(dst, uu____0);
3646
0
    size_t uu____1 = i0 / (size_t)5U;
3647
0
    size_t uu____2 = i0 % (size_t)5U;
3648
0
    s[uu____1][uu____2] =
3649
0
        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
3650
0
  }
3651
0
}
3652
3653
/**
3654
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3655
usize> for u64)}
3656
*/
3657
/**
3658
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a
3659
with const generics
3660
- RATE= 104
3661
*/
3662
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b82(
3663
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
3664
0
  uint64_t(*uu____0)[5U] = a;
3665
0
  /* Passing arrays by value in Rust generates a copy in C */
3666
0
  Eurydice_slice copy_of_b[1U];
3667
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice));
3668
0
  libcrux_sha3_portable_keccak_load_block_2c3(uu____0, copy_of_b);
3669
0
}
3670
3671
/**
3672
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block
3673
with types uint64_t
3674
with const generics
3675
- N= 1
3676
- RATE= 104
3677
*/
3678
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df2(
3679
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) {
3680
0
  uint64_t(*uu____0)[5U] = s->st;
3681
0
  Eurydice_slice uu____1[1U];
3682
0
  memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice));
3683
0
  libcrux_sha3_portable_keccak_load_block_5a_b82(uu____0, uu____1);
3684
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3685
0
}
3686
3687
/**
3688
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full
3689
with const generics
3690
- RATE= 104
3691
*/
3692
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df3(
3693
0
    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
3694
0
  Eurydice_slice buf[1U] = {
3695
0
      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
3696
0
  libcrux_sha3_portable_keccak_load_block_2c3(s, buf);
3697
0
}
3698
3699
/**
3700
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3701
usize> for u64)}
3702
*/
3703
/**
3704
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a
3705
with const generics
3706
- RATE= 104
3707
*/
3708
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d23(
3709
0
    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
3710
0
  uint64_t(*uu____0)[5U] = a;
3711
0
  /* Passing arrays by value in Rust generates a copy in C */
3712
0
  uint8_t copy_of_b[1U][200U];
3713
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
3714
0
  libcrux_sha3_portable_keccak_load_block_full_df3(uu____0, copy_of_b);
3715
0
}
3716
3717
/**
3718
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final
3719
with types uint64_t
3720
with const generics
3721
- N= 1
3722
- RATE= 104
3723
- DELIM= 6
3724
*/
3725
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c74(
3726
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
3727
0
  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
3728
0
  uint8_t blocks[1U][200U] = {{0U}};
3729
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3730
0
    size_t i0 = i;
3731
0
    if (last_len > (size_t)0U) {
3732
0
      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
3733
0
          blocks[i0], (size_t)0U, last_len, uint8_t);
3734
0
      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
3735
0
    }
3736
0
    blocks[i0][last_len] = 6U;
3737
0
    size_t uu____1 = i0;
3738
0
    size_t uu____2 = (size_t)104U - (size_t)1U;
3739
0
    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
3740
0
  }
3741
0
  uint64_t(*uu____3)[5U] = s->st;
3742
0
  uint8_t uu____4[1U][200U];
3743
0
  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
3744
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d23(uu____3, uu____4);
3745
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3746
0
}
3747
3748
/**
3749
A monomorphic instance of libcrux_sha3.portable_keccak.store_block
3750
with const generics
3751
- RATE= 104
3752
*/
3753
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_583(
3754
0
    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
3755
0
  for (size_t i = (size_t)0U; i < (size_t)104U / (size_t)8U; i++) {
3756
0
    size_t i0 = i;
3757
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
3758
0
        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
3759
0
    uint8_t ret[8U];
3760
0
    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
3761
0
    Eurydice_slice_copy(
3762
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
3763
0
  }
3764
0
}
3765
3766
/**
3767
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full
3768
with const generics
3769
- RATE= 104
3770
*/
3771
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d2(
3772
0
    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
3773
0
  uint8_t out[200U] = {0U};
3774
0
  Eurydice_slice buf[1U] = {
3775
0
      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
3776
0
  libcrux_sha3_portable_keccak_store_block_583(s, buf);
3777
0
  /* Passing arrays by value in Rust generates a copy in C */
3778
0
  uint8_t copy_of_out[200U];
3779
0
  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
3780
0
  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
3781
0
}
3782
3783
/**
3784
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3785
usize> for u64)}
3786
*/
3787
/**
3788
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a
3789
with const generics
3790
- RATE= 104
3791
*/
3792
static KRML_MUSTINLINE void
3793
libcrux_sha3_portable_keccak_store_block_full_5a_292(uint64_t (*a)[5U],
3794
0
                                                     uint8_t ret[1U][200U]) {
3795
0
  libcrux_sha3_portable_keccak_store_block_full_2d2(a, ret);
3796
0
}
3797
3798
/**
3799
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last
3800
with types uint64_t
3801
with const generics
3802
- N= 1
3803
- RATE= 104
3804
*/
3805
static KRML_MUSTINLINE void
3806
libcrux_sha3_generic_keccak_squeeze_first_and_last_c52(
3807
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3808
0
  uint8_t b[1U][200U];
3809
0
  libcrux_sha3_portable_keccak_store_block_full_5a_292(s->st, b);
3810
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3811
0
    size_t i0 = i;
3812
0
    Eurydice_slice uu____0 = out[i0];
3813
0
    uint8_t *uu____1 = b[i0];
3814
0
    core_ops_range_Range_b3 lit;
3815
0
    lit.start = (size_t)0U;
3816
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
3817
0
    Eurydice_slice_copy(
3818
0
        uu____0,
3819
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
3820
0
                                   core_ops_range_Range_b3),
3821
0
        uint8_t);
3822
0
  }
3823
0
}
3824
3825
/**
3826
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
3827
usize> for u64)}
3828
*/
3829
/**
3830
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a
3831
with const generics
3832
- RATE= 104
3833
*/
3834
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_593(
3835
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
3836
0
  libcrux_sha3_portable_keccak_store_block_583(a, b);
3837
0
}
3838
3839
/**
3840
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block
3841
with types uint64_t
3842
with const generics
3843
- N= 1
3844
- RATE= 104
3845
*/
3846
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_843(
3847
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3848
0
  libcrux_sha3_portable_keccak_store_block_5a_593(s->st, out);
3849
0
}
3850
3851
/**
3852
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block
3853
with types uint64_t
3854
with const generics
3855
- N= 1
3856
- RATE= 104
3857
*/
3858
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc3(
3859
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
3860
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
3861
0
  libcrux_sha3_portable_keccak_store_block_5a_593(s->st, out);
3862
0
}
3863
3864
/**
3865
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last
3866
with types uint64_t
3867
with const generics
3868
- N= 1
3869
- RATE= 104
3870
*/
3871
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf2(
3872
0
    libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) {
3873
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&s);
3874
0
  uint8_t b[1U][200U];
3875
0
  libcrux_sha3_portable_keccak_store_block_full_5a_292(s.st, b);
3876
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
3877
0
    size_t i0 = i;
3878
0
    Eurydice_slice uu____0 = out[i0];
3879
0
    uint8_t *uu____1 = b[i0];
3880
0
    core_ops_range_Range_b3 lit;
3881
0
    lit.start = (size_t)0U;
3882
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
3883
0
    Eurydice_slice_copy(
3884
0
        uu____0,
3885
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
3886
0
                                   core_ops_range_Range_b3),
3887
0
        uint8_t);
3888
0
  }
3889
0
}
3890
3891
/**
3892
A monomorphic instance of libcrux_sha3.generic_keccak.keccak
3893
with types uint64_t
3894
with const generics
3895
- N= 1
3896
- RATE= 104
3897
- DELIM= 6
3898
*/
3899
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e93(
3900
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
3901
0
  libcrux_sha3_generic_keccak_KeccakState_48 s =
3902
0
      libcrux_sha3_generic_keccak_new_1e_f4();
3903
0
  for (size_t i = (size_t)0U;
3904
0
       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)104U; i++) {
3905
0
    size_t i0 = i;
3906
0
    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
3907
0
    /* Passing arrays by value in Rust generates a copy in C */
3908
0
    Eurydice_slice copy_of_data[1U];
3909
0
    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3910
0
    Eurydice_slice ret[1U];
3911
0
    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)104U,
3912
0
                                            (size_t)104U, ret);
3913
0
    libcrux_sha3_generic_keccak_absorb_block_df2(uu____0, ret);
3914
0
  }
3915
0
  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)104U;
3916
0
  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
3917
0
  /* Passing arrays by value in Rust generates a copy in C */
3918
0
  Eurydice_slice copy_of_data[1U];
3919
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3920
0
  Eurydice_slice ret[1U];
3921
0
  libcrux_sha3_portable_keccak_slice_n_5a(
3922
0
      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
3923
0
  libcrux_sha3_generic_keccak_absorb_final_c74(uu____2, ret);
3924
0
  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
3925
0
  size_t blocks = outlen / (size_t)104U;
3926
0
  size_t last = outlen - outlen % (size_t)104U;
3927
0
  if (blocks == (size_t)0U) {
3928
0
    libcrux_sha3_generic_keccak_squeeze_first_and_last_c52(&s, out);
3929
0
  } else {
3930
0
    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
3931
0
        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)104U);
3932
0
    Eurydice_slice o0[1U];
3933
0
    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
3934
0
    Eurydice_slice o1[1U];
3935
0
    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
3936
0
    libcrux_sha3_generic_keccak_squeeze_first_block_843(&s, o0);
3937
0
    core_ops_range_Range_b3 iter =
3938
0
        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
3939
0
            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
3940
0
                                               .end = blocks}),
3941
0
            core_ops_range_Range_b3, core_ops_range_Range_b3);
3942
0
    while (true) {
3943
0
      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
3944
0
              &iter, size_t, Option_b3)
3945
0
              .tag == None) {
3946
0
        break;
3947
0
      } else {
3948
0
        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
3949
0
            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)104U);
3950
0
        Eurydice_slice o[1U];
3951
0
        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
3952
0
        Eurydice_slice orest[1U];
3953
0
        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
3954
0
        libcrux_sha3_generic_keccak_squeeze_next_block_fc3(&s, o);
3955
0
        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
3956
0
      }
3957
0
    }
3958
0
    if (last < outlen) {
3959
0
      libcrux_sha3_generic_keccak_squeeze_last_cf2(s, o1);
3960
0
    }
3961
0
  }
3962
0
}
3963
3964
/**
3965
A monomorphic instance of libcrux_sha3.portable.keccakx1
3966
with const generics
3967
- RATE= 104
3968
- DELIM= 6
3969
*/
3970
static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce3(
3971
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
3972
0
  /* Passing arrays by value in Rust generates a copy in C */
3973
0
  Eurydice_slice copy_of_data[1U];
3974
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
3975
0
  libcrux_sha3_generic_keccak_keccak_e93(copy_of_data, out);
3976
0
}
3977
3978
/**
3979
 A portable SHA3 384 implementation.
3980
*/
3981
static KRML_MUSTINLINE void libcrux_sha3_portable_sha384(Eurydice_slice digest,
3982
0
                                                         Eurydice_slice data) {
3983
0
  Eurydice_slice buf0[1U] = {data};
3984
0
  Eurydice_slice buf[1U] = {digest};
3985
0
  libcrux_sha3_portable_keccakx1_ce3(buf0, buf);
3986
0
}
3987
3988
/**
3989
 SHA3 224
3990
3991
 Preconditions:
3992
 - `digest.len() == 28`
3993
*/
3994
static KRML_MUSTINLINE void libcrux_sha3_sha224_ema(Eurydice_slice digest,
3995
0
                                                    Eurydice_slice payload) {
3996
0
  libcrux_sha3_portable_sha224(digest, payload);
3997
0
}
3998
3999
/**
4000
 SHA3 224
4001
*/
4002
static KRML_MUSTINLINE void libcrux_sha3_sha224(Eurydice_slice data,
4003
0
                                                uint8_t ret[28U]) {
4004
0
  uint8_t out[28U] = {0U};
4005
0
  libcrux_sha3_sha224_ema(Eurydice_array_to_slice((size_t)28U, out, uint8_t),
4006
0
                          data);
4007
0
  memcpy(ret, out, (size_t)28U * sizeof(uint8_t));
4008
0
}
4009
4010
/**
4011
 SHA3 256
4012
*/
4013
static KRML_MUSTINLINE void libcrux_sha3_sha256_ema(Eurydice_slice digest,
4014
0
                                                    Eurydice_slice payload) {
4015
0
  libcrux_sha3_portable_sha256(digest, payload);
4016
0
}
4017
4018
/**
4019
 SHA3 256
4020
*/
4021
static KRML_MUSTINLINE void libcrux_sha3_sha256(Eurydice_slice data,
4022
0
                                                uint8_t ret[32U]) {
4023
0
  uint8_t out[32U] = {0U};
4024
0
  libcrux_sha3_sha256_ema(Eurydice_array_to_slice((size_t)32U, out, uint8_t),
4025
0
                          data);
4026
0
  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
4027
0
}
4028
4029
/**
4030
 SHA3 384
4031
*/
4032
static KRML_MUSTINLINE void libcrux_sha3_sha384_ema(Eurydice_slice digest,
4033
0
                                                    Eurydice_slice payload) {
4034
0
  libcrux_sha3_portable_sha384(digest, payload);
4035
0
}
4036
4037
/**
4038
 SHA3 384
4039
*/
4040
static KRML_MUSTINLINE void libcrux_sha3_sha384(Eurydice_slice data,
4041
0
                                                uint8_t ret[48U]) {
4042
0
  uint8_t out[48U] = {0U};
4043
0
  libcrux_sha3_sha384_ema(Eurydice_array_to_slice((size_t)48U, out, uint8_t),
4044
0
                          data);
4045
0
  memcpy(ret, out, (size_t)48U * sizeof(uint8_t));
4046
0
}
4047
4048
/**
4049
 SHA3 512
4050
*/
4051
static KRML_MUSTINLINE void libcrux_sha3_sha512_ema(Eurydice_slice digest,
4052
0
                                                    Eurydice_slice payload) {
4053
0
  libcrux_sha3_portable_sha512(digest, payload);
4054
0
}
4055
4056
/**
4057
 SHA3 512
4058
*/
4059
static KRML_MUSTINLINE void libcrux_sha3_sha512(Eurydice_slice data,
4060
0
                                                uint8_t ret[64U]) {
4061
0
  uint8_t out[64U] = {0U};
4062
0
  libcrux_sha3_sha512_ema(Eurydice_array_to_slice((size_t)64U, out, uint8_t),
4063
0
                          data);
4064
0
  memcpy(ret, out, (size_t)64U * sizeof(uint8_t));
4065
0
}
4066
4067
/**
4068
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
4069
usize> for u64)}
4070
*/
4071
/**
4072
A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a
4073
with const generics
4074
- RATE= 168
4075
*/
4076
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b83(
4077
0
    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
4078
0
  uint64_t(*uu____0)[5U] = a;
4079
0
  /* Passing arrays by value in Rust generates a copy in C */
4080
0
  Eurydice_slice copy_of_b[1U];
4081
0
  memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice));
4082
0
  libcrux_sha3_portable_keccak_load_block_2c1(uu____0, copy_of_b);
4083
0
}
4084
4085
/**
4086
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block
4087
with types uint64_t
4088
with const generics
4089
- N= 1
4090
- RATE= 168
4091
*/
4092
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df3(
4093
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) {
4094
0
  uint64_t(*uu____0)[5U] = s->st;
4095
0
  Eurydice_slice uu____1[1U];
4096
0
  memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice));
4097
0
  libcrux_sha3_portable_keccak_load_block_5a_b83(uu____0, uu____1);
4098
0
  libcrux_sha3_generic_keccak_keccakf1600_21(s);
4099
0
}
4100
4101
/**
4102
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full
4103
with const generics
4104
- RATE= 168
4105
*/
4106
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d3(
4107
0
    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
4108
0
  uint8_t out[200U] = {0U};
4109
0
  Eurydice_slice buf[1U] = {
4110
0
      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
4111
0
  libcrux_sha3_portable_keccak_store_block_581(s, buf);
4112
0
  /* Passing arrays by value in Rust generates a copy in C */
4113
0
  uint8_t copy_of_out[200U];
4114
0
  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
4115
0
  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
4116
0
}
4117
4118
/**
4119
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
4120
usize> for u64)}
4121
*/
4122
/**
4123
A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a
4124
with const generics
4125
- RATE= 168
4126
*/
4127
static KRML_MUSTINLINE void
4128
libcrux_sha3_portable_keccak_store_block_full_5a_293(uint64_t (*a)[5U],
4129
0
                                                     uint8_t ret[1U][200U]) {
4130
0
  libcrux_sha3_portable_keccak_store_block_full_2d3(a, ret);
4131
0
}
4132
4133
/**
4134
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last
4135
with types uint64_t
4136
with const generics
4137
- N= 1
4138
- RATE= 168
4139
*/
4140
static KRML_MUSTINLINE void
4141
libcrux_sha3_generic_keccak_squeeze_first_and_last_c53(
4142
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
4143
0
  uint8_t b[1U][200U];
4144
0
  libcrux_sha3_portable_keccak_store_block_full_5a_293(s->st, b);
4145
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4146
0
    size_t i0 = i;
4147
0
    Eurydice_slice uu____0 = out[i0];
4148
0
    uint8_t *uu____1 = b[i0];
4149
0
    core_ops_range_Range_b3 lit;
4150
0
    lit.start = (size_t)0U;
4151
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
4152
0
    Eurydice_slice_copy(
4153
0
        uu____0,
4154
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
4155
0
                                   core_ops_range_Range_b3),
4156
0
        uint8_t);
4157
0
  }
4158
0
}
4159
4160
/**
4161
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last
4162
with types uint64_t
4163
with const generics
4164
- N= 1
4165
- RATE= 168
4166
*/
4167
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf3(
4168
0
    libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) {
4169
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&s);
4170
0
  uint8_t b[1U][200U];
4171
0
  libcrux_sha3_portable_keccak_store_block_full_5a_293(s.st, b);
4172
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4173
0
    size_t i0 = i;
4174
0
    Eurydice_slice uu____0 = out[i0];
4175
0
    uint8_t *uu____1 = b[i0];
4176
0
    core_ops_range_Range_b3 lit;
4177
0
    lit.start = (size_t)0U;
4178
0
    lit.end = Eurydice_slice_len(out[i0], uint8_t);
4179
0
    Eurydice_slice_copy(
4180
0
        uu____0,
4181
0
        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
4182
0
                                   core_ops_range_Range_b3),
4183
0
        uint8_t);
4184
0
  }
4185
0
}
4186
4187
/**
4188
A monomorphic instance of libcrux_sha3.generic_keccak.keccak
4189
with types uint64_t
4190
with const generics
4191
- N= 1
4192
- RATE= 168
4193
- DELIM= 31
4194
*/
4195
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e94(
4196
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
4197
0
  libcrux_sha3_generic_keccak_KeccakState_48 s =
4198
0
      libcrux_sha3_generic_keccak_new_1e_f4();
4199
0
  for (size_t i = (size_t)0U;
4200
0
       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)168U; i++) {
4201
0
    size_t i0 = i;
4202
0
    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
4203
0
    /* Passing arrays by value in Rust generates a copy in C */
4204
0
    Eurydice_slice copy_of_data[1U];
4205
0
    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
4206
0
    Eurydice_slice ret[1U];
4207
0
    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)168U,
4208
0
                                            (size_t)168U, ret);
4209
0
    libcrux_sha3_generic_keccak_absorb_block_df3(uu____0, ret);
4210
0
  }
4211
0
  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)168U;
4212
0
  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
4213
0
  /* Passing arrays by value in Rust generates a copy in C */
4214
0
  Eurydice_slice copy_of_data[1U];
4215
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
4216
0
  Eurydice_slice ret[1U];
4217
0
  libcrux_sha3_portable_keccak_slice_n_5a(
4218
0
      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
4219
0
  libcrux_sha3_generic_keccak_absorb_final_c72(uu____2, ret);
4220
0
  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
4221
0
  size_t blocks = outlen / (size_t)168U;
4222
0
  size_t last = outlen - outlen % (size_t)168U;
4223
0
  if (blocks == (size_t)0U) {
4224
0
    libcrux_sha3_generic_keccak_squeeze_first_and_last_c53(&s, out);
4225
0
  } else {
4226
0
    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
4227
0
        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U);
4228
0
    Eurydice_slice o0[1U];
4229
0
    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
4230
0
    Eurydice_slice o1[1U];
4231
0
    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
4232
0
    libcrux_sha3_generic_keccak_squeeze_first_block_841(&s, o0);
4233
0
    core_ops_range_Range_b3 iter =
4234
0
        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
4235
0
            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
4236
0
                                               .end = blocks}),
4237
0
            core_ops_range_Range_b3, core_ops_range_Range_b3);
4238
0
    while (true) {
4239
0
      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
4240
0
              &iter, size_t, Option_b3)
4241
0
              .tag == None) {
4242
0
        break;
4243
0
      } else {
4244
0
        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
4245
0
            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)168U);
4246
0
        Eurydice_slice o[1U];
4247
0
        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
4248
0
        Eurydice_slice orest[1U];
4249
0
        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
4250
0
        libcrux_sha3_generic_keccak_squeeze_next_block_fc1(&s, o);
4251
0
        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
4252
0
      }
4253
0
    }
4254
0
    if (last < outlen) {
4255
0
      libcrux_sha3_generic_keccak_squeeze_last_cf3(s, o1);
4256
0
    }
4257
0
  }
4258
0
}
4259
4260
/**
4261
A monomorphic instance of libcrux_sha3.portable.keccakx1
4262
with const generics
4263
- RATE= 168
4264
- DELIM= 31
4265
*/
4266
static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce4(
4267
0
    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
4268
0
  /* Passing arrays by value in Rust generates a copy in C */
4269
0
  Eurydice_slice copy_of_data[1U];
4270
0
  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
4271
0
  libcrux_sha3_generic_keccak_keccak_e94(copy_of_data, out);
4272
0
}
4273
4274
/**
4275
 A portable SHAKE128 implementation.
4276
*/
4277
static KRML_MUSTINLINE void libcrux_sha3_portable_shake128(
4278
0
    Eurydice_slice digest, Eurydice_slice data) {
4279
0
  Eurydice_slice buf0[1U] = {data};
4280
0
  Eurydice_slice buf[1U] = {digest};
4281
0
  libcrux_sha3_portable_keccakx1_ce4(buf0, buf);
4282
0
}
4283
4284
/**
4285
 SHAKE 128
4286
4287
 Writes `out.len()` bytes.
4288
*/
4289
static KRML_MUSTINLINE void libcrux_sha3_shake128_ema(Eurydice_slice out,
4290
0
                                                      Eurydice_slice data) {
4291
0
  libcrux_sha3_portable_shake128(out, data);
4292
0
}
4293
4294
/**
4295
 SHAKE 256
4296
4297
 Writes `out.len()` bytes.
4298
*/
4299
static KRML_MUSTINLINE void libcrux_sha3_shake256_ema(Eurydice_slice out,
4300
0
                                                      Eurydice_slice data) {
4301
0
  libcrux_sha3_portable_shake256(out, data);
4302
0
}
4303
4304
static const size_t libcrux_sha3_generic_keccak__PI[24U] = {
4305
    (size_t)6U, (size_t)12U, (size_t)18U, (size_t)24U, (size_t)3U,
4306
    (size_t)9U, (size_t)10U, (size_t)16U, (size_t)22U, (size_t)1U,
4307
    (size_t)7U, (size_t)13U, (size_t)19U, (size_t)20U, (size_t)4U,
4308
    (size_t)5U, (size_t)11U, (size_t)17U, (size_t)23U, (size_t)2U,
4309
    (size_t)8U, (size_t)14U, (size_t)15U, (size_t)21U};
4310
4311
static const size_t libcrux_sha3_generic_keccak__ROTC[24U] = {
4312
    (size_t)1U,  (size_t)62U, (size_t)28U, (size_t)27U, (size_t)36U,
4313
    (size_t)44U, (size_t)6U,  (size_t)55U, (size_t)20U, (size_t)3U,
4314
    (size_t)10U, (size_t)43U, (size_t)25U, (size_t)39U, (size_t)41U,
4315
    (size_t)45U, (size_t)15U, (size_t)21U, (size_t)8U,  (size_t)18U,
4316
    (size_t)2U,  (size_t)61U, (size_t)56U, (size_t)14U};
4317
4318
/**
4319
 A portable SHA3 224 implementation.
4320
*/
4321
static KRML_MUSTINLINE void libcrux_sha3_neon_sha224(Eurydice_slice digest,
4322
0
                                                     Eurydice_slice data) {
4323
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4324
0
                    "panic!");
4325
0
  KRML_HOST_EXIT(255U);
4326
0
}
4327
4328
/**
4329
 A portable SHA3 256 implementation.
4330
*/
4331
static KRML_MUSTINLINE void libcrux_sha3_neon_sha256(Eurydice_slice digest,
4332
0
                                                     Eurydice_slice data) {
4333
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4334
0
                    "panic!");
4335
0
  KRML_HOST_EXIT(255U);
4336
0
}
4337
4338
/**
4339
 A portable SHA3 384 implementation.
4340
*/
4341
static KRML_MUSTINLINE void libcrux_sha3_neon_sha384(Eurydice_slice digest,
4342
0
                                                     Eurydice_slice data) {
4343
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4344
0
                    "panic!");
4345
0
  KRML_HOST_EXIT(255U);
4346
0
}
4347
4348
/**
4349
 A portable SHA3 512 implementation.
4350
*/
4351
static KRML_MUSTINLINE void libcrux_sha3_neon_sha512(Eurydice_slice digest,
4352
0
                                                     Eurydice_slice data) {
4353
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4354
0
                    "panic!");
4355
0
  KRML_HOST_EXIT(255U);
4356
0
}
4357
4358
/**
4359
 Run SHAKE256 on both inputs in parallel.
4360
4361
 Writes the two results into `out0` and `out1`
4362
*/
4363
static KRML_MUSTINLINE void libcrux_sha3_neon_x2_shake256(Eurydice_slice input0,
4364
                                                          Eurydice_slice input1,
4365
                                                          Eurydice_slice out0,
4366
0
                                                          Eurydice_slice out1) {
4367
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4368
0
                    "panic!");
4369
0
  KRML_HOST_EXIT(255U);
4370
0
}
4371
4372
typedef struct libcrux_sha3_neon_x2_incremental_KeccakState_s {
4373
  libcrux_sha3_generic_keccak_KeccakState_48 state[2U];
4374
} libcrux_sha3_neon_x2_incremental_KeccakState;
4375
4376
/**
4377
 Initialise the `KeccakState2`.
4378
*/
4379
static KRML_MUSTINLINE libcrux_sha3_neon_x2_incremental_KeccakState
4380
0
libcrux_sha3_neon_x2_incremental_shake128_init(void) {
4381
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4382
0
                    "panic!");
4383
0
  KRML_HOST_EXIT(255U);
4384
0
}
4385
4386
/**
4387
 Shake128 absorb `data0` and `data1` in the [`KeccakState`] `s`.
4388
*/
4389
static KRML_MUSTINLINE void
4390
libcrux_sha3_neon_x2_incremental_shake128_absorb_final(
4391
    libcrux_sha3_neon_x2_incremental_KeccakState *s, Eurydice_slice data0,
4392
0
    Eurydice_slice data1) {
4393
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4394
0
                    "panic!");
4395
0
  KRML_HOST_EXIT(255U);
4396
0
}
4397
4398
/**
4399
 Squeeze 2 times the first three blocks in parallel in the
4400
 [`KeccakState`] and return the output in `out0` and `out1`.
4401
*/
4402
static KRML_MUSTINLINE void
4403
libcrux_sha3_neon_x2_incremental_shake128_squeeze_first_three_blocks(
4404
    libcrux_sha3_neon_x2_incremental_KeccakState *s, Eurydice_slice out0,
4405
0
    Eurydice_slice out1) {
4406
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4407
0
                    "panic!");
4408
0
  KRML_HOST_EXIT(255U);
4409
0
}
4410
4411
/**
4412
 Squeeze 2 times the next block in parallel in the
4413
 [`KeccakState`] and return the output in `out0` and `out1`.
4414
*/
4415
static KRML_MUSTINLINE void
4416
libcrux_sha3_neon_x2_incremental_shake128_squeeze_next_block(
4417
    libcrux_sha3_neon_x2_incremental_KeccakState *s, Eurydice_slice out0,
4418
0
    Eurydice_slice out1) {
4419
0
  KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
4420
0
                    "panic!");
4421
0
  KRML_HOST_EXIT(255U);
4422
0
}
4423
4424
/**
4425
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_five_blocks
4426
with types uint64_t
4427
with const generics
4428
- N= 1
4429
- RATE= 168
4430
*/
4431
static KRML_MUSTINLINE void
4432
libcrux_sha3_generic_keccak_squeeze_first_five_blocks_4f(
4433
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
4434
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____0 =
4435
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U);
4436
0
  Eurydice_slice o0[1U];
4437
0
  memcpy(o0, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice));
4438
0
  Eurydice_slice o10[1U];
4439
0
  memcpy(o10, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice));
4440
0
  libcrux_sha3_generic_keccak_squeeze_first_block_841(s, o0);
4441
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____1 =
4442
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(o10, (size_t)168U);
4443
0
  Eurydice_slice o1[1U];
4444
0
  memcpy(o1, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice));
4445
0
  Eurydice_slice o20[1U];
4446
0
  memcpy(o20, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice));
4447
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o1);
4448
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____2 =
4449
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(o20, (size_t)168U);
4450
0
  Eurydice_slice o2[1U];
4451
0
  memcpy(o2, uu____2.fst, (size_t)1U * sizeof(Eurydice_slice));
4452
0
  Eurydice_slice o30[1U];
4453
0
  memcpy(o30, uu____2.snd, (size_t)1U * sizeof(Eurydice_slice));
4454
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o2);
4455
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____3 =
4456
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(o30, (size_t)168U);
4457
0
  Eurydice_slice o3[1U];
4458
0
  memcpy(o3, uu____3.fst, (size_t)1U * sizeof(Eurydice_slice));
4459
0
  Eurydice_slice o4[1U];
4460
0
  memcpy(o4, uu____3.snd, (size_t)1U * sizeof(Eurydice_slice));
4461
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o3);
4462
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o4);
4463
0
}
4464
4465
/**
4466
 Squeeze five blocks
4467
*/
4468
static KRML_MUSTINLINE void
4469
libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks(
4470
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) {
4471
0
  Eurydice_slice buf[1U] = {out0};
4472
0
  libcrux_sha3_generic_keccak_squeeze_first_five_blocks_4f(s, buf);
4473
0
}
4474
4475
/**
4476
 Absorb some data for SHAKE-256 for the last time
4477
*/
4478
static KRML_MUSTINLINE void
4479
libcrux_sha3_portable_incremental_shake256_absorb_final(
4480
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice data) {
4481
0
  Eurydice_slice buf[1U] = {data};
4482
0
  libcrux_sha3_generic_keccak_absorb_final_c71(s, buf);
4483
0
}
4484
4485
/**
4486
 Create a new SHAKE-256 state object.
4487
*/
4488
static KRML_MUSTINLINE libcrux_sha3_generic_keccak_KeccakState_48
4489
0
libcrux_sha3_portable_incremental_shake256_init(void) {
4490
0
  return libcrux_sha3_generic_keccak_new_1e_f4();
4491
0
}
4492
4493
/**
4494
 Squeeze the first SHAKE-256 block
4495
*/
4496
static KRML_MUSTINLINE void
4497
libcrux_sha3_portable_incremental_shake256_squeeze_first_block(
4498
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out) {
4499
0
  Eurydice_slice buf[1U] = {out};
4500
0
  libcrux_sha3_generic_keccak_squeeze_first_block_840(s, buf);
4501
0
}
4502
4503
/**
4504
 Squeeze the next SHAKE-256 block
4505
*/
4506
static KRML_MUSTINLINE void
4507
libcrux_sha3_portable_incremental_shake256_squeeze_next_block(
4508
0
    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out) {
4509
0
  Eurydice_slice buf[1U] = {out};
4510
0
  libcrux_sha3_generic_keccak_squeeze_next_block_fc0(s, buf);
4511
0
}
4512
4513
/**
4514
A monomorphic instance of libcrux_sha3.generic_keccak.KeccakXofState
4515
with types uint64_t
4516
with const generics
4517
- $1size_t
4518
- $136size_t
4519
*/
4520
typedef struct libcrux_sha3_generic_keccak_KeccakXofState_4f_s {
4521
  libcrux_sha3_generic_keccak_KeccakState_48 inner;
4522
  uint8_t buf[1U][136U];
4523
  size_t buf_len;
4524
  bool sponge;
4525
} libcrux_sha3_generic_keccak_KeccakXofState_4f;
4526
4527
typedef libcrux_sha3_generic_keccak_KeccakXofState_4f
4528
    libcrux_sha3_portable_incremental_Shake256Absorb;
4529
4530
/**
4531
 Consume the internal buffer and the required amount of the input to pad to
4532
 `RATE`.
4533
4534
 Returns the `consumed` bytes from `inputs` if there's enough buffered
4535
 content to consume, and `0` otherwise.
4536
 If `consumed > 0` is returned, `self.buf` contains a full block to be
4537
 loaded.
4538
*/
4539
/**
4540
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4541
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4542
*/
4543
/**
4544
A monomorphic instance of libcrux_sha3.generic_keccak.fill_buffer_9d
4545
with types uint64_t
4546
with const generics
4547
- PARALLEL_LANES= 1
4548
- RATE= 136
4549
*/
4550
static inline size_t libcrux_sha3_generic_keccak_fill_buffer_9d_b0(
4551
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self,
4552
0
    Eurydice_slice inputs[1U]) {
4553
0
  size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t);
4554
0
  size_t consumed = (size_t)0U;
4555
0
  if (self->buf_len > (size_t)0U) {
4556
0
    if (self->buf_len + input_len >= (size_t)136U) {
4557
0
      consumed = (size_t)136U - self->buf_len;
4558
0
      for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4559
0
        size_t i0 = i;
4560
0
        Eurydice_slice uu____0 = Eurydice_array_to_subslice_from(
4561
0
            (size_t)136U, self->buf[i0], self->buf_len, uint8_t, size_t);
4562
0
        Eurydice_slice_copy(
4563
0
            uu____0,
4564
0
            Eurydice_slice_subslice_to(inputs[i0], consumed, uint8_t, size_t),
4565
0
            uint8_t);
4566
0
      }
4567
0
      self->buf_len = self->buf_len + consumed;
4568
0
    }
4569
0
  }
4570
0
  return consumed;
4571
0
}
4572
4573
/**
4574
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4575
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4576
*/
4577
/**
4578
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_full_9d
4579
with types uint64_t
4580
with const generics
4581
- PARALLEL_LANES= 1
4582
- RATE= 136
4583
*/
4584
static inline size_t libcrux_sha3_generic_keccak_absorb_full_9d_f8(
4585
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self,
4586
0
    Eurydice_slice inputs[1U]) {
4587
0
  libcrux_sha3_generic_keccak_KeccakXofState_4f *uu____0 = self;
4588
0
  /* Passing arrays by value in Rust generates a copy in C */
4589
0
  Eurydice_slice copy_of_inputs0[1U];
4590
0
  memcpy(copy_of_inputs0, inputs, (size_t)1U * sizeof(Eurydice_slice));
4591
0
  size_t input_consumed =
4592
0
      libcrux_sha3_generic_keccak_fill_buffer_9d_b0(uu____0, copy_of_inputs0);
4593
0
  if (input_consumed > (size_t)0U) {
4594
0
    Eurydice_slice borrowed[1U];
4595
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4596
0
      uint8_t buf[136U] = {0U};
4597
0
      borrowed[i] = core_array___Array_T__N__23__as_slice(
4598
0
          (size_t)136U, buf, uint8_t, Eurydice_slice);
4599
0
    }
4600
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4601
0
      size_t i0 = i;
4602
0
      borrowed[i0] =
4603
0
          Eurydice_array_to_slice((size_t)136U, self->buf[i0], uint8_t);
4604
0
    }
4605
0
    uint64_t(*uu____2)[5U] = self->inner.st;
4606
0
    Eurydice_slice uu____3[1U];
4607
0
    memcpy(uu____3, borrowed, (size_t)1U * sizeof(Eurydice_slice));
4608
0
    libcrux_sha3_portable_keccak_load_block_5a_b80(uu____2, uu____3);
4609
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
4610
0
    self->buf_len = (size_t)0U;
4611
0
  }
4612
0
  size_t input_to_consume =
4613
0
      Eurydice_slice_len(inputs[0U], uint8_t) - input_consumed;
4614
0
  size_t num_blocks = input_to_consume / (size_t)136U;
4615
0
  size_t remainder = input_to_consume % (size_t)136U;
4616
0
  for (size_t i = (size_t)0U; i < num_blocks; i++) {
4617
0
    size_t i0 = i;
4618
0
    uint64_t(*uu____4)[5U] = self->inner.st;
4619
0
    /* Passing arrays by value in Rust generates a copy in C */
4620
0
    Eurydice_slice copy_of_inputs[1U];
4621
0
    memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice));
4622
0
    Eurydice_slice ret[1U];
4623
0
    libcrux_sha3_portable_keccak_slice_n_5a(
4624
0
        copy_of_inputs, input_consumed + i0 * (size_t)136U, (size_t)136U, ret);
4625
0
    libcrux_sha3_portable_keccak_load_block_5a_b80(uu____4, ret);
4626
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
4627
0
  }
4628
0
  return remainder;
4629
0
}
4630
4631
/**
4632
 Absorb
4633
4634
 This function takes any number of bytes to absorb and buffers if it's not
4635
 enough. The function assumes that all input slices in `blocks` have the same
4636
 length.
4637
4638
 Only a multiple of `RATE` blocks are absorbed.
4639
 For the remaining bytes [`absorb_final`] needs to be called.
4640
4641
 This works best with relatively small `inputs`.
4642
*/
4643
/**
4644
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4645
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4646
*/
4647
/**
4648
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_9d
4649
with types uint64_t
4650
with const generics
4651
- PARALLEL_LANES= 1
4652
- RATE= 136
4653
*/
4654
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_9d_7b(
4655
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self,
4656
0
    Eurydice_slice inputs[1U]) {
4657
0
  libcrux_sha3_generic_keccak_KeccakXofState_4f *uu____0 = self;
4658
0
  /* Passing arrays by value in Rust generates a copy in C */
4659
0
  Eurydice_slice copy_of_inputs[1U];
4660
0
  memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice));
4661
0
  size_t input_remainder_len =
4662
0
      libcrux_sha3_generic_keccak_absorb_full_9d_f8(uu____0, copy_of_inputs);
4663
0
  if (input_remainder_len > (size_t)0U) {
4664
0
    size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t);
4665
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4666
0
      size_t i0 = i;
4667
0
      Eurydice_slice uu____2 = Eurydice_array_to_subslice2(
4668
0
          self->buf[i0], self->buf_len, self->buf_len + input_remainder_len,
4669
0
          uint8_t);
4670
0
      Eurydice_slice_copy(
4671
0
          uu____2,
4672
0
          Eurydice_slice_subslice_from(
4673
0
              inputs[i0], input_len - input_remainder_len, uint8_t, size_t),
4674
0
          uint8_t);
4675
0
    }
4676
0
    self->buf_len = self->buf_len + input_remainder_len;
4677
0
  }
4678
0
}
4679
4680
/**
4681
 Shake256 absorb
4682
*/
4683
/**
4684
This function found in impl
4685
{(libcrux_sha3::portable::incremental::XofAbsorb<136: usize> for
4686
libcrux_sha3::portable::incremental::Shake256Absorb)#2}
4687
*/
4688
static inline void libcrux_sha3_portable_incremental_absorb_7d(
4689
0
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self, Eurydice_slice input) {
4690
0
  Eurydice_slice buf[1U] = {input};
4691
0
  libcrux_sha3_generic_keccak_absorb_9d_7b(self, buf);
4692
0
}
4693
4694
typedef libcrux_sha3_generic_keccak_KeccakXofState_4f
4695
    libcrux_sha3_portable_incremental_Shake256Squeeze;
4696
4697
/**
4698
 Absorb a final block.
4699
4700
 The `inputs` block may be empty. Everything in the `inputs` block beyond
4701
 `RATE` bytes is ignored.
4702
*/
4703
/**
4704
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4705
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4706
*/
4707
/**
4708
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_9d
4709
with types uint64_t
4710
with const generics
4711
- PARALLEL_LANES= 1
4712
- RATE= 136
4713
- DELIMITER= 31
4714
*/
4715
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_9d_25(
4716
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self,
4717
0
    Eurydice_slice inputs[1U]) {
4718
0
  libcrux_sha3_generic_keccak_KeccakXofState_4f *uu____0 = self;
4719
0
  /* Passing arrays by value in Rust generates a copy in C */
4720
0
  Eurydice_slice copy_of_inputs[1U];
4721
0
  memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice));
4722
0
  size_t input_remainder_len =
4723
0
      libcrux_sha3_generic_keccak_absorb_full_9d_f8(uu____0, copy_of_inputs);
4724
0
  size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t);
4725
0
  uint8_t blocks[1U][200U] = {{0U}};
4726
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
4727
0
    size_t i0 = i;
4728
0
    if (self->buf_len > (size_t)0U) {
4729
0
      Eurydice_slice uu____2 = Eurydice_array_to_subslice2(
4730
0
          blocks[i0], (size_t)0U, self->buf_len, uint8_t);
4731
0
      Eurydice_slice_copy(uu____2,
4732
0
                          Eurydice_array_to_subslice2(self->buf[i0], (size_t)0U,
4733
0
                                                      self->buf_len, uint8_t),
4734
0
                          uint8_t);
4735
0
    }
4736
0
    if (input_remainder_len > (size_t)0U) {
4737
0
      Eurydice_slice uu____3 = Eurydice_array_to_subslice2(
4738
0
          blocks[i0], self->buf_len, self->buf_len + input_remainder_len,
4739
0
          uint8_t);
4740
0
      Eurydice_slice_copy(
4741
0
          uu____3,
4742
0
          Eurydice_slice_subslice_from(
4743
0
              inputs[i0], input_len - input_remainder_len, uint8_t, size_t),
4744
0
          uint8_t);
4745
0
    }
4746
0
    blocks[i0][self->buf_len + input_remainder_len] = 31U;
4747
0
    size_t uu____4 = i0;
4748
0
    size_t uu____5 = (size_t)136U - (size_t)1U;
4749
0
    blocks[uu____4][uu____5] = (uint32_t)blocks[uu____4][uu____5] | 128U;
4750
0
  }
4751
0
  uint64_t(*uu____6)[5U] = self->inner.st;
4752
0
  uint8_t uu____7[1U][200U];
4753
0
  memcpy(uu____7, blocks, (size_t)1U * sizeof(uint8_t[200U]));
4754
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____6, uu____7);
4755
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
4756
0
}
4757
4758
/**
4759
 Shake256 absorb final
4760
*/
4761
/**
4762
This function found in impl
4763
{(libcrux_sha3::portable::incremental::XofAbsorb<136: usize> for
4764
libcrux_sha3::portable::incremental::Shake256Absorb)#2}
4765
*/
4766
static inline libcrux_sha3_generic_keccak_KeccakXofState_4f
4767
libcrux_sha3_portable_incremental_absorb_final_7d(
4768
0
    libcrux_sha3_generic_keccak_KeccakXofState_4f self, Eurydice_slice input) {
4769
0
  Eurydice_slice buf[1U] = {input};
4770
0
  libcrux_sha3_generic_keccak_absorb_final_9d_25(&self, buf);
4771
0
  return self;
4772
0
}
4773
4774
/**
4775
 An all zero block
4776
*/
4777
/**
4778
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4779
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4780
*/
4781
/**
4782
A monomorphic instance of libcrux_sha3.generic_keccak.zero_block_9d
4783
with types uint64_t
4784
with const generics
4785
- PARALLEL_LANES= 1
4786
- RATE= 136
4787
*/
4788
static inline void libcrux_sha3_generic_keccak_zero_block_9d_e6(
4789
0
    uint8_t ret[136U]) {
4790
0
  ret[0U] = 0U;
4791
0
  ret[1U] = 0U;
4792
0
  ret[2U] = 0U;
4793
0
  ret[3U] = 0U;
4794
0
  ret[4U] = 0U;
4795
0
  ret[5U] = 0U;
4796
0
  ret[6U] = 0U;
4797
0
  ret[7U] = 0U;
4798
0
  ret[8U] = 0U;
4799
0
  ret[9U] = 0U;
4800
0
  ret[10U] = 0U;
4801
0
  ret[11U] = 0U;
4802
0
  ret[12U] = 0U;
4803
0
  ret[13U] = 0U;
4804
0
  ret[14U] = 0U;
4805
0
  ret[15U] = 0U;
4806
0
  ret[16U] = 0U;
4807
0
  ret[17U] = 0U;
4808
0
  ret[18U] = 0U;
4809
0
  ret[19U] = 0U;
4810
0
  ret[20U] = 0U;
4811
0
  ret[21U] = 0U;
4812
0
  ret[22U] = 0U;
4813
0
  ret[23U] = 0U;
4814
0
  ret[24U] = 0U;
4815
0
  ret[25U] = 0U;
4816
0
  ret[26U] = 0U;
4817
0
  ret[27U] = 0U;
4818
0
  ret[28U] = 0U;
4819
0
  ret[29U] = 0U;
4820
0
  ret[30U] = 0U;
4821
0
  ret[31U] = 0U;
4822
0
  ret[32U] = 0U;
4823
0
  ret[33U] = 0U;
4824
0
  ret[34U] = 0U;
4825
0
  ret[35U] = 0U;
4826
0
  ret[36U] = 0U;
4827
0
  ret[37U] = 0U;
4828
0
  ret[38U] = 0U;
4829
0
  ret[39U] = 0U;
4830
0
  ret[40U] = 0U;
4831
0
  ret[41U] = 0U;
4832
0
  ret[42U] = 0U;
4833
0
  ret[43U] = 0U;
4834
0
  ret[44U] = 0U;
4835
0
  ret[45U] = 0U;
4836
0
  ret[46U] = 0U;
4837
0
  ret[47U] = 0U;
4838
0
  ret[48U] = 0U;
4839
0
  ret[49U] = 0U;
4840
0
  ret[50U] = 0U;
4841
0
  ret[51U] = 0U;
4842
0
  ret[52U] = 0U;
4843
0
  ret[53U] = 0U;
4844
0
  ret[54U] = 0U;
4845
0
  ret[55U] = 0U;
4846
0
  ret[56U] = 0U;
4847
0
  ret[57U] = 0U;
4848
0
  ret[58U] = 0U;
4849
0
  ret[59U] = 0U;
4850
0
  ret[60U] = 0U;
4851
0
  ret[61U] = 0U;
4852
0
  ret[62U] = 0U;
4853
0
  ret[63U] = 0U;
4854
0
  ret[64U] = 0U;
4855
0
  ret[65U] = 0U;
4856
0
  ret[66U] = 0U;
4857
0
  ret[67U] = 0U;
4858
0
  ret[68U] = 0U;
4859
0
  ret[69U] = 0U;
4860
0
  ret[70U] = 0U;
4861
0
  ret[71U] = 0U;
4862
0
  ret[72U] = 0U;
4863
0
  ret[73U] = 0U;
4864
0
  ret[74U] = 0U;
4865
0
  ret[75U] = 0U;
4866
0
  ret[76U] = 0U;
4867
0
  ret[77U] = 0U;
4868
0
  ret[78U] = 0U;
4869
0
  ret[79U] = 0U;
4870
0
  ret[80U] = 0U;
4871
0
  ret[81U] = 0U;
4872
0
  ret[82U] = 0U;
4873
0
  ret[83U] = 0U;
4874
0
  ret[84U] = 0U;
4875
0
  ret[85U] = 0U;
4876
0
  ret[86U] = 0U;
4877
0
  ret[87U] = 0U;
4878
0
  ret[88U] = 0U;
4879
0
  ret[89U] = 0U;
4880
0
  ret[90U] = 0U;
4881
0
  ret[91U] = 0U;
4882
0
  ret[92U] = 0U;
4883
0
  ret[93U] = 0U;
4884
0
  ret[94U] = 0U;
4885
0
  ret[95U] = 0U;
4886
0
  ret[96U] = 0U;
4887
0
  ret[97U] = 0U;
4888
0
  ret[98U] = 0U;
4889
0
  ret[99U] = 0U;
4890
0
  ret[100U] = 0U;
4891
0
  ret[101U] = 0U;
4892
0
  ret[102U] = 0U;
4893
0
  ret[103U] = 0U;
4894
0
  ret[104U] = 0U;
4895
0
  ret[105U] = 0U;
4896
0
  ret[106U] = 0U;
4897
0
  ret[107U] = 0U;
4898
0
  ret[108U] = 0U;
4899
0
  ret[109U] = 0U;
4900
0
  ret[110U] = 0U;
4901
0
  ret[111U] = 0U;
4902
0
  ret[112U] = 0U;
4903
0
  ret[113U] = 0U;
4904
0
  ret[114U] = 0U;
4905
0
  ret[115U] = 0U;
4906
0
  ret[116U] = 0U;
4907
0
  ret[117U] = 0U;
4908
0
  ret[118U] = 0U;
4909
0
  ret[119U] = 0U;
4910
0
  ret[120U] = 0U;
4911
0
  ret[121U] = 0U;
4912
0
  ret[122U] = 0U;
4913
0
  ret[123U] = 0U;
4914
0
  ret[124U] = 0U;
4915
0
  ret[125U] = 0U;
4916
0
  ret[126U] = 0U;
4917
0
  ret[127U] = 0U;
4918
0
  ret[128U] = 0U;
4919
0
  ret[129U] = 0U;
4920
0
  ret[130U] = 0U;
4921
0
  ret[131U] = 0U;
4922
0
  ret[132U] = 0U;
4923
0
  ret[133U] = 0U;
4924
0
  ret[134U] = 0U;
4925
0
  ret[135U] = 0U;
4926
0
}
4927
4928
/**
4929
 Generate a new keccak xof state.
4930
*/
4931
/**
4932
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4933
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4934
*/
4935
/**
4936
A monomorphic instance of libcrux_sha3.generic_keccak.new_9d
4937
with types uint64_t
4938
with const generics
4939
- PARALLEL_LANES= 1
4940
- RATE= 136
4941
*/
4942
static inline libcrux_sha3_generic_keccak_KeccakXofState_4f
4943
0
libcrux_sha3_generic_keccak_new_9d_7e(void) {
4944
0
  libcrux_sha3_generic_keccak_KeccakXofState_4f lit;
4945
0
  lit.inner = libcrux_sha3_generic_keccak_new_1e_f4();
4946
0
  uint8_t ret[136U];
4947
0
  libcrux_sha3_generic_keccak_zero_block_9d_e6(ret);
4948
0
  memcpy(lit.buf[0U], ret, (size_t)136U * sizeof(uint8_t));
4949
0
  lit.buf_len = (size_t)0U;
4950
0
  lit.sponge = false;
4951
0
  return lit;
4952
0
}
4953
4954
/**
4955
 Shake256 new state
4956
*/
4957
/**
4958
This function found in impl
4959
{(libcrux_sha3::portable::incremental::XofAbsorb<136: usize> for
4960
libcrux_sha3::portable::incremental::Shake256Absorb)#2}
4961
*/
4962
static inline libcrux_sha3_generic_keccak_KeccakXofState_4f
4963
0
libcrux_sha3_portable_incremental_new_7d(void) {
4964
0
  return libcrux_sha3_generic_keccak_new_9d_7e();
4965
0
}
4966
4967
/**
4968
A monomorphic instance of libcrux_sha3.generic_keccak.KeccakXofState
4969
with types uint64_t
4970
with const generics
4971
- $1size_t
4972
- $168size_t
4973
*/
4974
typedef struct libcrux_sha3_generic_keccak_KeccakXofState_78_s {
4975
  libcrux_sha3_generic_keccak_KeccakState_48 inner;
4976
  uint8_t buf[1U][168U];
4977
  size_t buf_len;
4978
  bool sponge;
4979
} libcrux_sha3_generic_keccak_KeccakXofState_78;
4980
4981
typedef libcrux_sha3_generic_keccak_KeccakXofState_78
4982
    libcrux_sha3_portable_incremental_Shake128Absorb;
4983
4984
/**
4985
 Consume the internal buffer and the required amount of the input to pad to
4986
 `RATE`.
4987
4988
 Returns the `consumed` bytes from `inputs` if there's enough buffered
4989
 content to consume, and `0` otherwise.
4990
 If `consumed > 0` is returned, `self.buf` contains a full block to be
4991
 loaded.
4992
*/
4993
/**
4994
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
4995
PARALLEL_LANES, RATE>[TraitClause@0]#2}
4996
*/
4997
/**
4998
A monomorphic instance of libcrux_sha3.generic_keccak.fill_buffer_9d
4999
with types uint64_t
5000
with const generics
5001
- PARALLEL_LANES= 1
5002
- RATE= 168
5003
*/
5004
static inline size_t libcrux_sha3_generic_keccak_fill_buffer_9d_b00(
5005
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self,
5006
0
    Eurydice_slice inputs[1U]) {
5007
0
  size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t);
5008
0
  size_t consumed = (size_t)0U;
5009
0
  if (self->buf_len > (size_t)0U) {
5010
0
    if (self->buf_len + input_len >= (size_t)168U) {
5011
0
      consumed = (size_t)168U - self->buf_len;
5012
0
      for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
5013
0
        size_t i0 = i;
5014
0
        Eurydice_slice uu____0 = Eurydice_array_to_subslice_from(
5015
0
            (size_t)168U, self->buf[i0], self->buf_len, uint8_t, size_t);
5016
0
        Eurydice_slice_copy(
5017
0
            uu____0,
5018
0
            Eurydice_slice_subslice_to(inputs[i0], consumed, uint8_t, size_t),
5019
0
            uint8_t);
5020
0
      }
5021
0
      self->buf_len = self->buf_len + consumed;
5022
0
    }
5023
0
  }
5024
0
  return consumed;
5025
0
}
5026
5027
/**
5028
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5029
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5030
*/
5031
/**
5032
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_full_9d
5033
with types uint64_t
5034
with const generics
5035
- PARALLEL_LANES= 1
5036
- RATE= 168
5037
*/
5038
static inline size_t libcrux_sha3_generic_keccak_absorb_full_9d_f80(
5039
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self,
5040
0
    Eurydice_slice inputs[1U]) {
5041
0
  libcrux_sha3_generic_keccak_KeccakXofState_78 *uu____0 = self;
5042
0
  /* Passing arrays by value in Rust generates a copy in C */
5043
0
  Eurydice_slice copy_of_inputs0[1U];
5044
0
  memcpy(copy_of_inputs0, inputs, (size_t)1U * sizeof(Eurydice_slice));
5045
0
  size_t input_consumed =
5046
0
      libcrux_sha3_generic_keccak_fill_buffer_9d_b00(uu____0, copy_of_inputs0);
5047
0
  if (input_consumed > (size_t)0U) {
5048
0
    Eurydice_slice borrowed[1U];
5049
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
5050
0
      uint8_t buf[168U] = {0U};
5051
0
      borrowed[i] = core_array___Array_T__N__23__as_slice(
5052
0
          (size_t)168U, buf, uint8_t, Eurydice_slice);
5053
0
    }
5054
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
5055
0
      size_t i0 = i;
5056
0
      borrowed[i0] =
5057
0
          Eurydice_array_to_slice((size_t)168U, self->buf[i0], uint8_t);
5058
0
    }
5059
0
    uint64_t(*uu____2)[5U] = self->inner.st;
5060
0
    Eurydice_slice uu____3[1U];
5061
0
    memcpy(uu____3, borrowed, (size_t)1U * sizeof(Eurydice_slice));
5062
0
    libcrux_sha3_portable_keccak_load_block_5a_b83(uu____2, uu____3);
5063
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5064
0
    self->buf_len = (size_t)0U;
5065
0
  }
5066
0
  size_t input_to_consume =
5067
0
      Eurydice_slice_len(inputs[0U], uint8_t) - input_consumed;
5068
0
  size_t num_blocks = input_to_consume / (size_t)168U;
5069
0
  size_t remainder = input_to_consume % (size_t)168U;
5070
0
  for (size_t i = (size_t)0U; i < num_blocks; i++) {
5071
0
    size_t i0 = i;
5072
0
    uint64_t(*uu____4)[5U] = self->inner.st;
5073
0
    /* Passing arrays by value in Rust generates a copy in C */
5074
0
    Eurydice_slice copy_of_inputs[1U];
5075
0
    memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice));
5076
0
    Eurydice_slice ret[1U];
5077
0
    libcrux_sha3_portable_keccak_slice_n_5a(
5078
0
        copy_of_inputs, input_consumed + i0 * (size_t)168U, (size_t)168U, ret);
5079
0
    libcrux_sha3_portable_keccak_load_block_5a_b83(uu____4, ret);
5080
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5081
0
  }
5082
0
  return remainder;
5083
0
}
5084
5085
/**
5086
 Absorb
5087
5088
 This function takes any number of bytes to absorb and buffers if it's not
5089
 enough. The function assumes that all input slices in `blocks` have the same
5090
 length.
5091
5092
 Only a multiple of `RATE` blocks are absorbed.
5093
 For the remaining bytes [`absorb_final`] needs to be called.
5094
5095
 This works best with relatively small `inputs`.
5096
*/
5097
/**
5098
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5099
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5100
*/
5101
/**
5102
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_9d
5103
with types uint64_t
5104
with const generics
5105
- PARALLEL_LANES= 1
5106
- RATE= 168
5107
*/
5108
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_9d_7b0(
5109
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self,
5110
0
    Eurydice_slice inputs[1U]) {
5111
0
  libcrux_sha3_generic_keccak_KeccakXofState_78 *uu____0 = self;
5112
0
  /* Passing arrays by value in Rust generates a copy in C */
5113
0
  Eurydice_slice copy_of_inputs[1U];
5114
0
  memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice));
5115
0
  size_t input_remainder_len =
5116
0
      libcrux_sha3_generic_keccak_absorb_full_9d_f80(uu____0, copy_of_inputs);
5117
0
  if (input_remainder_len > (size_t)0U) {
5118
0
    size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t);
5119
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
5120
0
      size_t i0 = i;
5121
0
      Eurydice_slice uu____2 = Eurydice_array_to_subslice2(
5122
0
          self->buf[i0], self->buf_len, self->buf_len + input_remainder_len,
5123
0
          uint8_t);
5124
0
      Eurydice_slice_copy(
5125
0
          uu____2,
5126
0
          Eurydice_slice_subslice_from(
5127
0
              inputs[i0], input_len - input_remainder_len, uint8_t, size_t),
5128
0
          uint8_t);
5129
0
    }
5130
0
    self->buf_len = self->buf_len + input_remainder_len;
5131
0
  }
5132
0
}
5133
5134
/**
5135
This function found in impl
5136
{(libcrux_sha3::portable::incremental::XofAbsorb<168: usize> for
5137
libcrux_sha3::portable::incremental::Shake128Absorb)}
5138
*/
5139
static inline void libcrux_sha3_portable_incremental_absorb_1c(
5140
0
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self, Eurydice_slice input) {
5141
0
  Eurydice_slice buf[1U] = {input};
5142
0
  libcrux_sha3_generic_keccak_absorb_9d_7b0(self, buf);
5143
0
}
5144
5145
typedef libcrux_sha3_generic_keccak_KeccakXofState_78
5146
    libcrux_sha3_portable_incremental_Shake128Squeeze;
5147
5148
/**
5149
 Absorb a final block.
5150
5151
 The `inputs` block may be empty. Everything in the `inputs` block beyond
5152
 `RATE` bytes is ignored.
5153
*/
5154
/**
5155
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5156
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5157
*/
5158
/**
5159
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_9d
5160
with types uint64_t
5161
with const generics
5162
- PARALLEL_LANES= 1
5163
- RATE= 168
5164
- DELIMITER= 31
5165
*/
5166
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_9d_250(
5167
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self,
5168
0
    Eurydice_slice inputs[1U]) {
5169
0
  libcrux_sha3_generic_keccak_KeccakXofState_78 *uu____0 = self;
5170
0
  /* Passing arrays by value in Rust generates a copy in C */
5171
0
  Eurydice_slice copy_of_inputs[1U];
5172
0
  memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice));
5173
0
  size_t input_remainder_len =
5174
0
      libcrux_sha3_generic_keccak_absorb_full_9d_f80(uu____0, copy_of_inputs);
5175
0
  size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t);
5176
0
  uint8_t blocks[1U][200U] = {{0U}};
5177
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
5178
0
    size_t i0 = i;
5179
0
    if (self->buf_len > (size_t)0U) {
5180
0
      Eurydice_slice uu____2 = Eurydice_array_to_subslice2(
5181
0
          blocks[i0], (size_t)0U, self->buf_len, uint8_t);
5182
0
      Eurydice_slice_copy(uu____2,
5183
0
                          Eurydice_array_to_subslice2(self->buf[i0], (size_t)0U,
5184
0
                                                      self->buf_len, uint8_t),
5185
0
                          uint8_t);
5186
0
    }
5187
0
    if (input_remainder_len > (size_t)0U) {
5188
0
      Eurydice_slice uu____3 = Eurydice_array_to_subslice2(
5189
0
          blocks[i0], self->buf_len, self->buf_len + input_remainder_len,
5190
0
          uint8_t);
5191
0
      Eurydice_slice_copy(
5192
0
          uu____3,
5193
0
          Eurydice_slice_subslice_from(
5194
0
              inputs[i0], input_len - input_remainder_len, uint8_t, size_t),
5195
0
          uint8_t);
5196
0
    }
5197
0
    blocks[i0][self->buf_len + input_remainder_len] = 31U;
5198
0
    size_t uu____4 = i0;
5199
0
    size_t uu____5 = (size_t)168U - (size_t)1U;
5200
0
    blocks[uu____4][uu____5] = (uint32_t)blocks[uu____4][uu____5] | 128U;
5201
0
  }
5202
0
  uint64_t(*uu____6)[5U] = self->inner.st;
5203
0
  uint8_t uu____7[1U][200U];
5204
0
  memcpy(uu____7, blocks, (size_t)1U * sizeof(uint8_t[200U]));
5205
0
  libcrux_sha3_portable_keccak_load_block_full_5a_d21(uu____6, uu____7);
5206
0
  libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5207
0
}
5208
5209
/**
5210
This function found in impl
5211
{(libcrux_sha3::portable::incremental::XofAbsorb<168: usize> for
5212
libcrux_sha3::portable::incremental::Shake128Absorb)}
5213
*/
5214
static inline libcrux_sha3_generic_keccak_KeccakXofState_78
5215
libcrux_sha3_portable_incremental_absorb_final_1c(
5216
0
    libcrux_sha3_generic_keccak_KeccakXofState_78 self, Eurydice_slice input) {
5217
0
  Eurydice_slice buf[1U] = {input};
5218
0
  libcrux_sha3_generic_keccak_absorb_final_9d_250(&self, buf);
5219
0
  return self;
5220
0
}
5221
5222
/**
5223
 An all zero block
5224
*/
5225
/**
5226
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5227
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5228
*/
5229
/**
5230
A monomorphic instance of libcrux_sha3.generic_keccak.zero_block_9d
5231
with types uint64_t
5232
with const generics
5233
- PARALLEL_LANES= 1
5234
- RATE= 168
5235
*/
5236
static inline void libcrux_sha3_generic_keccak_zero_block_9d_e60(
5237
0
    uint8_t ret[168U]) {
5238
0
  ret[0U] = 0U;
5239
0
  ret[1U] = 0U;
5240
0
  ret[2U] = 0U;
5241
0
  ret[3U] = 0U;
5242
0
  ret[4U] = 0U;
5243
0
  ret[5U] = 0U;
5244
0
  ret[6U] = 0U;
5245
0
  ret[7U] = 0U;
5246
0
  ret[8U] = 0U;
5247
0
  ret[9U] = 0U;
5248
0
  ret[10U] = 0U;
5249
0
  ret[11U] = 0U;
5250
0
  ret[12U] = 0U;
5251
0
  ret[13U] = 0U;
5252
0
  ret[14U] = 0U;
5253
0
  ret[15U] = 0U;
5254
0
  ret[16U] = 0U;
5255
0
  ret[17U] = 0U;
5256
0
  ret[18U] = 0U;
5257
0
  ret[19U] = 0U;
5258
0
  ret[20U] = 0U;
5259
0
  ret[21U] = 0U;
5260
0
  ret[22U] = 0U;
5261
0
  ret[23U] = 0U;
5262
0
  ret[24U] = 0U;
5263
0
  ret[25U] = 0U;
5264
0
  ret[26U] = 0U;
5265
0
  ret[27U] = 0U;
5266
0
  ret[28U] = 0U;
5267
0
  ret[29U] = 0U;
5268
0
  ret[30U] = 0U;
5269
0
  ret[31U] = 0U;
5270
0
  ret[32U] = 0U;
5271
0
  ret[33U] = 0U;
5272
0
  ret[34U] = 0U;
5273
0
  ret[35U] = 0U;
5274
0
  ret[36U] = 0U;
5275
0
  ret[37U] = 0U;
5276
0
  ret[38U] = 0U;
5277
0
  ret[39U] = 0U;
5278
0
  ret[40U] = 0U;
5279
0
  ret[41U] = 0U;
5280
0
  ret[42U] = 0U;
5281
0
  ret[43U] = 0U;
5282
0
  ret[44U] = 0U;
5283
0
  ret[45U] = 0U;
5284
0
  ret[46U] = 0U;
5285
0
  ret[47U] = 0U;
5286
0
  ret[48U] = 0U;
5287
0
  ret[49U] = 0U;
5288
0
  ret[50U] = 0U;
5289
0
  ret[51U] = 0U;
5290
0
  ret[52U] = 0U;
5291
0
  ret[53U] = 0U;
5292
0
  ret[54U] = 0U;
5293
0
  ret[55U] = 0U;
5294
0
  ret[56U] = 0U;
5295
0
  ret[57U] = 0U;
5296
0
  ret[58U] = 0U;
5297
0
  ret[59U] = 0U;
5298
0
  ret[60U] = 0U;
5299
0
  ret[61U] = 0U;
5300
0
  ret[62U] = 0U;
5301
0
  ret[63U] = 0U;
5302
0
  ret[64U] = 0U;
5303
0
  ret[65U] = 0U;
5304
0
  ret[66U] = 0U;
5305
0
  ret[67U] = 0U;
5306
0
  ret[68U] = 0U;
5307
0
  ret[69U] = 0U;
5308
0
  ret[70U] = 0U;
5309
0
  ret[71U] = 0U;
5310
0
  ret[72U] = 0U;
5311
0
  ret[73U] = 0U;
5312
0
  ret[74U] = 0U;
5313
0
  ret[75U] = 0U;
5314
0
  ret[76U] = 0U;
5315
0
  ret[77U] = 0U;
5316
0
  ret[78U] = 0U;
5317
0
  ret[79U] = 0U;
5318
0
  ret[80U] = 0U;
5319
0
  ret[81U] = 0U;
5320
0
  ret[82U] = 0U;
5321
0
  ret[83U] = 0U;
5322
0
  ret[84U] = 0U;
5323
0
  ret[85U] = 0U;
5324
0
  ret[86U] = 0U;
5325
0
  ret[87U] = 0U;
5326
0
  ret[88U] = 0U;
5327
0
  ret[89U] = 0U;
5328
0
  ret[90U] = 0U;
5329
0
  ret[91U] = 0U;
5330
0
  ret[92U] = 0U;
5331
0
  ret[93U] = 0U;
5332
0
  ret[94U] = 0U;
5333
0
  ret[95U] = 0U;
5334
0
  ret[96U] = 0U;
5335
0
  ret[97U] = 0U;
5336
0
  ret[98U] = 0U;
5337
0
  ret[99U] = 0U;
5338
0
  ret[100U] = 0U;
5339
0
  ret[101U] = 0U;
5340
0
  ret[102U] = 0U;
5341
0
  ret[103U] = 0U;
5342
0
  ret[104U] = 0U;
5343
0
  ret[105U] = 0U;
5344
0
  ret[106U] = 0U;
5345
0
  ret[107U] = 0U;
5346
0
  ret[108U] = 0U;
5347
0
  ret[109U] = 0U;
5348
0
  ret[110U] = 0U;
5349
0
  ret[111U] = 0U;
5350
0
  ret[112U] = 0U;
5351
0
  ret[113U] = 0U;
5352
0
  ret[114U] = 0U;
5353
0
  ret[115U] = 0U;
5354
0
  ret[116U] = 0U;
5355
0
  ret[117U] = 0U;
5356
0
  ret[118U] = 0U;
5357
0
  ret[119U] = 0U;
5358
0
  ret[120U] = 0U;
5359
0
  ret[121U] = 0U;
5360
0
  ret[122U] = 0U;
5361
0
  ret[123U] = 0U;
5362
0
  ret[124U] = 0U;
5363
0
  ret[125U] = 0U;
5364
0
  ret[126U] = 0U;
5365
0
  ret[127U] = 0U;
5366
0
  ret[128U] = 0U;
5367
0
  ret[129U] = 0U;
5368
0
  ret[130U] = 0U;
5369
0
  ret[131U] = 0U;
5370
0
  ret[132U] = 0U;
5371
0
  ret[133U] = 0U;
5372
0
  ret[134U] = 0U;
5373
0
  ret[135U] = 0U;
5374
0
  ret[136U] = 0U;
5375
0
  ret[137U] = 0U;
5376
0
  ret[138U] = 0U;
5377
0
  ret[139U] = 0U;
5378
0
  ret[140U] = 0U;
5379
0
  ret[141U] = 0U;
5380
0
  ret[142U] = 0U;
5381
0
  ret[143U] = 0U;
5382
0
  ret[144U] = 0U;
5383
0
  ret[145U] = 0U;
5384
0
  ret[146U] = 0U;
5385
0
  ret[147U] = 0U;
5386
0
  ret[148U] = 0U;
5387
0
  ret[149U] = 0U;
5388
0
  ret[150U] = 0U;
5389
0
  ret[151U] = 0U;
5390
0
  ret[152U] = 0U;
5391
0
  ret[153U] = 0U;
5392
0
  ret[154U] = 0U;
5393
0
  ret[155U] = 0U;
5394
0
  ret[156U] = 0U;
5395
0
  ret[157U] = 0U;
5396
0
  ret[158U] = 0U;
5397
0
  ret[159U] = 0U;
5398
0
  ret[160U] = 0U;
5399
0
  ret[161U] = 0U;
5400
0
  ret[162U] = 0U;
5401
0
  ret[163U] = 0U;
5402
0
  ret[164U] = 0U;
5403
0
  ret[165U] = 0U;
5404
0
  ret[166U] = 0U;
5405
0
  ret[167U] = 0U;
5406
0
}
5407
5408
/**
5409
 Generate a new keccak xof state.
5410
*/
5411
/**
5412
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5413
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5414
*/
5415
/**
5416
A monomorphic instance of libcrux_sha3.generic_keccak.new_9d
5417
with types uint64_t
5418
with const generics
5419
- PARALLEL_LANES= 1
5420
- RATE= 168
5421
*/
5422
static inline libcrux_sha3_generic_keccak_KeccakXofState_78
5423
0
libcrux_sha3_generic_keccak_new_9d_7e0(void) {
5424
0
  libcrux_sha3_generic_keccak_KeccakXofState_78 lit;
5425
0
  lit.inner = libcrux_sha3_generic_keccak_new_1e_f4();
5426
0
  uint8_t ret[168U];
5427
0
  libcrux_sha3_generic_keccak_zero_block_9d_e60(ret);
5428
0
  memcpy(lit.buf[0U], ret, (size_t)168U * sizeof(uint8_t));
5429
0
  lit.buf_len = (size_t)0U;
5430
0
  lit.sponge = false;
5431
0
  return lit;
5432
0
}
5433
5434
/**
5435
This function found in impl
5436
{(libcrux_sha3::portable::incremental::XofAbsorb<168: usize> for
5437
libcrux_sha3::portable::incremental::Shake128Absorb)}
5438
*/
5439
static inline libcrux_sha3_generic_keccak_KeccakXofState_78
5440
0
libcrux_sha3_portable_incremental_new_1c(void) {
5441
0
  return libcrux_sha3_generic_keccak_new_9d_7e0();
5442
0
}
5443
5444
/**
5445
 `out` has the exact size we want here. It must be less than or equal to `RATE`.
5446
*/
5447
/**
5448
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
5449
usize> for u64)}
5450
*/
5451
/**
5452
A monomorphic instance of libcrux_sha3.portable_keccak.store_5a
5453
with const generics
5454
- RATE= 136
5455
*/
5456
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_5a_1c(
5457
0
    uint64_t (*state)[5U], Eurydice_slice out[1U]) {
5458
0
  size_t num_full_blocks = Eurydice_slice_len(out[0U], uint8_t) / (size_t)8U;
5459
0
  size_t last_block_len = Eurydice_slice_len(out[0U], uint8_t) % (size_t)8U;
5460
0
  for (size_t i = (size_t)0U; i < num_full_blocks; i++) {
5461
0
    size_t i0 = i;
5462
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
5463
0
        out[0U], i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t);
5464
0
    uint8_t ret[8U];
5465
0
    core_num__u64_9__to_le_bytes(state[i0 / (size_t)5U][i0 % (size_t)5U], ret);
5466
0
    Eurydice_slice_copy(
5467
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
5468
0
  }
5469
0
  if (last_block_len != (size_t)0U) {
5470
0
    Eurydice_slice uu____1 = Eurydice_slice_subslice2(
5471
0
        out[0U], num_full_blocks * (size_t)8U,
5472
0
        num_full_blocks * (size_t)8U + last_block_len, uint8_t);
5473
0
    uint8_t ret[8U];
5474
0
    core_num__u64_9__to_le_bytes(
5475
0
        state[num_full_blocks / (size_t)5U][num_full_blocks % (size_t)5U], ret);
5476
0
    Eurydice_slice_copy(
5477
0
        uu____1,
5478
0
        Eurydice_array_to_subslice2(ret, (size_t)0U, last_block_len, uint8_t),
5479
0
        uint8_t);
5480
0
  }
5481
0
}
5482
5483
/**
5484
 Squeeze `N` x `LEN` bytes.
5485
*/
5486
/**
5487
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5488
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5489
*/
5490
/**
5491
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_9d
5492
with types uint64_t
5493
with const generics
5494
- PARALLEL_LANES= 1
5495
- RATE= 136
5496
*/
5497
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_9d_96(
5498
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self,
5499
0
    Eurydice_slice out[1U]) {
5500
0
  if (self->sponge) {
5501
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5502
0
  }
5503
0
  size_t out_len = Eurydice_slice_len(out[0U], uint8_t);
5504
0
  size_t blocks = out_len / (size_t)136U;
5505
0
  size_t last = out_len - out_len % (size_t)136U;
5506
0
  size_t mid;
5507
0
  if ((size_t)136U >= out_len) {
5508
0
    mid = out_len;
5509
0
  } else {
5510
0
    mid = (size_t)136U;
5511
0
  }
5512
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____0 =
5513
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, mid);
5514
0
  Eurydice_slice out00[1U];
5515
0
  memcpy(out00, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice));
5516
0
  Eurydice_slice out_rest[1U];
5517
0
  memcpy(out_rest, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice));
5518
0
  libcrux_sha3_portable_keccak_store_5a_1c(self->inner.st, out00);
5519
0
  core_ops_range_Range_b3 iter =
5520
0
      core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
5521
0
          (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
5522
0
                                             .end = blocks}),
5523
0
          core_ops_range_Range_b3, core_ops_range_Range_b3);
5524
0
  while (true) {
5525
0
    if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
5526
0
            &iter, size_t, Option_b3)
5527
0
            .tag == None) {
5528
0
      break;
5529
0
    } else {
5530
0
      Eurydice_slice_uint8_t_1size_t__x2 uu____1 =
5531
0
          libcrux_sha3_portable_keccak_split_at_mut_n_5a(out_rest,
5532
0
                                                         (size_t)136U);
5533
0
      Eurydice_slice out0[1U];
5534
0
      memcpy(out0, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice));
5535
0
      Eurydice_slice tmp[1U];
5536
0
      memcpy(tmp, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice));
5537
0
      libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5538
0
      libcrux_sha3_portable_keccak_store_5a_1c(self->inner.st, out0);
5539
0
      memcpy(out_rest, tmp, (size_t)1U * sizeof(Eurydice_slice));
5540
0
    }
5541
0
  }
5542
0
  if (last < out_len) {
5543
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5544
0
    libcrux_sha3_portable_keccak_store_5a_1c(self->inner.st, out_rest);
5545
0
  }
5546
0
  self->sponge = true;
5547
0
}
5548
5549
/**
5550
 Shake256 squeeze
5551
*/
5552
/**
5553
This function found in impl
5554
{(libcrux_sha3::portable::incremental::XofSqueeze<136: usize> for
5555
libcrux_sha3::portable::incremental::Shake256Squeeze)#3}
5556
*/
5557
static inline void libcrux_sha3_portable_incremental_squeeze_8a(
5558
0
    libcrux_sha3_generic_keccak_KeccakXofState_4f *self, Eurydice_slice out) {
5559
0
  Eurydice_slice buf[1U] = {out};
5560
0
  libcrux_sha3_generic_keccak_squeeze_9d_96(self, buf);
5561
0
}
5562
5563
/**
5564
 `out` has the exact size we want here. It must be less than or equal to `RATE`.
5565
*/
5566
/**
5567
This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1:
5568
usize> for u64)}
5569
*/
5570
/**
5571
A monomorphic instance of libcrux_sha3.portable_keccak.store_5a
5572
with const generics
5573
- RATE= 168
5574
*/
5575
static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_5a_1c0(
5576
0
    uint64_t (*state)[5U], Eurydice_slice out[1U]) {
5577
0
  size_t num_full_blocks = Eurydice_slice_len(out[0U], uint8_t) / (size_t)8U;
5578
0
  size_t last_block_len = Eurydice_slice_len(out[0U], uint8_t) % (size_t)8U;
5579
0
  for (size_t i = (size_t)0U; i < num_full_blocks; i++) {
5580
0
    size_t i0 = i;
5581
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
5582
0
        out[0U], i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t);
5583
0
    uint8_t ret[8U];
5584
0
    core_num__u64_9__to_le_bytes(state[i0 / (size_t)5U][i0 % (size_t)5U], ret);
5585
0
    Eurydice_slice_copy(
5586
0
        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
5587
0
  }
5588
0
  if (last_block_len != (size_t)0U) {
5589
0
    Eurydice_slice uu____1 = Eurydice_slice_subslice2(
5590
0
        out[0U], num_full_blocks * (size_t)8U,
5591
0
        num_full_blocks * (size_t)8U + last_block_len, uint8_t);
5592
0
    uint8_t ret[8U];
5593
0
    core_num__u64_9__to_le_bytes(
5594
0
        state[num_full_blocks / (size_t)5U][num_full_blocks % (size_t)5U], ret);
5595
0
    Eurydice_slice_copy(
5596
0
        uu____1,
5597
0
        Eurydice_array_to_subslice2(ret, (size_t)0U, last_block_len, uint8_t),
5598
0
        uint8_t);
5599
0
  }
5600
0
}
5601
5602
/**
5603
 Squeeze `N` x `LEN` bytes.
5604
*/
5605
/**
5606
This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE,
5607
PARALLEL_LANES, RATE>[TraitClause@0]#2}
5608
*/
5609
/**
5610
A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_9d
5611
with types uint64_t
5612
with const generics
5613
- PARALLEL_LANES= 1
5614
- RATE= 168
5615
*/
5616
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_9d_960(
5617
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self,
5618
0
    Eurydice_slice out[1U]) {
5619
0
  if (self->sponge) {
5620
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5621
0
  }
5622
0
  size_t out_len = Eurydice_slice_len(out[0U], uint8_t);
5623
0
  size_t blocks = out_len / (size_t)168U;
5624
0
  size_t last = out_len - out_len % (size_t)168U;
5625
0
  size_t mid;
5626
0
  if ((size_t)168U >= out_len) {
5627
0
    mid = out_len;
5628
0
  } else {
5629
0
    mid = (size_t)168U;
5630
0
  }
5631
0
  Eurydice_slice_uint8_t_1size_t__x2 uu____0 =
5632
0
      libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, mid);
5633
0
  Eurydice_slice out00[1U];
5634
0
  memcpy(out00, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice));
5635
0
  Eurydice_slice out_rest[1U];
5636
0
  memcpy(out_rest, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice));
5637
0
  libcrux_sha3_portable_keccak_store_5a_1c0(self->inner.st, out00);
5638
0
  core_ops_range_Range_b3 iter =
5639
0
      core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
5640
0
          (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
5641
0
                                             .end = blocks}),
5642
0
          core_ops_range_Range_b3, core_ops_range_Range_b3);
5643
0
  while (true) {
5644
0
    if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
5645
0
            &iter, size_t, Option_b3)
5646
0
            .tag == None) {
5647
0
      break;
5648
0
    } else {
5649
0
      Eurydice_slice_uint8_t_1size_t__x2 uu____1 =
5650
0
          libcrux_sha3_portable_keccak_split_at_mut_n_5a(out_rest,
5651
0
                                                         (size_t)168U);
5652
0
      Eurydice_slice out0[1U];
5653
0
      memcpy(out0, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice));
5654
0
      Eurydice_slice tmp[1U];
5655
0
      memcpy(tmp, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice));
5656
0
      libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5657
0
      libcrux_sha3_portable_keccak_store_5a_1c0(self->inner.st, out0);
5658
0
      memcpy(out_rest, tmp, (size_t)1U * sizeof(Eurydice_slice));
5659
0
    }
5660
0
  }
5661
0
  if (last < out_len) {
5662
0
    libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner);
5663
0
    libcrux_sha3_portable_keccak_store_5a_1c0(self->inner.st, out_rest);
5664
0
  }
5665
0
  self->sponge = true;
5666
0
}
5667
5668
/**
5669
 Shake128 squeeze
5670
*/
5671
/**
5672
This function found in impl
5673
{(libcrux_sha3::portable::incremental::XofSqueeze<168: usize> for
5674
libcrux_sha3::portable::incremental::Shake128Squeeze)#1}
5675
*/
5676
static inline void libcrux_sha3_portable_incremental_squeeze_10(
5677
0
    libcrux_sha3_generic_keccak_KeccakXofState_78 *self, Eurydice_slice out) {
5678
0
  Eurydice_slice buf[1U] = {out};
5679
0
  libcrux_sha3_generic_keccak_squeeze_9d_960(self, buf);
5680
0
}
5681
5682
/**
5683
This function found in impl {(core::clone::Clone for
5684
libcrux_sha3::portable::KeccakState)}
5685
*/
5686
static inline libcrux_sha3_generic_keccak_KeccakState_48
5687
libcrux_sha3_portable_clone_3d(
5688
0
    libcrux_sha3_generic_keccak_KeccakState_48 *self) {
5689
0
  return self[0U];
5690
0
}
5691
5692
/**
5693
This function found in impl {(core::convert::From<libcrux_sha3::Algorithm> for
5694
u32)#1}
5695
*/
5696
0
static inline uint32_t libcrux_sha3_from_eb(libcrux_sha3_Algorithm v) {
5697
0
  uint32_t uu____0;
5698
0
  switch (v) {
5699
0
    case libcrux_sha3_Sha224: {
5700
0
      uu____0 = 1U;
5701
0
      break;
5702
0
    }
5703
0
    case libcrux_sha3_Sha256: {
5704
0
      uu____0 = 2U;
5705
0
      break;
5706
0
    }
5707
0
    case libcrux_sha3_Sha384: {
5708
0
      uu____0 = 3U;
5709
0
      break;
5710
0
    }
5711
0
    case libcrux_sha3_Sha512: {
5712
0
      uu____0 = 4U;
5713
0
      break;
5714
0
    }
5715
0
    default: {
5716
0
      KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__,
5717
0
                        __LINE__);
5718
0
      KRML_HOST_EXIT(253U);
5719
0
    }
5720
0
  }
5721
0
  return uu____0;
5722
0
}
5723
5724
/**
5725
This function found in impl {(core::convert::From<u32> for
5726
libcrux_sha3::Algorithm)}
5727
*/
5728
0
static inline libcrux_sha3_Algorithm libcrux_sha3_from_2d(uint32_t v) {
5729
0
  libcrux_sha3_Algorithm uu____0;
5730
0
  switch (v) {
5731
0
    case 1U: {
5732
0
      uu____0 = libcrux_sha3_Sha224;
5733
0
      break;
5734
0
    }
5735
0
    case 2U: {
5736
0
      uu____0 = libcrux_sha3_Sha256;
5737
0
      break;
5738
0
    }
5739
0
    case 3U: {
5740
0
      uu____0 = libcrux_sha3_Sha384;
5741
0
      break;
5742
0
    }
5743
0
    case 4U: {
5744
0
      uu____0 = libcrux_sha3_Sha512;
5745
0
      break;
5746
0
    }
5747
0
    default: {
5748
0
      KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
5749
0
                        "panic!");
5750
0
      KRML_HOST_EXIT(255U);
5751
0
    }
5752
0
  }
5753
0
  return uu____0;
5754
0
}
5755
5756
typedef uint8_t libcrux_sha3_Sha3_512Digest[64U];
5757
5758
typedef uint8_t libcrux_sha3_Sha3_384Digest[48U];
5759
5760
typedef uint8_t libcrux_sha3_Sha3_256Digest[32U];
5761
5762
typedef uint8_t libcrux_sha3_Sha3_224Digest[28U];
5763
5764
#if defined(__cplusplus)
5765
}
5766
#endif
5767
5768
#define __libcrux_sha3_portable_H_DEFINED
5769
#endif
5770
5771
/* from libcrux/libcrux-ml-kem/cg/libcrux_mlkem768_portable.h */
5772
/*
5773
 * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com>
5774
 *
5775
 * SPDX-License-Identifier: MIT or Apache-2.0
5776
 *
5777
 * This code was generated with the following revisions:
5778
 * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4
5779
 * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb
5780
 * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908
5781
 * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty
5782
 * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee
5783
 */
5784
5785
#ifndef __libcrux_mlkem768_portable_H
5786
#define __libcrux_mlkem768_portable_H
5787
5788
#if defined(__cplusplus)
5789
extern "C" {
5790
#endif
5791
5792
5793
#define LIBCRUX_ML_KEM_HASH_FUNCTIONS_BLOCK_SIZE ((size_t)168U)
5794
5795
#define LIBCRUX_ML_KEM_HASH_FUNCTIONS_THREE_BLOCKS \
5796
  (LIBCRUX_ML_KEM_HASH_FUNCTIONS_BLOCK_SIZE * (size_t)3U)
5797
5798
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_G(
5799
0
    Eurydice_slice input, uint8_t ret[64U]) {
5800
0
  uint8_t digest[64U] = {0U};
5801
0
  libcrux_sha3_portable_sha512(
5802
0
      Eurydice_array_to_slice((size_t)64U, digest, uint8_t), input);
5803
0
  memcpy(ret, digest, (size_t)64U * sizeof(uint8_t));
5804
0
}
5805
5806
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_H(
5807
0
    Eurydice_slice input, uint8_t ret[32U]) {
5808
0
  uint8_t digest[32U] = {0U};
5809
0
  libcrux_sha3_portable_sha256(
5810
0
      Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input);
5811
0
  memcpy(ret, digest, (size_t)32U * sizeof(uint8_t));
5812
0
}
5813
5814
#define LIBCRUX_ML_KEM_IND_CCA_ENCAPS_SEED_SIZE \
5815
  (LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE)
5816
5817
#define LIBCRUX_ML_KEM_IND_CCA_KEY_GENERATION_SEED_SIZE        \
5818
  (LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE + \
5819
   LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE)
5820
5821
typedef uint8_t libcrux_ml_kem_ind_cca_MlKemSharedSecret[32U];
5822
5823
static const int16_t libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[128U] =
5824
    {(int16_t)-1044, (int16_t)-758,  (int16_t)-359,  (int16_t)-1517,
5825
     (int16_t)1493,  (int16_t)1422,  (int16_t)287,   (int16_t)202,
5826
     (int16_t)-171,  (int16_t)622,   (int16_t)1577,  (int16_t)182,
5827
     (int16_t)962,   (int16_t)-1202, (int16_t)-1474, (int16_t)1468,
5828
     (int16_t)573,   (int16_t)-1325, (int16_t)264,   (int16_t)383,
5829
     (int16_t)-829,  (int16_t)1458,  (int16_t)-1602, (int16_t)-130,
5830
     (int16_t)-681,  (int16_t)1017,  (int16_t)732,   (int16_t)608,
5831
     (int16_t)-1542, (int16_t)411,   (int16_t)-205,  (int16_t)-1571,
5832
     (int16_t)1223,  (int16_t)652,   (int16_t)-552,  (int16_t)1015,
5833
     (int16_t)-1293, (int16_t)1491,  (int16_t)-282,  (int16_t)-1544,
5834
     (int16_t)516,   (int16_t)-8,    (int16_t)-320,  (int16_t)-666,
5835
     (int16_t)-1618, (int16_t)-1162, (int16_t)126,   (int16_t)1469,
5836
     (int16_t)-853,  (int16_t)-90,   (int16_t)-271,  (int16_t)830,
5837
     (int16_t)107,   (int16_t)-1421, (int16_t)-247,  (int16_t)-951,
5838
     (int16_t)-398,  (int16_t)961,   (int16_t)-1508, (int16_t)-725,
5839
     (int16_t)448,   (int16_t)-1065, (int16_t)677,   (int16_t)-1275,
5840
     (int16_t)-1103, (int16_t)430,   (int16_t)555,   (int16_t)843,
5841
     (int16_t)-1251, (int16_t)871,   (int16_t)1550,  (int16_t)105,
5842
     (int16_t)422,   (int16_t)587,   (int16_t)177,   (int16_t)-235,
5843
     (int16_t)-291,  (int16_t)-460,  (int16_t)1574,  (int16_t)1653,
5844
     (int16_t)-246,  (int16_t)778,   (int16_t)1159,  (int16_t)-147,
5845
     (int16_t)-777,  (int16_t)1483,  (int16_t)-602,  (int16_t)1119,
5846
     (int16_t)-1590, (int16_t)644,   (int16_t)-872,  (int16_t)349,
5847
     (int16_t)418,   (int16_t)329,   (int16_t)-156,  (int16_t)-75,
5848
     (int16_t)817,   (int16_t)1097,  (int16_t)603,   (int16_t)610,
5849
     (int16_t)1322,  (int16_t)-1285, (int16_t)-1465, (int16_t)384,
5850
     (int16_t)-1215, (int16_t)-136,  (int16_t)1218,  (int16_t)-1335,
5851
     (int16_t)-874,  (int16_t)220,   (int16_t)-1187, (int16_t)-1659,
5852
     (int16_t)-1185, (int16_t)-1530, (int16_t)-1278, (int16_t)794,
5853
     (int16_t)-1510, (int16_t)-854,  (int16_t)-870,  (int16_t)478,
5854
     (int16_t)-108,  (int16_t)-308,  (int16_t)996,   (int16_t)991,
5855
     (int16_t)958,   (int16_t)-1460, (int16_t)1522,  (int16_t)1628};
5856
5857
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
5858
5859
#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT  \
5860
0
  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
5861
0
   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
5862
5863
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
5864
5865
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS \
5866
0
  ((int16_t)1353)
5867
5868
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R \
5869
0
  (62209U)
5870
5871
typedef struct libcrux_ml_kem_vector_portable_vector_type_PortableVector_s {
5872
  int16_t elements[16U];
5873
} libcrux_ml_kem_vector_portable_vector_type_PortableVector;
5874
5875
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
5876
libcrux_ml_kem_vector_portable_vector_type_from_i16_array(
5877
0
    Eurydice_slice array) {
5878
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
5879
0
  int16_t ret[16U];
5880
0
  Result_c0 dst;
5881
0
  Eurydice_slice_to_array2(
5882
0
      &dst, Eurydice_slice_subslice2(array, (size_t)0U, (size_t)16U, int16_t),
5883
0
      Eurydice_slice, int16_t[16U]);
5884
0
  unwrap_41_f9(dst, ret);
5885
0
  memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t));
5886
0
  return lit;
5887
0
}
5888
5889
/**
5890
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
5891
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
5892
*/
5893
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
5894
0
libcrux_ml_kem_vector_portable_from_i16_array_0d(Eurydice_slice array) {
5895
0
  return libcrux_ml_kem_vector_portable_vector_type_from_i16_array(array);
5896
0
}
5897
5898
typedef struct uint8_t_x11_s {
5899
  uint8_t fst;
5900
  uint8_t snd;
5901
  uint8_t thd;
5902
  uint8_t f3;
5903
  uint8_t f4;
5904
  uint8_t f5;
5905
  uint8_t f6;
5906
  uint8_t f7;
5907
  uint8_t f8;
5908
  uint8_t f9;
5909
  uint8_t f10;
5910
} uint8_t_x11;
5911
5912
static KRML_MUSTINLINE uint8_t_x11
5913
0
libcrux_ml_kem_vector_portable_serialize_serialize_11_int(Eurydice_slice v) {
5914
0
  uint8_t r0 = (uint8_t)Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *);
5915
0
  uint8_t r1 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t,
5916
0
                                                        int16_t *) &
5917
0
                                   (int16_t)31)
5918
0
                   << 3U |
5919
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t,
5920
0
                                                        int16_t *) >>
5921
0
                                   8U);
5922
0
  uint8_t r2 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t,
5923
0
                                                        int16_t *) &
5924
0
                                   (int16_t)3)
5925
0
                   << 6U |
5926
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t,
5927
0
                                                        int16_t *) >>
5928
0
                                   5U);
5929
0
  uint8_t r3 =
5930
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t, int16_t *) >> 2U &
5931
0
                (int16_t)255);
5932
0
  uint8_t r4 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t,
5933
0
                                                        int16_t *) &
5934
0
                                   (int16_t)127)
5935
0
                   << 1U |
5936
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t,
5937
0
                                                        int16_t *) >>
5938
0
                                   10U);
5939
0
  uint8_t r5 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)4U, int16_t,
5940
0
                                                        int16_t *) &
5941
0
                                   (int16_t)15)
5942
0
                   << 4U |
5943
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t,
5944
0
                                                        int16_t *) >>
5945
0
                                   7U);
5946
0
  uint8_t r6 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)5U, int16_t,
5947
0
                                                        int16_t *) &
5948
0
                                   (int16_t)1)
5949
0
                   << 7U |
5950
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)4U, int16_t,
5951
0
                                                        int16_t *) >>
5952
0
                                   4U);
5953
0
  uint8_t r7 =
5954
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *) >> 1U &
5955
0
                (int16_t)255);
5956
0
  uint8_t r8 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)6U, int16_t,
5957
0
                                                        int16_t *) &
5958
0
                                   (int16_t)63)
5959
0
                   << 2U |
5960
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)5U, int16_t,
5961
0
                                                        int16_t *) >>
5962
0
                                   9U);
5963
0
  uint8_t r9 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)7U, int16_t,
5964
0
                                                        int16_t *) &
5965
0
                                   (int16_t)7)
5966
0
                   << 5U |
5967
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)6U, int16_t,
5968
0
                                                        int16_t *) >>
5969
0
                                   6U);
5970
0
  uint8_t r10 =
5971
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *) >> 3U);
5972
0
  return (CLITERAL(uint8_t_x11){.fst = r0,
5973
0
                                .snd = r1,
5974
0
                                .thd = r2,
5975
0
                                .f3 = r3,
5976
0
                                .f4 = r4,
5977
0
                                .f5 = r5,
5978
0
                                .f6 = r6,
5979
0
                                .f7 = r7,
5980
0
                                .f8 = r8,
5981
0
                                .f9 = r9,
5982
0
                                .f10 = r10});
5983
0
}
5984
5985
static KRML_MUSTINLINE void
5986
libcrux_ml_kem_vector_portable_serialize_serialize_11(
5987
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v,
5988
0
    uint8_t ret[22U]) {
5989
0
  uint8_t_x11 r0_10 = libcrux_ml_kem_vector_portable_serialize_serialize_11_int(
5990
0
      Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)8U, int16_t));
5991
0
  uint8_t_x11 r11_21 =
5992
0
      libcrux_ml_kem_vector_portable_serialize_serialize_11_int(
5993
0
          Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)16U,
5994
0
                                      int16_t));
5995
0
  uint8_t result[22U] = {0U};
5996
0
  result[0U] = r0_10.fst;
5997
0
  result[1U] = r0_10.snd;
5998
0
  result[2U] = r0_10.thd;
5999
0
  result[3U] = r0_10.f3;
6000
0
  result[4U] = r0_10.f4;
6001
0
  result[5U] = r0_10.f5;
6002
0
  result[6U] = r0_10.f6;
6003
0
  result[7U] = r0_10.f7;
6004
0
  result[8U] = r0_10.f8;
6005
0
  result[9U] = r0_10.f9;
6006
0
  result[10U] = r0_10.f10;
6007
0
  result[11U] = r11_21.fst;
6008
0
  result[12U] = r11_21.snd;
6009
0
  result[13U] = r11_21.thd;
6010
0
  result[14U] = r11_21.f3;
6011
0
  result[15U] = r11_21.f4;
6012
0
  result[16U] = r11_21.f5;
6013
0
  result[17U] = r11_21.f6;
6014
0
  result[18U] = r11_21.f7;
6015
0
  result[19U] = r11_21.f8;
6016
0
  result[20U] = r11_21.f9;
6017
0
  result[21U] = r11_21.f10;
6018
0
  memcpy(ret, result, (size_t)22U * sizeof(uint8_t));
6019
0
}
6020
6021
/**
6022
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6023
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6024
*/
6025
static inline void libcrux_ml_kem_vector_portable_serialize_11_0d(
6026
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
6027
0
    uint8_t ret[22U]) {
6028
0
  libcrux_ml_kem_vector_portable_serialize_serialize_11(a, ret);
6029
0
}
6030
6031
typedef struct int16_t_x8_s {
6032
  int16_t fst;
6033
  int16_t snd;
6034
  int16_t thd;
6035
  int16_t f3;
6036
  int16_t f4;
6037
  int16_t f5;
6038
  int16_t f6;
6039
  int16_t f7;
6040
} int16_t_x8;
6041
6042
static KRML_MUSTINLINE int16_t_x8
6043
libcrux_ml_kem_vector_portable_serialize_deserialize_11_int(
6044
0
    Eurydice_slice bytes) {
6045
0
  int16_t r0 =
6046
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) &
6047
0
       (int16_t)7)
6048
0
          << 8U |
6049
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *);
6050
0
  int16_t r1 =
6051
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) &
6052
0
       (int16_t)63)
6053
0
          << 5U |
6054
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) >>
6055
0
          3U;
6056
0
  int16_t r2 =
6057
0
      (((int16_t)Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *) &
6058
0
        (int16_t)1)
6059
0
           << 10U |
6060
0
       (int16_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *)
6061
0
           << 2U) |
6062
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) >>
6063
0
          6U;
6064
0
  int16_t r3 =
6065
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *) &
6066
0
       (int16_t)15)
6067
0
          << 7U |
6068
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *) >>
6069
0
          1U;
6070
0
  int16_t r4 =
6071
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) &
6072
0
       (int16_t)127)
6073
0
          << 4U |
6074
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *) >>
6075
0
          4U;
6076
0
  int16_t r5 =
6077
0
      (((int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) &
6078
0
        (int16_t)3)
6079
0
           << 9U |
6080
0
       (int16_t)Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *)
6081
0
           << 1U) |
6082
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) >>
6083
0
          7U;
6084
0
  int16_t r6 =
6085
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *) &
6086
0
       (int16_t)31)
6087
0
          << 6U |
6088
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) >>
6089
0
          2U;
6090
0
  int16_t r7 =
6091
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)10U, uint8_t, uint8_t *)
6092
0
          << 3U |
6093
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *) >>
6094
0
          5U;
6095
0
  return (CLITERAL(int16_t_x8){.fst = r0,
6096
0
                               .snd = r1,
6097
0
                               .thd = r2,
6098
0
                               .f3 = r3,
6099
0
                               .f4 = r4,
6100
0
                               .f5 = r5,
6101
0
                               .f6 = r6,
6102
0
                               .f7 = r7});
6103
0
}
6104
6105
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6106
0
libcrux_ml_kem_vector_portable_vector_type_zero(void) {
6107
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
6108
0
  lit.elements[0U] = (int16_t)0;
6109
0
  lit.elements[1U] = (int16_t)0;
6110
0
  lit.elements[2U] = (int16_t)0;
6111
0
  lit.elements[3U] = (int16_t)0;
6112
0
  lit.elements[4U] = (int16_t)0;
6113
0
  lit.elements[5U] = (int16_t)0;
6114
0
  lit.elements[6U] = (int16_t)0;
6115
0
  lit.elements[7U] = (int16_t)0;
6116
0
  lit.elements[8U] = (int16_t)0;
6117
0
  lit.elements[9U] = (int16_t)0;
6118
0
  lit.elements[10U] = (int16_t)0;
6119
0
  lit.elements[11U] = (int16_t)0;
6120
0
  lit.elements[12U] = (int16_t)0;
6121
0
  lit.elements[13U] = (int16_t)0;
6122
0
  lit.elements[14U] = (int16_t)0;
6123
0
  lit.elements[15U] = (int16_t)0;
6124
0
  return lit;
6125
0
}
6126
6127
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6128
0
libcrux_ml_kem_vector_portable_serialize_deserialize_11(Eurydice_slice bytes) {
6129
0
  int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_11_int(
6130
0
      Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)11U, uint8_t));
6131
0
  int16_t_x8 v8_15 =
6132
0
      libcrux_ml_kem_vector_portable_serialize_deserialize_11_int(
6133
0
          Eurydice_slice_subslice2(bytes, (size_t)11U, (size_t)22U, uint8_t));
6134
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector v =
6135
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
6136
0
  v.elements[0U] = v0_7.fst;
6137
0
  v.elements[1U] = v0_7.snd;
6138
0
  v.elements[2U] = v0_7.thd;
6139
0
  v.elements[3U] = v0_7.f3;
6140
0
  v.elements[4U] = v0_7.f4;
6141
0
  v.elements[5U] = v0_7.f5;
6142
0
  v.elements[6U] = v0_7.f6;
6143
0
  v.elements[7U] = v0_7.f7;
6144
0
  v.elements[8U] = v8_15.fst;
6145
0
  v.elements[9U] = v8_15.snd;
6146
0
  v.elements[10U] = v8_15.thd;
6147
0
  v.elements[11U] = v8_15.f3;
6148
0
  v.elements[12U] = v8_15.f4;
6149
0
  v.elements[13U] = v8_15.f5;
6150
0
  v.elements[14U] = v8_15.f6;
6151
0
  v.elements[15U] = v8_15.f7;
6152
0
  return v;
6153
0
}
6154
6155
/**
6156
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6157
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6158
*/
6159
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6160
0
libcrux_ml_kem_vector_portable_deserialize_11_0d(Eurydice_slice a) {
6161
0
  return libcrux_ml_kem_vector_portable_serialize_deserialize_11(a);
6162
0
}
6163
6164
static KRML_MUSTINLINE void
6165
libcrux_ml_kem_vector_portable_vector_type_to_i16_array(
6166
    libcrux_ml_kem_vector_portable_vector_type_PortableVector x,
6167
0
    int16_t ret[16U]) {
6168
0
  memcpy(ret, x.elements, (size_t)16U * sizeof(int16_t));
6169
0
}
6170
6171
/**
6172
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6173
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6174
*/
6175
static inline void libcrux_ml_kem_vector_portable_to_i16_array_0d(
6176
    libcrux_ml_kem_vector_portable_vector_type_PortableVector x,
6177
0
    int16_t ret[16U]) {
6178
0
  libcrux_ml_kem_vector_portable_vector_type_to_i16_array(x, ret);
6179
0
}
6180
6181
static const uint8_t
6182
    libcrux_ml_kem_vector_rej_sample_table_REJECTION_SAMPLE_SHUFFLE_TABLE
6183
        [256U][16U] = {{255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6184
                        255U, 255U, 255U, 255U, 255U, 255U, 255U},
6185
                       {0U, 1U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6186
                        255U, 255U, 255U, 255U, 255U, 255U},
6187
                       {2U, 3U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6188
                        255U, 255U, 255U, 255U, 255U, 255U},
6189
                       {0U, 1U, 2U, 3U, 255U, 255U, 255U, 255U, 255U, 255U,
6190
                        255U, 255U, 255U, 255U, 255U, 255U},
6191
                       {4U, 5U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6192
                        255U, 255U, 255U, 255U, 255U, 255U},
6193
                       {0U, 1U, 4U, 5U, 255U, 255U, 255U, 255U, 255U, 255U,
6194
                        255U, 255U, 255U, 255U, 255U, 255U},
6195
                       {2U, 3U, 4U, 5U, 255U, 255U, 255U, 255U, 255U, 255U,
6196
                        255U, 255U, 255U, 255U, 255U, 255U},
6197
                       {0U, 1U, 2U, 3U, 4U, 5U, 255U, 255U, 255U, 255U, 255U,
6198
                        255U, 255U, 255U, 255U, 255U},
6199
                       {6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6200
                        255U, 255U, 255U, 255U, 255U, 255U},
6201
                       {0U, 1U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U,
6202
                        255U, 255U, 255U, 255U, 255U, 255U},
6203
                       {2U, 3U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U,
6204
                        255U, 255U, 255U, 255U, 255U, 255U},
6205
                       {0U, 1U, 2U, 3U, 6U, 7U, 255U, 255U, 255U, 255U, 255U,
6206
                        255U, 255U, 255U, 255U, 255U},
6207
                       {4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U,
6208
                        255U, 255U, 255U, 255U, 255U, 255U},
6209
                       {0U, 1U, 4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, 255U,
6210
                        255U, 255U, 255U, 255U, 255U},
6211
                       {2U, 3U, 4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, 255U,
6212
                        255U, 255U, 255U, 255U, 255U},
6213
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U,
6214
                        255U, 255U, 255U, 255U},
6215
                       {8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6216
                        255U, 255U, 255U, 255U, 255U, 255U},
6217
                       {0U, 1U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U,
6218
                        255U, 255U, 255U, 255U, 255U, 255U},
6219
                       {2U, 3U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U,
6220
                        255U, 255U, 255U, 255U, 255U, 255U},
6221
                       {0U, 1U, 2U, 3U, 8U, 9U, 255U, 255U, 255U, 255U, 255U,
6222
                        255U, 255U, 255U, 255U, 255U},
6223
                       {4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U,
6224
                        255U, 255U, 255U, 255U, 255U, 255U},
6225
                       {0U, 1U, 4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, 255U,
6226
                        255U, 255U, 255U, 255U, 255U},
6227
                       {2U, 3U, 4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, 255U,
6228
                        255U, 255U, 255U, 255U, 255U},
6229
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U,
6230
                        255U, 255U, 255U, 255U},
6231
                       {6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U,
6232
                        255U, 255U, 255U, 255U, 255U, 255U},
6233
                       {0U, 1U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U,
6234
                        255U, 255U, 255U, 255U, 255U},
6235
                       {2U, 3U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U,
6236
                        255U, 255U, 255U, 255U, 255U},
6237
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U,
6238
                        255U, 255U, 255U, 255U},
6239
                       {4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U,
6240
                        255U, 255U, 255U, 255U, 255U},
6241
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U,
6242
                        255U, 255U, 255U, 255U},
6243
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U,
6244
                        255U, 255U, 255U, 255U},
6245
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U,
6246
                        255U, 255U, 255U, 255U},
6247
                       {10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6248
                        255U, 255U, 255U, 255U, 255U, 255U, 255U},
6249
                       {0U, 1U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U,
6250
                        255U, 255U, 255U, 255U, 255U, 255U},
6251
                       {2U, 3U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U,
6252
                        255U, 255U, 255U, 255U, 255U, 255U},
6253
                       {0U, 1U, 2U, 3U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6254
                        255U, 255U, 255U, 255U, 255U},
6255
                       {4U, 5U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U,
6256
                        255U, 255U, 255U, 255U, 255U, 255U},
6257
                       {0U, 1U, 4U, 5U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6258
                        255U, 255U, 255U, 255U, 255U},
6259
                       {2U, 3U, 4U, 5U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6260
                        255U, 255U, 255U, 255U, 255U},
6261
                       {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 255U, 255U, 255U,
6262
                        255U, 255U, 255U, 255U, 255U},
6263
                       {6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U,
6264
                        255U, 255U, 255U, 255U, 255U, 255U},
6265
                       {0U, 1U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6266
                        255U, 255U, 255U, 255U, 255U},
6267
                       {2U, 3U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6268
                        255U, 255U, 255U, 255U, 255U},
6269
                       {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 255U, 255U, 255U,
6270
                        255U, 255U, 255U, 255U, 255U},
6271
                       {4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6272
                        255U, 255U, 255U, 255U, 255U},
6273
                       {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, 255U,
6274
                        255U, 255U, 255U, 255U, 255U},
6275
                       {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, 255U,
6276
                        255U, 255U, 255U, 255U, 255U},
6277
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U,
6278
                        255U, 255U, 255U, 255U},
6279
                       {8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U,
6280
                        255U, 255U, 255U, 255U, 255U, 255U},
6281
                       {0U, 1U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6282
                        255U, 255U, 255U, 255U, 255U},
6283
                       {2U, 3U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6284
                        255U, 255U, 255U, 255U, 255U},
6285
                       {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 255U, 255U, 255U,
6286
                        255U, 255U, 255U, 255U, 255U},
6287
                       {4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6288
                        255U, 255U, 255U, 255U, 255U},
6289
                       {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, 255U,
6290
                        255U, 255U, 255U, 255U, 255U},
6291
                       {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, 255U,
6292
                        255U, 255U, 255U, 255U, 255U},
6293
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U,
6294
                        255U, 255U, 255U, 255U},
6295
                       {6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U,
6296
                        255U, 255U, 255U, 255U, 255U},
6297
                       {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U,
6298
                        255U, 255U, 255U, 255U, 255U},
6299
                       {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U,
6300
                        255U, 255U, 255U, 255U, 255U},
6301
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U,
6302
                        255U, 255U, 255U, 255U},
6303
                       {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U,
6304
                        255U, 255U, 255U, 255U, 255U},
6305
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U,
6306
                        255U, 255U, 255U, 255U},
6307
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U,
6308
                        255U, 255U, 255U, 255U},
6309
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U,
6310
                        255U, 255U, 255U},
6311
                       {12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6312
                        255U, 255U, 255U, 255U, 255U, 255U, 255U},
6313
                       {0U, 1U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U,
6314
                        255U, 255U, 255U, 255U, 255U, 255U},
6315
                       {2U, 3U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U,
6316
                        255U, 255U, 255U, 255U, 255U, 255U},
6317
                       {0U, 1U, 2U, 3U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6318
                        255U, 255U, 255U, 255U, 255U},
6319
                       {4U, 5U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U,
6320
                        255U, 255U, 255U, 255U, 255U, 255U},
6321
                       {0U, 1U, 4U, 5U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6322
                        255U, 255U, 255U, 255U, 255U},
6323
                       {2U, 3U, 4U, 5U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6324
                        255U, 255U, 255U, 255U, 255U},
6325
                       {0U, 1U, 2U, 3U, 4U, 5U, 12U, 13U, 255U, 255U, 255U,
6326
                        255U, 255U, 255U, 255U, 255U},
6327
                       {6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U,
6328
                        255U, 255U, 255U, 255U, 255U, 255U},
6329
                       {0U, 1U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6330
                        255U, 255U, 255U, 255U, 255U},
6331
                       {2U, 3U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6332
                        255U, 255U, 255U, 255U, 255U},
6333
                       {0U, 1U, 2U, 3U, 6U, 7U, 12U, 13U, 255U, 255U, 255U,
6334
                        255U, 255U, 255U, 255U, 255U},
6335
                       {4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6336
                        255U, 255U, 255U, 255U, 255U},
6337
                       {0U, 1U, 4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, 255U,
6338
                        255U, 255U, 255U, 255U, 255U},
6339
                       {2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, 255U,
6340
                        255U, 255U, 255U, 255U, 255U},
6341
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U,
6342
                        255U, 255U, 255U, 255U},
6343
                       {8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U,
6344
                        255U, 255U, 255U, 255U, 255U, 255U},
6345
                       {0U, 1U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6346
                        255U, 255U, 255U, 255U, 255U},
6347
                       {2U, 3U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6348
                        255U, 255U, 255U, 255U, 255U},
6349
                       {0U, 1U, 2U, 3U, 8U, 9U, 12U, 13U, 255U, 255U, 255U,
6350
                        255U, 255U, 255U, 255U, 255U},
6351
                       {4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6352
                        255U, 255U, 255U, 255U, 255U},
6353
                       {0U, 1U, 4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, 255U,
6354
                        255U, 255U, 255U, 255U, 255U},
6355
                       {2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, 255U,
6356
                        255U, 255U, 255U, 255U, 255U},
6357
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U,
6358
                        255U, 255U, 255U, 255U},
6359
                       {6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U,
6360
                        255U, 255U, 255U, 255U, 255U},
6361
                       {0U, 1U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U,
6362
                        255U, 255U, 255U, 255U, 255U},
6363
                       {2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U,
6364
                        255U, 255U, 255U, 255U, 255U},
6365
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U,
6366
                        255U, 255U, 255U, 255U},
6367
                       {4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U,
6368
                        255U, 255U, 255U, 255U, 255U},
6369
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U,
6370
                        255U, 255U, 255U, 255U},
6371
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U,
6372
                        255U, 255U, 255U, 255U},
6373
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U,
6374
                        255U, 255U, 255U},
6375
                       {10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U,
6376
                        255U, 255U, 255U, 255U, 255U, 255U},
6377
                       {0U, 1U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U,
6378
                        255U, 255U, 255U, 255U, 255U, 255U},
6379
                       {2U, 3U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U,
6380
                        255U, 255U, 255U, 255U, 255U, 255U},
6381
                       {0U, 1U, 2U, 3U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6382
                        255U, 255U, 255U, 255U, 255U},
6383
                       {4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U,
6384
                        255U, 255U, 255U, 255U, 255U, 255U},
6385
                       {0U, 1U, 4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6386
                        255U, 255U, 255U, 255U, 255U},
6387
                       {2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6388
                        255U, 255U, 255U, 255U, 255U},
6389
                       {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U,
6390
                        255U, 255U, 255U, 255U},
6391
                       {6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U,
6392
                        255U, 255U, 255U, 255U, 255U, 255U},
6393
                       {0U, 1U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6394
                        255U, 255U, 255U, 255U, 255U},
6395
                       {2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6396
                        255U, 255U, 255U, 255U, 255U},
6397
                       {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U,
6398
                        255U, 255U, 255U, 255U},
6399
                       {4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6400
                        255U, 255U, 255U, 255U, 255U},
6401
                       {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U,
6402
                        255U, 255U, 255U, 255U},
6403
                       {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U,
6404
                        255U, 255U, 255U, 255U},
6405
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U,
6406
                        255U, 255U, 255U, 255U},
6407
                       {8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U,
6408
                        255U, 255U, 255U, 255U, 255U, 255U},
6409
                       {0U, 1U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6410
                        255U, 255U, 255U, 255U, 255U},
6411
                       {2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6412
                        255U, 255U, 255U, 255U, 255U},
6413
                       {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U,
6414
                        255U, 255U, 255U, 255U},
6415
                       {4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6416
                        255U, 255U, 255U, 255U, 255U},
6417
                       {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U,
6418
                        255U, 255U, 255U, 255U},
6419
                       {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U,
6420
                        255U, 255U, 255U, 255U},
6421
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U,
6422
                        255U, 255U, 255U, 255U},
6423
                       {6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U,
6424
                        255U, 255U, 255U, 255U, 255U},
6425
                       {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U,
6426
                        255U, 255U, 255U, 255U},
6427
                       {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U,
6428
                        255U, 255U, 255U, 255U},
6429
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U,
6430
                        255U, 255U, 255U, 255U},
6431
                       {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U,
6432
                        255U, 255U, 255U, 255U},
6433
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U,
6434
                        255U, 255U, 255U, 255U},
6435
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U,
6436
                        255U, 255U, 255U, 255U},
6437
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U,
6438
                        13U, 255U, 255U},
6439
                       {14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, 255U,
6440
                        255U, 255U, 255U, 255U, 255U, 255U, 255U},
6441
                       {0U, 1U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6442
                        255U, 255U, 255U, 255U, 255U, 255U},
6443
                       {2U, 3U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6444
                        255U, 255U, 255U, 255U, 255U, 255U},
6445
                       {0U, 1U, 2U, 3U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6446
                        255U, 255U, 255U, 255U, 255U},
6447
                       {4U, 5U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6448
                        255U, 255U, 255U, 255U, 255U, 255U},
6449
                       {0U, 1U, 4U, 5U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6450
                        255U, 255U, 255U, 255U, 255U},
6451
                       {2U, 3U, 4U, 5U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6452
                        255U, 255U, 255U, 255U, 255U},
6453
                       {0U, 1U, 2U, 3U, 4U, 5U, 14U, 15U, 255U, 255U, 255U,
6454
                        255U, 255U, 255U, 255U, 255U},
6455
                       {6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6456
                        255U, 255U, 255U, 255U, 255U, 255U},
6457
                       {0U, 1U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6458
                        255U, 255U, 255U, 255U, 255U},
6459
                       {2U, 3U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6460
                        255U, 255U, 255U, 255U, 255U},
6461
                       {0U, 1U, 2U, 3U, 6U, 7U, 14U, 15U, 255U, 255U, 255U,
6462
                        255U, 255U, 255U, 255U, 255U},
6463
                       {4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6464
                        255U, 255U, 255U, 255U, 255U},
6465
                       {0U, 1U, 4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, 255U,
6466
                        255U, 255U, 255U, 255U, 255U},
6467
                       {2U, 3U, 4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, 255U,
6468
                        255U, 255U, 255U, 255U, 255U},
6469
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U,
6470
                        255U, 255U, 255U, 255U},
6471
                       {8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6472
                        255U, 255U, 255U, 255U, 255U, 255U},
6473
                       {0U, 1U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6474
                        255U, 255U, 255U, 255U, 255U},
6475
                       {2U, 3U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6476
                        255U, 255U, 255U, 255U, 255U},
6477
                       {0U, 1U, 2U, 3U, 8U, 9U, 14U, 15U, 255U, 255U, 255U,
6478
                        255U, 255U, 255U, 255U, 255U},
6479
                       {4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6480
                        255U, 255U, 255U, 255U, 255U},
6481
                       {0U, 1U, 4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, 255U,
6482
                        255U, 255U, 255U, 255U, 255U},
6483
                       {2U, 3U, 4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, 255U,
6484
                        255U, 255U, 255U, 255U, 255U},
6485
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U,
6486
                        255U, 255U, 255U, 255U},
6487
                       {6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U,
6488
                        255U, 255U, 255U, 255U, 255U},
6489
                       {0U, 1U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U,
6490
                        255U, 255U, 255U, 255U, 255U},
6491
                       {2U, 3U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U,
6492
                        255U, 255U, 255U, 255U, 255U},
6493
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U,
6494
                        255U, 255U, 255U, 255U},
6495
                       {4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U,
6496
                        255U, 255U, 255U, 255U, 255U},
6497
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U,
6498
                        255U, 255U, 255U, 255U},
6499
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U,
6500
                        255U, 255U, 255U, 255U},
6501
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U,
6502
                        255U, 255U, 255U},
6503
                       {10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6504
                        255U, 255U, 255U, 255U, 255U, 255U},
6505
                       {0U, 1U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U,
6506
                        255U, 255U, 255U, 255U, 255U, 255U},
6507
                       {2U, 3U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U,
6508
                        255U, 255U, 255U, 255U, 255U, 255U},
6509
                       {0U, 1U, 2U, 3U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6510
                        255U, 255U, 255U, 255U, 255U},
6511
                       {4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U,
6512
                        255U, 255U, 255U, 255U, 255U, 255U},
6513
                       {0U, 1U, 4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6514
                        255U, 255U, 255U, 255U, 255U},
6515
                       {2U, 3U, 4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6516
                        255U, 255U, 255U, 255U, 255U},
6517
                       {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U,
6518
                        255U, 255U, 255U, 255U},
6519
                       {6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U,
6520
                        255U, 255U, 255U, 255U, 255U, 255U},
6521
                       {0U, 1U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6522
                        255U, 255U, 255U, 255U, 255U},
6523
                       {2U, 3U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6524
                        255U, 255U, 255U, 255U, 255U},
6525
                       {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U,
6526
                        255U, 255U, 255U, 255U},
6527
                       {4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6528
                        255U, 255U, 255U, 255U, 255U},
6529
                       {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U,
6530
                        255U, 255U, 255U, 255U},
6531
                       {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U,
6532
                        255U, 255U, 255U, 255U},
6533
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U,
6534
                        255U, 255U, 255U, 255U},
6535
                       {8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U,
6536
                        255U, 255U, 255U, 255U, 255U, 255U},
6537
                       {0U, 1U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6538
                        255U, 255U, 255U, 255U, 255U},
6539
                       {2U, 3U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6540
                        255U, 255U, 255U, 255U, 255U},
6541
                       {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U,
6542
                        255U, 255U, 255U, 255U},
6543
                       {4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6544
                        255U, 255U, 255U, 255U, 255U},
6545
                       {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U,
6546
                        255U, 255U, 255U, 255U},
6547
                       {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U,
6548
                        255U, 255U, 255U, 255U},
6549
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U,
6550
                        255U, 255U, 255U, 255U},
6551
                       {6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U,
6552
                        255U, 255U, 255U, 255U, 255U},
6553
                       {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U,
6554
                        255U, 255U, 255U, 255U},
6555
                       {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U,
6556
                        255U, 255U, 255U, 255U},
6557
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U,
6558
                        255U, 255U, 255U, 255U},
6559
                       {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U,
6560
                        255U, 255U, 255U, 255U},
6561
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U,
6562
                        255U, 255U, 255U, 255U},
6563
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U,
6564
                        255U, 255U, 255U, 255U},
6565
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U,
6566
                        15U, 255U, 255U},
6567
                       {12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U,
6568
                        255U, 255U, 255U, 255U, 255U, 255U},
6569
                       {0U, 1U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U,
6570
                        255U, 255U, 255U, 255U, 255U, 255U},
6571
                       {2U, 3U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U,
6572
                        255U, 255U, 255U, 255U, 255U, 255U},
6573
                       {0U, 1U, 2U, 3U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6574
                        255U, 255U, 255U, 255U, 255U},
6575
                       {4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U,
6576
                        255U, 255U, 255U, 255U, 255U, 255U},
6577
                       {0U, 1U, 4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6578
                        255U, 255U, 255U, 255U, 255U},
6579
                       {2U, 3U, 4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6580
                        255U, 255U, 255U, 255U, 255U},
6581
                       {0U, 1U, 2U, 3U, 4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U,
6582
                        255U, 255U, 255U, 255U},
6583
                       {6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U,
6584
                        255U, 255U, 255U, 255U, 255U, 255U},
6585
                       {0U, 1U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6586
                        255U, 255U, 255U, 255U, 255U},
6587
                       {2U, 3U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6588
                        255U, 255U, 255U, 255U, 255U},
6589
                       {0U, 1U, 2U, 3U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U,
6590
                        255U, 255U, 255U, 255U},
6591
                       {4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6592
                        255U, 255U, 255U, 255U, 255U},
6593
                       {0U, 1U, 4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U,
6594
                        255U, 255U, 255U, 255U},
6595
                       {2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U,
6596
                        255U, 255U, 255U, 255U},
6597
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U,
6598
                        255U, 255U, 255U, 255U},
6599
                       {8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U,
6600
                        255U, 255U, 255U, 255U, 255U, 255U},
6601
                       {0U, 1U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6602
                        255U, 255U, 255U, 255U, 255U},
6603
                       {2U, 3U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6604
                        255U, 255U, 255U, 255U, 255U},
6605
                       {0U, 1U, 2U, 3U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U,
6606
                        255U, 255U, 255U, 255U},
6607
                       {4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6608
                        255U, 255U, 255U, 255U, 255U},
6609
                       {0U, 1U, 4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U,
6610
                        255U, 255U, 255U, 255U},
6611
                       {2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U,
6612
                        255U, 255U, 255U, 255U},
6613
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U,
6614
                        255U, 255U, 255U, 255U},
6615
                       {6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6616
                        255U, 255U, 255U, 255U, 255U},
6617
                       {0U, 1U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U,
6618
                        255U, 255U, 255U, 255U},
6619
                       {2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U,
6620
                        255U, 255U, 255U, 255U},
6621
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U,
6622
                        255U, 255U, 255U, 255U},
6623
                       {4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U,
6624
                        255U, 255U, 255U, 255U},
6625
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U,
6626
                        255U, 255U, 255U, 255U},
6627
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U,
6628
                        255U, 255U, 255U, 255U},
6629
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U,
6630
                        15U, 255U, 255U},
6631
                       {10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U,
6632
                        255U, 255U, 255U, 255U, 255U, 255U},
6633
                       {0U, 1U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6634
                        255U, 255U, 255U, 255U, 255U},
6635
                       {2U, 3U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6636
                        255U, 255U, 255U, 255U, 255U},
6637
                       {0U, 1U, 2U, 3U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6638
                        255U, 255U, 255U, 255U, 255U},
6639
                       {4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6640
                        255U, 255U, 255U, 255U, 255U},
6641
                       {0U, 1U, 4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6642
                        255U, 255U, 255U, 255U, 255U},
6643
                       {2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6644
                        255U, 255U, 255U, 255U, 255U},
6645
                       {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U,
6646
                        255U, 255U, 255U, 255U},
6647
                       {6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6648
                        255U, 255U, 255U, 255U, 255U},
6649
                       {0U, 1U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6650
                        255U, 255U, 255U, 255U, 255U},
6651
                       {2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6652
                        255U, 255U, 255U, 255U, 255U},
6653
                       {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U,
6654
                        255U, 255U, 255U, 255U},
6655
                       {4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6656
                        255U, 255U, 255U, 255U, 255U},
6657
                       {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U,
6658
                        255U, 255U, 255U, 255U},
6659
                       {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U,
6660
                        255U, 255U, 255U, 255U},
6661
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U,
6662
                        15U, 255U, 255U},
6663
                       {8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U,
6664
                        255U, 255U, 255U, 255U, 255U},
6665
                       {0U, 1U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6666
                        255U, 255U, 255U, 255U, 255U},
6667
                       {2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6668
                        255U, 255U, 255U, 255U, 255U},
6669
                       {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
6670
                        255U, 255U, 255U, 255U},
6671
                       {4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6672
                        255U, 255U, 255U, 255U, 255U},
6673
                       {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
6674
                        255U, 255U, 255U, 255U},
6675
                       {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
6676
                        255U, 255U, 255U, 255U},
6677
                       {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U,
6678
                        15U, 255U, 255U},
6679
                       {6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U,
6680
                        255U, 255U, 255U, 255U, 255U},
6681
                       {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
6682
                        255U, 255U, 255U, 255U},
6683
                       {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
6684
                        255U, 255U, 255U, 255U},
6685
                       {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U,
6686
                        15U, 255U, 255U},
6687
                       {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
6688
                        255U, 255U, 255U, 255U},
6689
                       {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U,
6690
                        15U, 255U, 255U},
6691
                       {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U,
6692
                        15U, 255U, 255U},
6693
                       {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U,
6694
                        13U, 14U, 15U}};
6695
6696
/**
6697
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6698
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6699
*/
6700
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6701
0
libcrux_ml_kem_vector_portable_ZERO_0d(void) {
6702
0
  return libcrux_ml_kem_vector_portable_vector_type_zero();
6703
0
}
6704
6705
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6706
libcrux_ml_kem_vector_portable_arithmetic_add(
6707
    libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs,
6708
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
6709
0
  for (size_t i = (size_t)0U;
6710
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
6711
0
    size_t i0 = i;
6712
0
    size_t uu____0 = i0;
6713
0
    lhs.elements[uu____0] = lhs.elements[uu____0] + rhs->elements[i0];
6714
0
  }
6715
0
  return lhs;
6716
0
}
6717
6718
/**
6719
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6720
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6721
*/
6722
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6723
libcrux_ml_kem_vector_portable_add_0d(
6724
    libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs,
6725
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
6726
0
  return libcrux_ml_kem_vector_portable_arithmetic_add(lhs, rhs);
6727
0
}
6728
6729
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6730
libcrux_ml_kem_vector_portable_arithmetic_sub(
6731
    libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs,
6732
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
6733
0
  for (size_t i = (size_t)0U;
6734
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
6735
0
    size_t i0 = i;
6736
0
    size_t uu____0 = i0;
6737
0
    lhs.elements[uu____0] = lhs.elements[uu____0] - rhs->elements[i0];
6738
0
  }
6739
0
  return lhs;
6740
0
}
6741
6742
/**
6743
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6744
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6745
*/
6746
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6747
libcrux_ml_kem_vector_portable_sub_0d(
6748
    libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs,
6749
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
6750
0
  return libcrux_ml_kem_vector_portable_arithmetic_sub(lhs, rhs);
6751
0
}
6752
6753
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6754
libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(
6755
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
6756
0
  for (size_t i = (size_t)0U;
6757
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
6758
0
    size_t i0 = i;
6759
0
    size_t uu____0 = i0;
6760
0
    v.elements[uu____0] = v.elements[uu____0] * c;
6761
0
  }
6762
0
  return v;
6763
0
}
6764
6765
/**
6766
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6767
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6768
*/
6769
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6770
libcrux_ml_kem_vector_portable_multiply_by_constant_0d(
6771
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
6772
0
  return libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(v, c);
6773
0
}
6774
6775
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6776
libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(
6777
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
6778
0
  for (size_t i = (size_t)0U;
6779
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
6780
0
    size_t i0 = i;
6781
0
    size_t uu____0 = i0;
6782
0
    v.elements[uu____0] = v.elements[uu____0] & c;
6783
0
  }
6784
0
  return v;
6785
0
}
6786
6787
/**
6788
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6789
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6790
*/
6791
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6792
libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d(
6793
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
6794
0
  return libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(v,
6795
0
                                                                             c);
6796
0
}
6797
6798
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6799
libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329(
6800
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
6801
0
  core_ops_range_Range_b3 iter =
6802
0
      core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
6803
0
          (CLITERAL(core_ops_range_Range_b3){
6804
0
              .start = (size_t)0U,
6805
0
              .end = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR}),
6806
0
          core_ops_range_Range_b3, core_ops_range_Range_b3);
6807
0
  while (true) {
6808
0
    Option_b3 uu____0 =
6809
0
        core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
6810
0
            &iter, size_t, Option_b3);
6811
0
    if (!(uu____0.tag == None)) {
6812
0
      size_t i = uu____0.f0;
6813
0
      if (v.elements[i] >= (int16_t)3329) {
6814
0
        size_t uu____1 = i;
6815
0
        v.elements[uu____1] = v.elements[uu____1] - (int16_t)3329;
6816
0
      }
6817
0
      continue;
6818
0
    }
6819
0
    return v;
6820
0
  }
6821
0
}
6822
6823
/**
6824
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6825
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6826
*/
6827
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6828
libcrux_ml_kem_vector_portable_cond_subtract_3329_0d(
6829
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
6830
0
  return libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329(v);
6831
0
}
6832
6833
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER \
6834
0
  ((int32_t)20159)
6835
6836
0
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT ((int32_t)26)
6837
6838
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_R \
6839
0
  ((int32_t)1 << (uint32_t)                                 \
6840
0
       LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT)
6841
6842
/**
6843
 Signed Barrett Reduction
6844
6845
 Given an input `value`, `barrett_reduce` outputs a representative `result`
6846
 such that:
6847
6848
 - result ≡ value (mod FIELD_MODULUS)
6849
 - the absolute value of `result` is bound as follows:
6850
6851
 `|result| ≤ FIELD_MODULUS / 2 · (|value|/BARRETT_R + 1)
6852
6853
 In particular, if `|value| < BARRETT_R`, then `|result| < FIELD_MODULUS`.
6854
*/
6855
static inline int16_t
6856
libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
6857
0
    int16_t value) {
6858
0
  int32_t t = (int32_t)value *
6859
0
                  LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER +
6860
0
              (LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_R >> 1U);
6861
0
  int16_t quotient =
6862
0
      (int16_t)(t >>
6863
0
                (uint32_t)
6864
0
                    LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT);
6865
0
  return value - quotient * LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
6866
0
}
6867
6868
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6869
libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(
6870
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
6871
0
  for (size_t i = (size_t)0U;
6872
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
6873
0
    size_t i0 = i;
6874
0
    v.elements[i0] =
6875
0
        libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
6876
0
            v.elements[i0]);
6877
0
  }
6878
0
  return v;
6879
0
}
6880
6881
/**
6882
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6883
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6884
*/
6885
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6886
libcrux_ml_kem_vector_portable_barrett_reduce_0d(
6887
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
6888
0
  return libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(v);
6889
0
}
6890
6891
0
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
6892
6893
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_R \
6894
  ((int32_t)1 << (uint32_t)                                    \
6895
       LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT)
6896
6897
/**
6898
 Signed Montgomery Reduction
6899
6900
 Given an input `value`, `montgomery_reduce` outputs a representative `o`
6901
 such that:
6902
6903
 - o ≡ value · MONTGOMERY_R^(-1) (mod FIELD_MODULUS)
6904
 - the absolute value of `o` is bound as follows:
6905
6906
 `|result| ≤ (|value| / MONTGOMERY_R) + (FIELD_MODULUS / 2)
6907
6908
 In particular, if `|value| ≤ FIELD_MODULUS * MONTGOMERY_R`, then `|o| < (3 ·
6909
 FIELD_MODULUS) / 2`.
6910
*/
6911
static inline int16_t
6912
libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
6913
0
    int32_t value) {
6914
0
  int32_t k =
6915
0
      (int32_t)(int16_t)value *
6916
0
      (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R;
6917
0
  int32_t k_times_modulus =
6918
0
      (int32_t)(int16_t)k * (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
6919
0
  int16_t c =
6920
0
      (int16_t)(k_times_modulus >>
6921
0
                (uint32_t)
6922
0
                    LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
6923
0
  int16_t value_high =
6924
0
      (int16_t)(value >>
6925
0
                (uint32_t)
6926
0
                    LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
6927
0
  return value_high - c;
6928
0
}
6929
6930
/**
6931
 If `fe` is some field element 'x' of the Kyber field and `fer` is congruent to
6932
 `y · MONTGOMERY_R`, this procedure outputs a value that is congruent to
6933
 `x · y`, as follows:
6934
6935
    `fe · fer ≡ x · y · MONTGOMERY_R (mod FIELD_MODULUS)`
6936
6937
 `montgomery_reduce` takes the value `x · y · MONTGOMERY_R` and outputs a
6938
 representative `x · y · MONTGOMERY_R * MONTGOMERY_R^{-1} ≡ x · y (mod
6939
 FIELD_MODULUS)`.
6940
*/
6941
static KRML_MUSTINLINE int16_t
6942
libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
6943
0
    int16_t fe, int16_t fer) {
6944
0
  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
6945
0
      (int32_t)fe * (int32_t)fer);
6946
0
}
6947
6948
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
6949
libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(
6950
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
6951
0
  for (size_t i = (size_t)0U;
6952
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
6953
0
    size_t i0 = i;
6954
0
    v.elements[i0] =
6955
0
        libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
6956
0
            v.elements[i0], c);
6957
0
  }
6958
0
  return v;
6959
0
}
6960
6961
/**
6962
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
6963
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
6964
*/
6965
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
6966
libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(
6967
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t r) {
6968
0
  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(
6969
0
      v, r);
6970
0
}
6971
6972
/**
6973
 The `compress_*` functions implement the `Compress` function specified in the
6974
 NIST FIPS 203 standard (Page 18, Expression 4.5), which is defined as:
6975
6976
 ```plaintext
6977
 Compress_d: ℤq -> ℤ_{2ᵈ}
6978
 Compress_d(x) = ⌈(2ᵈ/q)·x⌋
6979
 ```
6980
6981
 Since `⌈x⌋ = ⌊x + 1/2⌋` we have:
6982
6983
 ```plaintext
6984
 Compress_d(x) = ⌊(2ᵈ/q)·x + 1/2⌋
6985
               = ⌊(2^{d+1}·x + q) / 2q⌋
6986
 ```
6987
6988
 For further information about the function implementations, consult the
6989
 `implementation_notes.pdf` document in this directory.
6990
6991
 The NIST FIPS 203 standard can be found at
6992
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
6993
*/
6994
static inline uint8_t
6995
libcrux_ml_kem_vector_portable_compress_compress_message_coefficient(
6996
0
    uint16_t fe) {
6997
0
  int16_t shifted = (int16_t)1664 - (int16_t)fe;
6998
0
  int16_t mask = shifted >> 15U;
6999
0
  int16_t shifted_to_positive = mask ^ shifted;
7000
0
  int16_t shifted_positive_in_range = shifted_to_positive - (int16_t)832;
7001
0
  return (uint8_t)(shifted_positive_in_range >> 15U & (int16_t)1);
7002
0
}
7003
7004
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7005
libcrux_ml_kem_vector_portable_compress_compress_1(
7006
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
7007
0
  for (size_t i = (size_t)0U;
7008
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
7009
0
    size_t i0 = i;
7010
0
    v.elements[i0] = (int16_t)
7011
0
        libcrux_ml_kem_vector_portable_compress_compress_message_coefficient(
7012
0
            (uint16_t)v.elements[i0]);
7013
0
  }
7014
0
  return v;
7015
0
}
7016
7017
/**
7018
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7019
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7020
*/
7021
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7022
libcrux_ml_kem_vector_portable_compress_1_0d(
7023
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
7024
0
  return libcrux_ml_kem_vector_portable_compress_compress_1(v);
7025
0
}
7026
7027
static KRML_MUSTINLINE uint32_t
7028
libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits(
7029
0
    uint8_t n, uint32_t value) {
7030
0
  return value & ((1U << (uint32_t)n) - 1U);
7031
0
}
7032
7033
static inline int16_t
7034
libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
7035
0
    uint8_t coefficient_bits, uint16_t fe) {
7036
0
  uint64_t compressed = (uint64_t)fe << (uint32_t)coefficient_bits;
7037
0
  compressed = compressed + 1664ULL;
7038
0
  compressed = compressed * 10321340ULL;
7039
0
  compressed = compressed >> 35U;
7040
0
  return (int16_t)
7041
0
      libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits(
7042
0
          coefficient_bits, (uint32_t)compressed);
7043
0
}
7044
7045
static KRML_MUSTINLINE void libcrux_ml_kem_vector_portable_ntt_ntt_step(
7046
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *v, int16_t zeta,
7047
0
    size_t i, size_t j) {
7048
0
  int16_t t =
7049
0
      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
7050
0
          v->elements[j], zeta);
7051
0
  v->elements[j] = v->elements[i] - t;
7052
0
  v->elements[i] = v->elements[i] + t;
7053
0
}
7054
7055
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7056
libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(
7057
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0,
7058
0
    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
7059
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)0U,
7060
0
                                              (size_t)2U);
7061
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)1U,
7062
0
                                              (size_t)3U);
7063
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)4U,
7064
0
                                              (size_t)6U);
7065
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)5U,
7066
0
                                              (size_t)7U);
7067
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta2, (size_t)8U,
7068
0
                                              (size_t)10U);
7069
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta2, (size_t)9U,
7070
0
                                              (size_t)11U);
7071
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta3, (size_t)12U,
7072
0
                                              (size_t)14U);
7073
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta3, (size_t)13U,
7074
0
                                              (size_t)15U);
7075
0
  return v;
7076
0
}
7077
7078
/**
7079
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7080
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7081
*/
7082
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7083
libcrux_ml_kem_vector_portable_ntt_layer_1_step_0d(
7084
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0,
7085
0
    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
7086
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(a, zeta0, zeta1,
7087
0
                                                             zeta2, zeta3);
7088
0
}
7089
7090
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7091
libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(
7092
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0,
7093
0
    int16_t zeta1) {
7094
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)0U,
7095
0
                                              (size_t)4U);
7096
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)1U,
7097
0
                                              (size_t)5U);
7098
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)2U,
7099
0
                                              (size_t)6U);
7100
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)3U,
7101
0
                                              (size_t)7U);
7102
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)8U,
7103
0
                                              (size_t)12U);
7104
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)9U,
7105
0
                                              (size_t)13U);
7106
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)10U,
7107
0
                                              (size_t)14U);
7108
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)11U,
7109
0
                                              (size_t)15U);
7110
0
  return v;
7111
0
}
7112
7113
/**
7114
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7115
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7116
*/
7117
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7118
libcrux_ml_kem_vector_portable_ntt_layer_2_step_0d(
7119
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0,
7120
0
    int16_t zeta1) {
7121
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(a, zeta0, zeta1);
7122
0
}
7123
7124
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7125
libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(
7126
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta) {
7127
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)0U, (size_t)8U);
7128
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)1U, (size_t)9U);
7129
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)2U,
7130
0
                                              (size_t)10U);
7131
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)3U,
7132
0
                                              (size_t)11U);
7133
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)4U,
7134
0
                                              (size_t)12U);
7135
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)5U,
7136
0
                                              (size_t)13U);
7137
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)6U,
7138
0
                                              (size_t)14U);
7139
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)7U,
7140
0
                                              (size_t)15U);
7141
0
  return v;
7142
0
}
7143
7144
/**
7145
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7146
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7147
*/
7148
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7149
libcrux_ml_kem_vector_portable_ntt_layer_3_step_0d(
7150
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) {
7151
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(a, zeta);
7152
0
}
7153
7154
static KRML_MUSTINLINE void libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(
7155
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *v, int16_t zeta,
7156
0
    size_t i, size_t j) {
7157
0
  int16_t a_minus_b = v->elements[j] - v->elements[i];
7158
0
  v->elements[i] =
7159
0
      libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
7160
0
          v->elements[i] + v->elements[j]);
7161
0
  v->elements[j] =
7162
0
      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
7163
0
          a_minus_b, zeta);
7164
0
}
7165
7166
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7167
libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step(
7168
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0,
7169
0
    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
7170
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)0U,
7171
0
                                                  (size_t)2U);
7172
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)1U,
7173
0
                                                  (size_t)3U);
7174
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)4U,
7175
0
                                                  (size_t)6U);
7176
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)5U,
7177
0
                                                  (size_t)7U);
7178
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta2, (size_t)8U,
7179
0
                                                  (size_t)10U);
7180
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta2, (size_t)9U,
7181
0
                                                  (size_t)11U);
7182
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta3, (size_t)12U,
7183
0
                                                  (size_t)14U);
7184
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta3, (size_t)13U,
7185
0
                                                  (size_t)15U);
7186
0
  return v;
7187
0
}
7188
7189
/**
7190
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7191
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7192
*/
7193
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7194
libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_0d(
7195
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0,
7196
0
    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
7197
0
  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step(
7198
0
      a, zeta0, zeta1, zeta2, zeta3);
7199
0
}
7200
7201
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7202
libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step(
7203
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0,
7204
0
    int16_t zeta1) {
7205
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)0U,
7206
0
                                                  (size_t)4U);
7207
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)1U,
7208
0
                                                  (size_t)5U);
7209
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)2U,
7210
0
                                                  (size_t)6U);
7211
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)3U,
7212
0
                                                  (size_t)7U);
7213
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)8U,
7214
0
                                                  (size_t)12U);
7215
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)9U,
7216
0
                                                  (size_t)13U);
7217
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)10U,
7218
0
                                                  (size_t)14U);
7219
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)11U,
7220
0
                                                  (size_t)15U);
7221
0
  return v;
7222
0
}
7223
7224
/**
7225
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7226
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7227
*/
7228
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7229
libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_0d(
7230
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0,
7231
0
    int16_t zeta1) {
7232
0
  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step(a, zeta0,
7233
0
                                                                 zeta1);
7234
0
}
7235
7236
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7237
libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step(
7238
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta) {
7239
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)0U,
7240
0
                                                  (size_t)8U);
7241
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)1U,
7242
0
                                                  (size_t)9U);
7243
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)2U,
7244
0
                                                  (size_t)10U);
7245
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)3U,
7246
0
                                                  (size_t)11U);
7247
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)4U,
7248
0
                                                  (size_t)12U);
7249
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)5U,
7250
0
                                                  (size_t)13U);
7251
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)6U,
7252
0
                                                  (size_t)14U);
7253
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)7U,
7254
0
                                                  (size_t)15U);
7255
0
  return v;
7256
0
}
7257
7258
/**
7259
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7260
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7261
*/
7262
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7263
libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_0d(
7264
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) {
7265
0
  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step(a, zeta);
7266
0
}
7267
7268
/**
7269
 Compute the product of two Kyber binomials with respect to the
7270
 modulus `X² - zeta`.
7271
7272
 This function almost implements <strong>Algorithm 11</strong> of the
7273
 NIST FIPS 203 standard, which is reproduced below:
7274
7275
 ```plaintext
7276
 Input:  a₀, a₁, b₀, b₁ ∈ ℤq.
7277
 Input: γ ∈ ℤq.
7278
 Output: c₀, c₁ ∈ ℤq.
7279
7280
 c₀ ← a₀·b₀ + a₁·b₁·γ
7281
 c₁ ← a₀·b₁ + a₁·b₀
7282
 return c₀, c₁
7283
 ```
7284
 We say "almost" because the coefficients output by this function are in
7285
 the Montgomery domain (unlike in the specification).
7286
7287
 The NIST FIPS 203 standard can be found at
7288
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
7289
*/
7290
static KRML_MUSTINLINE void
7291
libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7292
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *a,
7293
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *b, int16_t zeta,
7294
    size_t i, size_t j,
7295
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *out) {
7296
0
  int16_t o0 = libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
7297
0
      (int32_t)a->elements[i] * (int32_t)b->elements[i] +
7298
0
      (int32_t)
7299
0
              libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
7300
0
                  (int32_t)a->elements[j] * (int32_t)b->elements[j]) *
7301
0
          (int32_t)zeta);
7302
0
  int16_t o1 =
7303
0
      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
7304
0
          (int32_t)a->elements[i] * (int32_t)b->elements[j] +
7305
0
          (int32_t)a->elements[j] * (int32_t)b->elements[i]);
7306
0
  out->elements[i] = o0;
7307
0
  out->elements[j] = o1;
7308
0
}
7309
7310
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7311
libcrux_ml_kem_vector_portable_ntt_ntt_multiply(
7312
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *lhs,
7313
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs,
7314
0
    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
7315
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector out =
7316
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
7317
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7318
0
      lhs, rhs, zeta0, (size_t)0U, (size_t)1U, &out);
7319
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7320
0
      lhs, rhs, -zeta0, (size_t)2U, (size_t)3U, &out);
7321
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7322
0
      lhs, rhs, zeta1, (size_t)4U, (size_t)5U, &out);
7323
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7324
0
      lhs, rhs, -zeta1, (size_t)6U, (size_t)7U, &out);
7325
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7326
0
      lhs, rhs, zeta2, (size_t)8U, (size_t)9U, &out);
7327
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7328
0
      lhs, rhs, -zeta2, (size_t)10U, (size_t)11U, &out);
7329
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7330
0
      lhs, rhs, zeta3, (size_t)12U, (size_t)13U, &out);
7331
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
7332
0
      lhs, rhs, -zeta3, (size_t)14U, (size_t)15U, &out);
7333
0
  return out;
7334
0
}
7335
7336
/**
7337
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7338
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7339
*/
7340
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7341
libcrux_ml_kem_vector_portable_ntt_multiply_0d(
7342
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *lhs,
7343
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs,
7344
0
    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
7345
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_multiply(lhs, rhs, zeta0, zeta1,
7346
0
                                                         zeta2, zeta3);
7347
0
}
7348
7349
static KRML_MUSTINLINE void
7350
libcrux_ml_kem_vector_portable_serialize_serialize_1(
7351
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v,
7352
0
    uint8_t ret[2U]) {
7353
0
  uint8_t result[2U] = {0U};
7354
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++) {
7355
0
    size_t i0 = i;
7356
0
    size_t uu____0 = (size_t)0U;
7357
0
    result[uu____0] = (uint32_t)result[uu____0] |
7358
0
                      (uint32_t)(uint8_t)v.elements[i0] << (uint32_t)i0;
7359
0
  }
7360
0
  for (size_t i = (size_t)8U; i < (size_t)16U; i++) {
7361
0
    size_t i0 = i;
7362
0
    size_t uu____1 = (size_t)1U;
7363
0
    result[uu____1] =
7364
0
        (uint32_t)result[uu____1] | (uint32_t)(uint8_t)v.elements[i0]
7365
0
                                        << (uint32_t)(i0 - (size_t)8U);
7366
0
  }
7367
0
  memcpy(ret, result, (size_t)2U * sizeof(uint8_t));
7368
0
}
7369
7370
/**
7371
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7372
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7373
*/
7374
static inline void libcrux_ml_kem_vector_portable_serialize_1_0d(
7375
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
7376
0
    uint8_t ret[2U]) {
7377
0
  libcrux_ml_kem_vector_portable_serialize_serialize_1(a, ret);
7378
0
}
7379
7380
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7381
0
libcrux_ml_kem_vector_portable_serialize_deserialize_1(Eurydice_slice v) {
7382
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector result =
7383
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
7384
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++) {
7385
0
    size_t i0 = i;
7386
0
    result.elements[i0] = (int16_t)((uint32_t)Eurydice_slice_index(
7387
0
                                        v, (size_t)0U, uint8_t, uint8_t *) >>
7388
0
                                        (uint32_t)i0 &
7389
0
                                    1U);
7390
0
  }
7391
0
  for (size_t i = (size_t)8U;
7392
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
7393
0
    size_t i0 = i;
7394
0
    result.elements[i0] = (int16_t)((uint32_t)Eurydice_slice_index(
7395
0
                                        v, (size_t)1U, uint8_t, uint8_t *) >>
7396
0
                                        (uint32_t)(i0 - (size_t)8U) &
7397
0
                                    1U);
7398
0
  }
7399
0
  return result;
7400
0
}
7401
7402
/**
7403
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7404
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7405
*/
7406
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7407
0
libcrux_ml_kem_vector_portable_deserialize_1_0d(Eurydice_slice a) {
7408
0
  return libcrux_ml_kem_vector_portable_serialize_deserialize_1(a);
7409
0
}
7410
7411
typedef struct uint8_t_x4_s {
7412
  uint8_t fst;
7413
  uint8_t snd;
7414
  uint8_t thd;
7415
  uint8_t f3;
7416
} uint8_t_x4;
7417
7418
static KRML_MUSTINLINE uint8_t_x4
7419
0
libcrux_ml_kem_vector_portable_serialize_serialize_4_int(Eurydice_slice v) {
7420
0
  uint8_t result0 =
7421
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *)
7422
0
          << 4U |
7423
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)0U, int16_t,
7424
0
                                              int16_t *);
7425
0
  uint8_t result1 =
7426
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *)
7427
0
          << 4U |
7428
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)2U, int16_t,
7429
0
                                              int16_t *);
7430
0
  uint8_t result2 =
7431
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *)
7432
0
          << 4U |
7433
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)4U, int16_t,
7434
0
                                              int16_t *);
7435
0
  uint8_t result3 =
7436
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *)
7437
0
          << 4U |
7438
0
      (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)6U, int16_t,
7439
0
                                              int16_t *);
7440
0
  return (CLITERAL(uint8_t_x4){
7441
0
      .fst = result0, .snd = result1, .thd = result2, .f3 = result3});
7442
0
}
7443
7444
static KRML_MUSTINLINE void
7445
libcrux_ml_kem_vector_portable_serialize_serialize_4(
7446
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v,
7447
0
    uint8_t ret[8U]) {
7448
0
  uint8_t_x4 result0_3 =
7449
0
      libcrux_ml_kem_vector_portable_serialize_serialize_4_int(
7450
0
          Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)8U,
7451
0
                                      int16_t));
7452
0
  uint8_t_x4 result4_7 =
7453
0
      libcrux_ml_kem_vector_portable_serialize_serialize_4_int(
7454
0
          Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)16U,
7455
0
                                      int16_t));
7456
0
  uint8_t result[8U] = {0U};
7457
0
  result[0U] = result0_3.fst;
7458
0
  result[1U] = result0_3.snd;
7459
0
  result[2U] = result0_3.thd;
7460
0
  result[3U] = result0_3.f3;
7461
0
  result[4U] = result4_7.fst;
7462
0
  result[5U] = result4_7.snd;
7463
0
  result[6U] = result4_7.thd;
7464
0
  result[7U] = result4_7.f3;
7465
0
  memcpy(ret, result, (size_t)8U * sizeof(uint8_t));
7466
0
}
7467
7468
/**
7469
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7470
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7471
*/
7472
static inline void libcrux_ml_kem_vector_portable_serialize_4_0d(
7473
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
7474
0
    uint8_t ret[8U]) {
7475
0
  libcrux_ml_kem_vector_portable_serialize_serialize_4(a, ret);
7476
0
}
7477
7478
static KRML_MUSTINLINE int16_t_x8
7479
libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(
7480
0
    Eurydice_slice bytes) {
7481
0
  int16_t v0 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)0U,
7482
0
                                                        uint8_t, uint8_t *) &
7483
0
                         15U);
7484
0
  int16_t v1 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)0U,
7485
0
                                                        uint8_t, uint8_t *) >>
7486
0
                             4U &
7487
0
                         15U);
7488
0
  int16_t v2 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)1U,
7489
0
                                                        uint8_t, uint8_t *) &
7490
0
                         15U);
7491
0
  int16_t v3 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)1U,
7492
0
                                                        uint8_t, uint8_t *) >>
7493
0
                             4U &
7494
0
                         15U);
7495
0
  int16_t v4 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)2U,
7496
0
                                                        uint8_t, uint8_t *) &
7497
0
                         15U);
7498
0
  int16_t v5 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)2U,
7499
0
                                                        uint8_t, uint8_t *) >>
7500
0
                             4U &
7501
0
                         15U);
7502
0
  int16_t v6 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)3U,
7503
0
                                                        uint8_t, uint8_t *) &
7504
0
                         15U);
7505
0
  int16_t v7 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)3U,
7506
0
                                                        uint8_t, uint8_t *) >>
7507
0
                             4U &
7508
0
                         15U);
7509
0
  return (CLITERAL(int16_t_x8){.fst = v0,
7510
0
                               .snd = v1,
7511
0
                               .thd = v2,
7512
0
                               .f3 = v3,
7513
0
                               .f4 = v4,
7514
0
                               .f5 = v5,
7515
0
                               .f6 = v6,
7516
0
                               .f7 = v7});
7517
0
}
7518
7519
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7520
0
libcrux_ml_kem_vector_portable_serialize_deserialize_4(Eurydice_slice bytes) {
7521
0
  int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(
7522
0
      Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)4U, uint8_t));
7523
0
  int16_t_x8 v8_15 = libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(
7524
0
      Eurydice_slice_subslice2(bytes, (size_t)4U, (size_t)8U, uint8_t));
7525
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector v =
7526
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
7527
0
  v.elements[0U] = v0_7.fst;
7528
0
  v.elements[1U] = v0_7.snd;
7529
0
  v.elements[2U] = v0_7.thd;
7530
0
  v.elements[3U] = v0_7.f3;
7531
0
  v.elements[4U] = v0_7.f4;
7532
0
  v.elements[5U] = v0_7.f5;
7533
0
  v.elements[6U] = v0_7.f6;
7534
0
  v.elements[7U] = v0_7.f7;
7535
0
  v.elements[8U] = v8_15.fst;
7536
0
  v.elements[9U] = v8_15.snd;
7537
0
  v.elements[10U] = v8_15.thd;
7538
0
  v.elements[11U] = v8_15.f3;
7539
0
  v.elements[12U] = v8_15.f4;
7540
0
  v.elements[13U] = v8_15.f5;
7541
0
  v.elements[14U] = v8_15.f6;
7542
0
  v.elements[15U] = v8_15.f7;
7543
0
  return v;
7544
0
}
7545
7546
/**
7547
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7548
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7549
*/
7550
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7551
0
libcrux_ml_kem_vector_portable_deserialize_4_0d(Eurydice_slice a) {
7552
0
  return libcrux_ml_kem_vector_portable_serialize_deserialize_4(a);
7553
0
}
7554
7555
typedef struct uint8_t_x5_s {
7556
  uint8_t fst;
7557
  uint8_t snd;
7558
  uint8_t thd;
7559
  uint8_t f3;
7560
  uint8_t f4;
7561
} uint8_t_x5;
7562
7563
static KRML_MUSTINLINE uint8_t_x5
7564
0
libcrux_ml_kem_vector_portable_serialize_serialize_5_int(Eurydice_slice v) {
7565
0
  uint8_t r0 =
7566
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) |
7567
0
                Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) << 5U);
7568
0
  uint8_t r1 =
7569
0
      (uint8_t)((Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 3U |
7570
0
                 Eurydice_slice_index(v, (size_t)2U, int16_t, int16_t *)
7571
0
                     << 2U) |
7572
0
                Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) << 7U);
7573
0
  uint8_t r2 =
7574
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) >> 1U |
7575
0
                Eurydice_slice_index(v, (size_t)4U, int16_t, int16_t *) << 4U);
7576
0
  uint8_t r3 =
7577
0
      (uint8_t)((Eurydice_slice_index(v, (size_t)4U, int16_t, int16_t *) >> 4U |
7578
0
                 Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *)
7579
0
                     << 1U) |
7580
0
                Eurydice_slice_index(v, (size_t)6U, int16_t, int16_t *) << 6U);
7581
0
  uint8_t r4 =
7582
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)6U, int16_t, int16_t *) >> 2U |
7583
0
                Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *) << 3U);
7584
0
  return (CLITERAL(uint8_t_x5){
7585
0
      .fst = r0, .snd = r1, .thd = r2, .f3 = r3, .f4 = r4});
7586
0
}
7587
7588
static KRML_MUSTINLINE void
7589
libcrux_ml_kem_vector_portable_serialize_serialize_5(
7590
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v,
7591
0
    uint8_t ret[10U]) {
7592
0
  uint8_t_x5 r0_4 = libcrux_ml_kem_vector_portable_serialize_serialize_5_int(
7593
0
      Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)8U, int16_t));
7594
0
  uint8_t_x5 r5_9 = libcrux_ml_kem_vector_portable_serialize_serialize_5_int(
7595
0
      Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)16U,
7596
0
                                  int16_t));
7597
0
  uint8_t result[10U] = {0U};
7598
0
  result[0U] = r0_4.fst;
7599
0
  result[1U] = r0_4.snd;
7600
0
  result[2U] = r0_4.thd;
7601
0
  result[3U] = r0_4.f3;
7602
0
  result[4U] = r0_4.f4;
7603
0
  result[5U] = r5_9.fst;
7604
0
  result[6U] = r5_9.snd;
7605
0
  result[7U] = r5_9.thd;
7606
0
  result[8U] = r5_9.f3;
7607
0
  result[9U] = r5_9.f4;
7608
0
  memcpy(ret, result, (size_t)10U * sizeof(uint8_t));
7609
0
}
7610
7611
/**
7612
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7613
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7614
*/
7615
static inline void libcrux_ml_kem_vector_portable_serialize_5_0d(
7616
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
7617
0
    uint8_t ret[10U]) {
7618
0
  libcrux_ml_kem_vector_portable_serialize_serialize_5(a, ret);
7619
0
}
7620
7621
static KRML_MUSTINLINE int16_t_x8
7622
libcrux_ml_kem_vector_portable_serialize_deserialize_5_int(
7623
0
    Eurydice_slice bytes) {
7624
0
  int16_t v0 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)0U,
7625
0
                                                        uint8_t, uint8_t *) &
7626
0
                         31U);
7627
0
  int16_t v1 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)1U,
7628
0
                                                         uint8_t, uint8_t *) &
7629
0
                          3U) << 3U |
7630
0
                         (uint32_t)Eurydice_slice_index(bytes, (size_t)0U,
7631
0
                                                        uint8_t, uint8_t *) >>
7632
0
                             5U);
7633
0
  int16_t v2 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)1U,
7634
0
                                                        uint8_t, uint8_t *) >>
7635
0
                             2U &
7636
0
                         31U);
7637
0
  int16_t v3 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)2U,
7638
0
                                                         uint8_t, uint8_t *) &
7639
0
                          15U)
7640
0
                             << 1U |
7641
0
                         (uint32_t)Eurydice_slice_index(bytes, (size_t)1U,
7642
0
                                                        uint8_t, uint8_t *) >>
7643
0
                             7U);
7644
0
  int16_t v4 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)3U,
7645
0
                                                         uint8_t, uint8_t *) &
7646
0
                          1U) << 4U |
7647
0
                         (uint32_t)Eurydice_slice_index(bytes, (size_t)2U,
7648
0
                                                        uint8_t, uint8_t *) >>
7649
0
                             4U);
7650
0
  int16_t v5 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)3U,
7651
0
                                                        uint8_t, uint8_t *) >>
7652
0
                             1U &
7653
0
                         31U);
7654
0
  int16_t v6 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)4U,
7655
0
                                                         uint8_t, uint8_t *) &
7656
0
                          7U) << 2U |
7657
0
                         (uint32_t)Eurydice_slice_index(bytes, (size_t)3U,
7658
0
                                                        uint8_t, uint8_t *) >>
7659
0
                             6U);
7660
0
  int16_t v7 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)4U,
7661
0
                                                        uint8_t, uint8_t *) >>
7662
0
                         3U);
7663
0
  return (CLITERAL(int16_t_x8){.fst = v0,
7664
0
                               .snd = v1,
7665
0
                               .thd = v2,
7666
0
                               .f3 = v3,
7667
0
                               .f4 = v4,
7668
0
                               .f5 = v5,
7669
0
                               .f6 = v6,
7670
0
                               .f7 = v7});
7671
0
}
7672
7673
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7674
0
libcrux_ml_kem_vector_portable_serialize_deserialize_5(Eurydice_slice bytes) {
7675
0
  int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_5_int(
7676
0
      Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)5U, uint8_t));
7677
0
  int16_t_x8 v8_15 = libcrux_ml_kem_vector_portable_serialize_deserialize_5_int(
7678
0
      Eurydice_slice_subslice2(bytes, (size_t)5U, (size_t)10U, uint8_t));
7679
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector v =
7680
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
7681
0
  v.elements[0U] = v0_7.fst;
7682
0
  v.elements[1U] = v0_7.snd;
7683
0
  v.elements[2U] = v0_7.thd;
7684
0
  v.elements[3U] = v0_7.f3;
7685
0
  v.elements[4U] = v0_7.f4;
7686
0
  v.elements[5U] = v0_7.f5;
7687
0
  v.elements[6U] = v0_7.f6;
7688
0
  v.elements[7U] = v0_7.f7;
7689
0
  v.elements[8U] = v8_15.fst;
7690
0
  v.elements[9U] = v8_15.snd;
7691
0
  v.elements[10U] = v8_15.thd;
7692
0
  v.elements[11U] = v8_15.f3;
7693
0
  v.elements[12U] = v8_15.f4;
7694
0
  v.elements[13U] = v8_15.f5;
7695
0
  v.elements[14U] = v8_15.f6;
7696
0
  v.elements[15U] = v8_15.f7;
7697
0
  return v;
7698
0
}
7699
7700
/**
7701
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7702
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7703
*/
7704
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7705
0
libcrux_ml_kem_vector_portable_deserialize_5_0d(Eurydice_slice a) {
7706
0
  return libcrux_ml_kem_vector_portable_serialize_deserialize_5(a);
7707
0
}
7708
7709
static KRML_MUSTINLINE uint8_t_x5
7710
0
libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_slice v) {
7711
0
  uint8_t r0 =
7712
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) &
7713
0
                (int16_t)255);
7714
0
  uint8_t r1 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t,
7715
0
                                                        int16_t *) &
7716
0
                                   (int16_t)63)
7717
0
                   << 2U |
7718
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t,
7719
0
                                                        int16_t *) >>
7720
0
                                       8U &
7721
0
                                   (int16_t)3);
7722
0
  uint8_t r2 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t,
7723
0
                                                        int16_t *) &
7724
0
                                   (int16_t)15)
7725
0
                   << 4U |
7726
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t,
7727
0
                                                        int16_t *) >>
7728
0
                                       6U &
7729
0
                                   (int16_t)15);
7730
0
  uint8_t r3 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t,
7731
0
                                                        int16_t *) &
7732
0
                                   (int16_t)3)
7733
0
                   << 6U |
7734
0
               (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t,
7735
0
                                                        int16_t *) >>
7736
0
                                       4U &
7737
0
                                   (int16_t)63);
7738
0
  uint8_t r4 =
7739
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) >> 2U &
7740
0
                (int16_t)255);
7741
0
  return (CLITERAL(uint8_t_x5){
7742
0
      .fst = r0, .snd = r1, .thd = r2, .f3 = r3, .f4 = r4});
7743
0
}
7744
7745
static KRML_MUSTINLINE void
7746
libcrux_ml_kem_vector_portable_serialize_serialize_10(
7747
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v,
7748
0
    uint8_t ret[20U]) {
7749
0
  uint8_t_x5 r0_4 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
7750
0
      Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)4U, int16_t));
7751
0
  uint8_t_x5 r5_9 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
7752
0
      Eurydice_array_to_subslice2(v.elements, (size_t)4U, (size_t)8U, int16_t));
7753
0
  uint8_t_x5 r10_14 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
7754
0
      Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)12U,
7755
0
                                  int16_t));
7756
0
  uint8_t_x5 r15_19 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
7757
0
      Eurydice_array_to_subslice2(v.elements, (size_t)12U, (size_t)16U,
7758
0
                                  int16_t));
7759
0
  uint8_t result[20U] = {0U};
7760
0
  result[0U] = r0_4.fst;
7761
0
  result[1U] = r0_4.snd;
7762
0
  result[2U] = r0_4.thd;
7763
0
  result[3U] = r0_4.f3;
7764
0
  result[4U] = r0_4.f4;
7765
0
  result[5U] = r5_9.fst;
7766
0
  result[6U] = r5_9.snd;
7767
0
  result[7U] = r5_9.thd;
7768
0
  result[8U] = r5_9.f3;
7769
0
  result[9U] = r5_9.f4;
7770
0
  result[10U] = r10_14.fst;
7771
0
  result[11U] = r10_14.snd;
7772
0
  result[12U] = r10_14.thd;
7773
0
  result[13U] = r10_14.f3;
7774
0
  result[14U] = r10_14.f4;
7775
0
  result[15U] = r15_19.fst;
7776
0
  result[16U] = r15_19.snd;
7777
0
  result[17U] = r15_19.thd;
7778
0
  result[18U] = r15_19.f3;
7779
0
  result[19U] = r15_19.f4;
7780
0
  memcpy(ret, result, (size_t)20U * sizeof(uint8_t));
7781
0
}
7782
7783
/**
7784
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7785
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7786
*/
7787
static inline void libcrux_ml_kem_vector_portable_serialize_10_0d(
7788
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
7789
0
    uint8_t ret[20U]) {
7790
0
  libcrux_ml_kem_vector_portable_serialize_serialize_10(a, ret);
7791
0
}
7792
7793
static KRML_MUSTINLINE int16_t_x8
7794
libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(
7795
0
    Eurydice_slice bytes) {
7796
0
  int16_t r0 =
7797
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) &
7798
0
       (int16_t)3)
7799
0
          << 8U |
7800
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *) &
7801
0
       (int16_t)255);
7802
0
  int16_t r1 =
7803
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) &
7804
0
       (int16_t)15)
7805
0
          << 6U |
7806
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) >>
7807
0
          2U;
7808
0
  int16_t r2 =
7809
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) &
7810
0
       (int16_t)63)
7811
0
          << 4U |
7812
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) >>
7813
0
          4U;
7814
0
  int16_t r3 =
7815
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *)
7816
0
          << 2U |
7817
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) >>
7818
0
          6U;
7819
0
  int16_t r4 =
7820
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) &
7821
0
       (int16_t)3)
7822
0
          << 8U |
7823
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *) &
7824
0
       (int16_t)255);
7825
0
  int16_t r5 =
7826
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *) &
7827
0
       (int16_t)15)
7828
0
          << 6U |
7829
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) >>
7830
0
          2U;
7831
0
  int16_t r6 =
7832
0
      ((int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) &
7833
0
       (int16_t)63)
7834
0
          << 4U |
7835
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *) >>
7836
0
          4U;
7837
0
  int16_t r7 =
7838
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *)
7839
0
          << 2U |
7840
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) >>
7841
0
          6U;
7842
0
  return (CLITERAL(int16_t_x8){.fst = r0,
7843
0
                               .snd = r1,
7844
0
                               .thd = r2,
7845
0
                               .f3 = r3,
7846
0
                               .f4 = r4,
7847
0
                               .f5 = r5,
7848
0
                               .f6 = r6,
7849
0
                               .f7 = r7});
7850
0
}
7851
7852
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7853
0
libcrux_ml_kem_vector_portable_serialize_deserialize_10(Eurydice_slice bytes) {
7854
0
  int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(
7855
0
      Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)10U, uint8_t));
7856
0
  int16_t_x8 v8_15 =
7857
0
      libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(
7858
0
          Eurydice_slice_subslice2(bytes, (size_t)10U, (size_t)20U, uint8_t));
7859
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector v =
7860
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
7861
0
  v.elements[0U] = v0_7.fst;
7862
0
  v.elements[1U] = v0_7.snd;
7863
0
  v.elements[2U] = v0_7.thd;
7864
0
  v.elements[3U] = v0_7.f3;
7865
0
  v.elements[4U] = v0_7.f4;
7866
0
  v.elements[5U] = v0_7.f5;
7867
0
  v.elements[6U] = v0_7.f6;
7868
0
  v.elements[7U] = v0_7.f7;
7869
0
  v.elements[8U] = v8_15.fst;
7870
0
  v.elements[9U] = v8_15.snd;
7871
0
  v.elements[10U] = v8_15.thd;
7872
0
  v.elements[11U] = v8_15.f3;
7873
0
  v.elements[12U] = v8_15.f4;
7874
0
  v.elements[13U] = v8_15.f5;
7875
0
  v.elements[14U] = v8_15.f6;
7876
0
  v.elements[15U] = v8_15.f7;
7877
0
  return v;
7878
0
}
7879
7880
/**
7881
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7882
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7883
*/
7884
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
7885
0
libcrux_ml_kem_vector_portable_deserialize_10_0d(Eurydice_slice a) {
7886
0
  return libcrux_ml_kem_vector_portable_serialize_deserialize_10(a);
7887
0
}
7888
7889
typedef struct uint8_t_x3_s {
7890
  uint8_t fst;
7891
  uint8_t snd;
7892
  uint8_t thd;
7893
} uint8_t_x3;
7894
7895
static KRML_MUSTINLINE uint8_t_x3
7896
0
libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_slice v) {
7897
0
  uint8_t r0 =
7898
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) &
7899
0
                (int16_t)255);
7900
0
  uint8_t r1 =
7901
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) >> 8U |
7902
0
                (Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) &
7903
0
                 (int16_t)15)
7904
0
                    << 4U);
7905
0
  uint8_t r2 =
7906
0
      (uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 4U &
7907
0
                (int16_t)255);
7908
0
  return (CLITERAL(uint8_t_x3){.fst = r0, .snd = r1, .thd = r2});
7909
0
}
7910
7911
static KRML_MUSTINLINE void
7912
libcrux_ml_kem_vector_portable_serialize_serialize_12(
7913
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v,
7914
0
    uint8_t ret[24U]) {
7915
0
  uint8_t_x3 r0_2 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7916
0
      Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)2U, int16_t));
7917
0
  uint8_t_x3 r3_5 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7918
0
      Eurydice_array_to_subslice2(v.elements, (size_t)2U, (size_t)4U, int16_t));
7919
0
  uint8_t_x3 r6_8 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7920
0
      Eurydice_array_to_subslice2(v.elements, (size_t)4U, (size_t)6U, int16_t));
7921
0
  uint8_t_x3 r9_11 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7922
0
      Eurydice_array_to_subslice2(v.elements, (size_t)6U, (size_t)8U, int16_t));
7923
0
  uint8_t_x3 r12_14 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7924
0
      Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)10U,
7925
0
                                  int16_t));
7926
0
  uint8_t_x3 r15_17 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7927
0
      Eurydice_array_to_subslice2(v.elements, (size_t)10U, (size_t)12U,
7928
0
                                  int16_t));
7929
0
  uint8_t_x3 r18_20 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7930
0
      Eurydice_array_to_subslice2(v.elements, (size_t)12U, (size_t)14U,
7931
0
                                  int16_t));
7932
0
  uint8_t_x3 r21_23 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
7933
0
      Eurydice_array_to_subslice2(v.elements, (size_t)14U, (size_t)16U,
7934
0
                                  int16_t));
7935
0
  uint8_t result[24U] = {0U};
7936
0
  result[0U] = r0_2.fst;
7937
0
  result[1U] = r0_2.snd;
7938
0
  result[2U] = r0_2.thd;
7939
0
  result[3U] = r3_5.fst;
7940
0
  result[4U] = r3_5.snd;
7941
0
  result[5U] = r3_5.thd;
7942
0
  result[6U] = r6_8.fst;
7943
0
  result[7U] = r6_8.snd;
7944
0
  result[8U] = r6_8.thd;
7945
0
  result[9U] = r9_11.fst;
7946
0
  result[10U] = r9_11.snd;
7947
0
  result[11U] = r9_11.thd;
7948
0
  result[12U] = r12_14.fst;
7949
0
  result[13U] = r12_14.snd;
7950
0
  result[14U] = r12_14.thd;
7951
0
  result[15U] = r15_17.fst;
7952
0
  result[16U] = r15_17.snd;
7953
0
  result[17U] = r15_17.thd;
7954
0
  result[18U] = r18_20.fst;
7955
0
  result[19U] = r18_20.snd;
7956
0
  result[20U] = r18_20.thd;
7957
0
  result[21U] = r21_23.fst;
7958
0
  result[22U] = r21_23.snd;
7959
0
  result[23U] = r21_23.thd;
7960
0
  memcpy(ret, result, (size_t)24U * sizeof(uint8_t));
7961
0
}
7962
7963
/**
7964
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
7965
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
7966
*/
7967
static inline void libcrux_ml_kem_vector_portable_serialize_12_0d(
7968
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
7969
0
    uint8_t ret[24U]) {
7970
0
  libcrux_ml_kem_vector_portable_serialize_serialize_12(a, ret);
7971
0
}
7972
7973
typedef struct int16_t_x2_s {
7974
  int16_t fst;
7975
  int16_t snd;
7976
} int16_t_x2;
7977
7978
static KRML_MUSTINLINE int16_t_x2
7979
libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
7980
0
    Eurydice_slice bytes) {
7981
0
  int16_t byte0 =
7982
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *);
7983
0
  int16_t byte1 =
7984
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *);
7985
0
  int16_t byte2 =
7986
0
      (int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *);
7987
0
  int16_t r0 = (byte1 & (int16_t)15) << 8U | (byte0 & (int16_t)255);
7988
0
  int16_t r1 = byte2 << 4U | (byte1 >> 4U & (int16_t)15);
7989
0
  return (CLITERAL(int16_t_x2){.fst = r0, .snd = r1});
7990
0
}
7991
7992
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
7993
0
libcrux_ml_kem_vector_portable_serialize_deserialize_12(Eurydice_slice bytes) {
7994
0
  int16_t_x2 v0_1 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
7995
0
      Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)3U, uint8_t));
7996
0
  int16_t_x2 v2_3 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
7997
0
      Eurydice_slice_subslice2(bytes, (size_t)3U, (size_t)6U, uint8_t));
7998
0
  int16_t_x2 v4_5 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
7999
0
      Eurydice_slice_subslice2(bytes, (size_t)6U, (size_t)9U, uint8_t));
8000
0
  int16_t_x2 v6_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
8001
0
      Eurydice_slice_subslice2(bytes, (size_t)9U, (size_t)12U, uint8_t));
8002
0
  int16_t_x2 v8_9 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
8003
0
      Eurydice_slice_subslice2(bytes, (size_t)12U, (size_t)15U, uint8_t));
8004
0
  int16_t_x2 v10_11 =
8005
0
      libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
8006
0
          Eurydice_slice_subslice2(bytes, (size_t)15U, (size_t)18U, uint8_t));
8007
0
  int16_t_x2 v12_13 =
8008
0
      libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
8009
0
          Eurydice_slice_subslice2(bytes, (size_t)18U, (size_t)21U, uint8_t));
8010
0
  int16_t_x2 v14_15 =
8011
0
      libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
8012
0
          Eurydice_slice_subslice2(bytes, (size_t)21U, (size_t)24U, uint8_t));
8013
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector re =
8014
0
      libcrux_ml_kem_vector_portable_vector_type_zero();
8015
0
  re.elements[0U] = v0_1.fst;
8016
0
  re.elements[1U] = v0_1.snd;
8017
0
  re.elements[2U] = v2_3.fst;
8018
0
  re.elements[3U] = v2_3.snd;
8019
0
  re.elements[4U] = v4_5.fst;
8020
0
  re.elements[5U] = v4_5.snd;
8021
0
  re.elements[6U] = v6_7.fst;
8022
0
  re.elements[7U] = v6_7.snd;
8023
0
  re.elements[8U] = v8_9.fst;
8024
0
  re.elements[9U] = v8_9.snd;
8025
0
  re.elements[10U] = v10_11.fst;
8026
0
  re.elements[11U] = v10_11.snd;
8027
0
  re.elements[12U] = v12_13.fst;
8028
0
  re.elements[13U] = v12_13.snd;
8029
0
  re.elements[14U] = v14_15.fst;
8030
0
  re.elements[15U] = v14_15.snd;
8031
0
  return re;
8032
0
}
8033
8034
/**
8035
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
8036
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
8037
*/
8038
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
8039
0
libcrux_ml_kem_vector_portable_deserialize_12_0d(Eurydice_slice a) {
8040
0
  return libcrux_ml_kem_vector_portable_serialize_deserialize_12(a);
8041
0
}
8042
8043
static KRML_MUSTINLINE size_t
8044
libcrux_ml_kem_vector_portable_sampling_rej_sample(Eurydice_slice a,
8045
0
                                                   Eurydice_slice result) {
8046
0
  size_t sampled = (size_t)0U;
8047
0
  for (size_t i = (size_t)0U; i < Eurydice_slice_len(a, uint8_t) / (size_t)3U;
8048
0
       i++) {
8049
0
    size_t i0 = i;
8050
0
    int16_t b1 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)0U,
8051
0
                                               uint8_t, uint8_t *);
8052
0
    int16_t b2 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)1U,
8053
0
                                               uint8_t, uint8_t *);
8054
0
    int16_t b3 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)2U,
8055
0
                                               uint8_t, uint8_t *);
8056
0
    int16_t d1 = (b2 & (int16_t)15) << 8U | b1;
8057
0
    int16_t d2 = b3 << 4U | b2 >> 4U;
8058
0
    bool uu____0;
8059
0
    int16_t uu____1;
8060
0
    bool uu____2;
8061
0
    size_t uu____3;
8062
0
    int16_t uu____4;
8063
0
    size_t uu____5;
8064
0
    int16_t uu____6;
8065
0
    if (d1 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) {
8066
0
      if (sampled < (size_t)16U) {
8067
0
        Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d1;
8068
0
        sampled++;
8069
0
        uu____1 = d2;
8070
0
        uu____6 = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
8071
0
        uu____0 = uu____1 < uu____6;
8072
0
        if (uu____0) {
8073
0
          uu____3 = sampled;
8074
0
          uu____2 = uu____3 < (size_t)16U;
8075
0
          if (uu____2) {
8076
0
            uu____4 = d2;
8077
0
            uu____5 = sampled;
8078
0
            Eurydice_slice_index(result, uu____5, int16_t, int16_t *) = uu____4;
8079
0
            sampled++;
8080
0
            continue;
8081
0
          }
8082
0
        }
8083
0
        continue;
8084
0
      }
8085
0
    }
8086
0
    uu____1 = d2;
8087
0
    uu____6 = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
8088
0
    uu____0 = uu____1 < uu____6;
8089
0
    if (uu____0) {
8090
0
      uu____3 = sampled;
8091
0
      uu____2 = uu____3 < (size_t)16U;
8092
0
      if (uu____2) {
8093
0
        uu____4 = d2;
8094
0
        uu____5 = sampled;
8095
0
        Eurydice_slice_index(result, uu____5, int16_t, int16_t *) = uu____4;
8096
0
        sampled++;
8097
0
        continue;
8098
0
      }
8099
0
    }
8100
0
  }
8101
0
  return sampled;
8102
0
}
8103
8104
/**
8105
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
8106
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
8107
*/
8108
static inline size_t libcrux_ml_kem_vector_portable_rej_sample_0d(
8109
0
    Eurydice_slice a, Eurydice_slice out) {
8110
0
  return libcrux_ml_kem_vector_portable_sampling_rej_sample(a, out);
8111
0
}
8112
8113
#define LIBCRUX_ML_KEM_MLKEM768_VECTOR_U_COMPRESSION_FACTOR_768 ((size_t)10U)
8114
8115
#define LIBCRUX_ML_KEM_MLKEM768_C1_BLOCK_SIZE_768          \
8116
  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \
8117
   LIBCRUX_ML_KEM_MLKEM768_VECTOR_U_COMPRESSION_FACTOR_768 / (size_t)8U)
8118
8119
#define LIBCRUX_ML_KEM_MLKEM768_RANK_768 ((size_t)3U)
8120
8121
#define LIBCRUX_ML_KEM_MLKEM768_C1_SIZE_768 \
8122
  (LIBCRUX_ML_KEM_MLKEM768_C1_BLOCK_SIZE_768 * LIBCRUX_ML_KEM_MLKEM768_RANK_768)
8123
8124
#define LIBCRUX_ML_KEM_MLKEM768_VECTOR_V_COMPRESSION_FACTOR_768 ((size_t)4U)
8125
8126
#define LIBCRUX_ML_KEM_MLKEM768_C2_SIZE_768                \
8127
  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \
8128
   LIBCRUX_ML_KEM_MLKEM768_VECTOR_V_COMPRESSION_FACTOR_768 / (size_t)8U)
8129
8130
#define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_CIPHERTEXT_SIZE_768 \
8131
  (LIBCRUX_ML_KEM_MLKEM768_C1_SIZE_768 + LIBCRUX_ML_KEM_MLKEM768_C2_SIZE_768)
8132
8133
#define LIBCRUX_ML_KEM_MLKEM768_T_AS_NTT_ENCODED_SIZE_768  \
8134
  (LIBCRUX_ML_KEM_MLKEM768_RANK_768 *                      \
8135
   LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \
8136
   LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT / (size_t)8U)
8137
8138
#define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_PUBLIC_KEY_SIZE_768 \
8139
  (LIBCRUX_ML_KEM_MLKEM768_T_AS_NTT_ENCODED_SIZE_768 + (size_t)32U)
8140
8141
#define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_SECRET_KEY_SIZE_768 \
8142
  (LIBCRUX_ML_KEM_MLKEM768_RANK_768 *                       \
8143
   LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *  \
8144
   LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT / (size_t)8U)
8145
8146
#define LIBCRUX_ML_KEM_MLKEM768_ETA1 ((size_t)2U)
8147
8148
#define LIBCRUX_ML_KEM_MLKEM768_ETA1_RANDOMNESS_SIZE \
8149
  (LIBCRUX_ML_KEM_MLKEM768_ETA1 * (size_t)64U)
8150
8151
#define LIBCRUX_ML_KEM_MLKEM768_ETA2 ((size_t)2U)
8152
8153
#define LIBCRUX_ML_KEM_MLKEM768_ETA2_RANDOMNESS_SIZE \
8154
  (LIBCRUX_ML_KEM_MLKEM768_ETA2 * (size_t)64U)
8155
8156
#define LIBCRUX_ML_KEM_MLKEM768_IMPLICIT_REJECTION_HASH_INPUT_SIZE \
8157
  (LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE +                   \
8158
   LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_CIPHERTEXT_SIZE_768)
8159
8160
typedef libcrux_ml_kem_types_MlKemPrivateKey_55
8161
    libcrux_ml_kem_mlkem768_MlKem768PrivateKey;
8162
8163
typedef libcrux_ml_kem_types_MlKemPublicKey_15
8164
    libcrux_ml_kem_mlkem768_MlKem768PublicKey;
8165
8166
#define LIBCRUX_ML_KEM_MLKEM768_RANKED_BYTES_PER_RING_ELEMENT_768 \
8167
  (LIBCRUX_ML_KEM_MLKEM768_RANK_768 *                             \
8168
   LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U)
8169
8170
#define LIBCRUX_ML_KEM_MLKEM768_SECRET_KEY_SIZE_768      \
8171
  (LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_SECRET_KEY_SIZE_768 + \
8172
   LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_PUBLIC_KEY_SIZE_768 + \
8173
   LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE +              \
8174
   LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE)
8175
8176
/**
8177
A monomorphic instance of libcrux_ml_kem.polynomial.PolynomialRingElement
8178
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8179
8180
*/
8181
typedef struct libcrux_ml_kem_polynomial_PolynomialRingElement_f0_s {
8182
  libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficients[16U];
8183
} libcrux_ml_kem_polynomial_PolynomialRingElement_f0;
8184
8185
/**
8186
This function found in impl
8187
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
8188
*/
8189
/**
8190
A monomorphic instance of libcrux_ml_kem.polynomial.ZERO_89
8191
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8192
with const generics
8193
8194
*/
8195
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8196
0
libcrux_ml_kem_polynomial_ZERO_89_ea(void) {
8197
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 lit;
8198
0
  lit.coefficients[0U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8199
0
  lit.coefficients[1U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8200
0
  lit.coefficients[2U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8201
0
  lit.coefficients[3U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8202
0
  lit.coefficients[4U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8203
0
  lit.coefficients[5U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8204
0
  lit.coefficients[6U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8205
0
  lit.coefficients[7U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8206
0
  lit.coefficients[8U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8207
0
  lit.coefficients[9U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8208
0
  lit.coefficients[10U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8209
0
  lit.coefficients[11U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8210
0
  lit.coefficients[12U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8211
0
  lit.coefficients[13U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8212
0
  lit.coefficients[14U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8213
0
  lit.coefficients[15U] = libcrux_ml_kem_vector_portable_ZERO_0d();
8214
0
  return lit;
8215
0
}
8216
8217
/**
8218
A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_secret_key.closure
8219
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8220
with const generics
8221
- K= 3
8222
*/
8223
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8224
0
libcrux_ml_kem_ind_cpa_deserialize_secret_key_closure_6b(size_t _) {
8225
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
8226
0
}
8227
8228
/**
8229
A monomorphic instance of
8230
libcrux_ml_kem.serialize.deserialize_to_uncompressed_ring_element with types
8231
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8232
8233
*/
8234
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8235
libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_af(
8236
0
    Eurydice_slice serialized) {
8237
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
8238
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
8239
0
  for (size_t i = (size_t)0U;
8240
0
       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)24U; i++) {
8241
0
    size_t i0 = i;
8242
0
    Eurydice_slice bytes = Eurydice_slice_subslice2(
8243
0
        serialized, i0 * (size_t)24U, i0 * (size_t)24U + (size_t)24U, uint8_t);
8244
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8245
0
        libcrux_ml_kem_vector_portable_deserialize_12_0d(bytes);
8246
0
    re.coefficients[i0] = uu____0;
8247
0
  }
8248
0
  return re;
8249
0
}
8250
8251
/**
8252
 Call [`deserialize_to_uncompressed_ring_element`] for each ring element.
8253
*/
8254
/**
8255
A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_secret_key
8256
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8257
with const generics
8258
- K= 3
8259
*/
8260
static KRML_MUSTINLINE void libcrux_ml_kem_ind_cpa_deserialize_secret_key_24(
8261
    Eurydice_slice secret_key,
8262
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
8263
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U];
8264
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
8265
0
    secret_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
8266
0
  }
8267
0
  for (size_t i = (size_t)0U;
8268
0
       i < Eurydice_slice_len(secret_key, uint8_t) /
8269
0
               LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT;
8270
0
       i++) {
8271
0
    size_t i0 = i;
8272
0
    Eurydice_slice secret_bytes = Eurydice_slice_subslice2(
8273
0
        secret_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
8274
0
        i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT +
8275
0
            LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
8276
0
        uint8_t);
8277
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____0 =
8278
0
        libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_af(
8279
0
            secret_bytes);
8280
0
    secret_as_ntt[i0] = uu____0;
8281
0
  }
8282
0
  memcpy(
8283
0
      ret, secret_as_ntt,
8284
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
8285
0
}
8286
8287
/**
8288
A monomorphic instance of
8289
libcrux_ml_kem.ind_cpa.unpacked.IndCpaPrivateKeyUnpacked with types
8290
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8291
- $3size_t
8292
*/
8293
typedef struct libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8_s {
8294
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U];
8295
} libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8;
8296
8297
/**
8298
A monomorphic instance of
8299
libcrux_ml_kem.ind_cpa.deserialize_then_decompress_u.closure with types
8300
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8301
- K= 3
8302
- CIPHERTEXT_SIZE= 1088
8303
- U_COMPRESSION_FACTOR= 10
8304
*/
8305
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8306
0
libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_closure_7c(size_t _) {
8307
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
8308
0
}
8309
8310
/**
8311
A monomorphic instance of
8312
libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with
8313
const generics
8314
- COEFFICIENT_BITS= 10
8315
*/
8316
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
8317
libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b(
8318
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8319
0
  for (size_t i = (size_t)0U;
8320
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
8321
0
    size_t i0 = i;
8322
0
    int32_t decompressed = (int32_t)v.elements[i0] *
8323
0
                           (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
8324
0
    decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)10);
8325
0
    decompressed = decompressed >> (uint32_t)((int32_t)10 + (int32_t)1);
8326
0
    v.elements[i0] = (int16_t)decompressed;
8327
0
  }
8328
0
  return v;
8329
0
}
8330
8331
/**
8332
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
8333
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
8334
*/
8335
/**
8336
A monomorphic instance of
8337
libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const
8338
generics
8339
- COEFFICIENT_BITS= 10
8340
*/
8341
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
8342
libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a(
8343
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8344
0
  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b(
8345
0
      v);
8346
0
}
8347
8348
/**
8349
A monomorphic instance of
8350
libcrux_ml_kem.serialize.deserialize_then_decompress_10 with types
8351
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8352
8353
*/
8354
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8355
libcrux_ml_kem_serialize_deserialize_then_decompress_10_2c(
8356
0
    Eurydice_slice serialized) {
8357
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
8358
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
8359
0
  for (size_t i = (size_t)0U;
8360
0
       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)20U; i++) {
8361
0
    size_t i0 = i;
8362
0
    Eurydice_slice bytes = Eurydice_slice_subslice2(
8363
0
        serialized, i0 * (size_t)20U, i0 * (size_t)20U + (size_t)20U, uint8_t);
8364
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
8365
0
        libcrux_ml_kem_vector_portable_deserialize_10_0d(bytes);
8366
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8367
0
        libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a(
8368
0
            coefficient);
8369
0
    re.coefficients[i0] = uu____0;
8370
0
  }
8371
0
  return re;
8372
0
}
8373
8374
/**
8375
A monomorphic instance of
8376
libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with
8377
const generics
8378
- COEFFICIENT_BITS= 11
8379
*/
8380
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
8381
libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b0(
8382
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8383
0
  for (size_t i = (size_t)0U;
8384
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
8385
0
    size_t i0 = i;
8386
0
    int32_t decompressed = (int32_t)v.elements[i0] *
8387
0
                           (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
8388
0
    decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)11);
8389
0
    decompressed = decompressed >> (uint32_t)((int32_t)11 + (int32_t)1);
8390
0
    v.elements[i0] = (int16_t)decompressed;
8391
0
  }
8392
0
  return v;
8393
0
}
8394
8395
/**
8396
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
8397
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
8398
*/
8399
/**
8400
A monomorphic instance of
8401
libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const
8402
generics
8403
- COEFFICIENT_BITS= 11
8404
*/
8405
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
8406
libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a0(
8407
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8408
0
  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b0(
8409
0
      v);
8410
0
}
8411
8412
/**
8413
A monomorphic instance of
8414
libcrux_ml_kem.serialize.deserialize_then_decompress_11 with types
8415
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8416
8417
*/
8418
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8419
libcrux_ml_kem_serialize_deserialize_then_decompress_11_8d(
8420
0
    Eurydice_slice serialized) {
8421
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
8422
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
8423
0
  for (size_t i = (size_t)0U;
8424
0
       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)22U; i++) {
8425
0
    size_t i0 = i;
8426
0
    Eurydice_slice bytes = Eurydice_slice_subslice2(
8427
0
        serialized, i0 * (size_t)22U, i0 * (size_t)22U + (size_t)22U, uint8_t);
8428
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
8429
0
        libcrux_ml_kem_vector_portable_deserialize_11_0d(bytes);
8430
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8431
0
        libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a0(
8432
0
            coefficient);
8433
0
    re.coefficients[i0] = uu____0;
8434
0
  }
8435
0
  return re;
8436
0
}
8437
8438
/**
8439
A monomorphic instance of
8440
libcrux_ml_kem.serialize.deserialize_then_decompress_ring_element_u with types
8441
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8442
- COMPRESSION_FACTOR= 10
8443
*/
8444
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8445
libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_34(
8446
0
    Eurydice_slice serialized) {
8447
0
  return libcrux_ml_kem_serialize_deserialize_then_decompress_10_2c(serialized);
8448
0
}
8449
8450
typedef struct libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2_s {
8451
  libcrux_ml_kem_vector_portable_vector_type_PortableVector fst;
8452
  libcrux_ml_kem_vector_portable_vector_type_PortableVector snd;
8453
} libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2;
8454
8455
/**
8456
A monomorphic instance of libcrux_ml_kem.vector.traits.montgomery_multiply_fe
8457
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8458
with const generics
8459
8460
*/
8461
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
8462
libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67(
8463
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t fer) {
8464
0
  return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(v,
8465
0
                                                                           fer);
8466
0
}
8467
8468
/**
8469
A monomorphic instance of libcrux_ml_kem.ntt.ntt_layer_int_vec_step
8470
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8471
with const generics
8472
8473
*/
8474
static KRML_MUSTINLINE
8475
    libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2
8476
    libcrux_ml_kem_ntt_ntt_layer_int_vec_step_0c(
8477
        libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
8478
        libcrux_ml_kem_vector_portable_vector_type_PortableVector b,
8479
0
        int16_t zeta_r) {
8480
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
8481
0
      libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67(b, zeta_r);
8482
0
  b = libcrux_ml_kem_vector_portable_sub_0d(a, &t);
8483
0
  a = libcrux_ml_kem_vector_portable_add_0d(a, &t);
8484
0
  return (
8485
0
      CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){
8486
0
          .fst = a, .snd = b});
8487
0
}
8488
8489
/**
8490
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_4_plus
8491
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8492
with const generics
8493
8494
*/
8495
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(
8496
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8497
0
    size_t layer, size_t _initial_coefficient_bound) {
8498
0
  size_t step = (size_t)1U << (uint32_t)layer;
8499
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) {
8500
0
    size_t round = i0;
8501
0
    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
8502
0
    size_t offset = round * step * (size_t)2U;
8503
0
    size_t offset_vec = offset / (size_t)16U;
8504
0
    size_t step_vec = step / (size_t)16U;
8505
0
    for (size_t i = offset_vec; i < offset_vec + step_vec; i++) {
8506
0
      size_t j = i;
8507
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 =
8508
0
          libcrux_ml_kem_ntt_ntt_layer_int_vec_step_0c(
8509
0
              re->coefficients[j], re->coefficients[j + step_vec],
8510
0
              libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]);
8511
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst;
8512
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd;
8513
0
      re->coefficients[j] = x;
8514
0
      re->coefficients[j + step_vec] = y;
8515
0
    }
8516
0
  }
8517
0
}
8518
8519
/**
8520
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_3
8521
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8522
with const generics
8523
8524
*/
8525
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_3_fd(
8526
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8527
0
    size_t _layer, size_t _initial_coefficient_bound) {
8528
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
8529
0
    size_t round = i;
8530
0
    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
8531
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8532
0
        libcrux_ml_kem_vector_portable_ntt_layer_3_step_0d(
8533
0
            re->coefficients[round],
8534
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]);
8535
0
    re->coefficients[round] = uu____0;
8536
0
  }
8537
0
}
8538
8539
/**
8540
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_2
8541
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8542
with const generics
8543
8544
*/
8545
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_2_ad(
8546
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8547
0
    size_t _layer, size_t _initial_coefficient_bound) {
8548
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
8549
0
    size_t round = i;
8550
0
    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
8551
0
    re->coefficients[round] =
8552
0
        libcrux_ml_kem_vector_portable_ntt_layer_2_step_0d(
8553
0
            re->coefficients[round],
8554
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]],
8555
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
8556
0
                                                               (size_t)1U]);
8557
0
    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
8558
0
  }
8559
0
}
8560
8561
/**
8562
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_1
8563
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8564
with const generics
8565
8566
*/
8567
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_1_a2(
8568
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8569
0
    size_t _layer, size_t _initial_coefficient_bound) {
8570
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
8571
0
    size_t round = i;
8572
0
    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
8573
0
    re->coefficients[round] =
8574
0
        libcrux_ml_kem_vector_portable_ntt_layer_1_step_0d(
8575
0
            re->coefficients[round],
8576
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]],
8577
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
8578
0
                                                               (size_t)1U],
8579
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
8580
0
                                                               (size_t)2U],
8581
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
8582
0
                                                               (size_t)3U]);
8583
0
    zeta_i[0U] = zeta_i[0U] + (size_t)3U;
8584
0
  }
8585
0
}
8586
8587
/**
8588
This function found in impl
8589
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
8590
*/
8591
/**
8592
A monomorphic instance of libcrux_ml_kem.polynomial.poly_barrett_reduce_89
8593
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8594
with const generics
8595
8596
*/
8597
static KRML_MUSTINLINE void libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(
8598
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self) {
8599
0
  for (size_t i = (size_t)0U;
8600
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
8601
0
    size_t i0 = i;
8602
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8603
0
        libcrux_ml_kem_vector_portable_barrett_reduce_0d(
8604
0
            self->coefficients[i0]);
8605
0
    self->coefficients[i0] = uu____0;
8606
0
  }
8607
0
}
8608
8609
/**
8610
A monomorphic instance of libcrux_ml_kem.ntt.ntt_vector_u
8611
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8612
with const generics
8613
- VECTOR_U_COMPRESSION_FACTOR= 10
8614
*/
8615
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_vector_u_9f(
8616
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) {
8617
0
  size_t zeta_i = (size_t)0U;
8618
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)7U,
8619
0
                                            (size_t)3328U);
8620
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)6U,
8621
0
                                            (size_t)3328U);
8622
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)5U,
8623
0
                                            (size_t)3328U);
8624
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)4U,
8625
0
                                            (size_t)3328U);
8626
0
  libcrux_ml_kem_ntt_ntt_at_layer_3_fd(&zeta_i, re, (size_t)3U, (size_t)3328U);
8627
0
  libcrux_ml_kem_ntt_ntt_at_layer_2_ad(&zeta_i, re, (size_t)2U, (size_t)3328U);
8628
0
  libcrux_ml_kem_ntt_ntt_at_layer_1_a2(&zeta_i, re, (size_t)1U, (size_t)3328U);
8629
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re);
8630
0
}
8631
8632
/**
8633
 Call [`deserialize_then_decompress_ring_element_u`] on each ring element
8634
 in the `ciphertext`.
8635
*/
8636
/**
8637
A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_then_decompress_u
8638
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8639
with const generics
8640
- K= 3
8641
- CIPHERTEXT_SIZE= 1088
8642
- U_COMPRESSION_FACTOR= 10
8643
*/
8644
static KRML_MUSTINLINE void
8645
libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_f4(
8646
    uint8_t *ciphertext,
8647
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
8648
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 u_as_ntt[3U];
8649
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
8650
0
    u_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
8651
0
  }
8652
0
  for (size_t i = (size_t)0U;
8653
0
       i < Eurydice_slice_len(
8654
0
               Eurydice_array_to_slice((size_t)1088U, ciphertext, uint8_t),
8655
0
               uint8_t) /
8656
0
               (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
8657
0
                (size_t)10U / (size_t)8U);
8658
0
       i++) {
8659
0
    size_t i0 = i;
8660
0
    Eurydice_slice u_bytes = Eurydice_array_to_subslice2(
8661
0
        ciphertext,
8662
0
        i0 * (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
8663
0
              (size_t)10U / (size_t)8U),
8664
0
        i0 * (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
8665
0
              (size_t)10U / (size_t)8U) +
8666
0
            LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
8667
0
                (size_t)10U / (size_t)8U,
8668
0
        uint8_t);
8669
0
    u_as_ntt[i0] =
8670
0
        libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_34(
8671
0
            u_bytes);
8672
0
    libcrux_ml_kem_ntt_ntt_vector_u_9f(&u_as_ntt[i0]);
8673
0
  }
8674
0
  memcpy(
8675
0
      ret, u_as_ntt,
8676
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
8677
0
}
8678
8679
/**
8680
A monomorphic instance of
8681
libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with
8682
const generics
8683
- COEFFICIENT_BITS= 4
8684
*/
8685
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
8686
libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b1(
8687
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8688
0
  for (size_t i = (size_t)0U;
8689
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
8690
0
    size_t i0 = i;
8691
0
    int32_t decompressed = (int32_t)v.elements[i0] *
8692
0
                           (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
8693
0
    decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)4);
8694
0
    decompressed = decompressed >> (uint32_t)((int32_t)4 + (int32_t)1);
8695
0
    v.elements[i0] = (int16_t)decompressed;
8696
0
  }
8697
0
  return v;
8698
0
}
8699
8700
/**
8701
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
8702
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
8703
*/
8704
/**
8705
A monomorphic instance of
8706
libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const
8707
generics
8708
- COEFFICIENT_BITS= 4
8709
*/
8710
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
8711
libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a1(
8712
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8713
0
  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b1(
8714
0
      v);
8715
0
}
8716
8717
/**
8718
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_4
8719
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8720
with const generics
8721
8722
*/
8723
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8724
libcrux_ml_kem_serialize_deserialize_then_decompress_4_41(
8725
0
    Eurydice_slice serialized) {
8726
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
8727
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
8728
0
  for (size_t i = (size_t)0U;
8729
0
       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)8U; i++) {
8730
0
    size_t i0 = i;
8731
0
    Eurydice_slice bytes = Eurydice_slice_subslice2(
8732
0
        serialized, i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t);
8733
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
8734
0
        libcrux_ml_kem_vector_portable_deserialize_4_0d(bytes);
8735
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8736
0
        libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a1(
8737
0
            coefficient);
8738
0
    re.coefficients[i0] = uu____0;
8739
0
  }
8740
0
  return re;
8741
0
}
8742
8743
/**
8744
A monomorphic instance of
8745
libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with
8746
const generics
8747
- COEFFICIENT_BITS= 5
8748
*/
8749
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
8750
libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b2(
8751
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8752
0
  for (size_t i = (size_t)0U;
8753
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
8754
0
    size_t i0 = i;
8755
0
    int32_t decompressed = (int32_t)v.elements[i0] *
8756
0
                           (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
8757
0
    decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)5);
8758
0
    decompressed = decompressed >> (uint32_t)((int32_t)5 + (int32_t)1);
8759
0
    v.elements[i0] = (int16_t)decompressed;
8760
0
  }
8761
0
  return v;
8762
0
}
8763
8764
/**
8765
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
8766
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
8767
*/
8768
/**
8769
A monomorphic instance of
8770
libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const
8771
generics
8772
- COEFFICIENT_BITS= 5
8773
*/
8774
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
8775
libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a2(
8776
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
8777
0
  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b2(
8778
0
      v);
8779
0
}
8780
8781
/**
8782
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_5
8783
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8784
with const generics
8785
8786
*/
8787
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8788
libcrux_ml_kem_serialize_deserialize_then_decompress_5_4e(
8789
0
    Eurydice_slice serialized) {
8790
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
8791
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
8792
0
  for (size_t i = (size_t)0U;
8793
0
       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)10U; i++) {
8794
0
    size_t i0 = i;
8795
0
    Eurydice_slice bytes = Eurydice_slice_subslice2(
8796
0
        serialized, i0 * (size_t)10U, i0 * (size_t)10U + (size_t)10U, uint8_t);
8797
0
    re.coefficients[i0] =
8798
0
        libcrux_ml_kem_vector_portable_deserialize_5_0d(bytes);
8799
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 =
8800
0
        libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a2(
8801
0
            re.coefficients[i0]);
8802
0
    re.coefficients[i0] = uu____1;
8803
0
  }
8804
0
  return re;
8805
0
}
8806
8807
/**
8808
A monomorphic instance of
8809
libcrux_ml_kem.serialize.deserialize_then_decompress_ring_element_v with types
8810
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8811
- COMPRESSION_FACTOR= 4
8812
*/
8813
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8814
libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_56(
8815
0
    Eurydice_slice serialized) {
8816
0
  return libcrux_ml_kem_serialize_deserialize_then_decompress_4_41(serialized);
8817
0
}
8818
8819
/**
8820
 Given two `KyberPolynomialRingElement`s in their NTT representations,
8821
 compute their product. Given two polynomials in the NTT domain `f^` and `ĵ`,
8822
 the `iᵗʰ` coefficient of the product `k̂` is determined by the calculation:
8823
8824
 ```plaintext
8825
 ĥ[2·i] + ĥ[2·i + 1]X = (f^[2·i] + f^[2·i + 1]X)·(ĝ[2·i] + ĝ[2·i + 1]X) mod (X²
8826
 - ζ^(2·BitRev₇(i) + 1))
8827
 ```
8828
8829
 This function almost implements <strong>Algorithm 10</strong> of the
8830
 NIST FIPS 203 standard, which is reproduced below:
8831
8832
 ```plaintext
8833
 Input: Two arrays fˆ ∈ ℤ₂₅₆ and ĝ ∈ ℤ₂₅₆.
8834
 Output: An array ĥ ∈ ℤq.
8835
8836
 for(i ← 0; i < 128; i++)
8837
     (ĥ[2i], ĥ[2i+1]) ← BaseCaseMultiply(fˆ[2i], fˆ[2i+1], ĝ[2i], ĝ[2i+1],
8838
 ζ^(2·BitRev₇(i) + 1)) end for return ĥ
8839
 ```
8840
 We say "almost" because the coefficients of the ring element output by
8841
 this function are in the Montgomery domain.
8842
8843
 The NIST FIPS 203 standard can be found at
8844
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
8845
*/
8846
/**
8847
This function found in impl
8848
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
8849
*/
8850
/**
8851
A monomorphic instance of libcrux_ml_kem.polynomial.ntt_multiply_89
8852
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8853
with const generics
8854
8855
*/
8856
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
8857
libcrux_ml_kem_polynomial_ntt_multiply_89_2a(
8858
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self,
8859
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *rhs) {
8860
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 out =
8861
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
8862
0
  for (size_t i = (size_t)0U;
8863
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
8864
0
    size_t i0 = i;
8865
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8866
0
        libcrux_ml_kem_vector_portable_ntt_multiply_0d(
8867
0
            &self->coefficients[i0], &rhs->coefficients[i0],
8868
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
8869
0
                                                               (size_t)4U * i0],
8870
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
8871
0
                                                               (size_t)4U * i0 +
8872
0
                                                               (size_t)1U],
8873
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
8874
0
                                                               (size_t)4U * i0 +
8875
0
                                                               (size_t)2U],
8876
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
8877
0
                                                               (size_t)4U * i0 +
8878
0
                                                               (size_t)3U]);
8879
0
    out.coefficients[i0] = uu____0;
8880
0
  }
8881
0
  return out;
8882
0
}
8883
8884
/**
8885
 Given two polynomial ring elements `lhs` and `rhs`, compute the pointwise
8886
 sum of their constituent coefficients.
8887
*/
8888
/**
8889
This function found in impl
8890
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
8891
*/
8892
/**
8893
A monomorphic instance of libcrux_ml_kem.polynomial.add_to_ring_element_89
8894
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8895
with const generics
8896
- K= 3
8897
*/
8898
static KRML_MUSTINLINE void libcrux_ml_kem_polynomial_add_to_ring_element_89_84(
8899
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self,
8900
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *rhs) {
8901
0
  for (size_t i = (size_t)0U;
8902
0
       i < Eurydice_slice_len(
8903
0
               Eurydice_array_to_slice(
8904
0
                   (size_t)16U, self->coefficients,
8905
0
                   libcrux_ml_kem_vector_portable_vector_type_PortableVector),
8906
0
               libcrux_ml_kem_vector_portable_vector_type_PortableVector);
8907
0
       i++) {
8908
0
    size_t i0 = i;
8909
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8910
0
        libcrux_ml_kem_vector_portable_add_0d(self->coefficients[i0],
8911
0
                                              &rhs->coefficients[i0]);
8912
0
    self->coefficients[i0] = uu____0;
8913
0
  }
8914
0
}
8915
8916
/**
8917
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_1
8918
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8919
with const generics
8920
8921
*/
8922
static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_83(
8923
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8924
0
    size_t _layer) {
8925
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
8926
0
    size_t round = i;
8927
0
    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
8928
0
    re->coefficients[round] =
8929
0
        libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_0d(
8930
0
            re->coefficients[round],
8931
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]],
8932
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] -
8933
0
                                                               (size_t)1U],
8934
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] -
8935
0
                                                               (size_t)2U],
8936
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] -
8937
0
                                                               (size_t)3U]);
8938
0
    zeta_i[0U] = zeta_i[0U] - (size_t)3U;
8939
0
  }
8940
0
}
8941
8942
/**
8943
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_2
8944
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8945
with const generics
8946
8947
*/
8948
static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_c3(
8949
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8950
0
    size_t _layer) {
8951
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
8952
0
    size_t round = i;
8953
0
    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
8954
0
    re->coefficients[round] =
8955
0
        libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_0d(
8956
0
            re->coefficients[round],
8957
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]],
8958
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] -
8959
0
                                                               (size_t)1U]);
8960
0
    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
8961
0
  }
8962
0
}
8963
8964
/**
8965
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_3
8966
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
8967
with const generics
8968
8969
*/
8970
static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_68(
8971
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
8972
0
    size_t _layer) {
8973
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
8974
0
    size_t round = i;
8975
0
    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
8976
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
8977
0
        libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_0d(
8978
0
            re->coefficients[round],
8979
0
            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]);
8980
0
    re->coefficients[round] = uu____0;
8981
0
  }
8982
0
}
8983
8984
/**
8985
A monomorphic instance of
8986
libcrux_ml_kem.invert_ntt.inv_ntt_layer_int_vec_step_reduce with types
8987
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
8988
8989
*/
8990
static KRML_MUSTINLINE
8991
    libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2
8992
    libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_65(
8993
        libcrux_ml_kem_vector_portable_vector_type_PortableVector a,
8994
        libcrux_ml_kem_vector_portable_vector_type_PortableVector b,
8995
0
        int16_t zeta_r) {
8996
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector a_minus_b =
8997
0
      libcrux_ml_kem_vector_portable_sub_0d(b, &a);
8998
0
  a = libcrux_ml_kem_vector_portable_barrett_reduce_0d(
8999
0
      libcrux_ml_kem_vector_portable_add_0d(a, &b));
9000
0
  b = libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67(a_minus_b, zeta_r);
9001
0
  return (
9002
0
      CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){
9003
0
          .fst = a, .snd = b});
9004
0
}
9005
9006
/**
9007
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_4_plus
9008
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9009
with const generics
9010
9011
*/
9012
static KRML_MUSTINLINE void
9013
libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(
9014
    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re,
9015
0
    size_t layer) {
9016
0
  size_t step = (size_t)1U << (uint32_t)layer;
9017
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) {
9018
0
    size_t round = i0;
9019
0
    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
9020
0
    size_t offset = round * step * (size_t)2U;
9021
0
    size_t offset_vec =
9022
0
        offset / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR;
9023
0
    size_t step_vec =
9024
0
        step / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR;
9025
0
    for (size_t i = offset_vec; i < offset_vec + step_vec; i++) {
9026
0
      size_t j = i;
9027
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 =
9028
0
          libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_65(
9029
0
              re->coefficients[j], re->coefficients[j + step_vec],
9030
0
              libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]);
9031
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst;
9032
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd;
9033
0
      re->coefficients[j] = x;
9034
0
      re->coefficients[j + step_vec] = y;
9035
0
    }
9036
0
  }
9037
0
}
9038
9039
/**
9040
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_montgomery
9041
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9042
with const generics
9043
- K= 3
9044
*/
9045
static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(
9046
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) {
9047
0
  size_t zeta_i =
9048
0
      LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)2U;
9049
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_83(&zeta_i, re, (size_t)1U);
9050
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_c3(&zeta_i, re, (size_t)2U);
9051
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_68(&zeta_i, re, (size_t)3U);
9052
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re,
9053
0
                                                          (size_t)4U);
9054
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re,
9055
0
                                                          (size_t)5U);
9056
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re,
9057
0
                                                          (size_t)6U);
9058
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re,
9059
0
                                                          (size_t)7U);
9060
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re);
9061
0
}
9062
9063
/**
9064
This function found in impl
9065
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
9066
*/
9067
/**
9068
A monomorphic instance of libcrux_ml_kem.polynomial.subtract_reduce_89
9069
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9070
with const generics
9071
9072
*/
9073
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9074
libcrux_ml_kem_polynomial_subtract_reduce_89_d4(
9075
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self,
9076
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 b) {
9077
0
  for (size_t i = (size_t)0U;
9078
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
9079
0
    size_t i0 = i;
9080
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector
9081
0
        coefficient_normal_form =
9082
0
            libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(
9083
0
                b.coefficients[i0], (int16_t)1441);
9084
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
9085
0
        libcrux_ml_kem_vector_portable_barrett_reduce_0d(
9086
0
            libcrux_ml_kem_vector_portable_sub_0d(self->coefficients[i0],
9087
0
                                                  &coefficient_normal_form));
9088
0
    b.coefficients[i0] = uu____0;
9089
0
  }
9090
0
  return b;
9091
0
}
9092
9093
/**
9094
 The following functions compute various expressions involving
9095
 vectors and matrices. The computation of these expressions has been
9096
 abstracted away into these functions in order to save on loop iterations.
9097
 Compute v − InverseNTT(sᵀ ◦ NTT(u))
9098
*/
9099
/**
9100
A monomorphic instance of libcrux_ml_kem.matrix.compute_message
9101
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9102
with const generics
9103
- K= 3
9104
*/
9105
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9106
libcrux_ml_kem_matrix_compute_message_b3(
9107
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *v,
9108
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *secret_as_ntt,
9109
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *u_as_ntt) {
9110
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result =
9111
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
9112
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9113
0
    size_t i0 = i;
9114
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product =
9115
0
        libcrux_ml_kem_polynomial_ntt_multiply_89_2a(&secret_as_ntt[i0],
9116
0
                                                     &u_as_ntt[i0]);
9117
0
    libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result, &product);
9118
0
  }
9119
0
  libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(&result);
9120
0
  result = libcrux_ml_kem_polynomial_subtract_reduce_89_d4(v, result);
9121
0
  return result;
9122
0
}
9123
9124
/**
9125
A monomorphic instance of libcrux_ml_kem.vector.portable.arithmetic.shift_right
9126
with const generics
9127
- SHIFT_BY= 15
9128
*/
9129
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
9130
libcrux_ml_kem_vector_portable_arithmetic_shift_right_94(
9131
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
9132
0
  for (size_t i = (size_t)0U;
9133
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
9134
0
    size_t i0 = i;
9135
0
    v.elements[i0] = v.elements[i0] >> (uint32_t)(int32_t)15;
9136
0
  }
9137
0
  return v;
9138
0
}
9139
9140
/**
9141
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
9142
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
9143
*/
9144
/**
9145
A monomorphic instance of libcrux_ml_kem.vector.portable.shift_right_0d
9146
with const generics
9147
- SHIFT_BY= 15
9148
*/
9149
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
9150
libcrux_ml_kem_vector_portable_shift_right_0d_19(
9151
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
9152
0
  return libcrux_ml_kem_vector_portable_arithmetic_shift_right_94(v);
9153
0
}
9154
9155
/**
9156
A monomorphic instance of
9157
libcrux_ml_kem.vector.traits.to_unsigned_representative with types
9158
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9159
9160
*/
9161
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
9162
libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
9163
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
9164
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
9165
0
      libcrux_ml_kem_vector_portable_shift_right_0d_19(a);
9166
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector fm =
9167
0
      libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d(
9168
0
          t, LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS);
9169
0
  return libcrux_ml_kem_vector_portable_add_0d(a, &fm);
9170
0
}
9171
9172
/**
9173
A monomorphic instance of
9174
libcrux_ml_kem.serialize.compress_then_serialize_message with types
9175
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9176
9177
*/
9178
static KRML_MUSTINLINE void
9179
libcrux_ml_kem_serialize_compress_then_serialize_message_aa(
9180
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re, uint8_t ret[32U]) {
9181
0
  uint8_t serialized[32U] = {0U};
9182
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
9183
0
    size_t i0 = i;
9184
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
9185
0
        libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
9186
0
            re.coefficients[i0]);
9187
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector
9188
0
        coefficient_compressed =
9189
0
            libcrux_ml_kem_vector_portable_compress_1_0d(coefficient);
9190
0
    uint8_t bytes[2U];
9191
0
    libcrux_ml_kem_vector_portable_serialize_1_0d(coefficient_compressed,
9192
0
                                                  bytes);
9193
0
    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
9194
0
        serialized, (size_t)2U * i0, (size_t)2U * i0 + (size_t)2U, uint8_t);
9195
0
    Eurydice_slice_copy(
9196
0
        uu____0, Eurydice_array_to_slice((size_t)2U, bytes, uint8_t), uint8_t);
9197
0
  }
9198
0
  memcpy(ret, serialized, (size_t)32U * sizeof(uint8_t));
9199
0
}
9200
9201
/**
9202
 This function implements <strong>Algorithm 14</strong> of the
9203
 NIST FIPS 203 specification; this is the Kyber CPA-PKE decryption algorithm.
9204
9205
 Algorithm 14 is reproduced below:
9206
9207
 ```plaintext
9208
 Input: decryption key dkₚₖₑ ∈ 𝔹^{384k}.
9209
 Input: ciphertext c ∈ 𝔹^{32(dᵤk + dᵥ)}.
9210
 Output: message m ∈ 𝔹^{32}.
9211
9212
 c₁ ← c[0 : 32dᵤk]
9213
 c₂ ← c[32dᵤk : 32(dᵤk + dᵥ)]
9214
 u ← Decompress_{dᵤ}(ByteDecode_{dᵤ}(c₁))
9215
 v ← Decompress_{dᵥ}(ByteDecode_{dᵥ}(c₂))
9216
 ŝ ← ByteDecode₁₂(dkₚₖₑ)
9217
 w ← v - NTT-¹(ŝᵀ ◦ NTT(u))
9218
 m ← ByteEncode₁(Compress₁(w))
9219
 return m
9220
 ```
9221
9222
 The NIST FIPS 203 standard can be found at
9223
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
9224
*/
9225
/**
9226
A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt_unpacked
9227
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9228
with const generics
9229
- K= 3
9230
- CIPHERTEXT_SIZE= 1088
9231
- VECTOR_U_ENCODED_SIZE= 960
9232
- U_COMPRESSION_FACTOR= 10
9233
- V_COMPRESSION_FACTOR= 4
9234
*/
9235
static inline void libcrux_ml_kem_ind_cpa_decrypt_unpacked_6d(
9236
    libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8 *secret_key,
9237
0
    uint8_t *ciphertext, uint8_t ret[32U]) {
9238
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 u_as_ntt[3U];
9239
0
  libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_f4(ciphertext, u_as_ntt);
9240
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 v =
9241
0
      libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_56(
9242
0
          Eurydice_array_to_subslice_from((size_t)1088U, ciphertext,
9243
0
                                          (size_t)960U, uint8_t, size_t));
9244
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 message =
9245
0
      libcrux_ml_kem_matrix_compute_message_b3(&v, secret_key->secret_as_ntt,
9246
0
                                               u_as_ntt);
9247
0
  uint8_t ret0[32U];
9248
0
  libcrux_ml_kem_serialize_compress_then_serialize_message_aa(message, ret0);
9249
0
  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
9250
0
}
9251
9252
/**
9253
A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt
9254
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9255
with const generics
9256
- K= 3
9257
- CIPHERTEXT_SIZE= 1088
9258
- VECTOR_U_ENCODED_SIZE= 960
9259
- U_COMPRESSION_FACTOR= 10
9260
- V_COMPRESSION_FACTOR= 4
9261
*/
9262
static inline void libcrux_ml_kem_ind_cpa_decrypt_43(Eurydice_slice secret_key,
9263
                                                     uint8_t *ciphertext,
9264
0
                                                     uint8_t ret[32U]) {
9265
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U];
9266
0
  libcrux_ml_kem_ind_cpa_deserialize_secret_key_24(secret_key, secret_as_ntt);
9267
  /* Passing arrays by value in Rust generates a copy in C */
9268
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_secret_as_ntt[3U];
9269
0
  memcpy(
9270
0
      copy_of_secret_as_ntt, secret_as_ntt,
9271
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
9272
0
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8
9273
0
      secret_key_unpacked;
9274
0
  memcpy(
9275
0
      secret_key_unpacked.secret_as_ntt, copy_of_secret_as_ntt,
9276
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
9277
0
  uint8_t ret0[32U];
9278
0
  libcrux_ml_kem_ind_cpa_decrypt_unpacked_6d(&secret_key_unpacked, ciphertext,
9279
0
                                             ret0);
9280
0
  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
9281
0
}
9282
9283
/**
9284
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
9285
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
9286
*/
9287
/**
9288
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.G_f1
9289
with const generics
9290
- K= 3
9291
*/
9292
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_G_f1_e4(
9293
0
    Eurydice_slice input, uint8_t ret[64U]) {
9294
0
  libcrux_ml_kem_hash_functions_portable_G(input, ret);
9295
0
}
9296
9297
/**
9298
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF
9299
with const generics
9300
- LEN= 32
9301
*/
9302
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_2b(
9303
0
    Eurydice_slice input, uint8_t ret[32U]) {
9304
0
  uint8_t digest[32U] = {0U};
9305
0
  libcrux_sha3_portable_shake256(
9306
0
      Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input);
9307
0
  memcpy(ret, digest, (size_t)32U * sizeof(uint8_t));
9308
0
}
9309
9310
/**
9311
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
9312
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
9313
*/
9314
/**
9315
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF_f1
9316
with const generics
9317
- K= 3
9318
- LEN= 32
9319
*/
9320
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_f1_ee(
9321
0
    Eurydice_slice input, uint8_t ret[32U]) {
9322
0
  libcrux_ml_kem_hash_functions_portable_PRF_2b(input, ret);
9323
0
}
9324
9325
/**
9326
A monomorphic instance of
9327
libcrux_ml_kem.serialize.deserialize_ring_elements_reduced.closure with types
9328
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9329
- PUBLIC_KEY_SIZE= 1152
9330
- K= 3
9331
*/
9332
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9333
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_closure_cd(
9334
0
    size_t _i) {
9335
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
9336
0
}
9337
9338
/**
9339
 Only use with public values.
9340
9341
 This MUST NOT be used with secret inputs, like its caller
9342
 `deserialize_ring_elements_reduced`.
9343
*/
9344
/**
9345
A monomorphic instance of
9346
libcrux_ml_kem.serialize.deserialize_to_reduced_ring_element with types
9347
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9348
9349
*/
9350
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9351
libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_4c(
9352
0
    Eurydice_slice serialized) {
9353
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
9354
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
9355
0
  for (size_t i = (size_t)0U;
9356
0
       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)24U; i++) {
9357
0
    size_t i0 = i;
9358
0
    Eurydice_slice bytes = Eurydice_slice_subslice2(
9359
0
        serialized, i0 * (size_t)24U, i0 * (size_t)24U + (size_t)24U, uint8_t);
9360
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
9361
0
        libcrux_ml_kem_vector_portable_deserialize_12_0d(bytes);
9362
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
9363
0
        libcrux_ml_kem_vector_portable_cond_subtract_3329_0d(coefficient);
9364
0
    re.coefficients[i0] = uu____0;
9365
0
  }
9366
0
  return re;
9367
0
}
9368
9369
/**
9370
 This function deserializes ring elements and reduces the result by the field
9371
 modulus.
9372
9373
 This function MUST NOT be used on secret inputs.
9374
*/
9375
/**
9376
A monomorphic instance of
9377
libcrux_ml_kem.serialize.deserialize_ring_elements_reduced with types
9378
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9379
- PUBLIC_KEY_SIZE= 1152
9380
- K= 3
9381
*/
9382
static KRML_MUSTINLINE void
9383
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_33(
9384
    Eurydice_slice public_key,
9385
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
9386
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 deserialized_pk[3U];
9387
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9388
0
    deserialized_pk[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
9389
0
  }
9390
0
  for (size_t i = (size_t)0U;
9391
0
       i < Eurydice_slice_len(public_key, uint8_t) /
9392
0
               LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT;
9393
0
       i++) {
9394
0
    size_t i0 = i;
9395
0
    Eurydice_slice ring_element = Eurydice_slice_subslice2(
9396
0
        public_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
9397
0
        i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT +
9398
0
            LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
9399
0
        uint8_t);
9400
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____0 =
9401
0
        libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_4c(
9402
0
            ring_element);
9403
0
    deserialized_pk[i0] = uu____0;
9404
0
  }
9405
0
  memcpy(
9406
0
      ret, deserialized_pk,
9407
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
9408
0
}
9409
9410
/**
9411
A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A.closure.closure
9412
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
9413
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
9414
generics
9415
- K= 3
9416
*/
9417
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9418
0
libcrux_ml_kem_matrix_sample_matrix_A_closure_closure_78(size_t _j) {
9419
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
9420
0
}
9421
9422
/**
9423
A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A.closure
9424
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
9425
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
9426
generics
9427
- K= 3
9428
*/
9429
static inline void libcrux_ml_kem_matrix_sample_matrix_A_closure_4b(
9430
0
    size_t _i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
9431
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9432
0
    ret[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
9433
0
  }
9434
0
}
9435
9436
/**
9437
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PortableHash
9438
with const generics
9439
- $3size_t
9440
*/
9441
typedef struct libcrux_ml_kem_hash_functions_portable_PortableHash_58_s {
9442
  libcrux_sha3_generic_keccak_KeccakState_48 shake128_state[3U];
9443
} libcrux_ml_kem_hash_functions_portable_PortableHash_58;
9444
9445
/**
9446
A monomorphic instance of
9447
libcrux_ml_kem.hash_functions.portable.shake128_init_absorb with const generics
9448
- K= 3
9449
*/
9450
static KRML_MUSTINLINE libcrux_ml_kem_hash_functions_portable_PortableHash_58
9451
libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_b7(
9452
0
    uint8_t input[3U][34U]) {
9453
0
  libcrux_sha3_generic_keccak_KeccakState_48 shake128_state[3U];
9454
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9455
0
    shake128_state[i] = libcrux_sha3_portable_incremental_shake128_init();
9456
0
  }
9457
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9458
0
    size_t i0 = i;
9459
0
    libcrux_sha3_portable_incremental_shake128_absorb_final(
9460
0
        &shake128_state[i0],
9461
0
        Eurydice_array_to_slice((size_t)34U, input[i0], uint8_t));
9462
0
  }
9463
  /* Passing arrays by value in Rust generates a copy in C */
9464
0
  libcrux_sha3_generic_keccak_KeccakState_48 copy_of_shake128_state[3U];
9465
0
  memcpy(copy_of_shake128_state, shake128_state,
9466
0
         (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_48));
9467
0
  libcrux_ml_kem_hash_functions_portable_PortableHash_58 lit;
9468
0
  memcpy(lit.shake128_state, copy_of_shake128_state,
9469
0
         (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_48));
9470
0
  return lit;
9471
0
}
9472
9473
/**
9474
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
9475
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
9476
*/
9477
/**
9478
A monomorphic instance of
9479
libcrux_ml_kem.hash_functions.portable.shake128_init_absorb_f1 with const
9480
generics
9481
- K= 3
9482
*/
9483
static KRML_MUSTINLINE libcrux_ml_kem_hash_functions_portable_PortableHash_58
9484
libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_f1_8c(
9485
0
    uint8_t input[3U][34U]) {
9486
  /* Passing arrays by value in Rust generates a copy in C */
9487
0
  uint8_t copy_of_input[3U][34U];
9488
0
  memcpy(copy_of_input, input, (size_t)3U * sizeof(uint8_t[34U]));
9489
0
  return libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_b7(
9490
0
      copy_of_input);
9491
0
}
9492
9493
/**
9494
A monomorphic instance of
9495
libcrux_ml_kem.hash_functions.portable.shake128_squeeze_three_blocks with const
9496
generics
9497
- K= 3
9498
*/
9499
static KRML_MUSTINLINE void
9500
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_ca(
9501
    libcrux_ml_kem_hash_functions_portable_PortableHash_58 *st,
9502
0
    uint8_t ret[3U][504U]) {
9503
0
  uint8_t out[3U][504U] = {{0U}};
9504
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9505
0
    size_t i0 = i;
9506
0
    libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(
9507
0
        &st->shake128_state[i0],
9508
0
        Eurydice_array_to_slice((size_t)504U, out[i0], uint8_t));
9509
0
  }
9510
0
  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[504U]));
9511
0
}
9512
9513
/**
9514
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
9515
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
9516
*/
9517
/**
9518
A monomorphic instance of
9519
libcrux_ml_kem.hash_functions.portable.shake128_squeeze_three_blocks_f1 with
9520
const generics
9521
- K= 3
9522
*/
9523
static KRML_MUSTINLINE void
9524
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_f1_69(
9525
    libcrux_ml_kem_hash_functions_portable_PortableHash_58 *self,
9526
0
    uint8_t ret[3U][504U]) {
9527
0
  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_ca(self,
9528
0
                                                                          ret);
9529
0
}
9530
9531
/**
9532
 If `bytes` contains a set of uniformly random bytes, this function
9533
 uniformly samples a ring element `â` that is treated as being the NTT
9534
 representation of the corresponding polynomial `a`.
9535
9536
 Since rejection sampling is used, it is possible the supplied bytes are
9537
 not enough to sample the element, in which case an `Err` is returned and the
9538
 caller must try again with a fresh set of bytes.
9539
9540
 This function <strong>partially</strong> implements <strong>Algorithm
9541
 6</strong> of the NIST FIPS 203 standard, We say "partially" because this
9542
 implementation only accepts a finite set of bytes as input and returns an error
9543
 if the set is not enough; Algorithm 6 of the FIPS 203 standard on the other
9544
 hand samples from an infinite stream of bytes until the ring element is filled.
9545
 Algorithm 6 is reproduced below:
9546
9547
 ```plaintext
9548
 Input: byte stream B ∈ 𝔹*.
9549
 Output: array â ∈ ℤ₂₅₆.
9550
9551
 i ← 0
9552
 j ← 0
9553
 while j < 256 do
9554
     d₁ ← B[i] + 256·(B[i+1] mod 16)
9555
     d₂ ← ⌊B[i+1]/16⌋ + 16·B[i+2]
9556
     if d₁ < q then
9557
         â[j] ← d₁
9558
         j ← j + 1
9559
     end if
9560
     if d₂ < q and j < 256 then
9561
         â[j] ← d₂
9562
         j ← j + 1
9563
     end if
9564
     i ← i + 3
9565
 end while
9566
 return â
9567
 ```
9568
9569
 The NIST FIPS 203 standard can be found at
9570
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
9571
*/
9572
/**
9573
A monomorphic instance of
9574
libcrux_ml_kem.sampling.sample_from_uniform_distribution_next with types
9575
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9576
- K= 3
9577
- N= 504
9578
*/
9579
static KRML_MUSTINLINE bool
9580
libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db(
9581
    uint8_t randomness[3U][504U], size_t *sampled_coefficients,
9582
0
    int16_t (*out)[272U]) {
9583
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
9584
0
    size_t i1 = i0;
9585
0
    for (size_t i = (size_t)0U; i < (size_t)504U / (size_t)24U; i++) {
9586
0
      size_t r = i;
9587
0
      if (sampled_coefficients[i1] <
9588
0
          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
9589
0
        Eurydice_slice uu____0 =
9590
0
            Eurydice_array_to_subslice2(randomness[i1], r * (size_t)24U,
9591
0
                                        r * (size_t)24U + (size_t)24U, uint8_t);
9592
0
        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_0d(
9593
0
            uu____0, Eurydice_array_to_subslice2(
9594
0
                         out[i1], sampled_coefficients[i1],
9595
0
                         sampled_coefficients[i1] + (size_t)16U, int16_t));
9596
0
        size_t uu____1 = i1;
9597
0
        sampled_coefficients[uu____1] = sampled_coefficients[uu____1] + sampled;
9598
0
      }
9599
0
    }
9600
0
  }
9601
0
  bool done = true;
9602
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9603
0
    size_t i0 = i;
9604
0
    if (sampled_coefficients[i0] >=
9605
0
        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
9606
0
      sampled_coefficients[i0] =
9607
0
          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
9608
0
    } else {
9609
0
      done = false;
9610
0
    }
9611
0
  }
9612
0
  return done;
9613
0
}
9614
9615
/**
9616
A monomorphic instance of
9617
libcrux_ml_kem.hash_functions.portable.shake128_squeeze_block with const
9618
generics
9619
- K= 3
9620
*/
9621
static KRML_MUSTINLINE void
9622
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_dd(
9623
    libcrux_ml_kem_hash_functions_portable_PortableHash_58 *st,
9624
0
    uint8_t ret[3U][168U]) {
9625
0
  uint8_t out[3U][168U] = {{0U}};
9626
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9627
0
    size_t i0 = i;
9628
0
    libcrux_sha3_portable_incremental_shake128_squeeze_next_block(
9629
0
        &st->shake128_state[i0],
9630
0
        Eurydice_array_to_slice((size_t)168U, out[i0], uint8_t));
9631
0
  }
9632
0
  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[168U]));
9633
0
}
9634
9635
/**
9636
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
9637
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
9638
*/
9639
/**
9640
A monomorphic instance of
9641
libcrux_ml_kem.hash_functions.portable.shake128_squeeze_block_f1 with const
9642
generics
9643
- K= 3
9644
*/
9645
static KRML_MUSTINLINE void
9646
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_f1_60(
9647
    libcrux_ml_kem_hash_functions_portable_PortableHash_58 *self,
9648
0
    uint8_t ret[3U][168U]) {
9649
0
  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_dd(self, ret);
9650
0
}
9651
9652
/**
9653
 If `bytes` contains a set of uniformly random bytes, this function
9654
 uniformly samples a ring element `â` that is treated as being the NTT
9655
 representation of the corresponding polynomial `a`.
9656
9657
 Since rejection sampling is used, it is possible the supplied bytes are
9658
 not enough to sample the element, in which case an `Err` is returned and the
9659
 caller must try again with a fresh set of bytes.
9660
9661
 This function <strong>partially</strong> implements <strong>Algorithm
9662
 6</strong> of the NIST FIPS 203 standard, We say "partially" because this
9663
 implementation only accepts a finite set of bytes as input and returns an error
9664
 if the set is not enough; Algorithm 6 of the FIPS 203 standard on the other
9665
 hand samples from an infinite stream of bytes until the ring element is filled.
9666
 Algorithm 6 is reproduced below:
9667
9668
 ```plaintext
9669
 Input: byte stream B ∈ 𝔹*.
9670
 Output: array â ∈ ℤ₂₅₆.
9671
9672
 i ← 0
9673
 j ← 0
9674
 while j < 256 do
9675
     d₁ ← B[i] + 256·(B[i+1] mod 16)
9676
     d₂ ← ⌊B[i+1]/16⌋ + 16·B[i+2]
9677
     if d₁ < q then
9678
         â[j] ← d₁
9679
         j ← j + 1
9680
     end if
9681
     if d₂ < q and j < 256 then
9682
         â[j] ← d₂
9683
         j ← j + 1
9684
     end if
9685
     i ← i + 3
9686
 end while
9687
 return â
9688
 ```
9689
9690
 The NIST FIPS 203 standard can be found at
9691
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
9692
*/
9693
/**
9694
A monomorphic instance of
9695
libcrux_ml_kem.sampling.sample_from_uniform_distribution_next with types
9696
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9697
- K= 3
9698
- N= 168
9699
*/
9700
static KRML_MUSTINLINE bool
9701
libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db0(
9702
    uint8_t randomness[3U][168U], size_t *sampled_coefficients,
9703
0
    int16_t (*out)[272U]) {
9704
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
9705
0
    size_t i1 = i0;
9706
0
    for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)24U; i++) {
9707
0
      size_t r = i;
9708
0
      if (sampled_coefficients[i1] <
9709
0
          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
9710
0
        Eurydice_slice uu____0 =
9711
0
            Eurydice_array_to_subslice2(randomness[i1], r * (size_t)24U,
9712
0
                                        r * (size_t)24U + (size_t)24U, uint8_t);
9713
0
        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_0d(
9714
0
            uu____0, Eurydice_array_to_subslice2(
9715
0
                         out[i1], sampled_coefficients[i1],
9716
0
                         sampled_coefficients[i1] + (size_t)16U, int16_t));
9717
0
        size_t uu____1 = i1;
9718
0
        sampled_coefficients[uu____1] = sampled_coefficients[uu____1] + sampled;
9719
0
      }
9720
0
    }
9721
0
  }
9722
0
  bool done = true;
9723
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9724
0
    size_t i0 = i;
9725
0
    if (sampled_coefficients[i0] >=
9726
0
        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
9727
0
      sampled_coefficients[i0] =
9728
0
          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
9729
0
    } else {
9730
0
      done = false;
9731
0
    }
9732
0
  }
9733
0
  return done;
9734
0
}
9735
9736
/**
9737
This function found in impl
9738
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
9739
*/
9740
/**
9741
A monomorphic instance of libcrux_ml_kem.polynomial.from_i16_array_89
9742
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
9743
with const generics
9744
9745
*/
9746
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9747
0
libcrux_ml_kem_polynomial_from_i16_array_89_c1(Eurydice_slice a) {
9748
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result =
9749
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
9750
0
  for (size_t i = (size_t)0U;
9751
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
9752
0
    size_t i0 = i;
9753
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
9754
0
        libcrux_ml_kem_vector_portable_from_i16_array_0d(
9755
0
            Eurydice_slice_subslice2(a, i0 * (size_t)16U,
9756
0
                                     (i0 + (size_t)1U) * (size_t)16U, int16_t));
9757
0
    result.coefficients[i0] = uu____0;
9758
0
  }
9759
0
  return result;
9760
0
}
9761
9762
/**
9763
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_xof.closure
9764
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
9765
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
9766
generics
9767
- K= 3
9768
*/
9769
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9770
0
libcrux_ml_kem_sampling_sample_from_xof_closure_04(int16_t s[272U]) {
9771
0
  return libcrux_ml_kem_polynomial_from_i16_array_89_c1(
9772
0
      Eurydice_array_to_subslice2(s, (size_t)0U, (size_t)256U, int16_t));
9773
0
}
9774
9775
/**
9776
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_xof
9777
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
9778
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
9779
generics
9780
- K= 3
9781
*/
9782
static KRML_MUSTINLINE void libcrux_ml_kem_sampling_sample_from_xof_3f(
9783
    uint8_t seeds[3U][34U],
9784
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
9785
0
  size_t sampled_coefficients[3U] = {0U};
9786
0
  int16_t out[3U][272U] = {{0U}};
9787
  /* Passing arrays by value in Rust generates a copy in C */
9788
0
  uint8_t copy_of_seeds[3U][34U];
9789
0
  memcpy(copy_of_seeds, seeds, (size_t)3U * sizeof(uint8_t[34U]));
9790
0
  libcrux_ml_kem_hash_functions_portable_PortableHash_58 xof_state =
9791
0
      libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_f1_8c(
9792
0
          copy_of_seeds);
9793
0
  uint8_t randomness0[3U][504U];
9794
0
  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_f1_69(
9795
0
      &xof_state, randomness0);
9796
  /* Passing arrays by value in Rust generates a copy in C */
9797
0
  uint8_t copy_of_randomness0[3U][504U];
9798
0
  memcpy(copy_of_randomness0, randomness0, (size_t)3U * sizeof(uint8_t[504U]));
9799
0
  bool done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db(
9800
0
      copy_of_randomness0, sampled_coefficients, out);
9801
0
  while (true) {
9802
0
    if (done) {
9803
0
      break;
9804
0
    } else {
9805
0
      uint8_t randomness[3U][168U];
9806
0
      libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_f1_60(
9807
0
          &xof_state, randomness);
9808
      /* Passing arrays by value in Rust generates a copy in C */
9809
0
      uint8_t copy_of_randomness[3U][168U];
9810
0
      memcpy(copy_of_randomness, randomness,
9811
0
             (size_t)3U * sizeof(uint8_t[168U]));
9812
0
      done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db0(
9813
0
          copy_of_randomness, sampled_coefficients, out);
9814
0
    }
9815
0
  }
9816
  /* Passing arrays by value in Rust generates a copy in C */
9817
0
  int16_t copy_of_out[3U][272U];
9818
0
  memcpy(copy_of_out, out, (size_t)3U * sizeof(int16_t[272U]));
9819
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret0[3U];
9820
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9821
0
    ret0[i] =
9822
0
        libcrux_ml_kem_sampling_sample_from_xof_closure_04(copy_of_out[i]);
9823
0
  }
9824
0
  memcpy(
9825
0
      ret, ret0,
9826
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
9827
0
}
9828
9829
/**
9830
A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A
9831
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
9832
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
9833
generics
9834
- K= 3
9835
*/
9836
static KRML_MUSTINLINE void libcrux_ml_kem_matrix_sample_matrix_A_38(
9837
    uint8_t seed[34U], bool transpose,
9838
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U][3U]) {
9839
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U];
9840
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9841
0
    libcrux_ml_kem_matrix_sample_matrix_A_closure_4b(i, A_transpose[i]);
9842
0
  }
9843
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
9844
0
    size_t i1 = i0;
9845
    /* Passing arrays by value in Rust generates a copy in C */
9846
0
    uint8_t copy_of_seed[34U];
9847
0
    memcpy(copy_of_seed, seed, (size_t)34U * sizeof(uint8_t));
9848
0
    uint8_t seeds[3U][34U];
9849
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9850
0
      memcpy(seeds[i], copy_of_seed, (size_t)34U * sizeof(uint8_t));
9851
0
    }
9852
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9853
0
      size_t j = i;
9854
0
      seeds[j][32U] = (uint8_t)i1;
9855
0
      seeds[j][33U] = (uint8_t)j;
9856
0
    }
9857
    /* Passing arrays by value in Rust generates a copy in C */
9858
0
    uint8_t copy_of_seeds[3U][34U];
9859
0
    memcpy(copy_of_seeds, seeds, (size_t)3U * sizeof(uint8_t[34U]));
9860
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 sampled[3U];
9861
0
    libcrux_ml_kem_sampling_sample_from_xof_3f(copy_of_seeds, sampled);
9862
0
    for (size_t i = (size_t)0U;
9863
0
         i < Eurydice_slice_len(
9864
0
                 Eurydice_array_to_slice(
9865
0
                     (size_t)3U, sampled,
9866
0
                     libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
9867
0
                 libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
9868
0
         i++) {
9869
0
      size_t j = i;
9870
0
      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 sample = sampled[j];
9871
0
      if (transpose) {
9872
0
        A_transpose[j][i1] = sample;
9873
0
      } else {
9874
0
        A_transpose[i1][j] = sample;
9875
0
      }
9876
0
    }
9877
0
  }
9878
0
  memcpy(ret, A_transpose,
9879
0
         (size_t)3U *
9880
0
             sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]));
9881
0
}
9882
9883
/**
9884
A monomorphic instance of K.
9885
with types libcrux_ml_kem_polynomial_PolynomialRingElement
9886
libcrux_ml_kem_vector_portable_vector_type_PortableVector[3size_t], uint8_t
9887
9888
*/
9889
typedef struct tuple_b0_s {
9890
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 fst[3U];
9891
  uint8_t snd;
9892
} tuple_b0;
9893
9894
/**
9895
A monomorphic instance of
9896
libcrux_ml_kem.ind_cpa.sample_vector_cbd_then_ntt.closure with types
9897
libcrux_ml_kem_vector_portable_vector_type_PortableVector,
9898
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
9899
generics
9900
- K= 3
9901
- ETA= 2
9902
- ETA_RANDOMNESS_SIZE= 128
9903
*/
9904
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9905
0
libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_closure_f7(size_t _i) {
9906
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
9907
0
}
9908
9909
/**
9910
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRFxN
9911
with const generics
9912
- K= 3
9913
- LEN= 128
9914
*/
9915
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRFxN_c5(
9916
0
    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
9917
0
  uint8_t out[3U][128U] = {{0U}};
9918
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
9919
0
    size_t i0 = i;
9920
0
    libcrux_sha3_portable_shake256(
9921
0
        Eurydice_array_to_slice((size_t)128U, out[i0], uint8_t),
9922
0
        Eurydice_array_to_slice((size_t)33U, input[i0], uint8_t));
9923
0
  }
9924
0
  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[128U]));
9925
0
}
9926
9927
/**
9928
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
9929
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
9930
*/
9931
/**
9932
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRFxN_f1
9933
with const generics
9934
- K= 3
9935
- LEN= 128
9936
*/
9937
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93(
9938
0
    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
9939
0
  libcrux_ml_kem_hash_functions_portable_PRFxN_c5(input, ret);
9940
0
}
9941
9942
/**
9943
 Given a series of uniformly random bytes in `randomness`, for some number
9944
 `eta`, the `sample_from_binomial_distribution_{eta}` functions sample a ring
9945
 element from a binomial distribution centered at 0 that uses two sets of `eta`
9946
 coin flips. If, for example, `eta = ETA`, each ring coefficient is a value `v`
9947
 such such that `v ∈ {-ETA, -ETA + 1, ..., 0, ..., ETA + 1, ETA}` and:
9948
9949
 ```plaintext
9950
 - If v < 0, Pr[v] = Pr[-v]
9951
 - If v >= 0, Pr[v] = BINOMIAL_COEFFICIENT(2 * ETA; ETA - v) / 2 ^ (2 * ETA)
9952
 ```
9953
9954
 The values `v < 0` are mapped to the appropriate `KyberFieldElement`.
9955
9956
 The expected value is:
9957
9958
 ```plaintext
9959
 E[X] = (-ETA)Pr[-ETA] + (-(ETA - 1))Pr[-(ETA - 1)] + ... + (ETA - 1)Pr[ETA - 1]
9960
 + (ETA)Pr[ETA] = 0 since Pr[-v] = Pr[v] when v < 0.
9961
 ```
9962
9963
 And the variance is:
9964
9965
 ```plaintext
9966
 Var(X) = E[(X - E[X])^2]
9967
        = E[X^2]
9968
        = sum_(v=-ETA to ETA)v^2 * (BINOMIAL_COEFFICIENT(2 * ETA; ETA - v) /
9969
 2^(2 * ETA)) = ETA / 2
9970
 ```
9971
9972
 This function implements <strong>Algorithm 7</strong> of the NIST FIPS 203
9973
 standard, which is reproduced below:
9974
9975
 ```plaintext
9976
 Input: byte array B ∈ 𝔹^{64η}.
9977
 Output: array f ∈ ℤ₂₅₆.
9978
9979
 b ← BytesToBits(B)
9980
 for (i ← 0; i < 256; i++)
9981
     x ← ∑(j=0 to η - 1) b[2iη + j]
9982
     y ← ∑(j=0 to η - 1) b[2iη + η + j]
9983
     f[i] ← x−y mod q
9984
 end for
9985
 return f
9986
 ```
9987
9988
 The NIST FIPS 203 standard can be found at
9989
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
9990
*/
9991
/**
9992
A monomorphic instance of
9993
libcrux_ml_kem.sampling.sample_from_binomial_distribution_2 with types
9994
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
9995
9996
*/
9997
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
9998
libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_85(
9999
0
    Eurydice_slice randomness) {
10000
0
  int16_t sampled_i16s[256U] = {0U};
10001
0
  for (size_t i0 = (size_t)0U;
10002
0
       i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)4U; i0++) {
10003
0
    size_t chunk_number = i0;
10004
0
    Eurydice_slice byte_chunk = Eurydice_slice_subslice2(
10005
0
        randomness, chunk_number * (size_t)4U,
10006
0
        chunk_number * (size_t)4U + (size_t)4U, uint8_t);
10007
0
    uint32_t random_bits_as_u32 =
10008
0
        (((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t,
10009
0
                                         uint8_t *) |
10010
0
          (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t,
10011
0
                                         uint8_t *)
10012
0
              << 8U) |
10013
0
         (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t,
10014
0
                                        uint8_t *)
10015
0
             << 16U) |
10016
0
        (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)3U, uint8_t,
10017
0
                                       uint8_t *)
10018
0
            << 24U;
10019
0
    uint32_t even_bits = random_bits_as_u32 & 1431655765U;
10020
0
    uint32_t odd_bits = random_bits_as_u32 >> 1U & 1431655765U;
10021
0
    uint32_t coin_toss_outcomes = even_bits + odd_bits;
10022
0
    for (uint32_t i = 0U; i < CORE_NUM__U32_8__BITS / 4U; i++) {
10023
0
      uint32_t outcome_set = i;
10024
0
      uint32_t outcome_set0 = outcome_set * 4U;
10025
0
      int16_t outcome_1 =
10026
0
          (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 3U);
10027
0
      int16_t outcome_2 =
10028
0
          (int16_t)(coin_toss_outcomes >> (uint32_t)(outcome_set0 + 2U) & 3U);
10029
0
      size_t offset = (size_t)(outcome_set0 >> 2U);
10030
0
      sampled_i16s[(size_t)8U * chunk_number + offset] = outcome_1 - outcome_2;
10031
0
    }
10032
0
  }
10033
0
  return libcrux_ml_kem_polynomial_from_i16_array_89_c1(
10034
0
      Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t));
10035
0
}
10036
10037
/**
10038
A monomorphic instance of
10039
libcrux_ml_kem.sampling.sample_from_binomial_distribution_3 with types
10040
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
10041
10042
*/
10043
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10044
libcrux_ml_kem_sampling_sample_from_binomial_distribution_3_eb(
10045
0
    Eurydice_slice randomness) {
10046
0
  int16_t sampled_i16s[256U] = {0U};
10047
0
  for (size_t i0 = (size_t)0U;
10048
0
       i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)3U; i0++) {
10049
0
    size_t chunk_number = i0;
10050
0
    Eurydice_slice byte_chunk = Eurydice_slice_subslice2(
10051
0
        randomness, chunk_number * (size_t)3U,
10052
0
        chunk_number * (size_t)3U + (size_t)3U, uint8_t);
10053
0
    uint32_t random_bits_as_u24 =
10054
0
        ((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t,
10055
0
                                        uint8_t *) |
10056
0
         (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t,
10057
0
                                        uint8_t *)
10058
0
             << 8U) |
10059
0
        (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t,
10060
0
                                       uint8_t *)
10061
0
            << 16U;
10062
0
    uint32_t first_bits = random_bits_as_u24 & 2396745U;
10063
0
    uint32_t second_bits = random_bits_as_u24 >> 1U & 2396745U;
10064
0
    uint32_t third_bits = random_bits_as_u24 >> 2U & 2396745U;
10065
0
    uint32_t coin_toss_outcomes = first_bits + second_bits + third_bits;
10066
0
    for (int32_t i = (int32_t)0; i < (int32_t)24 / (int32_t)6; i++) {
10067
0
      int32_t outcome_set = i;
10068
0
      int32_t outcome_set0 = outcome_set * (int32_t)6;
10069
0
      int16_t outcome_1 =
10070
0
          (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 7U);
10071
0
      int16_t outcome_2 = (int16_t)(coin_toss_outcomes >>
10072
0
                                        (uint32_t)(outcome_set0 + (int32_t)3) &
10073
0
                                    7U);
10074
0
      size_t offset = (size_t)(outcome_set0 / (int32_t)6);
10075
0
      sampled_i16s[(size_t)4U * chunk_number + offset] = outcome_1 - outcome_2;
10076
0
    }
10077
0
  }
10078
0
  return libcrux_ml_kem_polynomial_from_i16_array_89_c1(
10079
0
      Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t));
10080
0
}
10081
10082
/**
10083
A monomorphic instance of
10084
libcrux_ml_kem.sampling.sample_from_binomial_distribution with types
10085
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
10086
- ETA= 2
10087
*/
10088
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10089
libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6(
10090
0
    Eurydice_slice randomness) {
10091
0
  return libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_85(
10092
0
      randomness);
10093
0
}
10094
10095
/**
10096
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_7
10097
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10098
with const generics
10099
10100
*/
10101
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_7_f4(
10102
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) {
10103
0
  size_t step = LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT / (size_t)2U;
10104
0
  for (size_t i = (size_t)0U; i < step; i++) {
10105
0
    size_t j = i;
10106
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
10107
0
        libcrux_ml_kem_vector_portable_multiply_by_constant_0d(
10108
0
            re->coefficients[j + step], (int16_t)-1600);
10109
0
    re->coefficients[j + step] =
10110
0
        libcrux_ml_kem_vector_portable_sub_0d(re->coefficients[j], &t);
10111
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 =
10112
0
        libcrux_ml_kem_vector_portable_add_0d(re->coefficients[j], &t);
10113
0
    re->coefficients[j] = uu____1;
10114
0
  }
10115
0
}
10116
10117
/**
10118
A monomorphic instance of libcrux_ml_kem.ntt.ntt_binomially_sampled_ring_element
10119
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10120
with const generics
10121
10122
*/
10123
static KRML_MUSTINLINE void
10124
libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_0f(
10125
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) {
10126
0
  libcrux_ml_kem_ntt_ntt_at_layer_7_f4(re);
10127
0
  size_t zeta_i = (size_t)1U;
10128
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)6U,
10129
0
                                            (size_t)3U);
10130
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)5U,
10131
0
                                            (size_t)3U);
10132
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)4U,
10133
0
                                            (size_t)3U);
10134
0
  libcrux_ml_kem_ntt_ntt_at_layer_3_fd(&zeta_i, re, (size_t)3U, (size_t)3U);
10135
0
  libcrux_ml_kem_ntt_ntt_at_layer_2_ad(&zeta_i, re, (size_t)2U, (size_t)3U);
10136
0
  libcrux_ml_kem_ntt_ntt_at_layer_1_a2(&zeta_i, re, (size_t)1U, (size_t)3U);
10137
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re);
10138
0
}
10139
10140
/**
10141
 Sample a vector of ring elements from a centered binomial distribution and
10142
 convert them into their NTT representations.
10143
*/
10144
/**
10145
A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_vector_cbd_then_ntt
10146
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
10147
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
10148
generics
10149
- K= 3
10150
- ETA= 2
10151
- ETA_RANDOMNESS_SIZE= 128
10152
*/
10153
static KRML_MUSTINLINE tuple_b0
10154
libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(uint8_t prf_input[33U],
10155
0
                                                     uint8_t domain_separator) {
10156
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re_as_ntt[3U];
10157
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10158
0
    re_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
10159
0
  }
10160
  /* Passing arrays by value in Rust generates a copy in C */
10161
0
  uint8_t copy_of_prf_input[33U];
10162
0
  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
10163
0
  uint8_t prf_inputs[3U][33U];
10164
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10165
0
    memcpy(prf_inputs[i], copy_of_prf_input, (size_t)33U * sizeof(uint8_t));
10166
0
  }
10167
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10168
0
    size_t i0 = i;
10169
0
    prf_inputs[i0][32U] = domain_separator;
10170
0
    domain_separator = (uint32_t)domain_separator + 1U;
10171
0
  }
10172
0
  uint8_t prf_outputs[3U][128U];
10173
0
  libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93(prf_inputs, prf_outputs);
10174
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10175
0
    size_t i0 = i;
10176
0
    re_as_ntt[i0] =
10177
0
        libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6(
10178
0
            Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t));
10179
0
    libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_0f(&re_as_ntt[i0]);
10180
0
  }
10181
  /* Passing arrays by value in Rust generates a copy in C */
10182
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_re_as_ntt[3U];
10183
0
  memcpy(
10184
0
      copy_of_re_as_ntt, re_as_ntt,
10185
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10186
0
  tuple_b0 lit;
10187
0
  memcpy(
10188
0
      lit.fst, copy_of_re_as_ntt,
10189
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10190
0
  lit.snd = domain_separator;
10191
0
  return lit;
10192
0
}
10193
10194
/**
10195
A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_ring_element_cbd.closure
10196
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
10197
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
10198
generics
10199
- K= 3
10200
- ETA2_RANDOMNESS_SIZE= 128
10201
- ETA2= 2
10202
*/
10203
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10204
0
libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_closure_77(size_t _i) {
10205
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
10206
0
}
10207
10208
/**
10209
 Sample a vector of ring elements from a centered binomial distribution.
10210
*/
10211
/**
10212
A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_ring_element_cbd
10213
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
10214
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
10215
generics
10216
- K= 3
10217
- ETA2_RANDOMNESS_SIZE= 128
10218
- ETA2= 2
10219
*/
10220
static KRML_MUSTINLINE tuple_b0
10221
libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_ac(uint8_t prf_input[33U],
10222
0
                                                  uint8_t domain_separator) {
10223
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_1[3U];
10224
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10225
0
    error_1[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
10226
0
  }
10227
  /* Passing arrays by value in Rust generates a copy in C */
10228
0
  uint8_t copy_of_prf_input[33U];
10229
0
  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
10230
0
  uint8_t prf_inputs[3U][33U];
10231
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10232
0
    memcpy(prf_inputs[i], copy_of_prf_input, (size_t)33U * sizeof(uint8_t));
10233
0
  }
10234
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10235
0
    size_t i0 = i;
10236
0
    prf_inputs[i0][32U] = domain_separator;
10237
0
    domain_separator = (uint32_t)domain_separator + 1U;
10238
0
  }
10239
0
  uint8_t prf_outputs[3U][128U];
10240
0
  libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93(prf_inputs, prf_outputs);
10241
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10242
0
    size_t i0 = i;
10243
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____1 =
10244
0
        libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6(
10245
0
            Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t));
10246
0
    error_1[i0] = uu____1;
10247
0
  }
10248
  /* Passing arrays by value in Rust generates a copy in C */
10249
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_error_1[3U];
10250
0
  memcpy(
10251
0
      copy_of_error_1, error_1,
10252
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10253
0
  tuple_b0 lit;
10254
0
  memcpy(
10255
0
      lit.fst, copy_of_error_1,
10256
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10257
0
  lit.snd = domain_separator;
10258
0
  return lit;
10259
0
}
10260
10261
/**
10262
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF
10263
with const generics
10264
- LEN= 128
10265
*/
10266
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_2b0(
10267
0
    Eurydice_slice input, uint8_t ret[128U]) {
10268
0
  uint8_t digest[128U] = {0U};
10269
0
  libcrux_sha3_portable_shake256(
10270
0
      Eurydice_array_to_slice((size_t)128U, digest, uint8_t), input);
10271
0
  memcpy(ret, digest, (size_t)128U * sizeof(uint8_t));
10272
0
}
10273
10274
/**
10275
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
10276
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
10277
*/
10278
/**
10279
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF_f1
10280
with const generics
10281
- K= 3
10282
- LEN= 128
10283
*/
10284
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_f1_ee0(
10285
0
    Eurydice_slice input, uint8_t ret[128U]) {
10286
0
  libcrux_ml_kem_hash_functions_portable_PRF_2b0(input, ret);
10287
0
}
10288
10289
/**
10290
A monomorphic instance of libcrux_ml_kem.matrix.compute_vector_u.closure
10291
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10292
with const generics
10293
- K= 3
10294
*/
10295
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10296
0
libcrux_ml_kem_matrix_compute_vector_u_closure_d6(size_t _i) {
10297
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
10298
0
}
10299
10300
/**
10301
This function found in impl
10302
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
10303
*/
10304
/**
10305
A monomorphic instance of libcrux_ml_kem.polynomial.add_error_reduce_89
10306
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10307
with const generics
10308
10309
*/
10310
static KRML_MUSTINLINE void libcrux_ml_kem_polynomial_add_error_reduce_89_38(
10311
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self,
10312
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error) {
10313
0
  for (size_t i = (size_t)0U;
10314
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
10315
0
    size_t j = i;
10316
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector
10317
0
        coefficient_normal_form =
10318
0
            libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(
10319
0
                self->coefficients[j], (int16_t)1441);
10320
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
10321
0
        libcrux_ml_kem_vector_portable_barrett_reduce_0d(
10322
0
            libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form,
10323
0
                                                  &error->coefficients[j]));
10324
0
    self->coefficients[j] = uu____0;
10325
0
  }
10326
0
}
10327
10328
/**
10329
 Compute u := InvertNTT(Aᵀ ◦ r̂) + e₁
10330
*/
10331
/**
10332
A monomorphic instance of libcrux_ml_kem.matrix.compute_vector_u
10333
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10334
with const generics
10335
- K= 3
10336
*/
10337
static KRML_MUSTINLINE void libcrux_ml_kem_matrix_compute_vector_u_59(
10338
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 (*a_as_ntt)[3U],
10339
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *r_as_ntt,
10340
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error_1,
10341
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
10342
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result[3U];
10343
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10344
0
    result[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
10345
0
  }
10346
0
  for (size_t i0 = (size_t)0U;
10347
0
       i0 < Eurydice_slice_len(
10348
0
                Eurydice_array_to_slice(
10349
0
                    (size_t)3U, a_as_ntt,
10350
0
                    libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]),
10351
0
                libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]);
10352
0
       i0++) {
10353
0
    size_t i1 = i0;
10354
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *row = a_as_ntt[i1];
10355
0
    for (size_t i = (size_t)0U;
10356
0
         i < Eurydice_slice_len(
10357
0
                 Eurydice_array_to_slice(
10358
0
                     (size_t)3U, row,
10359
0
                     libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
10360
0
                 libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
10361
0
         i++) {
10362
0
      size_t j = i;
10363
0
      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *a_element = &row[j];
10364
0
      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product =
10365
0
          libcrux_ml_kem_polynomial_ntt_multiply_89_2a(a_element, &r_as_ntt[j]);
10366
0
      libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result[i1],
10367
0
                                                          &product);
10368
0
    }
10369
0
    libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(&result[i1]);
10370
0
    libcrux_ml_kem_polynomial_add_error_reduce_89_38(&result[i1], &error_1[i1]);
10371
0
  }
10372
0
  memcpy(
10373
0
      ret, result,
10374
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10375
0
}
10376
10377
/**
10378
A monomorphic instance of libcrux_ml_kem.vector.traits.decompress_1
10379
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10380
with const generics
10381
10382
*/
10383
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
10384
libcrux_ml_kem_vector_traits_decompress_1_63(
10385
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10386
0
  libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
10387
0
      libcrux_ml_kem_vector_portable_ZERO_0d();
10388
0
  return libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d(
10389
0
      libcrux_ml_kem_vector_portable_sub_0d(uu____0, &v), (int16_t)1665);
10390
0
}
10391
10392
/**
10393
A monomorphic instance of
10394
libcrux_ml_kem.serialize.deserialize_then_decompress_message with types
10395
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
10396
10397
*/
10398
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10399
libcrux_ml_kem_serialize_deserialize_then_decompress_message_0d(
10400
0
    uint8_t serialized[32U]) {
10401
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re =
10402
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
10403
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
10404
0
    size_t i0 = i;
10405
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector
10406
0
        coefficient_compressed =
10407
0
            libcrux_ml_kem_vector_portable_deserialize_1_0d(
10408
0
                Eurydice_array_to_subslice2(serialized, (size_t)2U * i0,
10409
0
                                            (size_t)2U * i0 + (size_t)2U,
10410
0
                                            uint8_t));
10411
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
10412
0
        libcrux_ml_kem_vector_traits_decompress_1_63(coefficient_compressed);
10413
0
    re.coefficients[i0] = uu____0;
10414
0
  }
10415
0
  return re;
10416
0
}
10417
10418
/**
10419
This function found in impl
10420
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
10421
*/
10422
/**
10423
A monomorphic instance of libcrux_ml_kem.polynomial.add_message_error_reduce_89
10424
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10425
with const generics
10426
10427
*/
10428
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10429
libcrux_ml_kem_polynomial_add_message_error_reduce_89_ea(
10430
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self,
10431
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *message,
10432
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result) {
10433
0
  for (size_t i = (size_t)0U;
10434
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
10435
0
    size_t i0 = i;
10436
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector
10437
0
        coefficient_normal_form =
10438
0
            libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(
10439
0
                result.coefficients[i0], (int16_t)1441);
10440
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector tmp =
10441
0
        libcrux_ml_kem_vector_portable_add_0d(self->coefficients[i0],
10442
0
                                              &message->coefficients[i0]);
10443
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector tmp0 =
10444
0
        libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form, &tmp);
10445
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
10446
0
        libcrux_ml_kem_vector_portable_barrett_reduce_0d(tmp0);
10447
0
    result.coefficients[i0] = uu____0;
10448
0
  }
10449
0
  return result;
10450
0
}
10451
10452
/**
10453
 Compute InverseNTT(tᵀ ◦ r̂) + e₂ + message
10454
*/
10455
/**
10456
A monomorphic instance of libcrux_ml_kem.matrix.compute_ring_element_v
10457
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10458
with const generics
10459
- K= 3
10460
*/
10461
static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0
10462
libcrux_ml_kem_matrix_compute_ring_element_v_54(
10463
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *t_as_ntt,
10464
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *r_as_ntt,
10465
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error_2,
10466
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *message) {
10467
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result =
10468
0
      libcrux_ml_kem_polynomial_ZERO_89_ea();
10469
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
10470
0
    size_t i0 = i;
10471
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product =
10472
0
        libcrux_ml_kem_polynomial_ntt_multiply_89_2a(&t_as_ntt[i0],
10473
0
                                                     &r_as_ntt[i0]);
10474
0
    libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result, &product);
10475
0
  }
10476
0
  libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(&result);
10477
0
  result = libcrux_ml_kem_polynomial_add_message_error_reduce_89_ea(
10478
0
      error_2, message, result);
10479
0
  return result;
10480
0
}
10481
10482
/**
10483
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress
10484
with const generics
10485
- COEFFICIENT_BITS= 10
10486
*/
10487
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
10488
libcrux_ml_kem_vector_portable_compress_compress_02(
10489
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10490
0
  for (size_t i = (size_t)0U;
10491
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
10492
0
    size_t i0 = i;
10493
0
    int16_t uu____0 =
10494
0
        libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
10495
0
            (uint8_t)(int32_t)10, (uint16_t)v.elements[i0]);
10496
0
    v.elements[i0] = uu____0;
10497
0
  }
10498
0
  return v;
10499
0
}
10500
10501
/**
10502
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
10503
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
10504
*/
10505
/**
10506
A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d
10507
with const generics
10508
- COEFFICIENT_BITS= 10
10509
*/
10510
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
10511
libcrux_ml_kem_vector_portable_compress_0d_28(
10512
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10513
0
  return libcrux_ml_kem_vector_portable_compress_compress_02(v);
10514
0
}
10515
10516
/**
10517
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_10
10518
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10519
with const generics
10520
- OUT_LEN= 320
10521
*/
10522
static KRML_MUSTINLINE void
10523
libcrux_ml_kem_serialize_compress_then_serialize_10_fc(
10524
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[320U]) {
10525
0
  uint8_t serialized[320U] = {0U};
10526
0
  for (size_t i = (size_t)0U;
10527
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
10528
0
    size_t i0 = i;
10529
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
10530
0
        libcrux_ml_kem_vector_portable_compress_0d_28(
10531
0
            libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
10532
0
                re->coefficients[i0]));
10533
0
    uint8_t bytes[20U];
10534
0
    libcrux_ml_kem_vector_portable_serialize_10_0d(coefficient, bytes);
10535
0
    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
10536
0
        serialized, (size_t)20U * i0, (size_t)20U * i0 + (size_t)20U, uint8_t);
10537
0
    Eurydice_slice_copy(
10538
0
        uu____0, Eurydice_array_to_slice((size_t)20U, bytes, uint8_t), uint8_t);
10539
0
  }
10540
0
  memcpy(ret, serialized, (size_t)320U * sizeof(uint8_t));
10541
0
}
10542
10543
/**
10544
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress
10545
with const generics
10546
- COEFFICIENT_BITS= 11
10547
*/
10548
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
10549
libcrux_ml_kem_vector_portable_compress_compress_020(
10550
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10551
0
  for (size_t i = (size_t)0U;
10552
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
10553
0
    size_t i0 = i;
10554
0
    int16_t uu____0 =
10555
0
        libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
10556
0
            (uint8_t)(int32_t)11, (uint16_t)v.elements[i0]);
10557
0
    v.elements[i0] = uu____0;
10558
0
  }
10559
0
  return v;
10560
0
}
10561
10562
/**
10563
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
10564
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
10565
*/
10566
/**
10567
A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d
10568
with const generics
10569
- COEFFICIENT_BITS= 11
10570
*/
10571
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
10572
libcrux_ml_kem_vector_portable_compress_0d_280(
10573
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10574
0
  return libcrux_ml_kem_vector_portable_compress_compress_020(v);
10575
0
}
10576
10577
/**
10578
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_11
10579
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10580
with const generics
10581
- OUT_LEN= 320
10582
*/
10583
static KRML_MUSTINLINE void
10584
libcrux_ml_kem_serialize_compress_then_serialize_11_e1(
10585
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[320U]) {
10586
0
  uint8_t serialized[320U] = {0U};
10587
0
  for (size_t i = (size_t)0U;
10588
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
10589
0
    size_t i0 = i;
10590
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
10591
0
        libcrux_ml_kem_vector_portable_compress_0d_280(
10592
0
            libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
10593
0
                re->coefficients[i0]));
10594
0
    uint8_t bytes[22U];
10595
0
    libcrux_ml_kem_vector_portable_serialize_11_0d(coefficient, bytes);
10596
0
    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
10597
0
        serialized, (size_t)22U * i0, (size_t)22U * i0 + (size_t)22U, uint8_t);
10598
0
    Eurydice_slice_copy(
10599
0
        uu____0, Eurydice_array_to_slice((size_t)22U, bytes, uint8_t), uint8_t);
10600
0
  }
10601
0
  memcpy(ret, serialized, (size_t)320U * sizeof(uint8_t));
10602
0
}
10603
10604
/**
10605
A monomorphic instance of
10606
libcrux_ml_kem.serialize.compress_then_serialize_ring_element_u with types
10607
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
10608
- COMPRESSION_FACTOR= 10
10609
- OUT_LEN= 320
10610
*/
10611
static KRML_MUSTINLINE void
10612
libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_5f(
10613
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[320U]) {
10614
0
  uint8_t uu____0[320U];
10615
0
  libcrux_ml_kem_serialize_compress_then_serialize_10_fc(re, uu____0);
10616
0
  memcpy(ret, uu____0, (size_t)320U * sizeof(uint8_t));
10617
0
}
10618
10619
/**
10620
 Call [`compress_then_serialize_ring_element_u`] on each ring element.
10621
*/
10622
/**
10623
A monomorphic instance of libcrux_ml_kem.ind_cpa.compress_then_serialize_u
10624
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10625
with const generics
10626
- K= 3
10627
- OUT_LEN= 960
10628
- COMPRESSION_FACTOR= 10
10629
- BLOCK_LEN= 320
10630
*/
10631
static inline void libcrux_ml_kem_ind_cpa_compress_then_serialize_u_a7(
10632
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 input[3U],
10633
0
    Eurydice_slice out) {
10634
0
  for (size_t i = (size_t)0U;
10635
0
       i < Eurydice_slice_len(
10636
0
               Eurydice_array_to_slice(
10637
0
                   (size_t)3U, input,
10638
0
                   libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
10639
0
               libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
10640
0
       i++) {
10641
0
    size_t i0 = i;
10642
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = input[i0];
10643
0
    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
10644
0
        out, i0 * ((size_t)960U / (size_t)3U),
10645
0
        (i0 + (size_t)1U) * ((size_t)960U / (size_t)3U), uint8_t);
10646
0
    uint8_t ret[320U];
10647
0
    libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_5f(&re,
10648
0
                                                                       ret);
10649
0
    Eurydice_slice_copy(
10650
0
        uu____0, Eurydice_array_to_slice((size_t)320U, ret, uint8_t), uint8_t);
10651
0
  }
10652
0
}
10653
10654
/**
10655
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress
10656
with const generics
10657
- COEFFICIENT_BITS= 4
10658
*/
10659
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
10660
libcrux_ml_kem_vector_portable_compress_compress_021(
10661
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10662
0
  for (size_t i = (size_t)0U;
10663
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
10664
0
    size_t i0 = i;
10665
0
    int16_t uu____0 =
10666
0
        libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
10667
0
            (uint8_t)(int32_t)4, (uint16_t)v.elements[i0]);
10668
0
    v.elements[i0] = uu____0;
10669
0
  }
10670
0
  return v;
10671
0
}
10672
10673
/**
10674
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
10675
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
10676
*/
10677
/**
10678
A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d
10679
with const generics
10680
- COEFFICIENT_BITS= 4
10681
*/
10682
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
10683
libcrux_ml_kem_vector_portable_compress_0d_281(
10684
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10685
0
  return libcrux_ml_kem_vector_portable_compress_compress_021(v);
10686
0
}
10687
10688
/**
10689
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_4
10690
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10691
with const generics
10692
10693
*/
10694
static KRML_MUSTINLINE void
10695
libcrux_ml_kem_serialize_compress_then_serialize_4_9a(
10696
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re,
10697
0
    Eurydice_slice serialized) {
10698
0
  for (size_t i = (size_t)0U;
10699
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
10700
0
    size_t i0 = i;
10701
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
10702
0
        libcrux_ml_kem_vector_portable_compress_0d_281(
10703
0
            libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
10704
0
                re.coefficients[i0]));
10705
0
    uint8_t bytes[8U];
10706
0
    libcrux_ml_kem_vector_portable_serialize_4_0d(coefficient, bytes);
10707
0
    Eurydice_slice_copy(
10708
0
        Eurydice_slice_subslice2(serialized, (size_t)8U * i0,
10709
0
                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
10710
0
        Eurydice_array_to_slice((size_t)8U, bytes, uint8_t), uint8_t);
10711
0
  }
10712
0
}
10713
10714
/**
10715
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress
10716
with const generics
10717
- COEFFICIENT_BITS= 5
10718
*/
10719
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector
10720
libcrux_ml_kem_vector_portable_compress_compress_022(
10721
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10722
0
  for (size_t i = (size_t)0U;
10723
0
       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
10724
0
    size_t i0 = i;
10725
0
    int16_t uu____0 =
10726
0
        libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
10727
0
            (uint8_t)(int32_t)5, (uint16_t)v.elements[i0]);
10728
0
    v.elements[i0] = uu____0;
10729
0
  }
10730
0
  return v;
10731
0
}
10732
10733
/**
10734
This function found in impl {(libcrux_ml_kem::vector::traits::Operations for
10735
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
10736
*/
10737
/**
10738
A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d
10739
with const generics
10740
- COEFFICIENT_BITS= 5
10741
*/
10742
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
10743
libcrux_ml_kem_vector_portable_compress_0d_282(
10744
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
10745
0
  return libcrux_ml_kem_vector_portable_compress_compress_022(v);
10746
0
}
10747
10748
/**
10749
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_5
10750
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
10751
with const generics
10752
10753
*/
10754
static KRML_MUSTINLINE void
10755
libcrux_ml_kem_serialize_compress_then_serialize_5_1f(
10756
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re,
10757
0
    Eurydice_slice serialized) {
10758
0
  for (size_t i = (size_t)0U;
10759
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
10760
0
    size_t i0 = i;
10761
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficients =
10762
0
        libcrux_ml_kem_vector_portable_compress_0d_282(
10763
0
            libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
10764
0
                re.coefficients[i0]));
10765
0
    uint8_t bytes[10U];
10766
0
    libcrux_ml_kem_vector_portable_serialize_5_0d(coefficients, bytes);
10767
0
    Eurydice_slice_copy(
10768
0
        Eurydice_slice_subslice2(serialized, (size_t)10U * i0,
10769
0
                                 (size_t)10U * i0 + (size_t)10U, uint8_t),
10770
0
        Eurydice_array_to_slice((size_t)10U, bytes, uint8_t), uint8_t);
10771
0
  }
10772
0
}
10773
10774
/**
10775
A monomorphic instance of
10776
libcrux_ml_kem.serialize.compress_then_serialize_ring_element_v with types
10777
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
10778
- COMPRESSION_FACTOR= 4
10779
- OUT_LEN= 128
10780
*/
10781
static KRML_MUSTINLINE void
10782
libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_4e(
10783
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re, Eurydice_slice out) {
10784
0
  libcrux_ml_kem_serialize_compress_then_serialize_4_9a(re, out);
10785
0
}
10786
10787
/**
10788
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt
10789
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
10790
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const
10791
generics
10792
- K= 3
10793
- CIPHERTEXT_SIZE= 1088
10794
- T_AS_NTT_ENCODED_SIZE= 1152
10795
- C1_LEN= 960
10796
- C2_LEN= 128
10797
- U_COMPRESSION_FACTOR= 10
10798
- V_COMPRESSION_FACTOR= 4
10799
- BLOCK_LEN= 320
10800
- ETA1= 2
10801
- ETA1_RANDOMNESS_SIZE= 128
10802
- ETA2= 2
10803
- ETA2_RANDOMNESS_SIZE= 128
10804
*/
10805
static inline void libcrux_ml_kem_ind_cpa_encrypt_60(Eurydice_slice public_key,
10806
                                                     uint8_t message[32U],
10807
                                                     Eurydice_slice randomness,
10808
0
                                                     uint8_t ret[1088U]) {
10809
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U];
10810
0
  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_33(
10811
0
      Eurydice_slice_subslice_to(public_key, (size_t)1152U, uint8_t, size_t),
10812
0
      t_as_ntt);
10813
0
  Eurydice_slice seed =
10814
0
      Eurydice_slice_subslice_from(public_key, (size_t)1152U, uint8_t, size_t);
10815
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A[3U][3U];
10816
0
  uint8_t ret0[34U];
10817
0
  libcrux_ml_kem_utils_into_padded_array_ea1(seed, ret0);
10818
0
  libcrux_ml_kem_matrix_sample_matrix_A_38(ret0, false, A);
10819
0
  uint8_t prf_input[33U];
10820
0
  libcrux_ml_kem_utils_into_padded_array_ea2(randomness, prf_input);
10821
  /* Passing arrays by value in Rust generates a copy in C */
10822
0
  uint8_t copy_of_prf_input0[33U];
10823
0
  memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t));
10824
0
  tuple_b0 uu____1 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(
10825
0
      copy_of_prf_input0, 0U);
10826
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 r_as_ntt[3U];
10827
0
  memcpy(
10828
0
      r_as_ntt, uu____1.fst,
10829
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10830
0
  uint8_t domain_separator0 = uu____1.snd;
10831
  /* Passing arrays by value in Rust generates a copy in C */
10832
0
  uint8_t copy_of_prf_input[33U];
10833
0
  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
10834
0
  tuple_b0 uu____3 = libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_ac(
10835
0
      copy_of_prf_input, domain_separator0);
10836
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_1[3U];
10837
0
  memcpy(
10838
0
      error_1, uu____3.fst,
10839
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10840
0
  uint8_t domain_separator = uu____3.snd;
10841
0
  prf_input[32U] = domain_separator;
10842
0
  uint8_t prf_output[128U];
10843
0
  libcrux_ml_kem_hash_functions_portable_PRF_f1_ee0(
10844
0
      Eurydice_array_to_slice((size_t)33U, prf_input, uint8_t), prf_output);
10845
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_2 =
10846
0
      libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6(
10847
0
          Eurydice_array_to_slice((size_t)128U, prf_output, uint8_t));
10848
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 u[3U];
10849
0
  libcrux_ml_kem_matrix_compute_vector_u_59(A, r_as_ntt, error_1, u);
10850
  /* Passing arrays by value in Rust generates a copy in C */
10851
0
  uint8_t copy_of_message[32U];
10852
0
  memcpy(copy_of_message, message, (size_t)32U * sizeof(uint8_t));
10853
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 message_as_ring_element =
10854
0
      libcrux_ml_kem_serialize_deserialize_then_decompress_message_0d(
10855
0
          copy_of_message);
10856
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 v =
10857
0
      libcrux_ml_kem_matrix_compute_ring_element_v_54(
10858
0
          t_as_ntt, r_as_ntt, &error_2, &message_as_ring_element);
10859
0
  uint8_t ciphertext[1088U] = {0U};
10860
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____5[3U];
10861
0
  memcpy(
10862
0
      uu____5, u,
10863
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10864
0
  libcrux_ml_kem_ind_cpa_compress_then_serialize_u_a7(
10865
0
      uu____5, Eurydice_array_to_subslice2(ciphertext, (size_t)0U, (size_t)960U,
10866
0
                                           uint8_t));
10867
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____6 = v;
10868
0
  libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_4e(
10869
0
      uu____6, Eurydice_array_to_subslice_from((size_t)1088U, ciphertext,
10870
0
                                               (size_t)960U, uint8_t, size_t));
10871
0
  memcpy(ret, ciphertext, (size_t)1088U * sizeof(uint8_t));
10872
0
}
10873
10874
/**
10875
This function found in impl {(libcrux_ml_kem::variant::Variant for
10876
libcrux_ml_kem::variant::MlKem)#1}
10877
*/
10878
/**
10879
A monomorphic instance of libcrux_ml_kem.variant.kdf_d8
10880
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
10881
with const generics
10882
- K= 3
10883
- CIPHERTEXT_SIZE= 1088
10884
*/
10885
static KRML_MUSTINLINE void libcrux_ml_kem_variant_kdf_d8_41(
10886
    Eurydice_slice shared_secret, libcrux_ml_kem_mlkem768_MlKem768Ciphertext *_,
10887
0
    uint8_t ret[32U]) {
10888
0
  uint8_t out[32U] = {0U};
10889
0
  Eurydice_slice_copy(Eurydice_array_to_slice((size_t)32U, out, uint8_t),
10890
0
                      shared_secret, uint8_t);
10891
0
  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
10892
0
}
10893
10894
/**
10895
A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate
10896
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
10897
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
10898
libcrux_ml_kem_variant_MlKem with const generics
10899
- K= 3
10900
- SECRET_KEY_SIZE= 2400
10901
- CPA_SECRET_KEY_SIZE= 1152
10902
- PUBLIC_KEY_SIZE= 1184
10903
- CIPHERTEXT_SIZE= 1088
10904
- T_AS_NTT_ENCODED_SIZE= 1152
10905
- C1_SIZE= 960
10906
- C2_SIZE= 128
10907
- VECTOR_U_COMPRESSION_FACTOR= 10
10908
- VECTOR_V_COMPRESSION_FACTOR= 4
10909
- C1_BLOCK_SIZE= 320
10910
- ETA1= 2
10911
- ETA1_RANDOMNESS_SIZE= 128
10912
- ETA2= 2
10913
- ETA2_RANDOMNESS_SIZE= 128
10914
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
10915
*/
10916
static inline void libcrux_ml_kem_ind_cca_decapsulate_70(
10917
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
10918
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
10919
0
  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
10920
0
      Eurydice_array_to_slice((size_t)2400U, private_key->value, uint8_t),
10921
0
      (size_t)1152U, uint8_t, Eurydice_slice_uint8_t_x2);
10922
0
  Eurydice_slice ind_cpa_secret_key = uu____0.fst;
10923
0
  Eurydice_slice secret_key0 = uu____0.snd;
10924
0
  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
10925
0
      secret_key0, (size_t)1184U, uint8_t, Eurydice_slice_uint8_t_x2);
10926
0
  Eurydice_slice ind_cpa_public_key = uu____1.fst;
10927
0
  Eurydice_slice secret_key = uu____1.snd;
10928
0
  Eurydice_slice_uint8_t_x2 uu____2 = Eurydice_slice_split_at(
10929
0
      secret_key, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
10930
0
      Eurydice_slice_uint8_t_x2);
10931
0
  Eurydice_slice ind_cpa_public_key_hash = uu____2.fst;
10932
0
  Eurydice_slice implicit_rejection_value = uu____2.snd;
10933
0
  uint8_t decrypted[32U];
10934
0
  libcrux_ml_kem_ind_cpa_decrypt_43(ind_cpa_secret_key, ciphertext->value,
10935
0
                                    decrypted);
10936
0
  uint8_t to_hash0[64U];
10937
0
  libcrux_ml_kem_utils_into_padded_array_ea(
10938
0
      Eurydice_array_to_slice((size_t)32U, decrypted, uint8_t), to_hash0);
10939
0
  Eurydice_slice_copy(
10940
0
      Eurydice_array_to_subslice_from(
10941
0
          (size_t)64U, to_hash0, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
10942
0
          uint8_t, size_t),
10943
0
      ind_cpa_public_key_hash, uint8_t);
10944
0
  uint8_t hashed[64U];
10945
0
  libcrux_ml_kem_hash_functions_portable_G_f1_e4(
10946
0
      Eurydice_array_to_slice((size_t)64U, to_hash0, uint8_t), hashed);
10947
0
  Eurydice_slice_uint8_t_x2 uu____3 = Eurydice_slice_split_at(
10948
0
      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t),
10949
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t,
10950
0
      Eurydice_slice_uint8_t_x2);
10951
0
  Eurydice_slice shared_secret0 = uu____3.fst;
10952
0
  Eurydice_slice pseudorandomness = uu____3.snd;
10953
0
  uint8_t to_hash[1120U];
10954
0
  libcrux_ml_kem_utils_into_padded_array_ea0(implicit_rejection_value, to_hash);
10955
0
  Eurydice_slice uu____4 = Eurydice_array_to_subslice_from(
10956
0
      (size_t)1120U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
10957
0
      uint8_t, size_t);
10958
0
  Eurydice_slice_copy(uu____4, libcrux_ml_kem_types_as_ref_00_24(ciphertext),
10959
0
                      uint8_t);
10960
0
  uint8_t implicit_rejection_shared_secret0[32U];
10961
0
  libcrux_ml_kem_hash_functions_portable_PRF_f1_ee(
10962
0
      Eurydice_array_to_slice((size_t)1120U, to_hash, uint8_t),
10963
0
      implicit_rejection_shared_secret0);
10964
0
  Eurydice_slice uu____5 = ind_cpa_public_key;
10965
  /* Passing arrays by value in Rust generates a copy in C */
10966
0
  uint8_t copy_of_decrypted[32U];
10967
0
  memcpy(copy_of_decrypted, decrypted, (size_t)32U * sizeof(uint8_t));
10968
0
  uint8_t expected_ciphertext[1088U];
10969
0
  libcrux_ml_kem_ind_cpa_encrypt_60(uu____5, copy_of_decrypted,
10970
0
                                    pseudorandomness, expected_ciphertext);
10971
0
  uint8_t implicit_rejection_shared_secret[32U];
10972
0
  libcrux_ml_kem_variant_kdf_d8_41(
10973
0
      Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret0,
10974
0
                              uint8_t),
10975
0
      ciphertext, implicit_rejection_shared_secret);
10976
0
  uint8_t shared_secret[32U];
10977
0
  libcrux_ml_kem_variant_kdf_d8_41(shared_secret0, ciphertext, shared_secret);
10978
0
  uint8_t ret0[32U];
10979
0
  libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time(
10980
0
      libcrux_ml_kem_types_as_ref_00_24(ciphertext),
10981
0
      Eurydice_array_to_slice((size_t)1088U, expected_ciphertext, uint8_t),
10982
0
      Eurydice_array_to_slice((size_t)32U, shared_secret, uint8_t),
10983
0
      Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret,
10984
0
                              uint8_t),
10985
0
      ret0);
10986
0
  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
10987
0
}
10988
10989
/**
10990
 Portable decapsulate
10991
*/
10992
/**
10993
A monomorphic instance of
10994
libcrux_ml_kem.ind_cca.instantiations.portable.decapsulate with const generics
10995
- K= 3
10996
- SECRET_KEY_SIZE= 2400
10997
- CPA_SECRET_KEY_SIZE= 1152
10998
- PUBLIC_KEY_SIZE= 1184
10999
- CIPHERTEXT_SIZE= 1088
11000
- T_AS_NTT_ENCODED_SIZE= 1152
11001
- C1_SIZE= 960
11002
- C2_SIZE= 128
11003
- VECTOR_U_COMPRESSION_FACTOR= 10
11004
- VECTOR_V_COMPRESSION_FACTOR= 4
11005
- C1_BLOCK_SIZE= 320
11006
- ETA1= 2
11007
- ETA1_RANDOMNESS_SIZE= 128
11008
- ETA2= 2
11009
- ETA2_RANDOMNESS_SIZE= 128
11010
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
11011
*/
11012
static inline void
11013
libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_2e(
11014
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
11015
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
11016
0
  libcrux_ml_kem_ind_cca_decapsulate_70(private_key, ciphertext, ret);
11017
0
}
11018
11019
/**
11020
 Decapsulate ML-KEM 768
11021
11022
 Generates an [`MlKemSharedSecret`].
11023
 The input is a reference to an [`MlKem768PrivateKey`] and an
11024
 [`MlKem768Ciphertext`].
11025
*/
11026
static inline void libcrux_ml_kem_mlkem768_portable_decapsulate(
11027
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
11028
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
11029
0
  libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_2e(
11030
0
      private_key, ciphertext, ret);
11031
0
}
11032
11033
/**
11034
This function found in impl {(libcrux_ml_kem::variant::Variant for
11035
libcrux_ml_kem::variant::MlKem)#1}
11036
*/
11037
/**
11038
A monomorphic instance of libcrux_ml_kem.variant.entropy_preprocess_d8
11039
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
11040
with const generics
11041
- K= 3
11042
*/
11043
static KRML_MUSTINLINE void libcrux_ml_kem_variant_entropy_preprocess_d8_63(
11044
0
    Eurydice_slice randomness, uint8_t ret[32U]) {
11045
0
  uint8_t out[32U] = {0U};
11046
0
  Eurydice_slice_copy(Eurydice_array_to_slice((size_t)32U, out, uint8_t),
11047
0
                      randomness, uint8_t);
11048
0
  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
11049
0
}
11050
11051
/**
11052
This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for
11053
libcrux_ml_kem::hash_functions::portable::PortableHash<K>)}
11054
*/
11055
/**
11056
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.H_f1
11057
with const generics
11058
- K= 3
11059
*/
11060
static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_H_f1_1a(
11061
0
    Eurydice_slice input, uint8_t ret[32U]) {
11062
0
  libcrux_ml_kem_hash_functions_portable_H(input, ret);
11063
0
}
11064
11065
/**
11066
A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate
11067
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
11068
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
11069
libcrux_ml_kem_variant_MlKem with const generics
11070
- K= 3
11071
- CIPHERTEXT_SIZE= 1088
11072
- PUBLIC_KEY_SIZE= 1184
11073
- T_AS_NTT_ENCODED_SIZE= 1152
11074
- C1_SIZE= 960
11075
- C2_SIZE= 128
11076
- VECTOR_U_COMPRESSION_FACTOR= 10
11077
- VECTOR_V_COMPRESSION_FACTOR= 4
11078
- VECTOR_U_BLOCK_LEN= 320
11079
- ETA1= 2
11080
- ETA1_RANDOMNESS_SIZE= 128
11081
- ETA2= 2
11082
- ETA2_RANDOMNESS_SIZE= 128
11083
*/
11084
static inline tuple_3c libcrux_ml_kem_ind_cca_encapsulate_cd(
11085
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key,
11086
0
    uint8_t randomness[32U]) {
11087
0
  uint8_t randomness0[32U];
11088
0
  libcrux_ml_kem_variant_entropy_preprocess_d8_63(
11089
0
      Eurydice_array_to_slice((size_t)32U, randomness, uint8_t), randomness0);
11090
0
  uint8_t to_hash[64U];
11091
0
  libcrux_ml_kem_utils_into_padded_array_ea(
11092
0
      Eurydice_array_to_slice((size_t)32U, randomness0, uint8_t), to_hash);
11093
0
  Eurydice_slice uu____0 = Eurydice_array_to_subslice_from(
11094
0
      (size_t)64U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
11095
0
      size_t);
11096
0
  uint8_t ret[32U];
11097
0
  libcrux_ml_kem_hash_functions_portable_H_f1_1a(
11098
0
      Eurydice_array_to_slice((size_t)1184U,
11099
0
                              libcrux_ml_kem_types_as_slice_cb_50(public_key),
11100
0
                              uint8_t),
11101
0
      ret);
11102
0
  Eurydice_slice_copy(
11103
0
      uu____0, Eurydice_array_to_slice((size_t)32U, ret, uint8_t), uint8_t);
11104
0
  uint8_t hashed[64U];
11105
0
  libcrux_ml_kem_hash_functions_portable_G_f1_e4(
11106
0
      Eurydice_array_to_slice((size_t)64U, to_hash, uint8_t), hashed);
11107
0
  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
11108
0
      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t),
11109
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t,
11110
0
      Eurydice_slice_uint8_t_x2);
11111
0
  Eurydice_slice shared_secret = uu____1.fst;
11112
0
  Eurydice_slice pseudorandomness = uu____1.snd;
11113
0
  Eurydice_slice uu____2 = Eurydice_array_to_slice(
11114
0
      (size_t)1184U, libcrux_ml_kem_types_as_slice_cb_50(public_key), uint8_t);
11115
  /* Passing arrays by value in Rust generates a copy in C */
11116
0
  uint8_t copy_of_randomness[32U];
11117
0
  memcpy(copy_of_randomness, randomness0, (size_t)32U * sizeof(uint8_t));
11118
0
  uint8_t ciphertext[1088U];
11119
0
  libcrux_ml_kem_ind_cpa_encrypt_60(uu____2, copy_of_randomness,
11120
0
                                    pseudorandomness, ciphertext);
11121
  /* Passing arrays by value in Rust generates a copy in C */
11122
0
  uint8_t copy_of_ciphertext[1088U];
11123
0
  memcpy(copy_of_ciphertext, ciphertext, (size_t)1088U * sizeof(uint8_t));
11124
0
  libcrux_ml_kem_mlkem768_MlKem768Ciphertext ciphertext0 =
11125
0
      libcrux_ml_kem_types_from_01_9f(copy_of_ciphertext);
11126
0
  uint8_t shared_secret_array[32U];
11127
0
  libcrux_ml_kem_variant_kdf_d8_41(shared_secret, &ciphertext0,
11128
0
                                   shared_secret_array);
11129
0
  libcrux_ml_kem_mlkem768_MlKem768Ciphertext uu____5 = ciphertext0;
11130
  /* Passing arrays by value in Rust generates a copy in C */
11131
0
  uint8_t copy_of_shared_secret_array[32U];
11132
0
  memcpy(copy_of_shared_secret_array, shared_secret_array,
11133
0
         (size_t)32U * sizeof(uint8_t));
11134
0
  tuple_3c lit;
11135
0
  lit.fst = uu____5;
11136
0
  memcpy(lit.snd, copy_of_shared_secret_array, (size_t)32U * sizeof(uint8_t));
11137
0
  return lit;
11138
0
}
11139
11140
/**
11141
A monomorphic instance of
11142
libcrux_ml_kem.ind_cca.instantiations.portable.encapsulate with const generics
11143
- K= 3
11144
- CIPHERTEXT_SIZE= 1088
11145
- PUBLIC_KEY_SIZE= 1184
11146
- T_AS_NTT_ENCODED_SIZE= 1152
11147
- C1_SIZE= 960
11148
- C2_SIZE= 128
11149
- VECTOR_U_COMPRESSION_FACTOR= 10
11150
- VECTOR_V_COMPRESSION_FACTOR= 4
11151
- VECTOR_U_BLOCK_LEN= 320
11152
- ETA1= 2
11153
- ETA1_RANDOMNESS_SIZE= 128
11154
- ETA2= 2
11155
- ETA2_RANDOMNESS_SIZE= 128
11156
*/
11157
static inline tuple_3c
11158
libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_c6(
11159
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key,
11160
0
    uint8_t randomness[32U]) {
11161
0
  libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key;
11162
  /* Passing arrays by value in Rust generates a copy in C */
11163
0
  uint8_t copy_of_randomness[32U];
11164
0
  memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t));
11165
0
  return libcrux_ml_kem_ind_cca_encapsulate_cd(uu____0, copy_of_randomness);
11166
0
}
11167
11168
/**
11169
 Encapsulate ML-KEM 768
11170
11171
 Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple.
11172
 The input is a reference to an [`MlKem768PublicKey`] and [`SHARED_SECRET_SIZE`]
11173
 bytes of `randomness`.
11174
*/
11175
static inline tuple_3c libcrux_ml_kem_mlkem768_portable_encapsulate(
11176
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key,
11177
0
    uint8_t randomness[32U]) {
11178
0
  libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key;
11179
  /* Passing arrays by value in Rust generates a copy in C */
11180
0
  uint8_t copy_of_randomness[32U];
11181
0
  memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t));
11182
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_c6(
11183
0
      uu____0, copy_of_randomness);
11184
0
}
11185
11186
/**
11187
This function found in impl {(libcrux_ml_kem::variant::Variant for
11188
libcrux_ml_kem::variant::MlKem)#1}
11189
*/
11190
/**
11191
A monomorphic instance of libcrux_ml_kem.variant.cpa_keygen_seed_d8
11192
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
11193
with const generics
11194
- K= 3
11195
*/
11196
static KRML_MUSTINLINE void libcrux_ml_kem_variant_cpa_keygen_seed_d8_0e(
11197
0
    Eurydice_slice key_generation_seed, uint8_t ret[64U]) {
11198
0
  uint8_t seed[33U] = {0U};
11199
0
  Eurydice_slice_copy(
11200
0
      Eurydice_array_to_subslice2(
11201
0
          seed, (size_t)0U,
11202
0
          LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t),
11203
0
      key_generation_seed, uint8_t);
11204
0
  seed[LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE] =
11205
0
      (uint8_t)(size_t)3U;
11206
0
  uint8_t ret0[64U];
11207
0
  libcrux_ml_kem_hash_functions_portable_G_f1_e4(
11208
0
      Eurydice_array_to_slice((size_t)33U, seed, uint8_t), ret0);
11209
0
  memcpy(ret, ret0, (size_t)64U * sizeof(uint8_t));
11210
0
}
11211
11212
/**
11213
A monomorphic instance of libcrux_ml_kem.matrix.compute_As_plus_e.closure
11214
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
11215
with const generics
11216
- K= 3
11217
*/
11218
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
11219
0
libcrux_ml_kem_matrix_compute_As_plus_e_closure_87(size_t _i) {
11220
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
11221
0
}
11222
11223
/**
11224
A monomorphic instance of libcrux_ml_kem.vector.traits.to_standard_domain
11225
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
11226
with const generics
11227
11228
*/
11229
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
11230
libcrux_ml_kem_vector_traits_to_standard_domain_59(
11231
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
11232
0
  return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(
11233
0
      v, LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS);
11234
0
}
11235
11236
/**
11237
This function found in impl
11238
{libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]}
11239
*/
11240
/**
11241
A monomorphic instance of libcrux_ml_kem.polynomial.add_standard_error_reduce_89
11242
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
11243
with const generics
11244
11245
*/
11246
static KRML_MUSTINLINE void
11247
libcrux_ml_kem_polynomial_add_standard_error_reduce_89_03(
11248
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self,
11249
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error) {
11250
0
  for (size_t i = (size_t)0U;
11251
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
11252
0
    size_t j = i;
11253
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector
11254
0
        coefficient_normal_form =
11255
0
            libcrux_ml_kem_vector_traits_to_standard_domain_59(
11256
0
                self->coefficients[j]);
11257
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
11258
0
        libcrux_ml_kem_vector_portable_barrett_reduce_0d(
11259
0
            libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form,
11260
0
                                                  &error->coefficients[j]));
11261
0
    self->coefficients[j] = uu____0;
11262
0
  }
11263
0
}
11264
11265
/**
11266
 Compute  ◦ ŝ + ê
11267
*/
11268
/**
11269
A monomorphic instance of libcrux_ml_kem.matrix.compute_As_plus_e
11270
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
11271
with const generics
11272
- K= 3
11273
*/
11274
static KRML_MUSTINLINE void libcrux_ml_kem_matrix_compute_As_plus_e_60(
11275
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 (*matrix_A)[3U],
11276
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *s_as_ntt,
11277
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error_as_ntt,
11278
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
11279
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result[3U];
11280
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
11281
0
    result[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
11282
0
  }
11283
0
  for (size_t i0 = (size_t)0U;
11284
0
       i0 < Eurydice_slice_len(
11285
0
                Eurydice_array_to_slice(
11286
0
                    (size_t)3U, matrix_A,
11287
0
                    libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]),
11288
0
                libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]);
11289
0
       i0++) {
11290
0
    size_t i1 = i0;
11291
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *row = matrix_A[i1];
11292
0
    for (size_t i = (size_t)0U;
11293
0
         i < Eurydice_slice_len(
11294
0
                 Eurydice_array_to_slice(
11295
0
                     (size_t)3U, row,
11296
0
                     libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
11297
0
                 libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
11298
0
         i++) {
11299
0
      size_t j = i;
11300
0
      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *matrix_element =
11301
0
          &row[j];
11302
0
      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product =
11303
0
          libcrux_ml_kem_polynomial_ntt_multiply_89_2a(matrix_element,
11304
0
                                                       &s_as_ntt[j]);
11305
0
      libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result[i1],
11306
0
                                                          &product);
11307
0
    }
11308
0
    libcrux_ml_kem_polynomial_add_standard_error_reduce_89_03(
11309
0
        &result[i1], &error_as_ntt[i1]);
11310
0
  }
11311
0
  memcpy(
11312
0
      ret, result,
11313
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11314
0
}
11315
11316
/**
11317
A monomorphic instance of
11318
libcrux_ml_kem.serialize.serialize_uncompressed_ring_element with types
11319
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
11320
11321
*/
11322
static KRML_MUSTINLINE void
11323
libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_5b(
11324
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[384U]) {
11325
0
  uint8_t serialized[384U] = {0U};
11326
0
  for (size_t i = (size_t)0U;
11327
0
       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
11328
0
    size_t i0 = i;
11329
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
11330
0
        libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
11331
0
            re->coefficients[i0]);
11332
0
    uint8_t bytes[24U];
11333
0
    libcrux_ml_kem_vector_portable_serialize_12_0d(coefficient, bytes);
11334
0
    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
11335
0
        serialized, (size_t)24U * i0, (size_t)24U * i0 + (size_t)24U, uint8_t);
11336
0
    Eurydice_slice_copy(
11337
0
        uu____0, Eurydice_array_to_slice((size_t)24U, bytes, uint8_t), uint8_t);
11338
0
  }
11339
0
  memcpy(ret, serialized, (size_t)384U * sizeof(uint8_t));
11340
0
}
11341
11342
/**
11343
 Call [`serialize_uncompressed_ring_element`] for each ring element.
11344
*/
11345
/**
11346
A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_secret_key
11347
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
11348
with const generics
11349
- K= 3
11350
- OUT_LEN= 1152
11351
*/
11352
static KRML_MUSTINLINE void libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(
11353
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *key,
11354
0
    uint8_t ret[1152U]) {
11355
0
  uint8_t out[1152U] = {0U};
11356
0
  for (size_t i = (size_t)0U;
11357
0
       i < Eurydice_slice_len(
11358
0
               Eurydice_array_to_slice(
11359
0
                   (size_t)3U, key,
11360
0
                   libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
11361
0
               libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
11362
0
       i++) {
11363
0
    size_t i0 = i;
11364
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = key[i0];
11365
0
    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
11366
0
        out, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
11367
0
        (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
11368
0
        uint8_t);
11369
0
    uint8_t ret0[384U];
11370
0
    libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_5b(&re, ret0);
11371
0
    Eurydice_slice_copy(
11372
0
        uu____0, Eurydice_array_to_slice((size_t)384U, ret0, uint8_t), uint8_t);
11373
0
  }
11374
0
  memcpy(ret, out, (size_t)1152U * sizeof(uint8_t));
11375
0
}
11376
11377
/**
11378
 Concatenate `t` and `ρ` into the public key.
11379
*/
11380
/**
11381
A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_public_key
11382
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
11383
with const generics
11384
- K= 3
11385
- RANKED_BYTES_PER_RING_ELEMENT= 1152
11386
- PUBLIC_KEY_SIZE= 1184
11387
*/
11388
static KRML_MUSTINLINE void libcrux_ml_kem_ind_cpa_serialize_public_key_79(
11389
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *t_as_ntt,
11390
0
    Eurydice_slice seed_for_a, uint8_t ret[1184U]) {
11391
0
  uint8_t public_key_serialized[1184U] = {0U};
11392
0
  Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
11393
0
      public_key_serialized, (size_t)0U, (size_t)1152U, uint8_t);
11394
0
  uint8_t ret0[1152U];
11395
0
  libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(t_as_ntt, ret0);
11396
0
  Eurydice_slice_copy(
11397
0
      uu____0, Eurydice_array_to_slice((size_t)1152U, ret0, uint8_t), uint8_t);
11398
0
  Eurydice_slice_copy(
11399
0
      Eurydice_array_to_subslice_from((size_t)1184U, public_key_serialized,
11400
0
                                      (size_t)1152U, uint8_t, size_t),
11401
0
      seed_for_a, uint8_t);
11402
0
  memcpy(ret, public_key_serialized, (size_t)1184U * sizeof(uint8_t));
11403
0
}
11404
11405
/**
11406
A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair
11407
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
11408
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
11409
libcrux_ml_kem_variant_MlKem with const generics
11410
- K= 3
11411
- PRIVATE_KEY_SIZE= 1152
11412
- PUBLIC_KEY_SIZE= 1184
11413
- RANKED_BYTES_PER_RING_ELEMENT= 1152
11414
- ETA1= 2
11415
- ETA1_RANDOMNESS_SIZE= 128
11416
*/
11417
static inline libcrux_ml_kem_utils_extraction_helper_Keypair768
11418
0
libcrux_ml_kem_ind_cpa_generate_keypair_fc(Eurydice_slice key_generation_seed) {
11419
0
  uint8_t hashed[64U];
11420
0
  libcrux_ml_kem_variant_cpa_keygen_seed_d8_0e(key_generation_seed, hashed);
11421
0
  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
11422
0
      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U,
11423
0
      uint8_t, Eurydice_slice_uint8_t_x2);
11424
0
  Eurydice_slice seed_for_A0 = uu____0.fst;
11425
0
  Eurydice_slice seed_for_secret_and_error = uu____0.snd;
11426
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U];
11427
0
  uint8_t ret[34U];
11428
0
  libcrux_ml_kem_utils_into_padded_array_ea1(seed_for_A0, ret);
11429
0
  libcrux_ml_kem_matrix_sample_matrix_A_38(ret, true, A_transpose);
11430
0
  uint8_t prf_input[33U];
11431
0
  libcrux_ml_kem_utils_into_padded_array_ea2(seed_for_secret_and_error,
11432
0
                                             prf_input);
11433
  /* Passing arrays by value in Rust generates a copy in C */
11434
0
  uint8_t copy_of_prf_input0[33U];
11435
0
  memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t));
11436
0
  tuple_b0 uu____2 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(
11437
0
      copy_of_prf_input0, 0U);
11438
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U];
11439
0
  memcpy(
11440
0
      secret_as_ntt, uu____2.fst,
11441
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11442
0
  uint8_t domain_separator = uu____2.snd;
11443
  /* Passing arrays by value in Rust generates a copy in C */
11444
0
  uint8_t copy_of_prf_input[33U];
11445
0
  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
11446
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_as_ntt[3U];
11447
0
  memcpy(
11448
0
      error_as_ntt,
11449
0
      libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(copy_of_prf_input,
11450
0
                                                           domain_separator)
11451
0
          .fst,
11452
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11453
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U];
11454
0
  libcrux_ml_kem_matrix_compute_As_plus_e_60(A_transpose, secret_as_ntt,
11455
0
                                             error_as_ntt, t_as_ntt);
11456
0
  uint8_t seed_for_A[32U];
11457
0
  Result_00 dst;
11458
0
  Eurydice_slice_to_array2(&dst, seed_for_A0, Eurydice_slice, uint8_t[32U]);
11459
0
  unwrap_41_83(dst, seed_for_A);
11460
0
  uint8_t public_key_serialized[1184U];
11461
0
  libcrux_ml_kem_ind_cpa_serialize_public_key_79(
11462
0
      t_as_ntt, Eurydice_array_to_slice((size_t)32U, seed_for_A, uint8_t),
11463
0
      public_key_serialized);
11464
0
  uint8_t secret_key_serialized[1152U];
11465
0
  libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(secret_as_ntt,
11466
0
                                                 secret_key_serialized);
11467
  /* Passing arrays by value in Rust generates a copy in C */
11468
0
  uint8_t copy_of_secret_key_serialized[1152U];
11469
0
  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
11470
0
         (size_t)1152U * sizeof(uint8_t));
11471
  /* Passing arrays by value in Rust generates a copy in C */
11472
0
  uint8_t copy_of_public_key_serialized[1184U];
11473
0
  memcpy(copy_of_public_key_serialized, public_key_serialized,
11474
0
         (size_t)1184U * sizeof(uint8_t));
11475
0
  libcrux_ml_kem_utils_extraction_helper_Keypair768 lit;
11476
0
  memcpy(lit.fst, copy_of_secret_key_serialized,
11477
0
         (size_t)1152U * sizeof(uint8_t));
11478
0
  memcpy(lit.snd, copy_of_public_key_serialized,
11479
0
         (size_t)1184U * sizeof(uint8_t));
11480
0
  return lit;
11481
0
}
11482
11483
/**
11484
 Serialize the secret key.
11485
*/
11486
/**
11487
A monomorphic instance of libcrux_ml_kem.ind_cca.serialize_kem_secret_key
11488
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
11489
with const generics
11490
- K= 3
11491
- SERIALIZED_KEY_LEN= 2400
11492
*/
11493
static KRML_MUSTINLINE void libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48(
11494
    Eurydice_slice private_key, Eurydice_slice public_key,
11495
0
    Eurydice_slice implicit_rejection_value, uint8_t ret[2400U]) {
11496
0
  uint8_t out[2400U] = {0U};
11497
0
  size_t pointer = (size_t)0U;
11498
0
  uint8_t *uu____0 = out;
11499
0
  size_t uu____1 = pointer;
11500
0
  size_t uu____2 = pointer;
11501
0
  Eurydice_slice_copy(
11502
0
      Eurydice_array_to_subslice2(
11503
0
          uu____0, uu____1, uu____2 + Eurydice_slice_len(private_key, uint8_t),
11504
0
          uint8_t),
11505
0
      private_key, uint8_t);
11506
0
  pointer = pointer + Eurydice_slice_len(private_key, uint8_t);
11507
0
  uint8_t *uu____3 = out;
11508
0
  size_t uu____4 = pointer;
11509
0
  size_t uu____5 = pointer;
11510
0
  Eurydice_slice_copy(
11511
0
      Eurydice_array_to_subslice2(
11512
0
          uu____3, uu____4, uu____5 + Eurydice_slice_len(public_key, uint8_t),
11513
0
          uint8_t),
11514
0
      public_key, uint8_t);
11515
0
  pointer = pointer + Eurydice_slice_len(public_key, uint8_t);
11516
0
  Eurydice_slice uu____6 = Eurydice_array_to_subslice2(
11517
0
      out, pointer, pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t);
11518
0
  uint8_t ret0[32U];
11519
0
  libcrux_ml_kem_hash_functions_portable_H_f1_1a(public_key, ret0);
11520
0
  Eurydice_slice_copy(
11521
0
      uu____6, Eurydice_array_to_slice((size_t)32U, ret0, uint8_t), uint8_t);
11522
0
  pointer = pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE;
11523
0
  uint8_t *uu____7 = out;
11524
0
  size_t uu____8 = pointer;
11525
0
  size_t uu____9 = pointer;
11526
0
  Eurydice_slice_copy(
11527
0
      Eurydice_array_to_subslice2(
11528
0
          uu____7, uu____8,
11529
0
          uu____9 + Eurydice_slice_len(implicit_rejection_value, uint8_t),
11530
0
          uint8_t),
11531
0
      implicit_rejection_value, uint8_t);
11532
0
  memcpy(ret, out, (size_t)2400U * sizeof(uint8_t));
11533
0
}
11534
11535
/**
11536
 Packed API
11537
11538
 Generate a key pair.
11539
11540
 Depending on the `Vector` and `Hasher` used, this requires different hardware
11541
 features
11542
*/
11543
/**
11544
A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair
11545
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
11546
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
11547
libcrux_ml_kem_variant_MlKem with const generics
11548
- K= 3
11549
- CPA_PRIVATE_KEY_SIZE= 1152
11550
- PRIVATE_KEY_SIZE= 2400
11551
- PUBLIC_KEY_SIZE= 1184
11552
- BYTES_PER_RING_ELEMENT= 1152
11553
- ETA1= 2
11554
- ETA1_RANDOMNESS_SIZE= 128
11555
*/
11556
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
11557
0
libcrux_ml_kem_ind_cca_generate_keypair_8c(uint8_t randomness[64U]) {
11558
0
  Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice2(
11559
0
      randomness, (size_t)0U,
11560
0
      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t);
11561
0
  Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from(
11562
0
      (size_t)64U, randomness,
11563
0
      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t,
11564
0
      size_t);
11565
0
  libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 =
11566
0
      libcrux_ml_kem_ind_cpa_generate_keypair_fc(ind_cpa_keypair_randomness);
11567
0
  uint8_t ind_cpa_private_key[1152U];
11568
0
  memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t));
11569
0
  uint8_t public_key[1184U];
11570
0
  memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t));
11571
0
  uint8_t secret_key_serialized[2400U];
11572
0
  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48(
11573
0
      Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t),
11574
0
      Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t),
11575
0
      implicit_rejection_value, secret_key_serialized);
11576
  /* Passing arrays by value in Rust generates a copy in C */
11577
0
  uint8_t copy_of_secret_key_serialized[2400U];
11578
0
  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
11579
0
         (size_t)2400U * sizeof(uint8_t));
11580
0
  libcrux_ml_kem_types_MlKemPrivateKey_55 private_key =
11581
0
      libcrux_ml_kem_types_from_05_f2(copy_of_secret_key_serialized);
11582
0
  libcrux_ml_kem_types_MlKemPrivateKey_55 uu____2 = private_key;
11583
  /* Passing arrays by value in Rust generates a copy in C */
11584
0
  uint8_t copy_of_public_key[1184U];
11585
0
  memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t));
11586
0
  return libcrux_ml_kem_types_from_17_35(
11587
0
      uu____2, libcrux_ml_kem_types_from_b6_da(copy_of_public_key));
11588
0
}
11589
11590
/**
11591
 Portable generate key pair.
11592
*/
11593
/**
11594
A monomorphic instance of
11595
libcrux_ml_kem.ind_cca.instantiations.portable.generate_keypair with const
11596
generics
11597
- K= 3
11598
- CPA_PRIVATE_KEY_SIZE= 1152
11599
- PRIVATE_KEY_SIZE= 2400
11600
- PUBLIC_KEY_SIZE= 1184
11601
- BYTES_PER_RING_ELEMENT= 1152
11602
- ETA1= 2
11603
- ETA1_RANDOMNESS_SIZE= 128
11604
*/
11605
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
11606
libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_d5(
11607
0
    uint8_t randomness[64U]) {
11608
  /* Passing arrays by value in Rust generates a copy in C */
11609
0
  uint8_t copy_of_randomness[64U];
11610
0
  memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
11611
0
  return libcrux_ml_kem_ind_cca_generate_keypair_8c(copy_of_randomness);
11612
0
}
11613
11614
/**
11615
 Generate ML-KEM 768 Key Pair
11616
*/
11617
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
11618
0
libcrux_ml_kem_mlkem768_portable_generate_key_pair(uint8_t randomness[64U]) {
11619
  /* Passing arrays by value in Rust generates a copy in C */
11620
0
  uint8_t copy_of_randomness[64U];
11621
0
  memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
11622
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_d5(
11623
0
      copy_of_randomness);
11624
0
}
11625
11626
/**
11627
This function found in impl {(libcrux_ml_kem::variant::Variant for
11628
libcrux_ml_kem::variant::Kyber)}
11629
*/
11630
/**
11631
A monomorphic instance of libcrux_ml_kem.variant.kdf_33
11632
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
11633
with const generics
11634
- K= 3
11635
- CIPHERTEXT_SIZE= 1088
11636
*/
11637
static KRML_MUSTINLINE void libcrux_ml_kem_variant_kdf_33_f0(
11638
    Eurydice_slice shared_secret,
11639
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
11640
0
  uint8_t kdf_input[64U];
11641
0
  libcrux_ml_kem_utils_into_padded_array_ea(shared_secret, kdf_input);
11642
0
  Eurydice_slice uu____0 = Eurydice_array_to_subslice_from(
11643
0
      (size_t)64U, kdf_input, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
11644
0
      size_t);
11645
0
  uint8_t ret0[32U];
11646
0
  libcrux_ml_kem_hash_functions_portable_H_f1_1a(
11647
0
      Eurydice_array_to_slice((size_t)1088U,
11648
0
                              libcrux_ml_kem_types_as_slice_d4_1d(ciphertext),
11649
0
                              uint8_t),
11650
0
      ret0);
11651
0
  Eurydice_slice_copy(
11652
0
      uu____0, Eurydice_array_to_slice((size_t)32U, ret0, uint8_t), uint8_t);
11653
0
  uint8_t ret1[32U];
11654
0
  libcrux_ml_kem_hash_functions_portable_PRF_f1_ee(
11655
0
      Eurydice_array_to_slice((size_t)64U, kdf_input, uint8_t), ret1);
11656
0
  memcpy(ret, ret1, (size_t)32U * sizeof(uint8_t));
11657
0
}
11658
11659
/**
11660
A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate
11661
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
11662
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
11663
libcrux_ml_kem_variant_Kyber with const generics
11664
- K= 3
11665
- SECRET_KEY_SIZE= 2400
11666
- CPA_SECRET_KEY_SIZE= 1152
11667
- PUBLIC_KEY_SIZE= 1184
11668
- CIPHERTEXT_SIZE= 1088
11669
- T_AS_NTT_ENCODED_SIZE= 1152
11670
- C1_SIZE= 960
11671
- C2_SIZE= 128
11672
- VECTOR_U_COMPRESSION_FACTOR= 10
11673
- VECTOR_V_COMPRESSION_FACTOR= 4
11674
- C1_BLOCK_SIZE= 320
11675
- ETA1= 2
11676
- ETA1_RANDOMNESS_SIZE= 128
11677
- ETA2= 2
11678
- ETA2_RANDOMNESS_SIZE= 128
11679
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
11680
*/
11681
static inline void libcrux_ml_kem_ind_cca_decapsulate_700(
11682
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
11683
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
11684
0
  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
11685
0
      Eurydice_array_to_slice((size_t)2400U, private_key->value, uint8_t),
11686
0
      (size_t)1152U, uint8_t, Eurydice_slice_uint8_t_x2);
11687
0
  Eurydice_slice ind_cpa_secret_key = uu____0.fst;
11688
0
  Eurydice_slice secret_key0 = uu____0.snd;
11689
0
  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
11690
0
      secret_key0, (size_t)1184U, uint8_t, Eurydice_slice_uint8_t_x2);
11691
0
  Eurydice_slice ind_cpa_public_key = uu____1.fst;
11692
0
  Eurydice_slice secret_key = uu____1.snd;
11693
0
  Eurydice_slice_uint8_t_x2 uu____2 = Eurydice_slice_split_at(
11694
0
      secret_key, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
11695
0
      Eurydice_slice_uint8_t_x2);
11696
0
  Eurydice_slice ind_cpa_public_key_hash = uu____2.fst;
11697
0
  Eurydice_slice implicit_rejection_value = uu____2.snd;
11698
0
  uint8_t decrypted[32U];
11699
0
  libcrux_ml_kem_ind_cpa_decrypt_43(ind_cpa_secret_key, ciphertext->value,
11700
0
                                    decrypted);
11701
0
  uint8_t to_hash0[64U];
11702
0
  libcrux_ml_kem_utils_into_padded_array_ea(
11703
0
      Eurydice_array_to_slice((size_t)32U, decrypted, uint8_t), to_hash0);
11704
0
  Eurydice_slice_copy(
11705
0
      Eurydice_array_to_subslice_from(
11706
0
          (size_t)64U, to_hash0, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
11707
0
          uint8_t, size_t),
11708
0
      ind_cpa_public_key_hash, uint8_t);
11709
0
  uint8_t hashed[64U];
11710
0
  libcrux_ml_kem_hash_functions_portable_G_f1_e4(
11711
0
      Eurydice_array_to_slice((size_t)64U, to_hash0, uint8_t), hashed);
11712
0
  Eurydice_slice_uint8_t_x2 uu____3 = Eurydice_slice_split_at(
11713
0
      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t),
11714
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t,
11715
0
      Eurydice_slice_uint8_t_x2);
11716
0
  Eurydice_slice shared_secret0 = uu____3.fst;
11717
0
  Eurydice_slice pseudorandomness = uu____3.snd;
11718
0
  uint8_t to_hash[1120U];
11719
0
  libcrux_ml_kem_utils_into_padded_array_ea0(implicit_rejection_value, to_hash);
11720
0
  Eurydice_slice uu____4 = Eurydice_array_to_subslice_from(
11721
0
      (size_t)1120U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
11722
0
      uint8_t, size_t);
11723
0
  Eurydice_slice_copy(uu____4, libcrux_ml_kem_types_as_ref_00_24(ciphertext),
11724
0
                      uint8_t);
11725
0
  uint8_t implicit_rejection_shared_secret0[32U];
11726
0
  libcrux_ml_kem_hash_functions_portable_PRF_f1_ee(
11727
0
      Eurydice_array_to_slice((size_t)1120U, to_hash, uint8_t),
11728
0
      implicit_rejection_shared_secret0);
11729
0
  Eurydice_slice uu____5 = ind_cpa_public_key;
11730
0
  /* Passing arrays by value in Rust generates a copy in C */
11731
0
  uint8_t copy_of_decrypted[32U];
11732
0
  memcpy(copy_of_decrypted, decrypted, (size_t)32U * sizeof(uint8_t));
11733
0
  uint8_t expected_ciphertext[1088U];
11734
0
  libcrux_ml_kem_ind_cpa_encrypt_60(uu____5, copy_of_decrypted,
11735
0
                                    pseudorandomness, expected_ciphertext);
11736
0
  uint8_t implicit_rejection_shared_secret[32U];
11737
0
  libcrux_ml_kem_variant_kdf_33_f0(
11738
0
      Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret0,
11739
0
                              uint8_t),
11740
0
      ciphertext, implicit_rejection_shared_secret);
11741
0
  uint8_t shared_secret[32U];
11742
0
  libcrux_ml_kem_variant_kdf_33_f0(shared_secret0, ciphertext, shared_secret);
11743
0
  uint8_t ret0[32U];
11744
0
  libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time(
11745
0
      libcrux_ml_kem_types_as_ref_00_24(ciphertext),
11746
0
      Eurydice_array_to_slice((size_t)1088U, expected_ciphertext, uint8_t),
11747
0
      Eurydice_array_to_slice((size_t)32U, shared_secret, uint8_t),
11748
0
      Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret,
11749
0
                              uint8_t),
11750
0
      ret0);
11751
0
  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
11752
0
}
11753
11754
/**
11755
 Portable decapsulate
11756
*/
11757
/**
11758
A monomorphic instance of
11759
libcrux_ml_kem.ind_cca.instantiations.portable.kyber_decapsulate with const
11760
generics
11761
- K= 3
11762
- SECRET_KEY_SIZE= 2400
11763
- CPA_SECRET_KEY_SIZE= 1152
11764
- PUBLIC_KEY_SIZE= 1184
11765
- CIPHERTEXT_SIZE= 1088
11766
- T_AS_NTT_ENCODED_SIZE= 1152
11767
- C1_SIZE= 960
11768
- C2_SIZE= 128
11769
- VECTOR_U_COMPRESSION_FACTOR= 10
11770
- VECTOR_V_COMPRESSION_FACTOR= 4
11771
- C1_BLOCK_SIZE= 320
11772
- ETA1= 2
11773
- ETA1_RANDOMNESS_SIZE= 128
11774
- ETA2= 2
11775
- ETA2_RANDOMNESS_SIZE= 128
11776
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
11777
*/
11778
static inline void
11779
libcrux_ml_kem_ind_cca_instantiations_portable_kyber_decapsulate_fc(
11780
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
11781
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
11782
0
  libcrux_ml_kem_ind_cca_decapsulate_700(private_key, ciphertext, ret);
11783
0
}
11784
11785
/**
11786
 Decapsulate Kyber 768
11787
11788
 Generates an [`MlKemSharedSecret`].
11789
 The input is a reference to an [`MlKem768PrivateKey`] and an
11790
 [`MlKem768Ciphertext`].
11791
*/
11792
static inline void libcrux_ml_kem_mlkem768_portable_kyber_decapsulate(
11793
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
11794
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
11795
0
  libcrux_ml_kem_ind_cca_instantiations_portable_kyber_decapsulate_fc(
11796
0
      private_key, ciphertext, ret);
11797
0
}
11798
11799
/**
11800
This function found in impl {(libcrux_ml_kem::variant::Variant for
11801
libcrux_ml_kem::variant::Kyber)}
11802
*/
11803
/**
11804
A monomorphic instance of libcrux_ml_kem.variant.entropy_preprocess_33
11805
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
11806
with const generics
11807
- K= 3
11808
*/
11809
static KRML_MUSTINLINE void libcrux_ml_kem_variant_entropy_preprocess_33_8a(
11810
0
    Eurydice_slice randomness, uint8_t ret[32U]) {
11811
0
  libcrux_ml_kem_hash_functions_portable_H_f1_1a(randomness, ret);
11812
0
}
11813
11814
/**
11815
A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate
11816
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
11817
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
11818
libcrux_ml_kem_variant_Kyber with const generics
11819
- K= 3
11820
- CIPHERTEXT_SIZE= 1088
11821
- PUBLIC_KEY_SIZE= 1184
11822
- T_AS_NTT_ENCODED_SIZE= 1152
11823
- C1_SIZE= 960
11824
- C2_SIZE= 128
11825
- VECTOR_U_COMPRESSION_FACTOR= 10
11826
- VECTOR_V_COMPRESSION_FACTOR= 4
11827
- VECTOR_U_BLOCK_LEN= 320
11828
- ETA1= 2
11829
- ETA1_RANDOMNESS_SIZE= 128
11830
- ETA2= 2
11831
- ETA2_RANDOMNESS_SIZE= 128
11832
*/
11833
static inline tuple_3c libcrux_ml_kem_ind_cca_encapsulate_cd0(
11834
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key,
11835
0
    uint8_t randomness[32U]) {
11836
0
  uint8_t randomness0[32U];
11837
0
  libcrux_ml_kem_variant_entropy_preprocess_33_8a(
11838
0
      Eurydice_array_to_slice((size_t)32U, randomness, uint8_t), randomness0);
11839
0
  uint8_t to_hash[64U];
11840
0
  libcrux_ml_kem_utils_into_padded_array_ea(
11841
0
      Eurydice_array_to_slice((size_t)32U, randomness0, uint8_t), to_hash);
11842
0
  Eurydice_slice uu____0 = Eurydice_array_to_subslice_from(
11843
0
      (size_t)64U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
11844
0
      size_t);
11845
0
  uint8_t ret[32U];
11846
0
  libcrux_ml_kem_hash_functions_portable_H_f1_1a(
11847
0
      Eurydice_array_to_slice((size_t)1184U,
11848
0
                              libcrux_ml_kem_types_as_slice_cb_50(public_key),
11849
0
                              uint8_t),
11850
0
      ret);
11851
0
  Eurydice_slice_copy(
11852
0
      uu____0, Eurydice_array_to_slice((size_t)32U, ret, uint8_t), uint8_t);
11853
0
  uint8_t hashed[64U];
11854
0
  libcrux_ml_kem_hash_functions_portable_G_f1_e4(
11855
0
      Eurydice_array_to_slice((size_t)64U, to_hash, uint8_t), hashed);
11856
0
  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
11857
0
      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t),
11858
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t,
11859
0
      Eurydice_slice_uint8_t_x2);
11860
0
  Eurydice_slice shared_secret = uu____1.fst;
11861
0
  Eurydice_slice pseudorandomness = uu____1.snd;
11862
0
  Eurydice_slice uu____2 = Eurydice_array_to_slice(
11863
0
      (size_t)1184U, libcrux_ml_kem_types_as_slice_cb_50(public_key), uint8_t);
11864
0
  /* Passing arrays by value in Rust generates a copy in C */
11865
0
  uint8_t copy_of_randomness[32U];
11866
0
  memcpy(copy_of_randomness, randomness0, (size_t)32U * sizeof(uint8_t));
11867
0
  uint8_t ciphertext[1088U];
11868
0
  libcrux_ml_kem_ind_cpa_encrypt_60(uu____2, copy_of_randomness,
11869
0
                                    pseudorandomness, ciphertext);
11870
0
  /* Passing arrays by value in Rust generates a copy in C */
11871
0
  uint8_t copy_of_ciphertext[1088U];
11872
0
  memcpy(copy_of_ciphertext, ciphertext, (size_t)1088U * sizeof(uint8_t));
11873
0
  libcrux_ml_kem_mlkem768_MlKem768Ciphertext ciphertext0 =
11874
0
      libcrux_ml_kem_types_from_01_9f(copy_of_ciphertext);
11875
0
  uint8_t shared_secret_array[32U];
11876
0
  libcrux_ml_kem_variant_kdf_33_f0(shared_secret, &ciphertext0,
11877
0
                                   shared_secret_array);
11878
0
  libcrux_ml_kem_mlkem768_MlKem768Ciphertext uu____5 = ciphertext0;
11879
0
  /* Passing arrays by value in Rust generates a copy in C */
11880
0
  uint8_t copy_of_shared_secret_array[32U];
11881
0
  memcpy(copy_of_shared_secret_array, shared_secret_array,
11882
0
         (size_t)32U * sizeof(uint8_t));
11883
0
  tuple_3c lit;
11884
0
  lit.fst = uu____5;
11885
0
  memcpy(lit.snd, copy_of_shared_secret_array, (size_t)32U * sizeof(uint8_t));
11886
0
  return lit;
11887
0
}
11888
11889
/**
11890
 Portable encapsulate
11891
*/
11892
/**
11893
A monomorphic instance of
11894
libcrux_ml_kem.ind_cca.instantiations.portable.kyber_encapsulate with const
11895
generics
11896
- K= 3
11897
- CIPHERTEXT_SIZE= 1088
11898
- PUBLIC_KEY_SIZE= 1184
11899
- T_AS_NTT_ENCODED_SIZE= 1152
11900
- C1_SIZE= 960
11901
- C2_SIZE= 128
11902
- VECTOR_U_COMPRESSION_FACTOR= 10
11903
- VECTOR_V_COMPRESSION_FACTOR= 4
11904
- VECTOR_U_BLOCK_LEN= 320
11905
- ETA1= 2
11906
- ETA1_RANDOMNESS_SIZE= 128
11907
- ETA2= 2
11908
- ETA2_RANDOMNESS_SIZE= 128
11909
*/
11910
static inline tuple_3c
11911
libcrux_ml_kem_ind_cca_instantiations_portable_kyber_encapsulate_7a(
11912
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key,
11913
0
    uint8_t randomness[32U]) {
11914
0
  libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key;
11915
0
  /* Passing arrays by value in Rust generates a copy in C */
11916
0
  uint8_t copy_of_randomness[32U];
11917
0
  memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t));
11918
0
  return libcrux_ml_kem_ind_cca_encapsulate_cd0(uu____0, copy_of_randomness);
11919
0
}
11920
11921
/**
11922
 Encapsulate Kyber 768
11923
11924
 Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple.
11925
 The input is a reference to an [`MlKem768PublicKey`] and [`SHARED_SECRET_SIZE`]
11926
 bytes of `randomness`.
11927
*/
11928
static inline tuple_3c libcrux_ml_kem_mlkem768_portable_kyber_encapsulate(
11929
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key,
11930
0
    uint8_t randomness[32U]) {
11931
0
  libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key;
11932
0
  /* Passing arrays by value in Rust generates a copy in C */
11933
0
  uint8_t copy_of_randomness[32U];
11934
0
  memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t));
11935
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_kyber_encapsulate_7a(
11936
0
      uu____0, copy_of_randomness);
11937
0
}
11938
11939
/**
11940
This function found in impl {(libcrux_ml_kem::variant::Variant for
11941
libcrux_ml_kem::variant::Kyber)}
11942
*/
11943
/**
11944
A monomorphic instance of libcrux_ml_kem.variant.cpa_keygen_seed_33
11945
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
11946
with const generics
11947
- K= 3
11948
*/
11949
static KRML_MUSTINLINE void libcrux_ml_kem_variant_cpa_keygen_seed_33_b6(
11950
0
    Eurydice_slice key_generation_seed, uint8_t ret[64U]) {
11951
0
  libcrux_ml_kem_hash_functions_portable_G_f1_e4(key_generation_seed, ret);
11952
0
}
11953
11954
/**
11955
A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair
11956
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
11957
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
11958
libcrux_ml_kem_variant_Kyber with const generics
11959
- K= 3
11960
- PRIVATE_KEY_SIZE= 1152
11961
- PUBLIC_KEY_SIZE= 1184
11962
- RANKED_BYTES_PER_RING_ELEMENT= 1152
11963
- ETA1= 2
11964
- ETA1_RANDOMNESS_SIZE= 128
11965
*/
11966
static inline libcrux_ml_kem_utils_extraction_helper_Keypair768
11967
libcrux_ml_kem_ind_cpa_generate_keypair_fc0(
11968
0
    Eurydice_slice key_generation_seed) {
11969
0
  uint8_t hashed[64U];
11970
0
  libcrux_ml_kem_variant_cpa_keygen_seed_33_b6(key_generation_seed, hashed);
11971
0
  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
11972
0
      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U,
11973
0
      uint8_t, Eurydice_slice_uint8_t_x2);
11974
0
  Eurydice_slice seed_for_A0 = uu____0.fst;
11975
0
  Eurydice_slice seed_for_secret_and_error = uu____0.snd;
11976
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U];
11977
0
  uint8_t ret[34U];
11978
0
  libcrux_ml_kem_utils_into_padded_array_ea1(seed_for_A0, ret);
11979
0
  libcrux_ml_kem_matrix_sample_matrix_A_38(ret, true, A_transpose);
11980
0
  uint8_t prf_input[33U];
11981
0
  libcrux_ml_kem_utils_into_padded_array_ea2(seed_for_secret_and_error,
11982
0
                                             prf_input);
11983
0
  /* Passing arrays by value in Rust generates a copy in C */
11984
0
  uint8_t copy_of_prf_input0[33U];
11985
0
  memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t));
11986
0
  tuple_b0 uu____2 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(
11987
0
      copy_of_prf_input0, 0U);
11988
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U];
11989
0
  memcpy(
11990
0
      secret_as_ntt, uu____2.fst,
11991
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11992
0
  uint8_t domain_separator = uu____2.snd;
11993
0
  /* Passing arrays by value in Rust generates a copy in C */
11994
0
  uint8_t copy_of_prf_input[33U];
11995
0
  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
11996
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_as_ntt[3U];
11997
0
  memcpy(
11998
0
      error_as_ntt,
11999
0
      libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(copy_of_prf_input,
12000
0
                                                           domain_separator)
12001
0
          .fst,
12002
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
12003
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U];
12004
0
  libcrux_ml_kem_matrix_compute_As_plus_e_60(A_transpose, secret_as_ntt,
12005
0
                                             error_as_ntt, t_as_ntt);
12006
0
  uint8_t seed_for_A[32U];
12007
0
  Result_00 dst;
12008
0
  Eurydice_slice_to_array2(&dst, seed_for_A0, Eurydice_slice, uint8_t[32U]);
12009
0
  unwrap_41_83(dst, seed_for_A);
12010
0
  uint8_t public_key_serialized[1184U];
12011
0
  libcrux_ml_kem_ind_cpa_serialize_public_key_79(
12012
0
      t_as_ntt, Eurydice_array_to_slice((size_t)32U, seed_for_A, uint8_t),
12013
0
      public_key_serialized);
12014
0
  uint8_t secret_key_serialized[1152U];
12015
0
  libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(secret_as_ntt,
12016
0
                                                 secret_key_serialized);
12017
0
  /* Passing arrays by value in Rust generates a copy in C */
12018
0
  uint8_t copy_of_secret_key_serialized[1152U];
12019
0
  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
12020
0
         (size_t)1152U * sizeof(uint8_t));
12021
0
  /* Passing arrays by value in Rust generates a copy in C */
12022
0
  uint8_t copy_of_public_key_serialized[1184U];
12023
0
  memcpy(copy_of_public_key_serialized, public_key_serialized,
12024
0
         (size_t)1184U * sizeof(uint8_t));
12025
0
  libcrux_ml_kem_utils_extraction_helper_Keypair768 lit;
12026
0
  memcpy(lit.fst, copy_of_secret_key_serialized,
12027
0
         (size_t)1152U * sizeof(uint8_t));
12028
0
  memcpy(lit.snd, copy_of_public_key_serialized,
12029
0
         (size_t)1184U * sizeof(uint8_t));
12030
0
  return lit;
12031
0
}
12032
12033
/**
12034
 Packed API
12035
12036
 Generate a key pair.
12037
12038
 Depending on the `Vector` and `Hasher` used, this requires different hardware
12039
 features
12040
*/
12041
/**
12042
A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair
12043
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
12044
libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
12045
libcrux_ml_kem_variant_Kyber with const generics
12046
- K= 3
12047
- CPA_PRIVATE_KEY_SIZE= 1152
12048
- PRIVATE_KEY_SIZE= 2400
12049
- PUBLIC_KEY_SIZE= 1184
12050
- BYTES_PER_RING_ELEMENT= 1152
12051
- ETA1= 2
12052
- ETA1_RANDOMNESS_SIZE= 128
12053
*/
12054
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
12055
0
libcrux_ml_kem_ind_cca_generate_keypair_8c0(uint8_t randomness[64U]) {
12056
0
  Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice2(
12057
0
      randomness, (size_t)0U,
12058
0
      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t);
12059
0
  Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from(
12060
0
      (size_t)64U, randomness,
12061
0
      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t,
12062
0
      size_t);
12063
0
  libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 =
12064
0
      libcrux_ml_kem_ind_cpa_generate_keypair_fc0(ind_cpa_keypair_randomness);
12065
0
  uint8_t ind_cpa_private_key[1152U];
12066
0
  memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t));
12067
0
  uint8_t public_key[1184U];
12068
0
  memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t));
12069
0
  uint8_t secret_key_serialized[2400U];
12070
0
  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48(
12071
0
      Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t),
12072
0
      Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t),
12073
0
      implicit_rejection_value, secret_key_serialized);
12074
0
  /* Passing arrays by value in Rust generates a copy in C */
12075
0
  uint8_t copy_of_secret_key_serialized[2400U];
12076
0
  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
12077
0
         (size_t)2400U * sizeof(uint8_t));
12078
0
  libcrux_ml_kem_types_MlKemPrivateKey_55 private_key =
12079
0
      libcrux_ml_kem_types_from_05_f2(copy_of_secret_key_serialized);
12080
0
  libcrux_ml_kem_types_MlKemPrivateKey_55 uu____2 = private_key;
12081
0
  /* Passing arrays by value in Rust generates a copy in C */
12082
0
  uint8_t copy_of_public_key[1184U];
12083
0
  memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t));
12084
0
  return libcrux_ml_kem_types_from_17_35(
12085
0
      uu____2, libcrux_ml_kem_types_from_b6_da(copy_of_public_key));
12086
0
}
12087
12088
/**
12089
A monomorphic instance of
12090
libcrux_ml_kem.ind_cca.instantiations.portable.kyber_generate_keypair with const
12091
generics
12092
- K= 3
12093
- CPA_PRIVATE_KEY_SIZE= 1152
12094
- PRIVATE_KEY_SIZE= 2400
12095
- PUBLIC_KEY_SIZE= 1184
12096
- BYTES_PER_RING_ELEMENT= 1152
12097
- ETA1= 2
12098
- ETA1_RANDOMNESS_SIZE= 128
12099
*/
12100
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
12101
libcrux_ml_kem_ind_cca_instantiations_portable_kyber_generate_keypair_9b(
12102
0
    uint8_t randomness[64U]) {
12103
0
  /* Passing arrays by value in Rust generates a copy in C */
12104
0
  uint8_t copy_of_randomness[64U];
12105
0
  memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
12106
0
  return libcrux_ml_kem_ind_cca_generate_keypair_8c0(copy_of_randomness);
12107
0
}
12108
12109
/**
12110
 Generate Kyber 768 Key Pair
12111
*/
12112
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
12113
libcrux_ml_kem_mlkem768_portable_kyber_generate_key_pair(
12114
0
    uint8_t randomness[64U]) {
12115
0
  /* Passing arrays by value in Rust generates a copy in C */
12116
0
  uint8_t copy_of_randomness[64U];
12117
0
  memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
12118
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_kyber_generate_keypair_9b(
12119
0
      copy_of_randomness);
12120
0
}
12121
12122
/**
12123
 Validate an ML-KEM private key.
12124
12125
 This implements the Hash check in 7.3 3.
12126
 Note that the size checks in 7.2 1 and 2 are covered by the `SECRET_KEY_SIZE`
12127
 and `CIPHERTEXT_SIZE` in the `private_key` and `ciphertext` types.
12128
*/
12129
/**
12130
A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key
12131
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
12132
with const generics
12133
- K= 3
12134
- SECRET_KEY_SIZE= 2400
12135
- CIPHERTEXT_SIZE= 1088
12136
*/
12137
static KRML_MUSTINLINE bool libcrux_ml_kem_ind_cca_validate_private_key_e7(
12138
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
12139
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *_ciphertext) {
12140
0
  uint8_t t[32U];
12141
0
  libcrux_ml_kem_hash_functions_portable_H_f1_1a(
12142
0
      Eurydice_array_to_subslice2(private_key->value, (size_t)384U * (size_t)3U,
12143
0
                                  (size_t)768U * (size_t)3U + (size_t)32U,
12144
0
                                  uint8_t),
12145
0
      t);
12146
0
  Eurydice_slice expected = Eurydice_array_to_subslice2(
12147
0
      private_key->value, (size_t)768U * (size_t)3U + (size_t)32U,
12148
0
      (size_t)768U * (size_t)3U + (size_t)64U, uint8_t);
12149
0
  return core_array_equality___core__cmp__PartialEq__0___Slice_U____for__Array_T__N___3__eq(
12150
0
      (size_t)32U, t, &expected, uint8_t, uint8_t, bool);
12151
0
}
12152
12153
/**
12154
 Portable private key validation
12155
*/
12156
/**
12157
A monomorphic instance of
12158
libcrux_ml_kem.ind_cca.instantiations.portable.validate_private_key with const
12159
generics
12160
- K= 3
12161
- SECRET_KEY_SIZE= 2400
12162
- CIPHERTEXT_SIZE= 1088
12163
*/
12164
static KRML_MUSTINLINE bool
12165
libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_9c(
12166
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
12167
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext) {
12168
0
  return libcrux_ml_kem_ind_cca_validate_private_key_e7(private_key,
12169
0
                                                        ciphertext);
12170
0
}
12171
12172
/**
12173
 Validate a private key.
12174
12175
 Returns `true` if valid, and `false` otherwise.
12176
*/
12177
static inline bool libcrux_ml_kem_mlkem768_portable_validate_private_key(
12178
    libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key,
12179
0
    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext) {
12180
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_9c(
12181
0
      private_key, ciphertext);
12182
0
}
12183
12184
/**
12185
A monomorphic instance of
12186
libcrux_ml_kem.serialize.deserialize_ring_elements_reduced.closure with types
12187
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
12188
- PUBLIC_KEY_SIZE= 1184
12189
- K= 3
12190
*/
12191
static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0
12192
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_closure_cd0(
12193
0
    size_t _i) {
12194
0
  return libcrux_ml_kem_polynomial_ZERO_89_ea();
12195
0
}
12196
12197
/**
12198
 This function deserializes ring elements and reduces the result by the field
12199
 modulus.
12200
12201
 This function MUST NOT be used on secret inputs.
12202
*/
12203
/**
12204
A monomorphic instance of
12205
libcrux_ml_kem.serialize.deserialize_ring_elements_reduced with types
12206
libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics
12207
- PUBLIC_KEY_SIZE= 1184
12208
- K= 3
12209
*/
12210
static KRML_MUSTINLINE void
12211
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_330(
12212
    Eurydice_slice public_key,
12213
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
12214
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 deserialized_pk[3U];
12215
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
12216
0
    deserialized_pk[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
12217
0
  }
12218
0
  for (size_t i = (size_t)0U;
12219
0
       i < Eurydice_slice_len(public_key, uint8_t) /
12220
0
               LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT;
12221
0
       i++) {
12222
0
    size_t i0 = i;
12223
0
    Eurydice_slice ring_element = Eurydice_slice_subslice2(
12224
0
        public_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
12225
0
        i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT +
12226
0
            LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
12227
0
        uint8_t);
12228
0
    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____0 =
12229
0
        libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_4c(
12230
0
            ring_element);
12231
0
    deserialized_pk[i0] = uu____0;
12232
0
  }
12233
0
  memcpy(
12234
0
      ret, deserialized_pk,
12235
0
      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
12236
0
}
12237
12238
/**
12239
 Validate an ML-KEM public key.
12240
12241
 This implements the Modulus check in 7.2 2.
12242
 Note that the size check in 7.2 1 is covered by the `PUBLIC_KEY_SIZE` in the
12243
 `public_key` type.
12244
*/
12245
/**
12246
A monomorphic instance of libcrux_ml_kem.ind_cca.validate_public_key
12247
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
12248
with const generics
12249
- K= 3
12250
- RANKED_BYTES_PER_RING_ELEMENT= 1152
12251
- PUBLIC_KEY_SIZE= 1184
12252
*/
12253
static KRML_MUSTINLINE bool libcrux_ml_kem_ind_cca_validate_public_key_19(
12254
0
    uint8_t *public_key) {
12255
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 deserialized_pk[3U];
12256
0
  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_330(
12257
0
      Eurydice_array_to_subslice_to((size_t)1184U, public_key, (size_t)1152U,
12258
0
                                    uint8_t, size_t),
12259
0
      deserialized_pk);
12260
0
  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *uu____0 = deserialized_pk;
12261
0
  uint8_t public_key_serialized[1184U];
12262
0
  libcrux_ml_kem_ind_cpa_serialize_public_key_79(
12263
0
      uu____0,
12264
0
      Eurydice_array_to_subslice_from((size_t)1184U, public_key, (size_t)1152U,
12265
0
                                      uint8_t, size_t),
12266
0
      public_key_serialized);
12267
0
  return core_array_equality___core__cmp__PartialEq__Array_U__N___for__Array_T__N____eq(
12268
0
      (size_t)1184U, public_key, public_key_serialized, uint8_t, uint8_t, bool);
12269
0
}
12270
12271
/**
12272
 Portable public key validation
12273
*/
12274
/**
12275
A monomorphic instance of
12276
libcrux_ml_kem.ind_cca.instantiations.portable.validate_public_key with const
12277
generics
12278
- K= 3
12279
- RANKED_BYTES_PER_RING_ELEMENT= 1152
12280
- PUBLIC_KEY_SIZE= 1184
12281
*/
12282
static KRML_MUSTINLINE bool
12283
libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_4b(
12284
0
    uint8_t *public_key) {
12285
0
  return libcrux_ml_kem_ind_cca_validate_public_key_19(public_key);
12286
0
}
12287
12288
/**
12289
 Validate a public key.
12290
12291
 Returns `true` if valid, and `false` otherwise.
12292
*/
12293
static inline bool libcrux_ml_kem_mlkem768_portable_validate_public_key(
12294
0
    libcrux_ml_kem_types_MlKemPublicKey_15 *public_key) {
12295
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_4b(
12296
0
      public_key->value);
12297
0
}
12298
12299
/**
12300
This function found in impl {(core::clone::Clone for
12301
libcrux_ml_kem::vector::portable::vector_type::PortableVector)}
12302
*/
12303
static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector
12304
libcrux_ml_kem_vector_portable_vector_type_clone_3b(
12305
0
    libcrux_ml_kem_vector_portable_vector_type_PortableVector *self) {
12306
0
  return self[0U];
12307
0
}
12308
12309
typedef int16_t libcrux_ml_kem_vector_portable_vector_type_FieldElement;
12310
12311
typedef int16_t
12312
    libcrux_ml_kem_vector_portable_arithmetic_MontgomeryFieldElement;
12313
12314
typedef int16_t
12315
    libcrux_ml_kem_vector_portable_arithmetic_FieldElementTimesMontgomeryR;
12316
12317
#if defined(__cplusplus)
12318
}
12319
#endif
12320
12321
#define __libcrux_mlkem768_portable_H_DEFINED
12322
#endif
12323
12324
12325
/* rename some types to be a bit more ergonomic */
12326
#define libcrux_mlkem768_keypair libcrux_ml_kem_mlkem768_MlKem768KeyPair_s
12327
#define libcrux_mlkem768_pk_valid_result Option_92_s
12328
#define libcrux_mlkem768_pk libcrux_ml_kem_types_MlKemPublicKey_15_s
12329
#define libcrux_mlkem768_sk libcrux_ml_kem_types_MlKemPrivateKey_55_s
12330
#define libcrux_mlkem768_ciphertext libcrux_ml_kem_mlkem768_MlKem768Ciphertext_s
12331
#define libcrux_mlkem768_enc_result tuple_3c_s
12332
/* defines for PRNG inputs */
12333
#define LIBCRUX_ML_KEM_KEY_PAIR_PRNG_LEN 64
12334
#define LIBCRUX_ML_KEM_ENC_PRNG_LEN 32