Coverage Report

Created: 2026-09-03 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssh/libcrux_internal.h
Line
Count
Source
1
/*  $OpenBSD: libcrux_internal.h,v 1.1 2026/06/14 03:59:34 djm Exp $ */
2
3
/* Extracted from libcrux revision c46481ce3cd1cc8315e90db114581d8c992c3d7d */
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) fatal_f("internal error")
36
#define KRML_UNION_CONSTRUCTOR(T)
37
38
static inline void
39
store64_le(uint8_t dst[8], uint64_t src)
40
0
{
41
0
  dst[0] = src & 0xff;
42
0
  dst[1] = (src >> 8) & 0xff;
43
0
  dst[2] = (src >> 16) & 0xff;
44
0
  dst[3] = (src >> 24) & 0xff;
45
0
  dst[4] = (src >> 32) & 0xff;
46
0
  dst[5] = (src >> 40) & 0xff;
47
0
  dst[6] = (src >> 48) & 0xff;
48
0
  dst[7] = (src >> 56) & 0xff;
49
0
}
50
51
static inline void
52
store32_le(uint8_t dst[4], uint32_t src)
53
0
{
54
0
  dst[0] = src & 0xff;
55
0
  dst[1] = (src >> 8) & 0xff;
56
0
  dst[2] = (src >> 16) & 0xff;
57
0
  dst[3] = (src >> 24) & 0xff;
58
0
}
59
60
static inline void
61
store16_le(uint8_t dst[2], uint16_t src)
62
0
{
63
0
  dst[0] = src & 0xff;
64
0
  dst[1] = (src >> 8) & 0xff;
65
0
}
66
67
static inline void
68
store32_be(uint8_t dst[4], uint32_t src)
69
0
{
70
0
  dst[0] = (src >> 24) & 0xff;
71
0
  dst[1] = (src >> 16) & 0xff;
72
0
  dst[2] = (src >> 8) & 0xff;
73
0
  dst[3] = src & 0xff;
74
0
}
75
76
static inline uint64_t
77
load64_le(uint8_t src[8])
78
0
{
79
0
  return (uint64_t)(src[0]) |
80
0
      ((uint64_t)(src[1]) << 8) |
81
0
      ((uint64_t)(src[2]) << 16) |
82
0
      ((uint64_t)(src[3]) << 24) |
83
0
      ((uint64_t)(src[4]) << 32) |
84
0
      ((uint64_t)(src[5]) << 40) |
85
0
      ((uint64_t)(src[6]) << 48) |
86
0
      ((uint64_t)(src[7]) << 56);
87
0
}
88
89
static inline uint32_t
90
load32_le(uint8_t src[4])
91
0
{
92
0
  return (uint32_t)(src[0]) |
93
0
      ((uint32_t)(src[1]) << 8) |
94
0
      ((uint32_t)(src[2]) << 16) |
95
0
      ((uint32_t)(src[3]) << 24);
96
0
}
97
98
static inline uint16_t
99
load16_le(uint8_t src[4])
100
0
{
101
0
  return (uint16_t)(src[0]) |
102
0
      ((uint16_t)(src[1]) << 8);
103
0
}
104
105
#ifdef MISSING_BUILTIN_POPCOUNT
106
static inline unsigned int
107
__builtin_popcount(unsigned int num)
108
{
109
  const int v[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
110
  return v[num & 0xf] + v[(num >> 4) & 0xf];
111
}
112
#endif
113
114
/* from libcrux/combined_extraction/generated/eurydice_glue.h */
115
#pragma once
116
117
118
#ifdef _MSC_VER
119
// For __popcnt
120
#endif
121
122
123
// C++ HELPERS
124
125
#if defined(__cplusplus)
126
127
#ifndef KRML_HOST_EPRINTF
128
#define KRML_HOST_EPRINTF(...) fprintf(stderr, __VA_ARGS__)
129
#endif
130
131
132
#ifndef __cpp_lib_type_identity
133
template <class T>
134
struct type_identity {
135
  using type = T;
136
};
137
138
template <class T>
139
using type_identity_t = typename type_identity<T>::type;
140
#else
141
using std::type_identity_t;
142
#endif
143
144
#define KRML_UNION_CONSTRUCTOR(T)                              \
145
  template <typename V>                                        \
146
  constexpr T(int t, V U::*m, type_identity_t<V> v) : tag(t) { \
147
    val.*m = std::move(v);                                     \
148
  }                                                            \
149
  T() = default;
150
151
#endif
152
153
// GENERAL-PURPOSE STUFF
154
155
#define LowStar_Ignore_ignore(e, t, _ret_t) ((void)e)
156
157
#define EURYDICE_ASSERT(test, msg)                                            \
158
  do {                                                                        \
159
    if (!(test)) {                                                            \
160
      fprintf(stderr, "assertion \"%s\" failed: file \"%s\", line %d\n", msg, \
161
              __FILE__, __LINE__);                                            \
162
      exit(255);                                                              \
163
    }                                                                         \
164
  } while (0)
165
166
// SIZEOF, ALIGNOF
167
168
#define Eurydice_sizeof(t) sizeof(t)
169
170
#define Eurydice_alignof(t) alignof(t)
171
172
// SLICES, ARRAYS, ETC.
173
174
// For convenience, we give these common slice types, below, a distinguished
175
// status and rather than emit them in the client code, we skip their
176
// code-generation in Cleanup3.ml and write them by hand here. This makes it
177
// easy to write interop code that brings those definitions in scope.
178
179
// &[u8]
180
typedef struct Eurydice_borrow_slice_u8_s {
181
  const uint8_t *ptr;
182
  size_t meta;
183
} Eurydice_borrow_slice_u8;
184
185
// &[u16]
186
typedef struct Eurydice_borrow_slice_i16_s {
187
  const int16_t *ptr;
188
  size_t meta;
189
} Eurydice_borrow_slice_i16;
190
191
// &mut [u8]
192
typedef struct Eurydice_mut_borrow_slice_u8_s {
193
  uint8_t *ptr;
194
  size_t meta;
195
} Eurydice_mut_borrow_slice_u8;
196
197
// &mut [u16]
198
typedef struct Eurydice_mut_borrow_slice_i16_s {
199
  int16_t *ptr;
200
  size_t meta;
201
} Eurydice_mut_borrow_slice_i16;
202
203
#if defined(__cplusplus)
204
#define KRML_CLITERAL(type) type
205
#else
206
0
#define KRML_CLITERAL(type) (type)
207
#endif
208
209
#if defined(__cplusplus) && defined(__cpp_designated_initializers) || \
210
    !(defined(__cplusplus))
211
#define EURYDICE_CFIELD(X) X
212
#else
213
#define EURYDICE_CFIELD(X)
214
#endif
215
216
#define Eurydice_array_repeat(dst, len, init, t) \
217
  ERROR "should've been desugared"
218
219
// Copy a slice with memcopy
220
#define Eurydice_slice_copy(dst, src, t) \
221
0
  memcpy(dst.ptr, src.ptr, dst.meta * sizeof(t))
222
223
#define core_array___T__N___as_slice(len_, ptr_, t, ret_t)   \
224
0
  (KRML_CLITERAL(ret_t){EURYDICE_CFIELD(.ptr =)(ptr_)->data, \
225
0
                        EURYDICE_CFIELD(.meta =) len_})
226
227
#define core_array__core__clone__Clone_for__T__N___clone(len, src, elem_type, \
228
                                                         _ret_t)              \
229
0
  (*(src))
230
#define TryFromSliceError uint8_t
231
#define core_array_TryFromSliceError uint8_t
232
233
// Distinguished support for some PartialEq trait implementations
234
//
235
// core::cmp::PartialEq<@Array<U, N>> for @Array<T, N>
236
#define Eurydice_array_eq(sz, a1, a2, t) \
237
0
  (memcmp((a1)->data, (a2)->data, sz * sizeof(t)) == 0)
238
// core::cmp::PartialEq<&0 (@Slice<U>)> for @Array<T, N>
239
#define Eurydice_array_eq_slice_shared(sz, a1, s2, t, _) \
240
  (memcmp((a1)->data, (s2)->ptr, sz * sizeof(t)) == 0)
241
#define Eurydice_array_eq_slice_mut(sz, a1, s2, t, _) \
242
  Eurydice_array_eq_slice_shared(sz, a1, s2, t, _)
243
244
// DEPRECATED -- should no longer be generated
245
#define core_array_equality__core__cmp__PartialEq__Array_U__N___for__Array_T__N___eq( \
246
    sz, a1, a2, t, _, _ret_t)                                                         \
247
  Eurydice_array_eq(sz, a1, a2, t)
248
#define core_array_equality__core__cmp__PartialEq__0___Slice_U____for__Array_T__N___eq( \
249
    sz, a1, a2, t, _, _ret_t)                                                           \
250
  Eurydice_array_eq(sz, a1, ((a2)->ptr), t)
251
#define core_cmp_impls__core__cmp__PartialEq__0_mut__B___for__1_mut__A___eq( \
252
    _m0, _m1, src1, src2, _0, _1, T)                                         \
253
  Eurydice_slice_eq(src1, src2, _, _, T, _)
254
255
#define Eurydice_slice_split_at(slice, mid, element_type, ret_t)        \
256
0
  KRML_CLITERAL(ret_t) {                                                \
257
0
    EURYDICE_CFIELD(.fst =){EURYDICE_CFIELD(.ptr =)((slice).ptr),       \
258
0
                            EURYDICE_CFIELD(.meta =) mid},              \
259
0
        EURYDICE_CFIELD(.snd =) {                                       \
260
0
      EURYDICE_CFIELD(.ptr =)                                           \
261
0
      ((slice).ptr + mid), EURYDICE_CFIELD(.meta =)((slice).meta - mid) \
262
0
    }                                                                   \
263
0
  }
264
265
#define Eurydice_slice_split_at_mut(slice, mid, element_type, ret_t)    \
266
  KRML_CLITERAL(ret_t) {                                                \
267
    EURYDICE_CFIELD(.fst =){EURYDICE_CFIELD(.ptr =)((slice).ptr),       \
268
                            EURYDICE_CFIELD(.meta =) mid},              \
269
        EURYDICE_CFIELD(.snd =) {                                       \
270
      EURYDICE_CFIELD(.ptr =)                                           \
271
      ((slice).ptr + mid), EURYDICE_CFIELD(.meta =)((slice).meta - mid) \
272
    }                                                                   \
273
  }
274
275
// Conversion of slice to an array, rewritten (by Eurydice) to name the
276
// destination array, since arrays are not values in C.
277
// N.B.: see note in karamel/lib/Inlining.ml if you change this.
278
279
#define Eurydice_slice_to_ref_array2(len_, src, arr_ptr, t_ptr, t_arr, t_err, \
280
                                     t_res)                                   \
281
  (src.meta >= len_                                                           \
282
       ? ((t_res){.tag = core_result_Ok, .val = {.case_Ok = arr_ptr}})        \
283
       : ((t_res){.tag = core_result_Err, .val = {.case_Err = 0}}))
284
285
// CORE STUFF (conversions, endianness, ...)
286
287
// We slap extern "C" on declarations that intend to implement a prototype
288
// generated by Eurydice, because Eurydice prototypes are always emitted within
289
// an extern "C" block, UNLESS you use -fcxx17-compat, in which case, you must
290
// pass -DKRML_CXX17_COMPAT="" to your C++ compiler.
291
#if defined(__cplusplus) && !defined(KRML_CXX17_COMPAT)
292
extern "C" {
293
#endif
294
295
#define core_hint_black_box(X, _0, _1) (X)
296
297
// [ u8; 2 ]
298
typedef struct Eurydice_array_u8x2_s {
299
  uint8_t data[2];
300
} Eurydice_array_u8x2;
301
302
// [ u8; 4 ]
303
typedef struct Eurydice_array_u8x4_s {
304
  uint8_t data[4];
305
} Eurydice_array_u8x4;
306
307
// [ u8; 8 ]
308
typedef struct Eurydice_array_u8x8_s {
309
  uint8_t data[8];
310
} Eurydice_array_u8x8;
311
312
0
static inline uint16_t core_num__u16__from_le_bytes(Eurydice_array_u8x2 buf) {
313
0
  return load16_le(buf.data);
314
0
}
315
316
0
static inline Eurydice_array_u8x4 core_num__u32__to_be_bytes(uint32_t src) {
317
0
  // TODO: why not store32_be?
318
0
  Eurydice_array_u8x4 a;
319
0
  uint32_t x = htobe32(src);
320
0
  memcpy(a.data, &x, 4);
321
0
  return a;
322
0
}
323
324
0
static inline Eurydice_array_u8x4 core_num__u32__to_le_bytes(uint32_t src) {
325
0
  Eurydice_array_u8x4 a;
326
0
  store32_le(a.data, src);
327
0
  return a;
328
0
}
329
330
0
static inline uint32_t core_num__u32__from_le_bytes(Eurydice_array_u8x4 buf) {
331
0
  return load32_le(buf.data);
332
0
}
333
334
0
static inline Eurydice_array_u8x8 core_num__u64__to_le_bytes(uint64_t v) {
335
0
  Eurydice_array_u8x8 a;
336
0
  store64_le(a.data, v);
337
0
  return a;
338
0
}
339
340
0
static inline uint64_t core_num__u64__from_le_bytes(Eurydice_array_u8x8 buf) {
341
0
  return load64_le(buf.data);
342
0
}
343
344
static inline int64_t core_convert_num__core__convert__From_i32__for_i64__from(
345
0
    int32_t x) {
346
0
  return x;
347
0
}
348
349
static inline uint64_t core_convert_num__core__convert__From_u8__for_u64__from(
350
0
    uint8_t x) {
351
0
  return x;
352
0
}
353
354
static inline uint64_t core_convert_num__core__convert__From_u16__for_u64__from(
355
0
    uint16_t x) {
356
0
  return x;
357
0
}
358
359
static inline size_t core_convert_num__core__convert__From_u16__for_usize__from(
360
0
    uint16_t x) {
361
0
  return x;
362
0
}
363
364
0
static inline uint32_t core_num__u8__count_ones(uint8_t x0) {
365
0
#ifdef _MSC_VER
366
0
  return __popcnt(x0);
367
0
#else
368
0
  return __builtin_popcount(x0);
369
0
#endif
370
0
}
371
372
0
static inline uint32_t core_num__u32__count_ones(uint32_t x0) {
373
0
#ifdef _MSC_VER
374
0
  return __popcnt(x0);
375
0
#else
376
0
  return __builtin_popcount(x0);
377
0
#endif
378
0
}
379
380
0
static inline uint32_t core_num__i32__count_ones(int32_t x0) {
381
0
#ifdef _MSC_VER
382
0
  return __popcnt(x0);
383
0
#else
384
0
  return __builtin_popcount(x0);
385
0
#endif
386
0
}
387
388
static inline size_t core_cmp_impls__core__cmp__Ord_for_usize__min(size_t a,
389
0
                                                                   size_t b) {
390
0
  if (a <= b)
391
0
    return a;
392
0
  else
393
0
    return b;
394
0
}
395
396
// unsigned overflow wraparound semantics in C
397
0
static inline uint8_t core_num__u8__wrapping_sub(uint8_t x, uint8_t y) {
398
0
  return x - y;
399
0
}
400
0
static inline uint8_t core_num__u8__wrapping_add(uint8_t x, uint8_t y) {
401
0
  return x + y;
402
0
}
403
0
static inline uint8_t core_num__u8__wrapping_mul(uint8_t x, uint8_t y) {
404
0
  return x * y;
405
0
}
406
0
static inline uint16_t core_num__u16__wrapping_sub(uint16_t x, uint16_t y) {
407
0
  return x - y;
408
0
}
409
0
static inline uint16_t core_num__u16__wrapping_add(uint16_t x, uint16_t y) {
410
0
  return x + y;
411
0
}
412
0
static inline uint16_t core_num__u16__wrapping_mul(uint16_t x, uint16_t y) {
413
0
  return x * y;
414
0
}
415
0
static inline uint32_t core_num__u32__wrapping_sub(uint32_t x, uint32_t y) {
416
0
  return x - y;
417
0
}
418
0
static inline uint32_t core_num__u32__wrapping_add(uint32_t x, uint32_t y) {
419
0
  return x + y;
420
0
}
421
0
static inline uint32_t core_num__u32__wrapping_mul(uint32_t x, uint32_t y) {
422
0
  return x * y;
423
0
}
424
0
static inline uint64_t core_num__u64__wrapping_sub(uint64_t x, uint64_t y) {
425
0
  return x - y;
426
0
}
427
0
static inline uint64_t core_num__u64__wrapping_add(uint64_t x, uint64_t y) {
428
0
  return x + y;
429
0
}
430
0
static inline uint64_t core_num__u64__wrapping_mul(uint64_t x, uint64_t y) {
431
0
  return x * y;
432
0
}
433
0
static inline size_t core_num__usize__wrapping_sub(size_t x, size_t y) {
434
0
  return x - y;
435
0
}
436
0
static inline size_t core_num__usize__wrapping_add(size_t x, size_t y) {
437
0
  return x + y;
438
0
}
439
0
static inline size_t core_num__usize__wrapping_mul(size_t x, size_t y) {
440
0
  return x * y;
441
0
}
442
443
0
static inline int8_t core_num__i8__wrapping_add(int8_t x, int8_t y) {
444
0
  return (int8_t)((uint8_t)x + (uint8_t)y);
445
0
}
446
0
static inline int8_t core_num__i8__wrapping_sub(int8_t x, int8_t y) {
447
0
  return (int8_t)((uint8_t)x - (uint8_t)y);
448
0
}
449
0
static inline int8_t core_num__i8__wrapping_mul(int8_t x, int8_t y) {
450
0
  return (int8_t)((uint8_t)x * (uint8_t)y);
451
0
}
452
0
static inline int16_t core_num__i16__wrapping_add(int16_t x, int16_t y) {
453
0
  return (int16_t)((uint16_t)x + (uint16_t)y);
454
0
}
455
0
static inline int16_t core_num__i16__wrapping_sub(int16_t x, int16_t y) {
456
0
  return (int16_t)((uint16_t)x - (uint16_t)y);
457
0
}
458
0
static inline int16_t core_num__i16__wrapping_mul(int16_t x, int16_t y) {
459
0
  return (int16_t)((uint16_t)x * (uint16_t)y);
460
0
}
461
0
static inline int32_t core_num__i32__wrapping_add(int32_t x, int32_t y) {
462
0
  return (int32_t)((uint32_t)x + (uint32_t)y);
463
0
}
464
0
static inline int32_t core_num__i32__wrapping_sub(int32_t x, int32_t y) {
465
0
  return (int32_t)((uint32_t)x - (uint32_t)y);
466
0
}
467
0
static inline int32_t core_num__i32__wrapping_mul(int32_t x, int32_t y) {
468
0
  return (int32_t)((uint32_t)x * (uint32_t)y);
469
0
}
470
0
static inline int64_t core_num__i64__wrapping_add(int64_t x, int64_t y) {
471
0
  return (int64_t)((uint64_t)x + (uint64_t)y);
472
0
}
473
0
static inline int64_t core_num__i64__wrapping_sub(int64_t x, int64_t y) {
474
0
  return (int64_t)((uint64_t)x - (uint64_t)y);
475
0
}
476
0
static inline int64_t core_num__i64__wrapping_mul(int64_t x, int64_t y) {
477
0
  return (int64_t)((uint64_t)x * (uint64_t)y);
478
0
}
479
0
static inline int8_t core_num__i8__wrapping_neg(int8_t x) {
480
0
  return (int8_t)(-(uint8_t)x);
481
0
}
482
0
static inline int16_t core_num__i16__wrapping_neg(int16_t x) {
483
0
  return (int16_t)(-(uint16_t)x);
484
0
}
485
0
static inline int32_t core_num__i32__wrapping_neg(int32_t x) {
486
0
  return (int32_t)(-(uint32_t)x);
487
0
}
488
0
static inline int64_t core_num__i64__wrapping_neg(int64_t x) {
489
0
  return (int64_t)(-(uint64_t)x);
490
0
}
491
492
0
static inline uint64_t core_num__u64__rotate_left(uint64_t x0, uint32_t x1) {
493
0
  return (x0 << x1) | (x0 >> ((-x1) & 63));
494
0
}
495
496
0
static inline void core_ops_arith__i32__add_assign(int32_t *x0, int32_t *x1) {
497
0
  *x0 = *x0 + *x1;
498
0
}
499
500
0
static inline uint8_t Eurydice_bitand_pv_u8(const uint8_t *p, uint8_t v) {
501
0
  return (*p) & v;
502
0
}
503
0
static inline uint8_t Eurydice_shr_pv_u8(const uint8_t *p, int32_t v) {
504
0
  return (*p) >> v;
505
0
}
506
0
static inline uint32_t Eurydice_min_u32(uint32_t x, uint32_t y) {
507
0
  return x < y ? x : y;
508
0
}
509
510
static inline uint8_t
511
core_ops_bit__core__ops__bit__BitAnd_u8__u8__for__0__u8___bitand(
512
0
    const uint8_t *x0, uint8_t x1) {
513
0
  return Eurydice_bitand_pv_u8(x0, x1);
514
0
}
515
516
static inline uint8_t
517
core_ops_bit__core__ops__bit__Shr_i32__u8__for__0__u8___shr(const uint8_t *x0,
518
0
                                                            int32_t x1) {
519
0
  return Eurydice_shr_pv_u8(x0, x1);
520
0
}
521
522
#define core_num_nonzero_private_NonZeroUsizeInner size_t
523
static inline core_num_nonzero_private_NonZeroUsizeInner
524
core_num_nonzero_private___core__clone__Clone_for_core__num__nonzero__private__NonZeroUsizeInner___clone(
525
0
    core_num_nonzero_private_NonZeroUsizeInner *x0) {
526
0
  return *x0;
527
0
}
528
529
#if defined(__cplusplus) && !defined(KRML_CXX17_COMPAT)
530
}
531
#endif
532
533
// ITERATORS
534
535
#define Eurydice_range_iter_next(iter_ptr, t, ret_t)      \
536
  (((iter_ptr)->start >= (iter_ptr)->end)                 \
537
       ? (KRML_CLITERAL(ret_t){EURYDICE_CFIELD(.tag =) 0, \
538
                               EURYDICE_CFIELD(.f0 =) 0}) \
539
       : (KRML_CLITERAL(ret_t){EURYDICE_CFIELD(.tag =) 1, \
540
                               EURYDICE_CFIELD(.f0 =)(iter_ptr)->start++}))
541
542
#define core_iter_range__core__iter__traits__iterator__Iterator_A__for_core__ops__range__Range_A__TraitClause_0___next \
543
  Eurydice_range_iter_next
544
545
// See note in karamel/lib/Inlining.ml if you change this
546
#define Eurydice_into_iter(x, t, _ret_t, _) (x)
547
#define core_iter_traits_collect__core__iter__traits__collect__IntoIterator_Clause1_Item__I__for_I__into_iter \
548
  Eurydice_into_iter
549
550
// STRINGS
551
552
typedef char Eurydice_c_char_t;
553
typedef const Eurydice_c_char_t *Prims_string;
554
typedef void Eurydice_c_void_t;
555
556
// UNSAFE CODE
557
558
#define core_slice___Slice_T___as_mut_ptr(x, t, _) (x.ptr)
559
#define core_mem_size_of(t, _) (sizeof(t))
560
#define core_slice_raw_from_raw_parts_mut(ptr, len, _0, _1) \
561
  (KRML_CLITERAL(Eurydice_slice){(void *)(ptr), len})
562
#define core_slice_raw_from_raw_parts(ptr, len, _0, _1) \
563
  (KRML_CLITERAL(Eurydice_slice){(void *)(ptr), len})
564
565
// FIXME: add dedicated extraction to extract NonNull<T> as T*
566
#define core_ptr_non_null_NonNull void *
567
568
// PRINTING
569
//
570
// This is temporary. Ultimately we want to be able to extract all of this.
571
572
typedef void *core_fmt_Formatter;
573
#define core_fmt_rt__core__fmt__rt__Argument__a___new_display(x1, x2, x3, x4) \
574
  NULL
575
576
// BOXES
577
578
#ifndef EURYDICE_MALLOC
579
#define EURYDICE_MALLOC malloc
580
#endif
581
582
#ifndef EURYDICE_REALLOC
583
#define EURYDICE_REALLOC realloc
584
#endif
585
586
0
static inline char *malloc_and_init(size_t sz, char *init) {
587
0
  char *ptr = (char *)EURYDICE_MALLOC(sz);
588
0
  if (ptr != NULL) memcpy(ptr, init, sz);
589
0
  return ptr;
590
0
}
591
592
#define Eurydice_box_new(init, t, t_dst) \
593
  ((t_dst)(malloc_and_init(sizeof(t), (char *)(&init))))
594
595
// Initializer for array of size zero
596
#define Eurydice_empty_array(dummy, t, t_dst) ((t_dst){.data = {}})
597
598
#define Eurydice_box_new_array(len, ptr, t, t_dst) \
599
  ((t_dst)(malloc_and_init(len * sizeof(t), (char *)(ptr))))
600
601
// FIXME this needs to handle allocation failure errors, but this seems hard to
602
// do without evaluating malloc_and_init twice...
603
#define alloc_boxed__alloc__boxed__Box_T___try_new(init, t, t_ret) \
604
  ((t_ret){.tag = core_result_Ok,                                  \
605
           .f0 = (t *)malloc_and_init(sizeof(t), (char *)(&init))})
606
607
// OPTIONS
608
609
#define core_option__core__option__Option_T__TraitClause_0___is_some( \
610
    x, _of_type, _)                                                   \
611
0
  x->tag
612
613
/* from libcrux/combined_extraction/generated/combined_core.h */
614
/*
615
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
616
 *
617
 * SPDX-License-Identifier: MIT or Apache-2.0
618
 *
619
 * This code was generated with the following revisions:
620
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
621
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
622
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
623
 * F*: unset
624
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
625
 */
626
627
628
#ifndef combined_core_H
629
#define combined_core_H
630
631
632
633
#if defined(__cplusplus)
634
extern "C" {
635
#endif
636
637
static inline uint32_t core_num__i32__count_ones(int32_t x0);
638
639
static inline uint16_t core_num__u16__wrapping_add(uint16_t x0, uint16_t x1);
640
641
static inline uint64_t core_num__u64__from_le_bytes(Eurydice_array_u8x8 x0);
642
643
static inline uint64_t core_num__u64__rotate_left(uint64_t x0, uint32_t x1);
644
645
static inline Eurydice_array_u8x8 core_num__u64__to_le_bytes(uint64_t x0);
646
647
static inline uint32_t core_num__u8__count_ones(uint8_t x0);
648
649
static inline uint8_t core_num__u8__wrapping_sub(uint8_t x0, uint8_t x1);
650
651
static inline uint8_t
652
core_ops_bit__core__ops__bit__BitAnd_u8__u8__for__0__u8___bitand(const uint8_t *x0, uint8_t x1);
653
654
static inline uint8_t
655
core_ops_bit__core__ops__bit__Shr_i32__u8__for__0__u8___shr(const uint8_t *x0, int32_t x1);
656
657
/**
658
A monomorphic instance of core.ops.range.Range
659
with types size_t
660
661
*/
662
typedef struct core_ops_range_Range_87_s
663
{
664
  size_t start;
665
  size_t end;
666
}
667
core_ops_range_Range_87;
668
669
/**
670
A monomorphic instance of Eurydice.slice_subslice_mut
671
with types int16_t, core_ops_range_Range size_t, Eurydice_derefed_slice int16_t
672
673
*/
674
static inline Eurydice_mut_borrow_slice_i16
675
Eurydice_slice_subslice_mut_a6(Eurydice_mut_borrow_slice_i16 s, core_ops_range_Range_87 r)
676
0
{
677
0
  return
678
0
    (
679
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_i16){
680
0
        .ptr = s.ptr + r.start,
681
0
        .meta = r.end - r.start
682
0
      }
683
0
    );
684
0
}
685
686
/**
687
A monomorphic instance of Eurydice.arr
688
with types uint8_t
689
with const generics
690
- $16size_t
691
*/
692
typedef struct Eurydice_arr_b2_s { uint8_t data[16U]; } Eurydice_arr_b2;
693
694
/**
695
A monomorphic instance of Eurydice.arr
696
with types Eurydice_arr_b2
697
with const generics
698
- $256size_t
699
*/
700
typedef struct Eurydice_arr_87_s { Eurydice_arr_b2 data[256U]; } Eurydice_arr_87;
701
702
/**
703
A monomorphic instance of Eurydice.arr
704
with types uint8_t
705
with const generics
706
- $24size_t
707
*/
708
typedef struct Eurydice_arr_94_s { uint8_t data[24U]; } Eurydice_arr_94;
709
710
0
#define core_result_Ok 0
711
0
#define core_result_Err 1
712
713
typedef uint8_t core_result_Result_57_tags;
714
715
/**
716
A monomorphic instance of core.result.Result
717
with types Eurydice_arr_94, core_array_TryFromSliceError
718
719
*/
720
typedef struct core_result_Result_57_s
721
{
722
  core_result_Result_57_tags tag;
723
  union {
724
    Eurydice_arr_94 case_Ok;
725
    core_array_TryFromSliceError case_Err;
726
  }
727
  val;
728
}
729
core_result_Result_57;
730
731
/**
732
This function found in impl {core::result::Result<T, E>[TraitClause@0, TraitClause@1]}
733
*/
734
/**
735
A monomorphic instance of core.result.unwrap_26
736
with types Eurydice_arr uint8_t[[$24size_t]], core_array_TryFromSliceError
737
738
*/
739
static inline Eurydice_arr_94 core_result_unwrap_26_78(core_result_Result_57 self)
740
0
{
741
0
  if (self.tag == core_result_Ok)
742
0
  {
743
0
    return self.val.case_Ok;
744
0
  }
745
0
  else
746
0
  {
747
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "unwrap not Ok");
748
0
    KRML_HOST_EXIT(255U);
749
0
  }
750
0
}
751
752
/**
753
A monomorphic instance of Eurydice.arr
754
with types int16_t
755
with const generics
756
- $16size_t
757
*/
758
typedef struct Eurydice_arr_d6_s { int16_t data[16U]; } Eurydice_arr_d6;
759
760
/**
761
A monomorphic instance of Eurydice.arr
762
with types uint8_t
763
with const generics
764
- $20size_t
765
*/
766
typedef struct Eurydice_arr_fc_s { uint8_t data[20U]; } Eurydice_arr_fc;
767
768
/**
769
A monomorphic instance of core.result.Result
770
with types Eurydice_arr_fc, core_array_TryFromSliceError
771
772
*/
773
typedef struct core_result_Result_83_s
774
{
775
  core_result_Result_57_tags tag;
776
  union {
777
    Eurydice_arr_fc case_Ok;
778
    core_array_TryFromSliceError case_Err;
779
  }
780
  val;
781
}
782
core_result_Result_83;
783
784
/**
785
This function found in impl {core::result::Result<T, E>[TraitClause@0, TraitClause@1]}
786
*/
787
/**
788
A monomorphic instance of core.result.unwrap_26
789
with types Eurydice_arr uint8_t[[$20size_t]], core_array_TryFromSliceError
790
791
*/
792
static inline Eurydice_arr_fc core_result_unwrap_26_7d(core_result_Result_83 self)
793
0
{
794
0
  if (self.tag == core_result_Ok)
795
0
  {
796
0
    return self.val.case_Ok;
797
0
  }
798
0
  else
799
0
  {
800
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "unwrap not Ok");
801
0
    KRML_HOST_EXIT(255U);
802
0
  }
803
0
}
804
805
/**
806
A monomorphic instance of Eurydice.arr
807
with types uint8_t
808
with const generics
809
- $1184size_t
810
*/
811
typedef struct Eurydice_arr_5f_s { uint8_t data[1184U]; } Eurydice_arr_5f;
812
813
/**
814
A monomorphic instance of Eurydice.array_to_subslice_from_shared
815
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
816
with const generics
817
- N= 1184
818
*/
819
static inline Eurydice_borrow_slice_u8
820
Eurydice_array_to_subslice_from_shared_5f2(const Eurydice_arr_5f *a, size_t r)
821
0
{
822
0
  return
823
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)1184U - r });
824
0
}
825
826
/**
827
A monomorphic instance of Eurydice.array_to_subslice_to_shared
828
with types uint8_t, core_ops_range_RangeTo size_t, Eurydice_derefed_slice uint8_t
829
with const generics
830
- N= 1184
831
*/
832
static inline Eurydice_borrow_slice_u8
833
Eurydice_array_to_subslice_to_shared_210(const Eurydice_arr_5f *a, size_t r)
834
0
{
835
0
  Eurydice_borrow_slice_u8 lit;
836
0
  lit.ptr = a->data;
837
0
  lit.meta = r;
838
0
  return lit;
839
0
}
840
841
/**
842
A monomorphic instance of Eurydice.arr
843
with types uint8_t
844
with const generics
845
- $2400size_t
846
*/
847
typedef struct Eurydice_arr_7d_s { uint8_t data[2400U]; } Eurydice_arr_7d;
848
849
/**
850
A monomorphic instance of Eurydice.array_to_subslice_shared
851
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
852
with const generics
853
- N= 2400
854
*/
855
static inline Eurydice_borrow_slice_u8
856
Eurydice_array_to_subslice_shared_d48(const Eurydice_arr_7d *a, core_ops_range_Range_87 r)
857
0
{
858
0
  return
859
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
860
0
}
861
862
/**
863
A monomorphic instance of Eurydice.arr
864
with types uint8_t
865
with const generics
866
- $1152size_t
867
*/
868
typedef struct Eurydice_arr_0e_s { uint8_t data[1152U]; } Eurydice_arr_0e;
869
870
/**
871
A monomorphic instance of Eurydice.array_to_slice_shared
872
with types uint8_t
873
with const generics
874
- N= 1152
875
*/
876
static inline Eurydice_borrow_slice_u8
877
Eurydice_array_to_slice_shared_f4(const Eurydice_arr_0e *a)
878
0
{
879
0
  Eurydice_borrow_slice_u8 lit;
880
0
  lit.ptr = a->data;
881
0
  lit.meta = (size_t)1152U;
882
0
  return lit;
883
0
}
884
885
/**
886
A monomorphic instance of Eurydice.array_to_subslice_mut
887
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
888
with const generics
889
- N= 2400
890
*/
891
static inline Eurydice_mut_borrow_slice_u8
892
Eurydice_array_to_subslice_mut_d417(Eurydice_arr_7d *a, core_ops_range_Range_87 r)
893
0
{
894
0
  return
895
0
    (
896
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
897
0
        .ptr = a->data + r.start,
898
0
        .meta = r.end - r.start
899
0
      }
900
0
    );
901
0
}
902
903
/**
904
A monomorphic instance of Eurydice.array_to_slice_mut
905
with types uint8_t
906
with const generics
907
- N= 1152
908
*/
909
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_f4(Eurydice_arr_0e *a)
910
0
{
911
0
  Eurydice_mut_borrow_slice_u8 lit;
912
0
  lit.ptr = a->data;
913
0
  lit.meta = (size_t)1152U;
914
0
  return lit;
915
0
}
916
917
/**
918
A monomorphic instance of Eurydice.array_to_subslice_from_mut
919
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
920
with const generics
921
- N= 1184
922
*/
923
static inline Eurydice_mut_borrow_slice_u8
924
Eurydice_array_to_subslice_from_mut_5f4(Eurydice_arr_5f *a, size_t r)
925
0
{
926
0
  return
927
0
    (KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)1184U - r });
928
0
}
929
930
/**
931
A monomorphic instance of Eurydice.array_to_subslice_mut
932
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
933
with const generics
934
- N= 1184
935
*/
936
static inline Eurydice_mut_borrow_slice_u8
937
Eurydice_array_to_subslice_mut_d416(Eurydice_arr_5f *a, core_ops_range_Range_87 r)
938
0
{
939
0
  return
940
0
    (
941
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
942
0
        .ptr = a->data + r.start,
943
0
        .meta = r.end - r.start
944
0
      }
945
0
    );
946
0
}
947
948
/**
949
A monomorphic instance of Eurydice.array_to_slice_shared
950
with types uint8_t
951
with const generics
952
- N= 24
953
*/
954
static inline Eurydice_borrow_slice_u8
955
Eurydice_array_to_slice_shared_ed(const Eurydice_arr_94 *a)
956
0
{
957
0
  Eurydice_borrow_slice_u8 lit;
958
0
  lit.ptr = a->data;
959
0
  lit.meta = (size_t)24U;
960
0
  return lit;
961
0
}
962
963
/**
964
A monomorphic instance of Eurydice.arr
965
with types uint8_t
966
with const generics
967
- $384size_t
968
*/
969
typedef struct Eurydice_arr_b20_s { uint8_t data[384U]; } Eurydice_arr_b20;
970
971
/**
972
A monomorphic instance of Eurydice.array_to_subslice_mut
973
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
974
with const generics
975
- N= 384
976
*/
977
static inline Eurydice_mut_borrow_slice_u8
978
Eurydice_array_to_subslice_mut_d415(Eurydice_arr_b20 *a, core_ops_range_Range_87 r)
979
0
{
980
0
  return
981
0
    (
982
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
983
0
        .ptr = a->data + r.start,
984
0
        .meta = r.end - r.start
985
0
      }
986
0
    );
987
0
}
988
989
/**
990
A monomorphic instance of Eurydice.array_to_slice_shared
991
with types uint8_t
992
with const generics
993
- N= 384
994
*/
995
static inline Eurydice_borrow_slice_u8
996
Eurydice_array_to_slice_shared_a9(const Eurydice_arr_b20 *a)
997
0
{
998
0
  Eurydice_borrow_slice_u8 lit;
999
0
  lit.ptr = a->data;
1000
0
  lit.meta = (size_t)384U;
1001
0
  return lit;
1002
0
}
1003
1004
/**
1005
A monomorphic instance of Eurydice.arr
1006
with types uint8_t
1007
with const generics
1008
- $32size_t
1009
*/
1010
typedef struct Eurydice_arr_ec_s { uint8_t data[32U]; } Eurydice_arr_ec;
1011
1012
/**
1013
A monomorphic instance of core.result.Result
1014
with types Eurydice_arr_ec, core_array_TryFromSliceError
1015
1016
*/
1017
typedef struct core_result_Result_07_s
1018
{
1019
  core_result_Result_57_tags tag;
1020
  union {
1021
    Eurydice_arr_ec case_Ok;
1022
    core_array_TryFromSliceError case_Err;
1023
  }
1024
  val;
1025
}
1026
core_result_Result_07;
1027
1028
/**
1029
This function found in impl {core::result::Result<T, E>[TraitClause@0, TraitClause@1]}
1030
*/
1031
/**
1032
A monomorphic instance of core.result.unwrap_26
1033
with types Eurydice_arr uint8_t[[$32size_t]], core_array_TryFromSliceError
1034
1035
*/
1036
static inline Eurydice_arr_ec core_result_unwrap_26_39(core_result_Result_07 self)
1037
0
{
1038
0
  if (self.tag == core_result_Ok)
1039
0
  {
1040
0
    return self.val.case_Ok;
1041
0
  }
1042
0
  else
1043
0
  {
1044
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "unwrap not Ok");
1045
0
    KRML_HOST_EXIT(255U);
1046
0
  }
1047
0
}
1048
1049
/**
1050
A monomorphic instance of Eurydice.arr
1051
with types uint8_t
1052
with const generics
1053
- $64size_t
1054
*/
1055
typedef struct Eurydice_arr_c7_s { uint8_t data[64U]; } Eurydice_arr_c7;
1056
1057
/**
1058
A monomorphic instance of Eurydice.array_to_subslice_from_shared
1059
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
1060
with const generics
1061
- N= 64
1062
*/
1063
static inline Eurydice_borrow_slice_u8
1064
Eurydice_array_to_subslice_from_shared_5f1(const Eurydice_arr_c7 *a, size_t r)
1065
0
{
1066
0
  return
1067
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)64U - r });
1068
0
}
1069
1070
/**
1071
A monomorphic instance of Eurydice.array_to_subslice_shared
1072
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1073
with const generics
1074
- N= 64
1075
*/
1076
static inline Eurydice_borrow_slice_u8
1077
Eurydice_array_to_subslice_shared_d47(const Eurydice_arr_c7 *a, core_ops_range_Range_87 r)
1078
0
{
1079
0
  return
1080
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1081
0
}
1082
1083
/**
1084
A monomorphic instance of Eurydice.array_to_slice_shared
1085
with types uint8_t
1086
with const generics
1087
- N= 1184
1088
*/
1089
static inline Eurydice_borrow_slice_u8
1090
Eurydice_array_to_slice_shared_ff(const Eurydice_arr_5f *a)
1091
0
{
1092
0
  Eurydice_borrow_slice_u8 lit;
1093
0
  lit.ptr = a->data;
1094
0
  lit.meta = (size_t)1184U;
1095
0
  return lit;
1096
0
}
1097
1098
/**
1099
A monomorphic instance of Eurydice.arr
1100
with types uint8_t
1101
with const generics
1102
- $1088size_t
1103
*/
1104
typedef struct Eurydice_arr_2b_s { uint8_t data[1088U]; } Eurydice_arr_2b;
1105
1106
/**
1107
A monomorphic instance of Eurydice.array_to_subslice_from_mut
1108
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
1109
with const generics
1110
- N= 1088
1111
*/
1112
static inline Eurydice_mut_borrow_slice_u8
1113
Eurydice_array_to_subslice_from_mut_5f3(Eurydice_arr_2b *a, size_t r)
1114
0
{
1115
0
  return
1116
0
    (KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)1088U - r });
1117
0
}
1118
1119
/**
1120
A monomorphic instance of Eurydice.array_to_subslice_mut
1121
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1122
with const generics
1123
- N= 1088
1124
*/
1125
static inline Eurydice_mut_borrow_slice_u8
1126
Eurydice_array_to_subslice_mut_d414(Eurydice_arr_2b *a, core_ops_range_Range_87 r)
1127
0
{
1128
0
  return
1129
0
    (
1130
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1131
0
        .ptr = a->data + r.start,
1132
0
        .meta = r.end - r.start
1133
0
      }
1134
0
    );
1135
0
}
1136
1137
/**
1138
A monomorphic instance of Eurydice.array_to_slice_shared
1139
with types uint8_t
1140
with const generics
1141
- N= 20
1142
*/
1143
static inline Eurydice_borrow_slice_u8
1144
Eurydice_array_to_slice_shared_8f(const Eurydice_arr_fc *a)
1145
0
{
1146
0
  Eurydice_borrow_slice_u8 lit;
1147
0
  lit.ptr = a->data;
1148
0
  lit.meta = (size_t)20U;
1149
0
  return lit;
1150
0
}
1151
1152
/**
1153
A monomorphic instance of Eurydice.arr
1154
with types uint8_t
1155
with const generics
1156
- $320size_t
1157
*/
1158
typedef struct Eurydice_arr_b0_s { uint8_t data[320U]; } Eurydice_arr_b0;
1159
1160
/**
1161
A monomorphic instance of Eurydice.array_to_subslice_mut
1162
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1163
with const generics
1164
- N= 320
1165
*/
1166
static inline Eurydice_mut_borrow_slice_u8
1167
Eurydice_array_to_subslice_mut_d413(Eurydice_arr_b0 *a, core_ops_range_Range_87 r)
1168
0
{
1169
0
  return
1170
0
    (
1171
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1172
0
        .ptr = a->data + r.start,
1173
0
        .meta = r.end - r.start
1174
0
      }
1175
0
    );
1176
0
}
1177
1178
/**
1179
A monomorphic instance of Eurydice.array_to_slice_shared
1180
with types uint8_t
1181
with const generics
1182
- N= 320
1183
*/
1184
static inline Eurydice_borrow_slice_u8
1185
Eurydice_array_to_slice_shared_56(const Eurydice_arr_b0 *a)
1186
0
{
1187
0
  Eurydice_borrow_slice_u8 lit;
1188
0
  lit.ptr = a->data;
1189
0
  lit.meta = (size_t)320U;
1190
0
  return lit;
1191
0
}
1192
1193
/**
1194
A monomorphic instance of Eurydice.arr
1195
with types int16_t
1196
with const generics
1197
- $256size_t
1198
*/
1199
typedef struct Eurydice_arr_04_s { int16_t data[256U]; } Eurydice_arr_04;
1200
1201
/**
1202
A monomorphic instance of Eurydice.array_to_slice_shared
1203
with types int16_t
1204
with const generics
1205
- N= 256
1206
*/
1207
static inline Eurydice_borrow_slice_i16
1208
Eurydice_array_to_slice_shared_99(const Eurydice_arr_04 *a)
1209
0
{
1210
0
  Eurydice_borrow_slice_i16 lit;
1211
0
  lit.ptr = a->data;
1212
0
  lit.meta = (size_t)256U;
1213
0
  return lit;
1214
0
}
1215
1216
/**
1217
A monomorphic instance of Eurydice.arr
1218
with types uint8_t
1219
with const generics
1220
- $128size_t
1221
*/
1222
typedef struct Eurydice_arr_89_s { uint8_t data[128U]; } Eurydice_arr_89;
1223
1224
/**
1225
A monomorphic instance of Eurydice.arr
1226
with types Eurydice_arr_89
1227
with const generics
1228
- $3size_t
1229
*/
1230
typedef struct Eurydice_arr_58_s { Eurydice_arr_89 data[3U]; } Eurydice_arr_58;
1231
1232
/**
1233
A monomorphic instance of Eurydice.arr
1234
with types uint8_t
1235
with const generics
1236
- $33size_t
1237
*/
1238
typedef struct Eurydice_arr_fa0_s { uint8_t data[33U]; } Eurydice_arr_fa0;
1239
1240
/**
1241
A monomorphic instance of Eurydice.array_to_slice_shared
1242
with types uint8_t
1243
with const generics
1244
- N= 33
1245
*/
1246
static inline Eurydice_borrow_slice_u8
1247
Eurydice_array_to_slice_shared_b5(const Eurydice_arr_fa0 *a)
1248
0
{
1249
0
  Eurydice_borrow_slice_u8 lit;
1250
0
  lit.ptr = a->data;
1251
0
  lit.meta = (size_t)33U;
1252
0
  return lit;
1253
0
}
1254
1255
/**
1256
A monomorphic instance of Eurydice.arr
1257
with types Eurydice_arr_fa0
1258
with const generics
1259
- $3size_t
1260
*/
1261
typedef struct Eurydice_arr_fd_s { Eurydice_arr_fa0 data[3U]; } Eurydice_arr_fd;
1262
1263
/**
1264
A monomorphic instance of Eurydice.array_to_subslice_mut
1265
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1266
with const generics
1267
- N= 33
1268
*/
1269
static inline Eurydice_mut_borrow_slice_u8
1270
Eurydice_array_to_subslice_mut_d412(Eurydice_arr_fa0 *a, core_ops_range_Range_87 r)
1271
0
{
1272
0
  return
1273
0
    (
1274
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1275
0
        .ptr = a->data + r.start,
1276
0
        .meta = r.end - r.start
1277
0
      }
1278
0
    );
1279
0
}
1280
1281
/**
1282
A monomorphic instance of Eurydice.arr
1283
with types int16_t
1284
with const generics
1285
- $272size_t
1286
*/
1287
typedef struct Eurydice_arr_5b_s { int16_t data[272U]; } Eurydice_arr_5b;
1288
1289
/**
1290
A monomorphic instance of Eurydice.array_to_subslice_shared
1291
with types int16_t, core_ops_range_Range size_t, Eurydice_derefed_slice int16_t
1292
with const generics
1293
- N= 272
1294
*/
1295
static inline Eurydice_borrow_slice_i16
1296
Eurydice_array_to_subslice_shared_e70(const Eurydice_arr_5b *a, core_ops_range_Range_87 r)
1297
0
{
1298
0
  return
1299
0
    (KRML_CLITERAL(Eurydice_borrow_slice_i16){ .ptr = a->data + r.start, .meta = r.end - r.start });
1300
0
}
1301
1302
/**
1303
A monomorphic instance of Eurydice.arr
1304
with types uint8_t
1305
with const generics
1306
- $168size_t
1307
*/
1308
typedef struct Eurydice_arr_c5_s { uint8_t data[168U]; } Eurydice_arr_c5;
1309
1310
/**
1311
A monomorphic instance of Eurydice.array_to_subslice_shared
1312
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1313
with const generics
1314
- N= 168
1315
*/
1316
static inline Eurydice_borrow_slice_u8
1317
Eurydice_array_to_subslice_shared_d46(const Eurydice_arr_c5 *a, core_ops_range_Range_87 r)
1318
0
{
1319
0
  return
1320
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1321
0
}
1322
1323
/**
1324
A monomorphic instance of Eurydice.arr
1325
with types Eurydice_arr_c5
1326
with const generics
1327
- $3size_t
1328
*/
1329
typedef struct Eurydice_arr_2c_s { Eurydice_arr_c5 data[3U]; } Eurydice_arr_2c;
1330
1331
/**
1332
A monomorphic instance of Eurydice.arr
1333
with types Eurydice_arr_5b
1334
with const generics
1335
- $3size_t
1336
*/
1337
typedef struct Eurydice_arr_b1_s { Eurydice_arr_5b data[3U]; } Eurydice_arr_b1;
1338
1339
/**
1340
A monomorphic instance of Eurydice.arr
1341
with types size_t
1342
with const generics
1343
- $3size_t
1344
*/
1345
typedef struct Eurydice_arr_eb_s { size_t data[3U]; } Eurydice_arr_eb;
1346
1347
/**
1348
A monomorphic instance of Eurydice.array_to_subslice_mut
1349
with types int16_t, core_ops_range_Range size_t, Eurydice_derefed_slice int16_t
1350
with const generics
1351
- N= 272
1352
*/
1353
static inline Eurydice_mut_borrow_slice_i16
1354
Eurydice_array_to_subslice_mut_e7(Eurydice_arr_5b *a, core_ops_range_Range_87 r)
1355
0
{
1356
0
  return
1357
0
    (
1358
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_i16){
1359
0
        .ptr = a->data + r.start,
1360
0
        .meta = r.end - r.start
1361
0
      }
1362
0
    );
1363
0
}
1364
1365
/**
1366
A monomorphic instance of Eurydice.arr
1367
with types uint8_t
1368
with const generics
1369
- $504size_t
1370
*/
1371
typedef struct Eurydice_arr_79_s { uint8_t data[504U]; } Eurydice_arr_79;
1372
1373
/**
1374
A monomorphic instance of Eurydice.array_to_subslice_shared
1375
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1376
with const generics
1377
- N= 504
1378
*/
1379
static inline Eurydice_borrow_slice_u8
1380
Eurydice_array_to_subslice_shared_d45(const Eurydice_arr_79 *a, core_ops_range_Range_87 r)
1381
0
{
1382
0
  return
1383
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1384
0
}
1385
1386
/**
1387
A monomorphic instance of Eurydice.arr
1388
with types Eurydice_arr_79
1389
with const generics
1390
- $3size_t
1391
*/
1392
typedef struct Eurydice_arr_7e_s { Eurydice_arr_79 data[3U]; } Eurydice_arr_7e;
1393
1394
/**
1395
A monomorphic instance of Eurydice.array_to_slice_mut
1396
with types uint8_t
1397
with const generics
1398
- N= 504
1399
*/
1400
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_48(Eurydice_arr_79 *a)
1401
0
{
1402
0
  Eurydice_mut_borrow_slice_u8 lit;
1403
0
  lit.ptr = a->data;
1404
0
  lit.meta = (size_t)504U;
1405
0
  return lit;
1406
0
}
1407
1408
/**
1409
A monomorphic instance of Eurydice.arr
1410
with types uint8_t
1411
with const generics
1412
- $34size_t
1413
*/
1414
typedef struct Eurydice_arr_31_s { uint8_t data[34U]; } Eurydice_arr_31;
1415
1416
/**
1417
A monomorphic instance of Eurydice.arr
1418
with types Eurydice_arr_31
1419
with const generics
1420
- $3size_t
1421
*/
1422
typedef struct Eurydice_arr_810_s { Eurydice_arr_31 data[3U]; } Eurydice_arr_810;
1423
1424
/**
1425
A monomorphic instance of Eurydice.slice_subslice_from_shared
1426
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
1427
1428
*/
1429
static inline Eurydice_borrow_slice_u8
1430
Eurydice_slice_subslice_from_shared_6d(Eurydice_borrow_slice_u8 s, size_t r)
1431
0
{
1432
0
  return (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = s.ptr + r, .meta = s.meta - r });
1433
0
}
1434
1435
/**
1436
A monomorphic instance of Eurydice.arr
1437
with types uint8_t
1438
with const generics
1439
- $1120size_t
1440
*/
1441
typedef struct Eurydice_arr_af_s { uint8_t data[1120U]; } Eurydice_arr_af;
1442
1443
/**
1444
A monomorphic instance of Eurydice.array_to_slice_shared
1445
with types uint8_t
1446
with const generics
1447
- N= 1120
1448
*/
1449
static inline Eurydice_borrow_slice_u8
1450
Eurydice_array_to_slice_shared_81(const Eurydice_arr_af *a)
1451
0
{
1452
0
  Eurydice_borrow_slice_u8 lit;
1453
0
  lit.ptr = a->data;
1454
0
  lit.meta = (size_t)1120U;
1455
0
  return lit;
1456
0
}
1457
1458
/**
1459
A monomorphic instance of Eurydice.array_to_slice_shared
1460
with types uint8_t
1461
with const generics
1462
- N= 1088
1463
*/
1464
static inline Eurydice_borrow_slice_u8
1465
Eurydice_array_to_slice_shared_06(const Eurydice_arr_2b *a)
1466
0
{
1467
0
  Eurydice_borrow_slice_u8 lit;
1468
0
  lit.ptr = a->data;
1469
0
  lit.meta = (size_t)1088U;
1470
0
  return lit;
1471
0
}
1472
1473
/**
1474
A monomorphic instance of Eurydice.array_to_subslice_from_mut
1475
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
1476
with const generics
1477
- N= 1120
1478
*/
1479
static inline Eurydice_mut_borrow_slice_u8
1480
Eurydice_array_to_subslice_from_mut_5f2(Eurydice_arr_af *a, size_t r)
1481
0
{
1482
0
  return
1483
0
    (KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)1120U - r });
1484
0
}
1485
1486
/**
1487
A monomorphic instance of Eurydice.array_to_subslice_mut
1488
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1489
with const generics
1490
- N= 1120
1491
*/
1492
static inline Eurydice_mut_borrow_slice_u8
1493
Eurydice_array_to_subslice_mut_d411(Eurydice_arr_af *a, core_ops_range_Range_87 r)
1494
0
{
1495
0
  return
1496
0
    (
1497
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1498
0
        .ptr = a->data + r.start,
1499
0
        .meta = r.end - r.start
1500
0
      }
1501
0
    );
1502
0
}
1503
1504
/**
1505
A monomorphic instance of Eurydice.array_to_subslice_from_mut
1506
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
1507
with const generics
1508
- N= 64
1509
*/
1510
static inline Eurydice_mut_borrow_slice_u8
1511
Eurydice_array_to_subslice_from_mut_5f1(Eurydice_arr_c7 *a, size_t r)
1512
0
{
1513
0
  return
1514
0
    (KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)64U - r });
1515
0
}
1516
1517
/**
1518
A monomorphic instance of Eurydice.array_to_subslice_mut
1519
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1520
with const generics
1521
- N= 64
1522
*/
1523
static inline Eurydice_mut_borrow_slice_u8
1524
Eurydice_array_to_subslice_mut_d410(Eurydice_arr_c7 *a, core_ops_range_Range_87 r)
1525
0
{
1526
0
  return
1527
0
    (
1528
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1529
0
        .ptr = a->data + r.start,
1530
0
        .meta = r.end - r.start
1531
0
      }
1532
0
    );
1533
0
}
1534
1535
/**
1536
A monomorphic instance of Eurydice.array_to_subslice_from_shared
1537
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
1538
with const generics
1539
- N= 1088
1540
*/
1541
static inline Eurydice_borrow_slice_u8
1542
Eurydice_array_to_subslice_from_shared_5f0(const Eurydice_arr_2b *a, size_t r)
1543
0
{
1544
0
  return
1545
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)1088U - r });
1546
0
}
1547
1548
/**
1549
A monomorphic instance of Eurydice.array_to_subslice_shared
1550
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1551
with const generics
1552
- N= 1088
1553
*/
1554
static inline Eurydice_borrow_slice_u8
1555
Eurydice_array_to_subslice_shared_d44(const Eurydice_arr_2b *a, core_ops_range_Range_87 r)
1556
0
{
1557
0
  return
1558
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1559
0
}
1560
1561
/**
1562
A monomorphic instance of Eurydice.array_to_slice_shared
1563
with types uint8_t
1564
with const generics
1565
- N= 2400
1566
*/
1567
static inline Eurydice_borrow_slice_u8
1568
Eurydice_array_to_slice_shared_51(const Eurydice_arr_7d *a)
1569
0
{
1570
0
  Eurydice_borrow_slice_u8 lit;
1571
0
  lit.ptr = a->data;
1572
0
  lit.meta = (size_t)2400U;
1573
0
  return lit;
1574
0
}
1575
1576
typedef struct int16_t_x2_s
1577
{
1578
  int16_t fst;
1579
  int16_t snd;
1580
}
1581
int16_t_x2;
1582
1583
/**
1584
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
1585
*/
1586
/**
1587
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
1588
with types Eurydice_arr uint8_t[[$24size_t]]
1589
1590
*/
1591
static KRML_MUSTINLINE Eurydice_arr_94
1592
libcrux_secrets_int_public_integers_declassify_d8_40(Eurydice_arr_94 self)
1593
0
{
1594
0
  return self;
1595
0
}
1596
1597
typedef struct uint8_t_x3_s
1598
{
1599
  uint8_t fst;
1600
  uint8_t snd;
1601
  uint8_t thd;
1602
}
1603
uint8_t_x3;
1604
1605
/**
1606
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
1607
*/
1608
/**
1609
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
1610
with types Eurydice_arr uint8_t[[$20size_t]]
1611
1612
*/
1613
static KRML_MUSTINLINE Eurydice_arr_fc
1614
libcrux_secrets_int_public_integers_declassify_d8_2b(Eurydice_arr_fc self)
1615
0
{
1616
0
  return self;
1617
0
}
1618
1619
typedef struct uint8_t_x5_s
1620
{
1621
  uint8_t fst;
1622
  uint8_t snd;
1623
  uint8_t thd;
1624
  uint8_t f3;
1625
  uint8_t f4;
1626
}
1627
uint8_t_x5;
1628
1629
/**
1630
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
1631
*/
1632
/**
1633
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
1634
with types Eurydice_arr uint8_t[[$8size_t]]
1635
1636
*/
1637
static KRML_MUSTINLINE Eurydice_array_u8x8
1638
libcrux_secrets_int_public_integers_declassify_d8_52(Eurydice_array_u8x8 self)
1639
0
{
1640
0
  return self;
1641
0
}
1642
1643
typedef struct uint8_t_x4_s
1644
{
1645
  uint8_t fst;
1646
  uint8_t snd;
1647
  uint8_t thd;
1648
  uint8_t f3;
1649
}
1650
uint8_t_x4;
1651
1652
/**
1653
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
1654
*/
1655
/**
1656
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
1657
with types Eurydice_arr uint8_t[[$2size_t]]
1658
1659
*/
1660
static KRML_MUSTINLINE Eurydice_array_u8x2
1661
libcrux_secrets_int_public_integers_declassify_d8_75(Eurydice_array_u8x2 self)
1662
0
{
1663
0
  return self;
1664
0
}
1665
1666
/**
1667
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
1668
*/
1669
/**
1670
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
1671
with types Eurydice_arr int16_t[[$16size_t]]
1672
1673
*/
1674
static KRML_MUSTINLINE Eurydice_arr_d6
1675
libcrux_secrets_int_public_integers_classify_27_4b(Eurydice_arr_d6 self)
1676
0
{
1677
0
  return self;
1678
0
}
1679
1680
/**
1681
This function found in impl {libcrux_secrets::traits::ClassifyRef<&'a ([T])> for &'a ([T])}
1682
*/
1683
/**
1684
A monomorphic instance of libcrux_secrets.int.classify_public.classify_ref_6d
1685
with types uint8_t
1686
1687
*/
1688
static KRML_MUSTINLINE Eurydice_borrow_slice_u8
1689
libcrux_secrets_int_classify_public_classify_ref_6d_90(Eurydice_borrow_slice_u8 self)
1690
0
{
1691
0
  return self;
1692
0
}
1693
1694
typedef struct int16_t_x8_s
1695
{
1696
  int16_t fst;
1697
  int16_t snd;
1698
  int16_t thd;
1699
  int16_t f3;
1700
  int16_t f4;
1701
  int16_t f5;
1702
  int16_t f6;
1703
  int16_t f7;
1704
}
1705
int16_t_x8;
1706
1707
/**
1708
A monomorphic instance of Eurydice.array_to_subslice_shared
1709
with types int16_t, core_ops_range_Range size_t, Eurydice_derefed_slice int16_t
1710
with const generics
1711
- N= 16
1712
*/
1713
static inline Eurydice_borrow_slice_i16
1714
Eurydice_array_to_subslice_shared_e7(const Eurydice_arr_d6 *a, core_ops_range_Range_87 r)
1715
0
{
1716
0
  return
1717
0
    (KRML_CLITERAL(Eurydice_borrow_slice_i16){ .ptr = a->data + r.start, .meta = r.end - r.start });
1718
0
}
1719
1720
/**
1721
This function found in impl {libcrux_secrets::traits::ClassifyRef<&'a ([T])> for &'a ([T])}
1722
*/
1723
/**
1724
A monomorphic instance of libcrux_secrets.int.classify_public.classify_ref_6d
1725
with types int16_t
1726
1727
*/
1728
static KRML_MUSTINLINE Eurydice_borrow_slice_i16
1729
libcrux_secrets_int_classify_public_classify_ref_6d_39(Eurydice_borrow_slice_i16 self)
1730
0
{
1731
0
  return self;
1732
0
}
1733
1734
/**
1735
A monomorphic instance of Eurydice.slice_subslice_shared
1736
with types int16_t, core_ops_range_Range size_t, Eurydice_derefed_slice int16_t
1737
1738
*/
1739
static inline Eurydice_borrow_slice_i16
1740
Eurydice_slice_subslice_shared_a6(Eurydice_borrow_slice_i16 s, core_ops_range_Range_87 r)
1741
0
{
1742
0
  return
1743
0
    (KRML_CLITERAL(Eurydice_borrow_slice_i16){ .ptr = s.ptr + r.start, .meta = r.end - r.start });
1744
0
}
1745
1746
/**
1747
A monomorphic instance of core.result.Result
1748
with types Eurydice_arr_d6, core_array_TryFromSliceError
1749
1750
*/
1751
typedef struct core_result_Result_ec_s
1752
{
1753
  core_result_Result_57_tags tag;
1754
  union {
1755
    Eurydice_arr_d6 case_Ok;
1756
    core_array_TryFromSliceError case_Err;
1757
  }
1758
  val;
1759
}
1760
core_result_Result_ec;
1761
1762
/**
1763
This function found in impl {core::result::Result<T, E>[TraitClause@0, TraitClause@1]}
1764
*/
1765
/**
1766
A monomorphic instance of core.result.unwrap_26
1767
with types Eurydice_arr int16_t[[$16size_t]], core_array_TryFromSliceError
1768
1769
*/
1770
static inline Eurydice_arr_d6 core_result_unwrap_26_d3(core_result_Result_ec self)
1771
0
{
1772
0
  if (self.tag == core_result_Ok)
1773
0
  {
1774
0
    return self.val.case_Ok;
1775
0
  }
1776
0
  else
1777
0
  {
1778
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "unwrap not Ok");
1779
0
    KRML_HOST_EXIT(255U);
1780
0
  }
1781
0
}
1782
1783
/**
1784
A monomorphic instance of Eurydice.arr
1785
with types int16_t
1786
with const generics
1787
- $128size_t
1788
*/
1789
typedef struct Eurydice_arr_34_s { int16_t data[128U]; } Eurydice_arr_34;
1790
1791
/**
1792
A monomorphic instance of Eurydice.array_to_subslice_shared
1793
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1794
with const generics
1795
- N= 24
1796
*/
1797
static inline Eurydice_borrow_slice_u8
1798
Eurydice_array_to_subslice_shared_d43(const Eurydice_arr_94 *a, core_ops_range_Range_87 r)
1799
0
{
1800
0
  return
1801
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1802
0
}
1803
1804
/**
1805
A monomorphic instance of Eurydice.array_to_subslice_mut
1806
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1807
with const generics
1808
- N= 24
1809
*/
1810
static inline Eurydice_mut_borrow_slice_u8
1811
Eurydice_array_to_subslice_mut_d49(Eurydice_arr_94 *a, core_ops_range_Range_87 r)
1812
0
{
1813
0
  return
1814
0
    (
1815
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1816
0
        .ptr = a->data + r.start,
1817
0
        .meta = r.end - r.start
1818
0
      }
1819
0
    );
1820
0
}
1821
1822
/**
1823
A monomorphic instance of Eurydice.array_to_slice_mut
1824
with types uint8_t
1825
with const generics
1826
- N= 16
1827
*/
1828
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_29(Eurydice_arr_b2 *a)
1829
0
{
1830
0
  Eurydice_mut_borrow_slice_u8 lit;
1831
0
  lit.ptr = a->data;
1832
0
  lit.meta = (size_t)16U;
1833
0
  return lit;
1834
0
}
1835
1836
/**
1837
A monomorphic instance of Eurydice.array_to_subslice_shared
1838
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1839
with const generics
1840
- N= 16
1841
*/
1842
static inline Eurydice_borrow_slice_u8
1843
Eurydice_array_to_subslice_shared_d42(const Eurydice_arr_b2 *a, core_ops_range_Range_87 r)
1844
0
{
1845
0
  return
1846
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1847
0
}
1848
1849
/**
1850
A monomorphic instance of Eurydice.array_to_subslice_mut
1851
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1852
with const generics
1853
- N= 16
1854
*/
1855
static inline Eurydice_mut_borrow_slice_u8
1856
Eurydice_array_to_subslice_mut_d48(Eurydice_arr_b2 *a, core_ops_range_Range_87 r)
1857
0
{
1858
0
  return
1859
0
    (
1860
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1861
0
        .ptr = a->data + r.start,
1862
0
        .meta = r.end - r.start
1863
0
      }
1864
0
    );
1865
0
}
1866
1867
/**
1868
A monomorphic instance of Eurydice.arr
1869
with types uint8_t
1870
with const generics
1871
- $19size_t
1872
*/
1873
typedef struct Eurydice_arr_38_s { uint8_t data[19U]; } Eurydice_arr_38;
1874
1875
/**
1876
A monomorphic instance of Eurydice.array_to_subslice_shared
1877
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1878
with const generics
1879
- N= 19
1880
*/
1881
static inline Eurydice_borrow_slice_u8
1882
Eurydice_array_to_subslice_shared_d41(const Eurydice_arr_38 *a, core_ops_range_Range_87 r)
1883
0
{
1884
0
  return
1885
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
1886
0
}
1887
1888
/**
1889
A monomorphic instance of Eurydice.array_to_subslice_mut
1890
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
1891
with const generics
1892
- N= 19
1893
*/
1894
static inline Eurydice_mut_borrow_slice_u8
1895
Eurydice_array_to_subslice_mut_d47(Eurydice_arr_38 *a, core_ops_range_Range_87 r)
1896
0
{
1897
0
  return
1898
0
    (
1899
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
1900
0
        .ptr = a->data + r.start,
1901
0
        .meta = r.end - r.start
1902
0
      }
1903
0
    );
1904
0
}
1905
1906
/**
1907
A monomorphic instance of Eurydice.dst_ref_mut
1908
with types int32_t, size_t
1909
1910
*/
1911
typedef struct Eurydice_dst_ref_mut_83_s
1912
{
1913
  int32_t *ptr;
1914
  size_t meta;
1915
}
1916
Eurydice_dst_ref_mut_83;
1917
1918
/**
1919
A monomorphic instance of Eurydice.slice_subslice_mut
1920
with types int32_t, core_ops_range_Range size_t, Eurydice_derefed_slice int32_t
1921
1922
*/
1923
static inline Eurydice_dst_ref_mut_83
1924
Eurydice_slice_subslice_mut_47(Eurydice_dst_ref_mut_83 s, core_ops_range_Range_87 r)
1925
0
{
1926
0
  return
1927
0
    (KRML_CLITERAL(Eurydice_dst_ref_mut_83){ .ptr = s.ptr + r.start, .meta = r.end - r.start });
1928
0
}
1929
1930
/**
1931
A monomorphic instance of Eurydice.array_to_slice_shared
1932
with types uint8_t
1933
with const generics
1934
- N= 16
1935
*/
1936
static inline Eurydice_borrow_slice_u8
1937
Eurydice_array_to_slice_shared_29(const Eurydice_arr_b2 *a)
1938
0
{
1939
0
  Eurydice_borrow_slice_u8 lit;
1940
0
  lit.ptr = a->data;
1941
0
  lit.meta = (size_t)16U;
1942
0
  return lit;
1943
0
}
1944
1945
/**
1946
A monomorphic instance of Eurydice.arr
1947
with types Eurydice_arr_b2
1948
with const generics
1949
- $16size_t
1950
*/
1951
typedef struct Eurydice_arr_a30_s { Eurydice_arr_b2 data[16U]; } Eurydice_arr_a30;
1952
1953
/**
1954
A monomorphic instance of Eurydice.array_to_subslice_to_mut
1955
with types uint8_t, core_ops_range_RangeTo size_t, Eurydice_derefed_slice uint8_t
1956
with const generics
1957
- N= 32
1958
*/
1959
static inline Eurydice_mut_borrow_slice_u8
1960
Eurydice_array_to_subslice_to_mut_21(Eurydice_arr_ec *a, size_t r)
1961
0
{
1962
0
  Eurydice_mut_borrow_slice_u8 lit;
1963
0
  lit.ptr = a->data;
1964
0
  lit.meta = r;
1965
0
  return lit;
1966
0
}
1967
1968
/**
1969
A monomorphic instance of Eurydice.arr
1970
with types uint8_t
1971
with const generics
1972
- $4627size_t
1973
*/
1974
typedef struct Eurydice_arr_93_s { uint8_t data[4627U]; } Eurydice_arr_93;
1975
1976
/**
1977
A monomorphic instance of Eurydice.array_to_slice_shared
1978
with types uint8_t
1979
with const generics
1980
- N= 4627
1981
*/
1982
static inline Eurydice_borrow_slice_u8
1983
Eurydice_array_to_slice_shared_11(const Eurydice_arr_93 *a)
1984
0
{
1985
0
  Eurydice_borrow_slice_u8 lit;
1986
0
  lit.ptr = a->data;
1987
0
  lit.meta = (size_t)4627U;
1988
0
  return lit;
1989
0
}
1990
1991
/**
1992
A monomorphic instance of Eurydice.arr
1993
with types uint8_t
1994
with const generics
1995
- $2592size_t
1996
*/
1997
typedef struct Eurydice_arr_43_s { uint8_t data[2592U]; } Eurydice_arr_43;
1998
1999
/**
2000
A monomorphic instance of Eurydice.array_to_slice_shared
2001
with types uint8_t
2002
with const generics
2003
- N= 2592
2004
*/
2005
static inline Eurydice_borrow_slice_u8
2006
Eurydice_array_to_slice_shared_fc(const Eurydice_arr_43 *a)
2007
0
{
2008
0
  Eurydice_borrow_slice_u8 lit;
2009
0
  lit.ptr = a->data;
2010
0
  lit.meta = (size_t)2592U;
2011
0
  return lit;
2012
0
}
2013
2014
/**
2015
A monomorphic instance of Eurydice.arr
2016
with types uint8_t
2017
with const generics
2018
- $4896size_t
2019
*/
2020
typedef struct Eurydice_arr_e2_s { uint8_t data[4896U]; } Eurydice_arr_e2;
2021
2022
/**
2023
A monomorphic instance of Eurydice.array_to_slice_shared
2024
with types uint8_t
2025
with const generics
2026
- N= 4896
2027
*/
2028
static inline Eurydice_borrow_slice_u8
2029
Eurydice_array_to_slice_shared_f7(const Eurydice_arr_e2 *a)
2030
0
{
2031
0
  Eurydice_borrow_slice_u8 lit;
2032
0
  lit.ptr = a->data;
2033
0
  lit.meta = (size_t)4896U;
2034
0
  return lit;
2035
0
}
2036
2037
/**
2038
A monomorphic instance of Eurydice.arr
2039
with types int32_t
2040
with const generics
2041
- $256size_t
2042
*/
2043
typedef struct Eurydice_arr_6c_s { int32_t data[256U]; } Eurydice_arr_6c;
2044
2045
/**
2046
A monomorphic instance of Eurydice.arr
2047
with types Eurydice_arr_6c
2048
with const generics
2049
- $8size_t
2050
*/
2051
typedef struct Eurydice_arr_81_s { Eurydice_arr_6c data[8U]; } Eurydice_arr_81;
2052
2053
0
#define core_option_None 0
2054
0
#define core_option_Some 1
2055
2056
typedef uint8_t core_option_Option_45_tags;
2057
2058
/**
2059
A monomorphic instance of core.option.Option
2060
with types Eurydice_arr_81
2061
2062
*/
2063
typedef struct core_option_Option_45_s
2064
{
2065
  core_option_Option_45_tags tag;
2066
  Eurydice_arr_81 f0;
2067
}
2068
core_option_Option_45;
2069
2070
/**
2071
A monomorphic instance of core.option.Option
2072
with types Eurydice_arr_c7
2073
2074
*/
2075
typedef struct core_option_Option_b2_s
2076
{
2077
  core_option_Option_45_tags tag;
2078
  Eurydice_arr_c7 f0;
2079
}
2080
core_option_Option_b2;
2081
2082
/**
2083
A monomorphic instance of Eurydice.array_to_slice_mut
2084
with types uint8_t
2085
with const generics
2086
- N= 4627
2087
*/
2088
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_11(Eurydice_arr_93 *a)
2089
0
{
2090
0
  Eurydice_mut_borrow_slice_u8 lit;
2091
0
  lit.ptr = a->data;
2092
0
  lit.meta = (size_t)4627U;
2093
0
  return lit;
2094
0
}
2095
2096
/**
2097
A monomorphic instance of Eurydice.dst_ref_shared
2098
with types Eurydice_arr_6c, size_t
2099
2100
*/
2101
typedef struct Eurydice_dst_ref_shared_20_s
2102
{
2103
  const Eurydice_arr_6c *ptr;
2104
  size_t meta;
2105
}
2106
Eurydice_dst_ref_shared_20;
2107
2108
/**
2109
A monomorphic instance of Eurydice.array_to_slice_shared
2110
with types Eurydice_arr int32_t[[$256size_t]]
2111
with const generics
2112
- N= 8
2113
*/
2114
static inline Eurydice_dst_ref_shared_20
2115
Eurydice_array_to_slice_shared_861(const Eurydice_arr_81 *a)
2116
0
{
2117
0
  Eurydice_dst_ref_shared_20 lit;
2118
0
  lit.ptr = a->data;
2119
0
  lit.meta = (size_t)8U;
2120
0
  return lit;
2121
0
}
2122
2123
/**
2124
A monomorphic instance of Eurydice.dst_ref_mut
2125
with types Eurydice_arr_6c, size_t
2126
2127
*/
2128
typedef struct Eurydice_dst_ref_mut_20_s
2129
{
2130
  Eurydice_arr_6c *ptr;
2131
  size_t meta;
2132
}
2133
Eurydice_dst_ref_mut_20;
2134
2135
/**
2136
A monomorphic instance of Eurydice.array_to_slice_mut
2137
with types Eurydice_arr int32_t[[$256size_t]]
2138
with const generics
2139
- N= 8
2140
*/
2141
static inline Eurydice_dst_ref_mut_20 Eurydice_array_to_slice_mut_861(Eurydice_arr_81 *a)
2142
0
{
2143
0
  Eurydice_dst_ref_mut_20 lit;
2144
0
  lit.ptr = a->data;
2145
0
  lit.meta = (size_t)8U;
2146
0
  return lit;
2147
0
}
2148
2149
/**
2150
 Declassify secret memory.
2151
2152
 No-op if `valgrind_ct_test` cfg is not enabled.
2153
*/
2154
/**
2155
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
2156
with types Eurydice_arr uint8_t[[$64size_t]]
2157
2158
*/
2159
static KRML_MUSTINLINE void
2160
libcrux_secrets_mem_requests_ct_declassify_56(const Eurydice_arr_c7 *val)
2161
0
{
2162
0
2163
0
}
2164
2165
/**
2166
A monomorphic instance of Eurydice.arr
2167
with types uint8_t
2168
with const generics
2169
- $1024size_t
2170
*/
2171
typedef struct Eurydice_arr_1b_s { uint8_t data[1024U]; } Eurydice_arr_1b;
2172
2173
/**
2174
A monomorphic instance of Eurydice.array_to_slice_shared
2175
with types uint8_t
2176
with const generics
2177
- N= 1024
2178
*/
2179
static inline Eurydice_borrow_slice_u8
2180
Eurydice_array_to_slice_shared_68(const Eurydice_arr_1b *a)
2181
0
{
2182
0
  Eurydice_borrow_slice_u8 lit;
2183
0
  lit.ptr = a->data;
2184
0
  lit.meta = (size_t)1024U;
2185
0
  return lit;
2186
0
}
2187
2188
/**
2189
A monomorphic instance of Eurydice.array_to_slice_mut
2190
with types uint8_t
2191
with const generics
2192
- N= 1024
2193
*/
2194
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_68(Eurydice_arr_1b *a)
2195
0
{
2196
0
  Eurydice_mut_borrow_slice_u8 lit;
2197
0
  lit.ptr = a->data;
2198
0
  lit.meta = (size_t)1024U;
2199
0
  return lit;
2200
0
}
2201
2202
/**
2203
A monomorphic instance of Eurydice.array_to_slice_mut
2204
with types uint8_t
2205
with const generics
2206
- N= 2592
2207
*/
2208
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_fc(Eurydice_arr_43 *a)
2209
0
{
2210
0
  Eurydice_mut_borrow_slice_u8 lit;
2211
0
  lit.ptr = a->data;
2212
0
  lit.meta = (size_t)2592U;
2213
0
  return lit;
2214
0
}
2215
2216
/**
2217
A monomorphic instance of Eurydice.array_to_slice_mut
2218
with types uint8_t
2219
with const generics
2220
- N= 4896
2221
*/
2222
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_f7(Eurydice_arr_e2 *a)
2223
0
{
2224
0
  Eurydice_mut_borrow_slice_u8 lit;
2225
0
  lit.ptr = a->data;
2226
0
  lit.meta = (size_t)4896U;
2227
0
  return lit;
2228
0
}
2229
2230
/**
2231
A monomorphic instance of Eurydice.arr
2232
with types uint8_t
2233
with const generics
2234
- $3309size_t
2235
*/
2236
typedef struct Eurydice_arr_0c_s { uint8_t data[3309U]; } Eurydice_arr_0c;
2237
2238
/**
2239
A monomorphic instance of Eurydice.array_to_slice_shared
2240
with types uint8_t
2241
with const generics
2242
- N= 3309
2243
*/
2244
static inline Eurydice_borrow_slice_u8
2245
Eurydice_array_to_slice_shared_6b(const Eurydice_arr_0c *a)
2246
0
{
2247
0
  Eurydice_borrow_slice_u8 lit;
2248
0
  lit.ptr = a->data;
2249
0
  lit.meta = (size_t)3309U;
2250
0
  return lit;
2251
0
}
2252
2253
/**
2254
A monomorphic instance of Eurydice.arr
2255
with types uint8_t
2256
with const generics
2257
- $1952size_t
2258
*/
2259
typedef struct Eurydice_arr_29_s { uint8_t data[1952U]; } Eurydice_arr_29;
2260
2261
/**
2262
A monomorphic instance of Eurydice.array_to_slice_shared
2263
with types uint8_t
2264
with const generics
2265
- N= 1952
2266
*/
2267
static inline Eurydice_borrow_slice_u8
2268
Eurydice_array_to_slice_shared_37(const Eurydice_arr_29 *a)
2269
0
{
2270
0
  Eurydice_borrow_slice_u8 lit;
2271
0
  lit.ptr = a->data;
2272
0
  lit.meta = (size_t)1952U;
2273
0
  return lit;
2274
0
}
2275
2276
/**
2277
A monomorphic instance of Eurydice.arr
2278
with types uint8_t
2279
with const generics
2280
- $4032size_t
2281
*/
2282
typedef struct Eurydice_arr_24_s { uint8_t data[4032U]; } Eurydice_arr_24;
2283
2284
/**
2285
A monomorphic instance of Eurydice.array_to_slice_shared
2286
with types uint8_t
2287
with const generics
2288
- N= 4032
2289
*/
2290
static inline Eurydice_borrow_slice_u8
2291
Eurydice_array_to_slice_shared_98(const Eurydice_arr_24 *a)
2292
0
{
2293
0
  Eurydice_borrow_slice_u8 lit;
2294
0
  lit.ptr = a->data;
2295
0
  lit.meta = (size_t)4032U;
2296
0
  return lit;
2297
0
}
2298
2299
/**
2300
A monomorphic instance of Eurydice.arr
2301
with types Eurydice_arr_6c
2302
with const generics
2303
- $6size_t
2304
*/
2305
typedef struct Eurydice_arr_5d0_s { Eurydice_arr_6c data[6U]; } Eurydice_arr_5d0;
2306
2307
/**
2308
A monomorphic instance of core.option.Option
2309
with types Eurydice_arr_5d0
2310
2311
*/
2312
typedef struct core_option_Option_05_s
2313
{
2314
  core_option_Option_45_tags tag;
2315
  Eurydice_arr_5d0 f0;
2316
}
2317
core_option_Option_05;
2318
2319
/**
2320
A monomorphic instance of Eurydice.arr
2321
with types uint8_t
2322
with const generics
2323
- $48size_t
2324
*/
2325
typedef struct Eurydice_arr_65_s { uint8_t data[48U]; } Eurydice_arr_65;
2326
2327
/**
2328
A monomorphic instance of core.option.Option
2329
with types Eurydice_arr_65
2330
2331
*/
2332
typedef struct core_option_Option_81_s
2333
{
2334
  core_option_Option_45_tags tag;
2335
  Eurydice_arr_65 f0;
2336
}
2337
core_option_Option_81;
2338
2339
/**
2340
A monomorphic instance of Eurydice.array_to_slice_mut
2341
with types uint8_t
2342
with const generics
2343
- N= 3309
2344
*/
2345
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_6b(Eurydice_arr_0c *a)
2346
0
{
2347
0
  Eurydice_mut_borrow_slice_u8 lit;
2348
0
  lit.ptr = a->data;
2349
0
  lit.meta = (size_t)3309U;
2350
0
  return lit;
2351
0
}
2352
2353
/**
2354
A monomorphic instance of Eurydice.array_to_slice_shared
2355
with types Eurydice_arr int32_t[[$256size_t]]
2356
with const generics
2357
- N= 6
2358
*/
2359
static inline Eurydice_dst_ref_shared_20
2360
Eurydice_array_to_slice_shared_860(const Eurydice_arr_5d0 *a)
2361
0
{
2362
0
  Eurydice_dst_ref_shared_20 lit;
2363
0
  lit.ptr = a->data;
2364
0
  lit.meta = (size_t)6U;
2365
0
  return lit;
2366
0
}
2367
2368
/**
2369
A monomorphic instance of Eurydice.array_to_slice_mut
2370
with types Eurydice_arr int32_t[[$256size_t]]
2371
with const generics
2372
- N= 6
2373
*/
2374
static inline Eurydice_dst_ref_mut_20 Eurydice_array_to_slice_mut_860(Eurydice_arr_5d0 *a)
2375
0
{
2376
0
  Eurydice_dst_ref_mut_20 lit;
2377
0
  lit.ptr = a->data;
2378
0
  lit.meta = (size_t)6U;
2379
0
  return lit;
2380
0
}
2381
2382
/**
2383
A monomorphic instance of Eurydice.array_to_slice_shared
2384
with types uint8_t
2385
with const generics
2386
- N= 48
2387
*/
2388
static inline Eurydice_borrow_slice_u8
2389
Eurydice_array_to_slice_shared_9f0(const Eurydice_arr_65 *a)
2390
0
{
2391
0
  Eurydice_borrow_slice_u8 lit;
2392
0
  lit.ptr = a->data;
2393
0
  lit.meta = (size_t)48U;
2394
0
  return lit;
2395
0
}
2396
2397
/**
2398
 Declassify secret memory.
2399
2400
 No-op if `valgrind_ct_test` cfg is not enabled.
2401
*/
2402
/**
2403
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
2404
with types Eurydice_arr uint8_t[[$48size_t]]
2405
2406
*/
2407
static KRML_MUSTINLINE void
2408
libcrux_secrets_mem_requests_ct_declassify_69(const Eurydice_arr_65 *val)
2409
0
{
2410
0
2411
0
}
2412
2413
/**
2414
A monomorphic instance of Eurydice.array_to_slice_mut
2415
with types uint8_t
2416
with const generics
2417
- N= 1952
2418
*/
2419
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_37(Eurydice_arr_29 *a)
2420
0
{
2421
0
  Eurydice_mut_borrow_slice_u8 lit;
2422
0
  lit.ptr = a->data;
2423
0
  lit.meta = (size_t)1952U;
2424
0
  return lit;
2425
0
}
2426
2427
/**
2428
A monomorphic instance of Eurydice.array_to_slice_mut
2429
with types uint8_t
2430
with const generics
2431
- N= 4032
2432
*/
2433
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_98(Eurydice_arr_24 *a)
2434
0
{
2435
0
  Eurydice_mut_borrow_slice_u8 lit;
2436
0
  lit.ptr = a->data;
2437
0
  lit.meta = (size_t)4032U;
2438
0
  return lit;
2439
0
}
2440
2441
/**
2442
A monomorphic instance of Eurydice.arr
2443
with types uint8_t
2444
with const generics
2445
- $2420size_t
2446
*/
2447
typedef struct Eurydice_arr_85_s { uint8_t data[2420U]; } Eurydice_arr_85;
2448
2449
/**
2450
A monomorphic instance of Eurydice.array_to_slice_shared
2451
with types uint8_t
2452
with const generics
2453
- N= 2420
2454
*/
2455
static inline Eurydice_borrow_slice_u8
2456
Eurydice_array_to_slice_shared_0d(const Eurydice_arr_85 *a)
2457
0
{
2458
0
  Eurydice_borrow_slice_u8 lit;
2459
0
  lit.ptr = a->data;
2460
0
  lit.meta = (size_t)2420U;
2461
0
  return lit;
2462
0
}
2463
2464
/**
2465
A monomorphic instance of Eurydice.arr
2466
with types uint8_t
2467
with const generics
2468
- $1312size_t
2469
*/
2470
typedef struct Eurydice_arr_02_s { uint8_t data[1312U]; } Eurydice_arr_02;
2471
2472
/**
2473
A monomorphic instance of Eurydice.array_to_slice_shared
2474
with types uint8_t
2475
with const generics
2476
- N= 1312
2477
*/
2478
static inline Eurydice_borrow_slice_u8
2479
Eurydice_array_to_slice_shared_9f(const Eurydice_arr_02 *a)
2480
0
{
2481
0
  Eurydice_borrow_slice_u8 lit;
2482
0
  lit.ptr = a->data;
2483
0
  lit.meta = (size_t)1312U;
2484
0
  return lit;
2485
0
}
2486
2487
/**
2488
A monomorphic instance of Eurydice.arr
2489
with types uint8_t
2490
with const generics
2491
- $2560size_t
2492
*/
2493
typedef struct Eurydice_arr_10_s { uint8_t data[2560U]; } Eurydice_arr_10;
2494
2495
/**
2496
A monomorphic instance of Eurydice.array_to_slice_shared
2497
with types uint8_t
2498
with const generics
2499
- N= 2560
2500
*/
2501
static inline Eurydice_borrow_slice_u8
2502
Eurydice_array_to_slice_shared_34(const Eurydice_arr_10 *a)
2503
0
{
2504
0
  Eurydice_borrow_slice_u8 lit;
2505
0
  lit.ptr = a->data;
2506
0
  lit.meta = (size_t)2560U;
2507
0
  return lit;
2508
0
}
2509
2510
/**
2511
A monomorphic instance of Eurydice.arr
2512
with types Eurydice_arr_6c
2513
with const generics
2514
- $4size_t
2515
*/
2516
typedef struct Eurydice_arr_b7_s { Eurydice_arr_6c data[4U]; } Eurydice_arr_b7;
2517
2518
/**
2519
A monomorphic instance of core.option.Option
2520
with types Eurydice_arr_b7
2521
2522
*/
2523
typedef struct core_option_Option_51_s
2524
{
2525
  core_option_Option_45_tags tag;
2526
  Eurydice_arr_b7 f0;
2527
}
2528
core_option_Option_51;
2529
2530
/**
2531
A monomorphic instance of core.option.Option
2532
with types Eurydice_arr_ec
2533
2534
*/
2535
typedef struct core_option_Option_14_s
2536
{
2537
  core_option_Option_45_tags tag;
2538
  Eurydice_arr_ec f0;
2539
}
2540
core_option_Option_14;
2541
2542
/**
2543
A monomorphic instance of Eurydice.array_to_slice_mut
2544
with types uint8_t
2545
with const generics
2546
- N= 2420
2547
*/
2548
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_0d(Eurydice_arr_85 *a)
2549
0
{
2550
0
  Eurydice_mut_borrow_slice_u8 lit;
2551
0
  lit.ptr = a->data;
2552
0
  lit.meta = (size_t)2420U;
2553
0
  return lit;
2554
0
}
2555
2556
/**
2557
A monomorphic instance of Eurydice.array_to_slice_shared
2558
with types Eurydice_arr int32_t[[$256size_t]]
2559
with const generics
2560
- N= 4
2561
*/
2562
static inline Eurydice_dst_ref_shared_20
2563
Eurydice_array_to_slice_shared_86(const Eurydice_arr_b7 *a)
2564
0
{
2565
0
  Eurydice_dst_ref_shared_20 lit;
2566
0
  lit.ptr = a->data;
2567
0
  lit.meta = (size_t)4U;
2568
0
  return lit;
2569
0
}
2570
2571
/**
2572
A monomorphic instance of Eurydice.array_to_slice_mut
2573
with types Eurydice_arr int32_t[[$256size_t]]
2574
with const generics
2575
- N= 4
2576
*/
2577
static inline Eurydice_dst_ref_mut_20 Eurydice_array_to_slice_mut_86(Eurydice_arr_b7 *a)
2578
0
{
2579
0
  Eurydice_dst_ref_mut_20 lit;
2580
0
  lit.ptr = a->data;
2581
0
  lit.meta = (size_t)4U;
2582
0
  return lit;
2583
0
}
2584
2585
/**
2586
A monomorphic instance of Eurydice.array_to_subslice_mut
2587
with types int32_t, core_ops_range_Range size_t, Eurydice_derefed_slice int32_t
2588
with const generics
2589
- N= 256
2590
*/
2591
static inline Eurydice_dst_ref_mut_83
2592
Eurydice_array_to_subslice_mut_44(Eurydice_arr_6c *a, core_ops_range_Range_87 r)
2593
0
{
2594
0
  return
2595
0
    (KRML_CLITERAL(Eurydice_dst_ref_mut_83){ .ptr = a->data + r.start, .meta = r.end - r.start });
2596
0
}
2597
2598
/**
2599
A monomorphic instance of Eurydice.dst_ref_shared
2600
with types int32_t, size_t
2601
2602
*/
2603
typedef struct Eurydice_dst_ref_shared_83_s
2604
{
2605
  const int32_t *ptr;
2606
  size_t meta;
2607
}
2608
Eurydice_dst_ref_shared_83;
2609
2610
/**
2611
A monomorphic instance of Eurydice.array_to_slice_shared
2612
with types int32_t
2613
with const generics
2614
- N= 256
2615
*/
2616
static inline Eurydice_dst_ref_shared_83
2617
Eurydice_array_to_slice_shared_af(const Eurydice_arr_6c *a)
2618
0
{
2619
0
  Eurydice_dst_ref_shared_83 lit;
2620
0
  lit.ptr = a->data;
2621
0
  lit.meta = (size_t)256U;
2622
0
  return lit;
2623
0
}
2624
2625
/**
2626
A monomorphic instance of Eurydice.arr
2627
with types uint8_t
2628
with const generics
2629
- $136size_t
2630
*/
2631
typedef struct Eurydice_arr_ff_s { uint8_t data[136U]; } Eurydice_arr_ff;
2632
2633
/**
2634
A monomorphic instance of Eurydice.array_to_subslice_from_shared
2635
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
2636
with const generics
2637
- N= 136
2638
*/
2639
static inline Eurydice_borrow_slice_u8
2640
Eurydice_array_to_subslice_from_shared_5f(const Eurydice_arr_ff *a, size_t r)
2641
0
{
2642
0
  return
2643
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)136U - r });
2644
0
}
2645
2646
/**
2647
A monomorphic instance of Eurydice.array_to_subslice_shared
2648
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
2649
with const generics
2650
- N= 136
2651
*/
2652
static inline Eurydice_borrow_slice_u8
2653
Eurydice_array_to_subslice_shared_d40(const Eurydice_arr_ff *a, core_ops_range_Range_87 r)
2654
0
{
2655
0
  return
2656
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
2657
0
}
2658
2659
/**
2660
 Declassify secret memory.
2661
2662
 No-op if `valgrind_ct_test` cfg is not enabled.
2663
*/
2664
/**
2665
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
2666
with types Eurydice_arr uint8_t[[$32size_t]]
2667
2668
*/
2669
static KRML_MUSTINLINE void
2670
libcrux_secrets_mem_requests_ct_declassify_4b(const Eurydice_arr_ec *val)
2671
0
{
2672
0
2673
0
}
2674
2675
/**
2676
A monomorphic instance of Eurydice.arr
2677
with types uint8_t
2678
with const generics
2679
- $768size_t
2680
*/
2681
typedef struct Eurydice_arr_d2_s { uint8_t data[768U]; } Eurydice_arr_d2;
2682
2683
/**
2684
A monomorphic instance of Eurydice.array_to_slice_shared
2685
with types uint8_t
2686
with const generics
2687
- N= 768
2688
*/
2689
static inline Eurydice_borrow_slice_u8
2690
Eurydice_array_to_slice_shared_27(const Eurydice_arr_d2 *a)
2691
0
{
2692
0
  Eurydice_borrow_slice_u8 lit;
2693
0
  lit.ptr = a->data;
2694
0
  lit.meta = (size_t)768U;
2695
0
  return lit;
2696
0
}
2697
2698
/**
2699
A monomorphic instance of Eurydice.array_to_slice_mut
2700
with types uint8_t
2701
with const generics
2702
- N= 768
2703
*/
2704
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_27(Eurydice_arr_d2 *a)
2705
0
{
2706
0
  Eurydice_mut_borrow_slice_u8 lit;
2707
0
  lit.ptr = a->data;
2708
0
  lit.meta = (size_t)768U;
2709
0
  return lit;
2710
0
}
2711
2712
/**
2713
A monomorphic instance of Eurydice.arr
2714
with types uint8_t
2715
with const generics
2716
- $640size_t
2717
*/
2718
typedef struct Eurydice_arr_20_s { uint8_t data[640U]; } Eurydice_arr_20;
2719
2720
/**
2721
A monomorphic instance of Eurydice.array_to_slice_shared
2722
with types uint8_t
2723
with const generics
2724
- N= 640
2725
*/
2726
static inline Eurydice_borrow_slice_u8
2727
Eurydice_array_to_slice_shared_4f(const Eurydice_arr_20 *a)
2728
0
{
2729
0
  Eurydice_borrow_slice_u8 lit;
2730
0
  lit.ptr = a->data;
2731
0
  lit.meta = (size_t)640U;
2732
0
  return lit;
2733
0
}
2734
2735
/**
2736
A monomorphic instance of Eurydice.array_to_slice_mut
2737
with types uint8_t
2738
with const generics
2739
- N= 640
2740
*/
2741
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_4f(Eurydice_arr_20 *a)
2742
0
{
2743
0
  Eurydice_mut_borrow_slice_u8 lit;
2744
0
  lit.ptr = a->data;
2745
0
  lit.meta = (size_t)640U;
2746
0
  return lit;
2747
0
}
2748
2749
/**
2750
A monomorphic instance of Eurydice.arr
2751
with types uint8_t
2752
with const generics
2753
- $576size_t
2754
*/
2755
typedef struct Eurydice_arr_220_s { uint8_t data[576U]; } Eurydice_arr_220;
2756
2757
/**
2758
A monomorphic instance of Eurydice.array_to_slice_shared
2759
with types uint8_t
2760
with const generics
2761
- N= 576
2762
*/
2763
static inline Eurydice_borrow_slice_u8
2764
Eurydice_array_to_slice_shared_8a(const Eurydice_arr_220 *a)
2765
0
{
2766
0
  Eurydice_borrow_slice_u8 lit;
2767
0
  lit.ptr = a->data;
2768
0
  lit.meta = (size_t)576U;
2769
0
  return lit;
2770
0
}
2771
2772
/**
2773
A monomorphic instance of Eurydice.array_to_slice_mut
2774
with types uint8_t
2775
with const generics
2776
- N= 576
2777
*/
2778
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_8a(Eurydice_arr_220 *a)
2779
0
{
2780
0
  Eurydice_mut_borrow_slice_u8 lit;
2781
0
  lit.ptr = a->data;
2782
0
  lit.meta = (size_t)576U;
2783
0
  return lit;
2784
0
}
2785
2786
/**
2787
A monomorphic instance of Eurydice.arr
2788
with types uint8_t
2789
with const generics
2790
- $11size_t
2791
*/
2792
typedef struct Eurydice_arr_c9_s { uint8_t data[11U]; } Eurydice_arr_c9;
2793
2794
/**
2795
A monomorphic instance of Eurydice.array_to_slice_shared
2796
with types uint8_t
2797
with const generics
2798
- N= 11
2799
*/
2800
static inline Eurydice_borrow_slice_u8
2801
Eurydice_array_to_slice_shared_2f(const Eurydice_arr_c9 *a)
2802
0
{
2803
0
  Eurydice_borrow_slice_u8 lit;
2804
0
  lit.ptr = a->data;
2805
0
  lit.meta = (size_t)11U;
2806
0
  return lit;
2807
0
}
2808
2809
/**
2810
A monomorphic instance of Eurydice.arr
2811
with types uint8_t
2812
with const generics
2813
- $1size_t
2814
*/
2815
typedef struct Eurydice_arr_82_s { uint8_t data[1U]; } Eurydice_arr_82;
2816
2817
/**
2818
A monomorphic instance of Eurydice.array_to_slice_shared
2819
with types uint8_t
2820
with const generics
2821
- N= 1
2822
*/
2823
static inline Eurydice_borrow_slice_u8
2824
Eurydice_array_to_slice_shared_79(const Eurydice_arr_82 *a)
2825
0
{
2826
0
  Eurydice_borrow_slice_u8 lit;
2827
0
  lit.ptr = a->data;
2828
0
  lit.meta = (size_t)1U;
2829
0
  return lit;
2830
0
}
2831
2832
/**
2833
 Mark memory as secret.
2834
2835
 No-op if `valgrind_ct_test` cfg is not enabled.
2836
*/
2837
/**
2838
A monomorphic instance of libcrux_secrets.mem_requests.ct_classify
2839
with types Eurydice_derefed_slice uint8_t
2840
2841
*/
2842
static KRML_MUSTINLINE void libcrux_secrets_mem_requests_ct_classify_45(const uint8_t (*val)[])
2843
0
{
2844
0
2845
0
}
2846
2847
/**
2848
A monomorphic instance of Eurydice.array_to_slice_mut
2849
with types uint8_t
2850
with const generics
2851
- N= 1312
2852
*/
2853
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_9f0(Eurydice_arr_02 *a)
2854
0
{
2855
0
  Eurydice_mut_borrow_slice_u8 lit;
2856
0
  lit.ptr = a->data;
2857
0
  lit.meta = (size_t)1312U;
2858
0
  return lit;
2859
0
}
2860
2861
/**
2862
A monomorphic instance of Eurydice.array_to_slice_mut
2863
with types uint8_t
2864
with const generics
2865
- N= 2560
2866
*/
2867
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_34(Eurydice_arr_10 *a)
2868
0
{
2869
0
  Eurydice_mut_borrow_slice_u8 lit;
2870
0
  lit.ptr = a->data;
2871
0
  lit.meta = (size_t)2560U;
2872
0
  return lit;
2873
0
}
2874
2875
/**
2876
A monomorphic instance of Eurydice.array_to_slice_shared
2877
with types uint8_t
2878
with const generics
2879
- N= 64
2880
*/
2881
static inline Eurydice_borrow_slice_u8
2882
Eurydice_array_to_slice_shared_17(const Eurydice_arr_c7 *a)
2883
0
{
2884
0
  Eurydice_borrow_slice_u8 lit;
2885
0
  lit.ptr = a->data;
2886
0
  lit.meta = (size_t)64U;
2887
0
  return lit;
2888
0
}
2889
2890
/**
2891
A monomorphic instance of Eurydice.arr
2892
with types int32_t
2893
with const generics
2894
- $263size_t
2895
*/
2896
typedef struct Eurydice_arr_d0_s { int32_t data[263U]; } Eurydice_arr_d0;
2897
2898
/**
2899
A monomorphic instance of Eurydice.dst_ref_mut
2900
with types Eurydice_arr_d0, size_t
2901
2902
*/
2903
typedef struct Eurydice_dst_ref_mut_33_s
2904
{
2905
  Eurydice_arr_d0 *ptr;
2906
  size_t meta;
2907
}
2908
Eurydice_dst_ref_mut_33;
2909
2910
/**
2911
A monomorphic instance of Eurydice.arr
2912
with types Eurydice_arr_d0
2913
with const generics
2914
- $4size_t
2915
*/
2916
typedef struct Eurydice_arr_930_s { Eurydice_arr_d0 data[4U]; } Eurydice_arr_930;
2917
2918
/**
2919
A monomorphic instance of Eurydice.array_to_slice_mut
2920
with types Eurydice_arr int32_t[[$263size_t]]
2921
with const generics
2922
- N= 4
2923
*/
2924
static inline Eurydice_dst_ref_mut_33 Eurydice_array_to_slice_mut_7e(Eurydice_arr_930 *a)
2925
0
{
2926
0
  Eurydice_dst_ref_mut_33 lit;
2927
0
  lit.ptr = a->data;
2928
0
  lit.meta = (size_t)4U;
2929
0
  return lit;
2930
0
}
2931
2932
/**
2933
A monomorphic instance of Eurydice.dst_ref_shared
2934
with types Eurydice_arr_d0, size_t
2935
2936
*/
2937
typedef struct Eurydice_dst_ref_shared_33_s
2938
{
2939
  const Eurydice_arr_d0 *ptr;
2940
  size_t meta;
2941
}
2942
Eurydice_dst_ref_shared_33;
2943
2944
/**
2945
A monomorphic instance of Eurydice.arr
2946
with types uint8_t
2947
with const generics
2948
- $840size_t
2949
*/
2950
typedef struct Eurydice_arr_d10_s { uint8_t data[840U]; } Eurydice_arr_d10;
2951
2952
/**
2953
A monomorphic instance of Eurydice.array_to_slice_shared
2954
with types uint8_t
2955
with const generics
2956
- N= 840
2957
*/
2958
static inline Eurydice_borrow_slice_u8
2959
Eurydice_array_to_slice_shared_4c(const Eurydice_arr_d10 *a)
2960
0
{
2961
0
  Eurydice_borrow_slice_u8 lit;
2962
0
  lit.ptr = a->data;
2963
0
  lit.meta = (size_t)840U;
2964
0
  return lit;
2965
0
}
2966
2967
/**
2968
A monomorphic instance of Eurydice.array_to_slice_shared
2969
with types uint8_t
2970
with const generics
2971
- N= 34
2972
*/
2973
static inline Eurydice_borrow_slice_u8
2974
Eurydice_array_to_slice_shared_e9(const Eurydice_arr_31 *a)
2975
0
{
2976
0
  Eurydice_borrow_slice_u8 lit;
2977
0
  lit.ptr = a->data;
2978
0
  lit.meta = (size_t)34U;
2979
0
  return lit;
2980
0
}
2981
2982
/**
2983
 Declassify secret memory.
2984
2985
 No-op if `valgrind_ct_test` cfg is not enabled.
2986
*/
2987
/**
2988
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
2989
with types Eurydice_derefed_slice uint8_t
2990
2991
*/
2992
static KRML_MUSTINLINE void
2993
libcrux_secrets_mem_requests_ct_declassify_45(const uint8_t (*val)[])
2994
0
{
2995
0
2996
0
}
2997
2998
/**
2999
A monomorphic instance of Eurydice.array_to_slice_shared
3000
with types int32_t
3001
with const generics
3002
- N= 263
3003
*/
3004
static inline Eurydice_dst_ref_shared_83
3005
Eurydice_array_to_slice_shared_2c0(const Eurydice_arr_d0 *a)
3006
0
{
3007
0
  Eurydice_dst_ref_shared_83 lit;
3008
0
  lit.ptr = a->data;
3009
0
  lit.meta = (size_t)263U;
3010
0
  return lit;
3011
0
}
3012
3013
/**
3014
A monomorphic instance of Eurydice.array_to_subslice_from_mut
3015
with types int32_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice int32_t
3016
with const generics
3017
- N= 263
3018
*/
3019
static inline Eurydice_dst_ref_mut_83
3020
Eurydice_array_to_subslice_from_mut_11(Eurydice_arr_d0 *a, size_t r)
3021
0
{
3022
0
  return
3023
0
    (KRML_CLITERAL(Eurydice_dst_ref_mut_83){ .ptr = a->data + r, .meta = (size_t)263U - r });
3024
0
}
3025
3026
/**
3027
A monomorphic instance of Eurydice.arr
3028
with types uint8_t
3029
with const generics
3030
- $66size_t
3031
*/
3032
typedef struct Eurydice_arr_91_s { uint8_t data[66U]; } Eurydice_arr_91;
3033
3034
/**
3035
A monomorphic instance of Eurydice.array_to_slice_shared
3036
with types uint8_t
3037
with const generics
3038
- N= 66
3039
*/
3040
static inline Eurydice_borrow_slice_u8
3041
Eurydice_array_to_slice_shared_f1(const Eurydice_arr_91 *a)
3042
0
{
3043
0
  Eurydice_borrow_slice_u8 lit;
3044
0
  lit.ptr = a->data;
3045
0
  lit.meta = (size_t)66U;
3046
0
  return lit;
3047
0
}
3048
3049
/**
3050
A monomorphic instance of Eurydice.array_to_slice_shared
3051
with types uint8_t
3052
with const generics
3053
- N= 128
3054
*/
3055
static inline Eurydice_borrow_slice_u8
3056
Eurydice_array_to_slice_shared_78(const Eurydice_arr_89 *a)
3057
0
{
3058
0
  Eurydice_borrow_slice_u8 lit;
3059
0
  lit.ptr = a->data;
3060
0
  lit.meta = (size_t)128U;
3061
0
  return lit;
3062
0
}
3063
3064
/**
3065
A monomorphic instance of Eurydice.array_to_slice_mut
3066
with types uint8_t
3067
with const generics
3068
- N= 128
3069
*/
3070
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_78(Eurydice_arr_89 *a)
3071
0
{
3072
0
  Eurydice_mut_borrow_slice_u8 lit;
3073
0
  lit.ptr = a->data;
3074
0
  lit.meta = (size_t)128U;
3075
0
  return lit;
3076
0
}
3077
3078
/**
3079
A monomorphic instance of Eurydice.array_to_slice_shared
3080
with types uint8_t
3081
with const generics
3082
- N= 2
3083
*/
3084
static inline Eurydice_borrow_slice_u8
3085
Eurydice_array_to_slice_shared_82(const Eurydice_array_u8x2 *a)
3086
0
{
3087
0
  Eurydice_borrow_slice_u8 lit;
3088
0
  lit.ptr = a->data;
3089
0
  lit.meta = (size_t)2U;
3090
0
  return lit;
3091
0
}
3092
3093
/**
3094
A monomorphic instance of Eurydice.array_to_slice_shared
3095
with types uint8_t
3096
with const generics
3097
- N= 32
3098
*/
3099
static inline Eurydice_borrow_slice_u8
3100
Eurydice_array_to_slice_shared_01(const Eurydice_arr_ec *a)
3101
0
{
3102
0
  Eurydice_borrow_slice_u8 lit;
3103
0
  lit.ptr = a->data;
3104
0
  lit.meta = (size_t)32U;
3105
0
  return lit;
3106
0
}
3107
3108
/**
3109
 Mark memory as secret.
3110
3111
 No-op if `valgrind_ct_test` cfg is not enabled.
3112
*/
3113
/**
3114
A monomorphic instance of libcrux_secrets.mem_requests.ct_classify
3115
with types Eurydice_arr uint8_t[[$32size_t]]
3116
3117
*/
3118
static KRML_MUSTINLINE void
3119
libcrux_secrets_mem_requests_ct_classify_4b(const Eurydice_arr_ec *val)
3120
0
{
3121
0
3122
0
}
3123
3124
typedef struct Eurydice_arr_c5_x4_s
3125
{
3126
  Eurydice_arr_c5 fst;
3127
  Eurydice_arr_c5 snd;
3128
  Eurydice_arr_c5 thd;
3129
  Eurydice_arr_c5 f3;
3130
}
3131
Eurydice_arr_c5_x4;
3132
3133
/**
3134
A monomorphic instance of Eurydice.array_to_slice_mut
3135
with types uint8_t
3136
with const generics
3137
- N= 168
3138
*/
3139
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_2c(Eurydice_arr_c5 *a)
3140
0
{
3141
0
  Eurydice_mut_borrow_slice_u8 lit;
3142
0
  lit.ptr = a->data;
3143
0
  lit.meta = (size_t)168U;
3144
0
  return lit;
3145
0
}
3146
3147
/**
3148
A monomorphic instance of Eurydice.array_to_slice_mut
3149
with types uint8_t
3150
with const generics
3151
- N= 840
3152
*/
3153
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_4c(Eurydice_arr_d10 *a)
3154
0
{
3155
0
  Eurydice_mut_borrow_slice_u8 lit;
3156
0
  lit.ptr = a->data;
3157
0
  lit.meta = (size_t)840U;
3158
0
  return lit;
3159
0
}
3160
3161
typedef struct Eurydice_arr_ff_x4_s
3162
{
3163
  Eurydice_arr_ff fst;
3164
  Eurydice_arr_ff snd;
3165
  Eurydice_arr_ff thd;
3166
  Eurydice_arr_ff f3;
3167
}
3168
Eurydice_arr_ff_x4;
3169
3170
/**
3171
A monomorphic instance of Eurydice.array_to_slice_mut
3172
with types uint8_t
3173
with const generics
3174
- N= 136
3175
*/
3176
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_58(Eurydice_arr_ff *a)
3177
0
{
3178
0
  Eurydice_mut_borrow_slice_u8 lit;
3179
0
  lit.ptr = a->data;
3180
0
  lit.meta = (size_t)136U;
3181
0
  return lit;
3182
0
}
3183
3184
/**
3185
A monomorphic instance of Eurydice.array_to_subslice_shared
3186
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3187
with const generics
3188
- N= 32
3189
*/
3190
static inline Eurydice_borrow_slice_u8
3191
Eurydice_array_to_subslice_shared_d4(const Eurydice_arr_ec *a, core_ops_range_Range_87 r)
3192
0
{
3193
0
  return
3194
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = a->data + r.start, .meta = r.end - r.start });
3195
0
}
3196
3197
/**
3198
A monomorphic instance of Eurydice.arr
3199
with types Eurydice_arr_ff
3200
with const generics
3201
- $4size_t
3202
*/
3203
typedef struct Eurydice_arr_dc0_s { Eurydice_arr_ff data[4U]; } Eurydice_arr_dc0;
3204
3205
/**
3206
A monomorphic instance of Eurydice.arr
3207
with types Eurydice_arr_c5
3208
with const generics
3209
- $4size_t
3210
*/
3211
typedef struct Eurydice_arr_9c_s { Eurydice_arr_c5 data[4U]; } Eurydice_arr_9c;
3212
3213
/**
3214
A monomorphic instance of Eurydice.arr
3215
with types Eurydice_borrow_slice_u8
3216
with const generics
3217
- $4size_t
3218
*/
3219
typedef struct Eurydice_arr_68_s { Eurydice_borrow_slice_u8 data[4U]; } Eurydice_arr_68;
3220
3221
/**
3222
A monomorphic instance of Eurydice.array_to_subslice_mut
3223
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3224
with const generics
3225
- N= 32
3226
*/
3227
static inline Eurydice_mut_borrow_slice_u8
3228
Eurydice_array_to_subslice_mut_d46(Eurydice_arr_ec *a, core_ops_range_Range_87 r)
3229
0
{
3230
0
  return
3231
0
    (
3232
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3233
0
        .ptr = a->data + r.start,
3234
0
        .meta = r.end - r.start
3235
0
      }
3236
0
    );
3237
0
}
3238
3239
/**
3240
A monomorphic instance of Eurydice.array_to_subslice_from_mut
3241
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
3242
with const generics
3243
- N= 168
3244
*/
3245
static inline Eurydice_mut_borrow_slice_u8
3246
Eurydice_array_to_subslice_from_mut_5f0(Eurydice_arr_c5 *a, size_t r)
3247
0
{
3248
0
  return
3249
0
    (KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)168U - r });
3250
0
}
3251
3252
/**
3253
A monomorphic instance of Eurydice.arr
3254
with types Eurydice_arr_c5
3255
with const generics
3256
- $1size_t
3257
*/
3258
typedef struct Eurydice_arr_88_s { Eurydice_arr_c5 data[1U]; } Eurydice_arr_88;
3259
3260
/**
3261
A monomorphic instance of Eurydice.array_to_slice_mut
3262
with types uint8_t
3263
with const generics
3264
- N= 64
3265
*/
3266
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_17(Eurydice_arr_c7 *a)
3267
0
{
3268
0
  Eurydice_mut_borrow_slice_u8 lit;
3269
0
  lit.ptr = a->data;
3270
0
  lit.meta = (size_t)64U;
3271
0
  return lit;
3272
0
}
3273
3274
/**
3275
A monomorphic instance of Eurydice.array_to_slice_mut
3276
with types uint8_t
3277
with const generics
3278
- N= 48
3279
*/
3280
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_9f(Eurydice_arr_65 *a)
3281
0
{
3282
0
  Eurydice_mut_borrow_slice_u8 lit;
3283
0
  lit.ptr = a->data;
3284
0
  lit.meta = (size_t)48U;
3285
0
  return lit;
3286
0
}
3287
3288
/**
3289
A monomorphic instance of Eurydice.array_to_slice_mut
3290
with types uint8_t
3291
with const generics
3292
- N= 32
3293
*/
3294
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_01(Eurydice_arr_ec *a)
3295
0
{
3296
0
  Eurydice_mut_borrow_slice_u8 lit;
3297
0
  lit.ptr = a->data;
3298
0
  lit.meta = (size_t)32U;
3299
0
  return lit;
3300
0
}
3301
3302
/**
3303
A monomorphic instance of Eurydice.arr
3304
with types uint8_t
3305
with const generics
3306
- $28size_t
3307
*/
3308
typedef struct Eurydice_arr_a2_s { uint8_t data[28U]; } Eurydice_arr_a2;
3309
3310
/**
3311
A monomorphic instance of Eurydice.array_to_slice_mut
3312
with types uint8_t
3313
with const generics
3314
- N= 28
3315
*/
3316
static inline Eurydice_mut_borrow_slice_u8 Eurydice_array_to_slice_mut_5e(Eurydice_arr_a2 *a)
3317
0
{
3318
0
  Eurydice_mut_borrow_slice_u8 lit;
3319
0
  lit.ptr = a->data;
3320
0
  lit.meta = (size_t)28U;
3321
0
  return lit;
3322
0
}
3323
3324
/**
3325
A monomorphic instance of Eurydice.arr
3326
with types uint8_t
3327
with const generics
3328
- $104size_t
3329
*/
3330
typedef struct Eurydice_arr_c4_s { uint8_t data[104U]; } Eurydice_arr_c4;
3331
3332
/**
3333
A monomorphic instance of Eurydice.array_to_slice_shared
3334
with types uint8_t
3335
with const generics
3336
- N= 104
3337
*/
3338
static inline Eurydice_borrow_slice_u8
3339
Eurydice_array_to_slice_shared_72(const Eurydice_arr_c4 *a)
3340
0
{
3341
0
  Eurydice_borrow_slice_u8 lit;
3342
0
  lit.ptr = a->data;
3343
0
  lit.meta = (size_t)104U;
3344
0
  return lit;
3345
0
}
3346
3347
/**
3348
A monomorphic instance of Eurydice.array_to_subslice_mut
3349
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3350
with const generics
3351
- N= 104
3352
*/
3353
static inline Eurydice_mut_borrow_slice_u8
3354
Eurydice_array_to_subslice_mut_d45(Eurydice_arr_c4 *a, core_ops_range_Range_87 r)
3355
0
{
3356
0
  return
3357
0
    (
3358
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3359
0
        .ptr = a->data + r.start,
3360
0
        .meta = r.end - r.start
3361
0
      }
3362
0
    );
3363
0
}
3364
3365
/**
3366
A monomorphic instance of Eurydice.arr
3367
with types uint8_t
3368
with const generics
3369
- $144size_t
3370
*/
3371
typedef struct Eurydice_arr_f4_s { uint8_t data[144U]; } Eurydice_arr_f4;
3372
3373
/**
3374
A monomorphic instance of Eurydice.array_to_slice_shared
3375
with types uint8_t
3376
with const generics
3377
- N= 144
3378
*/
3379
static inline Eurydice_borrow_slice_u8
3380
Eurydice_array_to_slice_shared_38(const Eurydice_arr_f4 *a)
3381
0
{
3382
0
  Eurydice_borrow_slice_u8 lit;
3383
0
  lit.ptr = a->data;
3384
0
  lit.meta = (size_t)144U;
3385
0
  return lit;
3386
0
}
3387
3388
/**
3389
A monomorphic instance of Eurydice.array_to_subslice_mut
3390
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3391
with const generics
3392
- N= 144
3393
*/
3394
static inline Eurydice_mut_borrow_slice_u8
3395
Eurydice_array_to_subslice_mut_d44(Eurydice_arr_f4 *a, core_ops_range_Range_87 r)
3396
0
{
3397
0
  return
3398
0
    (
3399
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3400
0
        .ptr = a->data + r.start,
3401
0
        .meta = r.end - r.start
3402
0
      }
3403
0
    );
3404
0
}
3405
3406
/**
3407
A monomorphic instance of Eurydice.arr
3408
with types uint8_t
3409
with const generics
3410
- $72size_t
3411
*/
3412
typedef struct Eurydice_arr_ab_s { uint8_t data[72U]; } Eurydice_arr_ab;
3413
3414
/**
3415
A monomorphic instance of Eurydice.array_to_slice_shared
3416
with types uint8_t
3417
with const generics
3418
- N= 72
3419
*/
3420
static inline Eurydice_borrow_slice_u8
3421
Eurydice_array_to_slice_shared_e2(const Eurydice_arr_ab *a)
3422
0
{
3423
0
  Eurydice_borrow_slice_u8 lit;
3424
0
  lit.ptr = a->data;
3425
0
  lit.meta = (size_t)72U;
3426
0
  return lit;
3427
0
}
3428
3429
/**
3430
A monomorphic instance of Eurydice.array_to_subslice_mut
3431
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3432
with const generics
3433
- N= 72
3434
*/
3435
static inline Eurydice_mut_borrow_slice_u8
3436
Eurydice_array_to_subslice_mut_d43(Eurydice_arr_ab *a, core_ops_range_Range_87 r)
3437
0
{
3438
0
  return
3439
0
    (
3440
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3441
0
        .ptr = a->data + r.start,
3442
0
        .meta = r.end - r.start
3443
0
      }
3444
0
    );
3445
0
}
3446
3447
/**
3448
A monomorphic instance of Eurydice.slice_subslice_to_shared
3449
with types uint8_t, core_ops_range_RangeTo size_t, Eurydice_derefed_slice uint8_t
3450
3451
*/
3452
static inline Eurydice_borrow_slice_u8
3453
Eurydice_slice_subslice_to_shared_72(Eurydice_borrow_slice_u8 s, size_t r)
3454
0
{
3455
0
  return (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = s.ptr, .meta = r });
3456
0
}
3457
3458
/**
3459
A monomorphic instance of Eurydice.array_to_subslice_from_mut
3460
with types uint8_t, core_ops_range_RangeFrom size_t, Eurydice_derefed_slice uint8_t
3461
with const generics
3462
- N= 136
3463
*/
3464
static inline Eurydice_mut_borrow_slice_u8
3465
Eurydice_array_to_subslice_from_mut_5f(Eurydice_arr_ff *a, size_t r)
3466
0
{
3467
0
  return
3468
0
    (KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = a->data + r, .meta = (size_t)136U - r });
3469
0
}
3470
3471
/**
3472
A monomorphic instance of Eurydice.array_to_subslice_to_shared
3473
with types uint8_t, core_ops_range_RangeTo size_t, Eurydice_derefed_slice uint8_t
3474
with const generics
3475
- N= 8
3476
*/
3477
static inline Eurydice_borrow_slice_u8
3478
Eurydice_array_to_subslice_to_shared_21(const Eurydice_array_u8x8 *a, size_t r)
3479
0
{
3480
0
  Eurydice_borrow_slice_u8 lit;
3481
0
  lit.ptr = a->data;
3482
0
  lit.meta = r;
3483
0
  return lit;
3484
0
}
3485
3486
/**
3487
A monomorphic instance of Eurydice.array_to_slice_shared
3488
with types uint8_t
3489
with const generics
3490
- N= 8
3491
*/
3492
static inline Eurydice_borrow_slice_u8
3493
Eurydice_array_to_slice_shared_6e(const Eurydice_array_u8x8 *a)
3494
0
{
3495
0
  Eurydice_borrow_slice_u8 lit;
3496
0
  lit.ptr = a->data;
3497
0
  lit.meta = (size_t)8U;
3498
0
  return lit;
3499
0
}
3500
3501
/**
3502
A monomorphic instance of Eurydice.slice_subslice_mut
3503
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3504
3505
*/
3506
static inline Eurydice_mut_borrow_slice_u8
3507
Eurydice_slice_subslice_mut_c8(Eurydice_mut_borrow_slice_u8 s, core_ops_range_Range_87 r)
3508
0
{
3509
0
  return
3510
0
    (
3511
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){ .ptr = s.ptr + r.start, .meta = r.end - r.start }
3512
0
    );
3513
0
}
3514
3515
/**
3516
A monomorphic instance of Eurydice.array_to_slice_shared
3517
with types uint8_t
3518
with const generics
3519
- N= 136
3520
*/
3521
static inline Eurydice_borrow_slice_u8
3522
Eurydice_array_to_slice_shared_58(const Eurydice_arr_ff *a)
3523
0
{
3524
0
  Eurydice_borrow_slice_u8 lit;
3525
0
  lit.ptr = a->data;
3526
0
  lit.meta = (size_t)136U;
3527
0
  return lit;
3528
0
}
3529
3530
/**
3531
A monomorphic instance of Eurydice.array_to_subslice_mut
3532
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3533
with const generics
3534
- N= 136
3535
*/
3536
static inline Eurydice_mut_borrow_slice_u8
3537
Eurydice_array_to_subslice_mut_d42(Eurydice_arr_ff *a, core_ops_range_Range_87 r)
3538
0
{
3539
0
  return
3540
0
    (
3541
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3542
0
        .ptr = a->data + r.start,
3543
0
        .meta = r.end - r.start
3544
0
      }
3545
0
    );
3546
0
}
3547
3548
/**
3549
A monomorphic instance of Eurydice.arr
3550
with types uint64_t
3551
with const generics
3552
- $5size_t
3553
*/
3554
typedef struct Eurydice_arr_84_s { uint64_t data[5U]; } Eurydice_arr_84;
3555
3556
typedef struct size_t_x2_s
3557
{
3558
  size_t fst;
3559
  size_t snd;
3560
}
3561
size_t_x2;
3562
3563
/**
3564
A monomorphic instance of Eurydice.arr
3565
with types Eurydice_borrow_slice_u8
3566
with const generics
3567
- $1size_t
3568
*/
3569
typedef struct Eurydice_arr_dc_s { Eurydice_borrow_slice_u8 data[1U]; } Eurydice_arr_dc;
3570
3571
/**
3572
A monomorphic instance of Eurydice.array_to_slice_shared
3573
with types uint8_t
3574
with const generics
3575
- N= 168
3576
*/
3577
static inline Eurydice_borrow_slice_u8
3578
Eurydice_array_to_slice_shared_2c(const Eurydice_arr_c5 *a)
3579
0
{
3580
0
  Eurydice_borrow_slice_u8 lit;
3581
0
  lit.ptr = a->data;
3582
0
  lit.meta = (size_t)168U;
3583
0
  return lit;
3584
0
}
3585
3586
/**
3587
A monomorphic instance of core.result.Result
3588
with types Eurydice_array_u8x8, core_array_TryFromSliceError
3589
3590
*/
3591
typedef struct core_result_Result_8e_s
3592
{
3593
  core_result_Result_57_tags tag;
3594
  union {
3595
    Eurydice_array_u8x8 case_Ok;
3596
    core_array_TryFromSliceError case_Err;
3597
  }
3598
  val;
3599
}
3600
core_result_Result_8e;
3601
3602
/**
3603
This function found in impl {core::result::Result<T, E>[TraitClause@0, TraitClause@1]}
3604
*/
3605
/**
3606
A monomorphic instance of core.result.unwrap_26
3607
with types Eurydice_arr uint8_t[[$8size_t]], core_array_TryFromSliceError
3608
3609
*/
3610
static inline Eurydice_array_u8x8 core_result_unwrap_26_e0(core_result_Result_8e self)
3611
0
{
3612
0
  if (self.tag == core_result_Ok)
3613
0
  {
3614
0
    return self.val.case_Ok;
3615
0
  }
3616
0
  else
3617
0
  {
3618
0
    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "unwrap not Ok");
3619
0
    KRML_HOST_EXIT(255U);
3620
0
  }
3621
0
}
3622
3623
/**
3624
A monomorphic instance of Eurydice.array_to_subslice_mut
3625
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3626
with const generics
3627
- N= 168
3628
*/
3629
static inline Eurydice_mut_borrow_slice_u8
3630
Eurydice_array_to_subslice_mut_d41(Eurydice_arr_c5 *a, core_ops_range_Range_87 r)
3631
0
{
3632
0
  return
3633
0
    (
3634
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3635
0
        .ptr = a->data + r.start,
3636
0
        .meta = r.end - r.start
3637
0
      }
3638
0
    );
3639
0
}
3640
3641
/**
3642
A monomorphic instance of Eurydice.arr
3643
with types uint64_t
3644
with const generics
3645
- $24size_t
3646
*/
3647
typedef struct Eurydice_arr_22_s { uint64_t data[24U]; } Eurydice_arr_22;
3648
3649
/**
3650
A monomorphic instance of Eurydice.arr
3651
with types Eurydice_arr_ff
3652
with const generics
3653
- $1size_t
3654
*/
3655
typedef struct Eurydice_arr_0b_s { Eurydice_arr_ff data[1U]; } Eurydice_arr_0b;
3656
3657
/**
3658
A monomorphic instance of Eurydice.arr
3659
with types uint64_t
3660
with const generics
3661
- $25size_t
3662
*/
3663
typedef struct Eurydice_arr_7c_s { uint64_t data[25U]; } Eurydice_arr_7c;
3664
3665
/**
3666
A monomorphic instance of Eurydice.slice_subslice_shared
3667
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3668
3669
*/
3670
static inline Eurydice_borrow_slice_u8
3671
Eurydice_slice_subslice_shared_c8(Eurydice_borrow_slice_u8 s, core_ops_range_Range_87 r)
3672
0
{
3673
0
  return
3674
0
    (KRML_CLITERAL(Eurydice_borrow_slice_u8){ .ptr = s.ptr + r.start, .meta = r.end - r.start });
3675
0
}
3676
3677
/**
3678
A monomorphic instance of Eurydice.arr
3679
with types int32_t
3680
with const generics
3681
- $8size_t
3682
*/
3683
typedef struct Eurydice_arr_4d_s { int32_t data[8U]; } Eurydice_arr_4d;
3684
3685
/**
3686
A monomorphic instance of Eurydice.array_to_subslice_shared
3687
with types int32_t, core_ops_range_Range size_t, Eurydice_derefed_slice int32_t
3688
with const generics
3689
- N= 8
3690
*/
3691
static inline Eurydice_dst_ref_shared_83
3692
Eurydice_array_to_subslice_shared_44(const Eurydice_arr_4d *a, core_ops_range_Range_87 r)
3693
0
{
3694
0
  return
3695
0
    (
3696
0
      KRML_CLITERAL(Eurydice_dst_ref_shared_83){ .ptr = a->data + r.start, .meta = r.end - r.start }
3697
0
    );
3698
0
}
3699
3700
/**
3701
 Declassify secret memory.
3702
3703
 No-op if `valgrind_ct_test` cfg is not enabled.
3704
*/
3705
/**
3706
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
3707
with types bool
3708
3709
*/
3710
static KRML_MUSTINLINE void libcrux_secrets_mem_requests_ct_declassify_5f(const bool *val)
3711
0
{
3712
0
3713
0
}
3714
3715
typedef struct int32_t_x2_s
3716
{
3717
  int32_t fst;
3718
  int32_t snd;
3719
}
3720
int32_t_x2;
3721
3722
/**
3723
A monomorphic instance of Eurydice.array_to_slice_shared
3724
with types int32_t
3725
with const generics
3726
- N= 8
3727
*/
3728
static inline Eurydice_dst_ref_shared_83
3729
Eurydice_array_to_slice_shared_fd(const Eurydice_arr_4d *a)
3730
0
{
3731
0
  Eurydice_dst_ref_shared_83 lit;
3732
0
  lit.ptr = a->data;
3733
0
  lit.meta = (size_t)8U;
3734
0
  return lit;
3735
0
}
3736
3737
/**
3738
A monomorphic instance of Eurydice.slice_subslice_shared
3739
with types int32_t, core_ops_range_Range size_t, Eurydice_derefed_slice int32_t
3740
3741
*/
3742
static inline Eurydice_dst_ref_shared_83
3743
Eurydice_slice_subslice_shared_47(Eurydice_dst_ref_shared_83 s, core_ops_range_Range_87 r)
3744
0
{
3745
0
  return
3746
0
    (KRML_CLITERAL(Eurydice_dst_ref_shared_83){ .ptr = s.ptr + r.start, .meta = r.end - r.start });
3747
0
}
3748
3749
/**
3750
A monomorphic instance of Eurydice.array_to_slice_mut
3751
with types int32_t
3752
with const generics
3753
- N= 8
3754
*/
3755
static inline Eurydice_dst_ref_mut_83 Eurydice_array_to_slice_mut_fd(Eurydice_arr_4d *a)
3756
0
{
3757
0
  Eurydice_dst_ref_mut_83 lit;
3758
0
  lit.ptr = a->data;
3759
0
  lit.meta = (size_t)8U;
3760
0
  return lit;
3761
0
}
3762
3763
/**
3764
A monomorphic instance of core.option.Option
3765
with types Eurydice_arr_c9
3766
3767
*/
3768
typedef struct core_option_Option_57_s
3769
{
3770
  core_option_Option_45_tags tag;
3771
  Eurydice_arr_c9 f0;
3772
}
3773
core_option_Option_57;
3774
3775
/**
3776
A monomorphic instance of Eurydice.array_to_subslice_mut
3777
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3778
with const generics
3779
- N= 34
3780
*/
3781
static inline Eurydice_mut_borrow_slice_u8
3782
Eurydice_array_to_subslice_mut_d40(Eurydice_arr_31 *a, core_ops_range_Range_87 r)
3783
0
{
3784
0
  return
3785
0
    (
3786
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3787
0
        .ptr = a->data + r.start,
3788
0
        .meta = r.end - r.start
3789
0
      }
3790
0
    );
3791
0
}
3792
3793
typedef struct uint8_t_x2_s
3794
{
3795
  uint8_t fst;
3796
  uint8_t snd;
3797
}
3798
uint8_t_x2;
3799
3800
/**
3801
A monomorphic instance of Eurydice.array_to_subslice_mut
3802
with types uint8_t, core_ops_range_Range size_t, Eurydice_derefed_slice uint8_t
3803
with const generics
3804
- N= 66
3805
*/
3806
static inline Eurydice_mut_borrow_slice_u8
3807
Eurydice_array_to_subslice_mut_d4(Eurydice_arr_91 *a, core_ops_range_Range_87 r)
3808
0
{
3809
0
  return
3810
0
    (
3811
0
      KRML_CLITERAL(Eurydice_mut_borrow_slice_u8){
3812
0
        .ptr = a->data + r.start,
3813
0
        .meta = r.end - r.start
3814
0
      }
3815
0
    );
3816
0
}
3817
3818
typedef struct libcrux_ml_kem_utils_extraction_helper_Keypair768_s
3819
{
3820
  Eurydice_arr_0e fst;
3821
  Eurydice_arr_5f snd;
3822
}
3823
libcrux_ml_kem_utils_extraction_helper_Keypair768;
3824
3825
/**
3826
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
3827
*/
3828
/**
3829
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
3830
with types uint64_t
3831
3832
*/
3833
static KRML_MUSTINLINE uint64_t
3834
libcrux_secrets_int_public_integers_declassify_d8_49(uint64_t self)
3835
0
{
3836
0
  return self;
3837
0
}
3838
3839
/**
3840
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
3841
*/
3842
/**
3843
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
3844
with types uint32_t
3845
3846
*/
3847
static KRML_MUSTINLINE uint32_t
3848
libcrux_secrets_int_public_integers_classify_27_df(uint32_t self)
3849
0
{
3850
0
  return self;
3851
0
}
3852
3853
/**
3854
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
3855
*/
3856
/**
3857
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
3858
with types uint64_t
3859
3860
*/
3861
static KRML_MUSTINLINE uint64_t
3862
libcrux_secrets_int_public_integers_classify_27_49(uint64_t self)
3863
0
{
3864
0
  return self;
3865
0
}
3866
3867
/**
3868
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
3869
*/
3870
/**
3871
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
3872
with types uint16_t
3873
3874
*/
3875
static KRML_MUSTINLINE uint16_t
3876
libcrux_secrets_int_public_integers_declassify_d8_de(uint16_t self)
3877
0
{
3878
0
  return self;
3879
0
}
3880
3881
/**
3882
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
3883
*/
3884
/**
3885
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
3886
with types uint16_t
3887
3888
*/
3889
static KRML_MUSTINLINE uint16_t
3890
libcrux_secrets_int_public_integers_classify_27_de(uint16_t self)
3891
0
{
3892
0
  return self;
3893
0
}
3894
3895
/**
3896
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
3897
*/
3898
/**
3899
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
3900
with types uint32_t
3901
3902
*/
3903
static KRML_MUSTINLINE uint32_t
3904
libcrux_secrets_int_public_integers_declassify_d8_df(uint32_t self)
3905
0
{
3906
0
  return self;
3907
0
}
3908
3909
/**
3910
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
3911
*/
3912
/**
3913
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
3914
with types int32_t
3915
3916
*/
3917
static KRML_MUSTINLINE int32_t
3918
libcrux_secrets_int_public_integers_declassify_d8_a8(int32_t self)
3919
0
{
3920
0
  return self;
3921
0
}
3922
3923
/**
3924
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
3925
*/
3926
/**
3927
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
3928
with types int32_t
3929
3930
*/
3931
static KRML_MUSTINLINE int32_t libcrux_secrets_int_public_integers_classify_27_a8(int32_t self)
3932
0
{
3933
0
  return self;
3934
0
}
3935
3936
/**
3937
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
3938
*/
3939
/**
3940
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
3941
with types uint8_t
3942
3943
*/
3944
static KRML_MUSTINLINE uint8_t
3945
libcrux_secrets_int_public_integers_declassify_d8_90(uint8_t self)
3946
0
{
3947
0
  return self;
3948
0
}
3949
3950
/**
3951
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
3952
*/
3953
/**
3954
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
3955
with types int16_t
3956
3957
*/
3958
static KRML_MUSTINLINE int16_t libcrux_secrets_int_public_integers_classify_27_39(int16_t self)
3959
0
{
3960
0
  return self;
3961
0
}
3962
3963
/**
3964
This function found in impl {libcrux_secrets::traits::Declassify<T> for T}
3965
*/
3966
/**
3967
A monomorphic instance of libcrux_secrets.int.public_integers.declassify_d8
3968
with types int16_t
3969
3970
*/
3971
static KRML_MUSTINLINE int16_t
3972
libcrux_secrets_int_public_integers_declassify_d8_39(int16_t self)
3973
0
{
3974
0
  return self;
3975
0
}
3976
3977
/**
3978
This function found in impl {libcrux_secrets::traits::Classify<T> for T}
3979
*/
3980
/**
3981
A monomorphic instance of libcrux_secrets.int.public_integers.classify_27
3982
with types uint8_t
3983
3984
*/
3985
static KRML_MUSTINLINE uint8_t libcrux_secrets_int_public_integers_classify_27_90(uint8_t self)
3986
0
{
3987
0
  return self;
3988
0
}
3989
3990
#if defined(__cplusplus)
3991
}
3992
#endif
3993
3994
#define combined_core_H_DEFINED
3995
#endif /* combined_core_H */
3996
3997
/* from libcrux/combined_extraction/generated/libcrux_sha3_portable.h */
3998
/*
3999
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
4000
 *
4001
 * SPDX-License-Identifier: MIT or Apache-2.0
4002
 *
4003
 * This code was generated with the following revisions:
4004
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
4005
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
4006
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
4007
 * F*: unset
4008
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
4009
 */
4010
4011
4012
#ifndef libcrux_sha3_portable_H
4013
#define libcrux_sha3_portable_H
4014
4015
4016
4017
#if defined(__cplusplus)
4018
extern "C" {
4019
#endif
4020
4021
4022
/**
4023
A monomorphic instance of libcrux_sha3.generic_keccak.KeccakState
4024
with types uint64_t
4025
with const generics
4026
- $1size_t
4027
*/
4028
typedef Eurydice_arr_7c libcrux_sha3_generic_keccak_KeccakState_f3;
4029
4030
typedef libcrux_sha3_generic_keccak_KeccakState_f3 libcrux_sha3_portable_KeccakState;
4031
4032
/**
4033
A monomorphic instance of libcrux_sha3.generic_keccak.xof.KeccakXofState
4034
with types uint64_t
4035
with const generics
4036
- $1size_t
4037
- $136size_t
4038
*/
4039
typedef struct libcrux_sha3_generic_keccak_xof_KeccakXofState_8d_s
4040
{
4041
  Eurydice_arr_7c inner;
4042
  Eurydice_arr_0b buf;
4043
  size_t buf_len;
4044
  bool sponge;
4045
}
4046
libcrux_sha3_generic_keccak_xof_KeccakXofState_8d;
4047
4048
typedef libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
4049
libcrux_sha3_portable_incremental_Shake256Xof;
4050
4051
/**
4052
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4053
*/
4054
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_zero_d2(void)
4055
0
{
4056
0
  return 0ULL;
4057
0
}
4058
4059
static KRML_MUSTINLINE uint64_t
4060
libcrux_sha3_simd_portable__veor5q_u64(
4061
  uint64_t a,
4062
  uint64_t b,
4063
  uint64_t c,
4064
  uint64_t d,
4065
  uint64_t e
4066
)
4067
0
{
4068
0
  return (((a ^ b) ^ c) ^ d) ^ e;
4069
0
}
4070
4071
/**
4072
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4073
*/
4074
static KRML_MUSTINLINE uint64_t
4075
libcrux_sha3_simd_portable_xor5_d2(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e)
4076
0
{
4077
0
  return libcrux_sha3_simd_portable__veor5q_u64(a, b, c, d, e);
4078
0
}
4079
4080
/**
4081
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4082
with const generics
4083
- LEFT= 1
4084
- RIGHT= 63
4085
*/
4086
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_76(uint64_t x)
4087
0
{
4088
0
  return core_num__u64__rotate_left(x, (uint32_t)1);
4089
0
}
4090
4091
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable__vrax1q_u64(uint64_t a, uint64_t b)
4092
0
{
4093
0
  return a ^ libcrux_sha3_simd_portable_rotate_left_76(b);
4094
0
}
4095
4096
/**
4097
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4098
*/
4099
static KRML_MUSTINLINE uint64_t
4100
libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(uint64_t a, uint64_t b)
4101
0
{
4102
0
  return libcrux_sha3_simd_portable__vrax1q_u64(a, b);
4103
0
}
4104
4105
static KRML_MUSTINLINE uint64_t
4106
libcrux_sha3_simd_portable__vbcaxq_u64(uint64_t a, uint64_t b, uint64_t c)
4107
0
{
4108
0
  return a ^ (b & ~c);
4109
0
}
4110
4111
/**
4112
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4113
*/
4114
static KRML_MUSTINLINE uint64_t
4115
libcrux_sha3_simd_portable_and_not_xor_d2(uint64_t a, uint64_t b, uint64_t c)
4116
0
{
4117
0
  return libcrux_sha3_simd_portable__vbcaxq_u64(a, b, c);
4118
0
}
4119
4120
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable__veorq_n_u64(uint64_t a, uint64_t c)
4121
0
{
4122
0
  return a ^ c;
4123
0
}
4124
4125
/**
4126
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4127
*/
4128
static KRML_MUSTINLINE uint64_t
4129
libcrux_sha3_simd_portable_xor_constant_d2(uint64_t a, uint64_t c)
4130
0
{
4131
0
  return libcrux_sha3_simd_portable__veorq_n_u64(a, c);
4132
0
}
4133
4134
/**
4135
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4136
*/
4137
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_xor_d2(uint64_t a, uint64_t b)
4138
0
{
4139
0
  return a ^ b;
4140
0
}
4141
4142
/**
4143
 Create a new Shake128 x4 state.
4144
*/
4145
/**
4146
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
4147
*/
4148
/**
4149
A monomorphic instance of libcrux_sha3.generic_keccak.new_80
4150
with types uint64_t
4151
with const generics
4152
- N= 1
4153
*/
4154
static KRML_MUSTINLINE Eurydice_arr_7c libcrux_sha3_generic_keccak_new_80_71(void)
4155
0
{
4156
0
  Eurydice_arr_7c lit;
4157
0
  uint64_t repeat_expression[25U];
4158
0
  for (size_t i = (size_t)0U; i < (size_t)25U; i++)
4159
0
  {
4160
0
    repeat_expression[i] = libcrux_sha3_simd_portable_zero_d2();
4161
0
  }
4162
0
  memcpy(lit.data, repeat_expression, (size_t)25U * sizeof (uint64_t));
4163
0
  return lit;
4164
0
}
4165
4166
/**
4167
 Create a new SHAKE-128 state object.
4168
*/
4169
static KRML_MUSTINLINE Eurydice_arr_7c libcrux_sha3_portable_incremental_shake128_init(void)
4170
0
{
4171
0
  return libcrux_sha3_generic_keccak_new_80_71();
4172
0
}
4173
4174
0
#define LIBCRUX_SHA3_GENERIC_KECCAK_CONSTANTS_ROUNDCONSTANTS ((KRML_CLITERAL(Eurydice_arr_22){ .data = { 1ULL, 32898ULL, 9223372036854808714ULL, 9223372039002292224ULL, 32907ULL, 2147483649ULL, 9223372039002292353ULL, 9223372036854808585ULL, 138ULL, 136ULL, 2147516425ULL, 2147483658ULL, 2147516555ULL, 9223372036854775947ULL, 9223372036854808713ULL, 9223372036854808579ULL, 9223372036854808578ULL, 9223372036854775936ULL, 32778ULL, 9223372039002259466ULL, 9223372039002292353ULL, 9223372036854808704ULL, 2147483649ULL, 9223372039002292232ULL } }))
4175
4176
/**
4177
A monomorphic instance of libcrux_sha3.traits.get_ij
4178
with types uint64_t
4179
with const generics
4180
- N= 1
4181
*/
4182
static KRML_MUSTINLINE const
4183
uint64_t
4184
*libcrux_sha3_traits_get_ij_71(const Eurydice_arr_7c *arr, size_t i, size_t j)
4185
0
{
4186
0
  return &arr->data[(size_t)5U * j + i];
4187
0
}
4188
4189
/**
4190
A monomorphic instance of libcrux_sha3.traits.set_ij
4191
with types uint64_t
4192
with const generics
4193
- N= 1
4194
*/
4195
static KRML_MUSTINLINE void
4196
libcrux_sha3_traits_set_ij_71(Eurydice_arr_7c *arr, size_t i, size_t j, uint64_t value)
4197
0
{
4198
0
  arr->data[(size_t)5U * j + i] = value;
4199
0
}
4200
4201
/**
4202
A monomorphic instance of libcrux_sha3.simd.portable.load_block
4203
with const generics
4204
- RATE= 168
4205
*/
4206
static KRML_MUSTINLINE void
4207
libcrux_sha3_simd_portable_load_block_60(
4208
  Eurydice_arr_7c *state,
4209
  Eurydice_borrow_slice_u8 blocks,
4210
  size_t start
4211
)
4212
0
{
4213
0
  Eurydice_arr_7c state_flat = { .data = { 0U } };
4214
0
  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++)
4215
0
  {
4216
0
    size_t i0 = i;
4217
0
    size_t offset = start + (size_t)8U * i0;
4218
0
    Eurydice_array_u8x8 arr;
4219
0
    memcpy(arr.data,
4220
0
      Eurydice_slice_subslice_shared_c8(blocks,
4221
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = offset, .end = offset + (size_t)8U })).ptr,
4222
0
      (size_t)8U * sizeof (uint8_t));
4223
0
    Eurydice_array_u8x8
4224
0
    uu____0 =
4225
0
      core_result_unwrap_26_e0((
4226
0
          KRML_CLITERAL(core_result_Result_8e){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
4227
0
        ));
4228
0
    state_flat.data[i0] = core_num__u64__from_le_bytes(uu____0);
4229
0
  }
4230
0
  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++)
4231
0
  {
4232
0
    size_t i0 = i;
4233
0
    libcrux_sha3_traits_set_ij_71(state,
4234
0
      i0 / (size_t)5U,
4235
0
      i0 % (size_t)5U,
4236
0
      libcrux_sha3_traits_get_ij_71(state, i0 / (size_t)5U, i0 % (size_t)5U)[0U] ^
4237
0
        state_flat.data[i0]);
4238
0
  }
4239
0
}
4240
4241
/**
4242
A monomorphic instance of libcrux_sha3.simd.portable.load_last
4243
with const generics
4244
- RATE= 168
4245
- DELIMITER= 31
4246
*/
4247
static KRML_MUSTINLINE void
4248
libcrux_sha3_simd_portable_load_last_37(
4249
  Eurydice_arr_7c *state,
4250
  Eurydice_borrow_slice_u8 blocks,
4251
  size_t start,
4252
  size_t len
4253
)
4254
0
{
4255
0
  Eurydice_arr_c5 buffer = { .data = { 0U } };
4256
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d41(&buffer,
4257
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = len })),
4258
0
    Eurydice_slice_subslice_shared_c8(blocks,
4259
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = start, .end = start + len })),
4260
0
    uint8_t);
4261
0
  buffer.data[len] = 31U;
4262
0
  size_t uu____0 = (size_t)168U - (size_t)1U;
4263
0
  buffer.data[uu____0] = (uint32_t)buffer.data[uu____0] | 128U;
4264
0
  libcrux_sha3_simd_portable_load_block_60(state,
4265
0
    Eurydice_array_to_slice_shared_2c(&buffer),
4266
0
    (size_t)0U);
4267
0
}
4268
4269
/**
4270
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
4271
*/
4272
/**
4273
A monomorphic instance of libcrux_sha3.simd.portable.load_last_a1
4274
with const generics
4275
- RATE= 168
4276
- DELIMITER= 31
4277
*/
4278
static inline void
4279
libcrux_sha3_simd_portable_load_last_a1_37(
4280
  Eurydice_arr_7c *self,
4281
  const Eurydice_arr_dc *input,
4282
  size_t start,
4283
  size_t len
4284
)
4285
0
{
4286
0
  libcrux_sha3_simd_portable_load_last_37(self, input->data[0U], start, len);
4287
0
}
4288
4289
/**
4290
 Get element `[i, j]`.
4291
*/
4292
/**
4293
This function found in impl {core::ops::index::Index<(usize, usize), T> for libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
4294
*/
4295
/**
4296
A monomorphic instance of libcrux_sha3.generic_keccak.index_c2
4297
with types uint64_t
4298
with const generics
4299
- N= 1
4300
*/
4301
static inline const
4302
uint64_t
4303
*libcrux_sha3_generic_keccak_index_c2_71(const Eurydice_arr_7c *self, size_t_x2 index)
4304
0
{
4305
0
  return libcrux_sha3_traits_get_ij_71(self, index.fst, index.snd);
4306
0
}
4307
4308
/**
4309
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
4310
*/
4311
/**
4312
A monomorphic instance of libcrux_sha3.generic_keccak.theta_80
4313
with types uint64_t
4314
with const generics
4315
- N= 1
4316
*/
4317
static KRML_MUSTINLINE Eurydice_arr_84
4318
libcrux_sha3_generic_keccak_theta_80_71(Eurydice_arr_7c *self)
4319
0
{
4320
0
  Eurydice_arr_84
4321
0
  c =
4322
0
    {
4323
0
      .data = {
4324
0
        libcrux_sha3_simd_portable_xor5_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
4325
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)0U }))[0U],
4326
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4327
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)0U }))[0U],
4328
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4329
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)0U }))[0U],
4330
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4331
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)0U }))[0U],
4332
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4333
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)0U }))[0U]),
4334
0
        libcrux_sha3_simd_portable_xor5_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
4335
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)1U }))[0U],
4336
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4337
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)1U }))[0U],
4338
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4339
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)1U }))[0U],
4340
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4341
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)1U }))[0U],
4342
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4343
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)1U }))[0U]),
4344
0
        libcrux_sha3_simd_portable_xor5_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
4345
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)2U }))[0U],
4346
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4347
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)2U }))[0U],
4348
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4349
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)2U }))[0U],
4350
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4351
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)2U }))[0U],
4352
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4353
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)2U }))[0U]),
4354
0
        libcrux_sha3_simd_portable_xor5_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
4355
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)3U }))[0U],
4356
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4357
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)3U }))[0U],
4358
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4359
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)3U }))[0U],
4360
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4361
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)3U }))[0U],
4362
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4363
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)3U }))[0U]),
4364
0
        libcrux_sha3_simd_portable_xor5_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
4365
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)4U }))[0U],
4366
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4367
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)4U }))[0U],
4368
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4369
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)4U }))[0U],
4370
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4371
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)4U }))[0U],
4372
0
          libcrux_sha3_generic_keccak_index_c2_71(self,
4373
0
            (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)4U }))[0U])
4374
0
      }
4375
0
    };
4376
0
  return
4377
0
    (
4378
0
      KRML_CLITERAL(Eurydice_arr_84){
4379
0
        .data = {
4380
0
          libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(c.data[((size_t)0U + (size_t)4U) %
4381
0
              (size_t)5U],
4382
0
            c.data[((size_t)0U + (size_t)1U) % (size_t)5U]),
4383
0
          libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(c.data[((size_t)1U + (size_t)4U) %
4384
0
              (size_t)5U],
4385
0
            c.data[((size_t)1U + (size_t)1U) % (size_t)5U]),
4386
0
          libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(c.data[((size_t)2U + (size_t)4U) %
4387
0
              (size_t)5U],
4388
0
            c.data[((size_t)2U + (size_t)1U) % (size_t)5U]),
4389
0
          libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(c.data[((size_t)3U + (size_t)4U) %
4390
0
              (size_t)5U],
4391
0
            c.data[((size_t)3U + (size_t)1U) % (size_t)5U]),
4392
0
          libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(c.data[((size_t)4U + (size_t)4U) %
4393
0
              (size_t)5U],
4394
0
            c.data[((size_t)4U + (size_t)1U) % (size_t)5U])
4395
0
        }
4396
0
      }
4397
0
    );
4398
0
}
4399
4400
/**
4401
 Set element `[i, j] = v`.
4402
*/
4403
/**
4404
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
4405
*/
4406
/**
4407
A monomorphic instance of libcrux_sha3.generic_keccak.set_80
4408
with types uint64_t
4409
with const generics
4410
- N= 1
4411
*/
4412
static inline void
4413
libcrux_sha3_generic_keccak_set_80_71(Eurydice_arr_7c *self, size_t i, size_t j, uint64_t v)
4414
0
{
4415
0
  libcrux_sha3_traits_set_ij_71(self, i, j, v);
4416
0
}
4417
4418
/**
4419
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4420
with const generics
4421
- LEFT= 36
4422
- RIGHT= 28
4423
*/
4424
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_02(uint64_t x)
4425
0
{
4426
0
  return core_num__u64__rotate_left(x, (uint32_t)36);
4427
0
}
4428
4429
/**
4430
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4431
with const generics
4432
- LEFT= 36
4433
- RIGHT= 28
4434
*/
4435
static KRML_MUSTINLINE uint64_t
4436
libcrux_sha3_simd_portable__vxarq_u64_02(uint64_t a, uint64_t b)
4437
0
{
4438
0
  return libcrux_sha3_simd_portable_rotate_left_02(a ^ b);
4439
0
}
4440
4441
/**
4442
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4443
*/
4444
/**
4445
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4446
with const generics
4447
- LEFT= 36
4448
- RIGHT= 28
4449
*/
4450
static KRML_MUSTINLINE uint64_t
4451
libcrux_sha3_simd_portable_xor_and_rotate_d2_02(uint64_t a, uint64_t b)
4452
0
{
4453
0
  return libcrux_sha3_simd_portable__vxarq_u64_02(a, b);
4454
0
}
4455
4456
/**
4457
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4458
with const generics
4459
- LEFT= 3
4460
- RIGHT= 61
4461
*/
4462
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_ac(uint64_t x)
4463
0
{
4464
0
  return core_num__u64__rotate_left(x, (uint32_t)3);
4465
0
}
4466
4467
/**
4468
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4469
with const generics
4470
- LEFT= 3
4471
- RIGHT= 61
4472
*/
4473
static KRML_MUSTINLINE uint64_t
4474
libcrux_sha3_simd_portable__vxarq_u64_ac(uint64_t a, uint64_t b)
4475
0
{
4476
0
  return libcrux_sha3_simd_portable_rotate_left_ac(a ^ b);
4477
0
}
4478
4479
/**
4480
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4481
*/
4482
/**
4483
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4484
with const generics
4485
- LEFT= 3
4486
- RIGHT= 61
4487
*/
4488
static KRML_MUSTINLINE uint64_t
4489
libcrux_sha3_simd_portable_xor_and_rotate_d2_ac(uint64_t a, uint64_t b)
4490
0
{
4491
0
  return libcrux_sha3_simd_portable__vxarq_u64_ac(a, b);
4492
0
}
4493
4494
/**
4495
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4496
with const generics
4497
- LEFT= 41
4498
- RIGHT= 23
4499
*/
4500
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_020(uint64_t x)
4501
0
{
4502
0
  return core_num__u64__rotate_left(x, (uint32_t)41);
4503
0
}
4504
4505
/**
4506
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4507
with const generics
4508
- LEFT= 41
4509
- RIGHT= 23
4510
*/
4511
static KRML_MUSTINLINE uint64_t
4512
libcrux_sha3_simd_portable__vxarq_u64_020(uint64_t a, uint64_t b)
4513
0
{
4514
0
  return libcrux_sha3_simd_portable_rotate_left_020(a ^ b);
4515
0
}
4516
4517
/**
4518
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4519
*/
4520
/**
4521
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4522
with const generics
4523
- LEFT= 41
4524
- RIGHT= 23
4525
*/
4526
static KRML_MUSTINLINE uint64_t
4527
libcrux_sha3_simd_portable_xor_and_rotate_d2_020(uint64_t a, uint64_t b)
4528
0
{
4529
0
  return libcrux_sha3_simd_portable__vxarq_u64_020(a, b);
4530
0
}
4531
4532
/**
4533
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4534
with const generics
4535
- LEFT= 18
4536
- RIGHT= 46
4537
*/
4538
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_a9(uint64_t x)
4539
0
{
4540
0
  return core_num__u64__rotate_left(x, (uint32_t)18);
4541
0
}
4542
4543
/**
4544
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4545
with const generics
4546
- LEFT= 18
4547
- RIGHT= 46
4548
*/
4549
static KRML_MUSTINLINE uint64_t
4550
libcrux_sha3_simd_portable__vxarq_u64_a9(uint64_t a, uint64_t b)
4551
0
{
4552
0
  return libcrux_sha3_simd_portable_rotate_left_a9(a ^ b);
4553
0
}
4554
4555
/**
4556
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4557
*/
4558
/**
4559
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4560
with const generics
4561
- LEFT= 18
4562
- RIGHT= 46
4563
*/
4564
static KRML_MUSTINLINE uint64_t
4565
libcrux_sha3_simd_portable_xor_and_rotate_d2_a9(uint64_t a, uint64_t b)
4566
0
{
4567
0
  return libcrux_sha3_simd_portable__vxarq_u64_a9(a, b);
4568
0
}
4569
4570
/**
4571
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
4572
*/
4573
/**
4574
A monomorphic instance of libcrux_sha3.generic_keccak.rho_0_80
4575
with types uint64_t
4576
with const generics
4577
- N= 1
4578
*/
4579
static KRML_MUSTINLINE void
4580
libcrux_sha3_generic_keccak_rho_0_80_71(Eurydice_arr_7c *self, Eurydice_arr_84 t)
4581
0
{
4582
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4583
0
    (size_t)0U,
4584
0
    (size_t)0U,
4585
0
    libcrux_sha3_simd_portable_xor_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
4586
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)0U }))[0U],
4587
0
      t.data[0U]));
4588
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4589
0
    (size_t)1U,
4590
0
    (size_t)0U,
4591
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_02(libcrux_sha3_generic_keccak_index_c2_71(self,
4592
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)0U }))[0U],
4593
0
      t.data[0U]));
4594
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4595
0
    (size_t)2U,
4596
0
    (size_t)0U,
4597
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_ac(libcrux_sha3_generic_keccak_index_c2_71(self,
4598
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)0U }))[0U],
4599
0
      t.data[0U]));
4600
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4601
0
    (size_t)3U,
4602
0
    (size_t)0U,
4603
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_020(libcrux_sha3_generic_keccak_index_c2_71(self,
4604
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)0U }))[0U],
4605
0
      t.data[0U]));
4606
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4607
0
    (size_t)4U,
4608
0
    (size_t)0U,
4609
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_a9(libcrux_sha3_generic_keccak_index_c2_71(self,
4610
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)0U }))[0U],
4611
0
      t.data[0U]));
4612
0
}
4613
4614
/**
4615
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4616
with const generics
4617
- LEFT= 1
4618
- RIGHT= 63
4619
*/
4620
static KRML_MUSTINLINE uint64_t
4621
libcrux_sha3_simd_portable__vxarq_u64_76(uint64_t a, uint64_t b)
4622
0
{
4623
0
  return libcrux_sha3_simd_portable_rotate_left_76(a ^ b);
4624
0
}
4625
4626
/**
4627
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4628
*/
4629
/**
4630
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4631
with const generics
4632
- LEFT= 1
4633
- RIGHT= 63
4634
*/
4635
static KRML_MUSTINLINE uint64_t
4636
libcrux_sha3_simd_portable_xor_and_rotate_d2_76(uint64_t a, uint64_t b)
4637
0
{
4638
0
  return libcrux_sha3_simd_portable__vxarq_u64_76(a, b);
4639
0
}
4640
4641
/**
4642
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4643
with const generics
4644
- LEFT= 44
4645
- RIGHT= 20
4646
*/
4647
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_58(uint64_t x)
4648
0
{
4649
0
  return core_num__u64__rotate_left(x, (uint32_t)44);
4650
0
}
4651
4652
/**
4653
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4654
with const generics
4655
- LEFT= 44
4656
- RIGHT= 20
4657
*/
4658
static KRML_MUSTINLINE uint64_t
4659
libcrux_sha3_simd_portable__vxarq_u64_58(uint64_t a, uint64_t b)
4660
0
{
4661
0
  return libcrux_sha3_simd_portable_rotate_left_58(a ^ b);
4662
0
}
4663
4664
/**
4665
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4666
*/
4667
/**
4668
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4669
with const generics
4670
- LEFT= 44
4671
- RIGHT= 20
4672
*/
4673
static KRML_MUSTINLINE uint64_t
4674
libcrux_sha3_simd_portable_xor_and_rotate_d2_58(uint64_t a, uint64_t b)
4675
0
{
4676
0
  return libcrux_sha3_simd_portable__vxarq_u64_58(a, b);
4677
0
}
4678
4679
/**
4680
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4681
with const generics
4682
- LEFT= 10
4683
- RIGHT= 54
4684
*/
4685
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_e0(uint64_t x)
4686
0
{
4687
0
  return core_num__u64__rotate_left(x, (uint32_t)10);
4688
0
}
4689
4690
/**
4691
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4692
with const generics
4693
- LEFT= 10
4694
- RIGHT= 54
4695
*/
4696
static KRML_MUSTINLINE uint64_t
4697
libcrux_sha3_simd_portable__vxarq_u64_e0(uint64_t a, uint64_t b)
4698
0
{
4699
0
  return libcrux_sha3_simd_portable_rotate_left_e0(a ^ b);
4700
0
}
4701
4702
/**
4703
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4704
*/
4705
/**
4706
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4707
with const generics
4708
- LEFT= 10
4709
- RIGHT= 54
4710
*/
4711
static KRML_MUSTINLINE uint64_t
4712
libcrux_sha3_simd_portable_xor_and_rotate_d2_e0(uint64_t a, uint64_t b)
4713
0
{
4714
0
  return libcrux_sha3_simd_portable__vxarq_u64_e0(a, b);
4715
0
}
4716
4717
/**
4718
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4719
with const generics
4720
- LEFT= 45
4721
- RIGHT= 19
4722
*/
4723
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_63(uint64_t x)
4724
0
{
4725
0
  return core_num__u64__rotate_left(x, (uint32_t)45);
4726
0
}
4727
4728
/**
4729
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4730
with const generics
4731
- LEFT= 45
4732
- RIGHT= 19
4733
*/
4734
static KRML_MUSTINLINE uint64_t
4735
libcrux_sha3_simd_portable__vxarq_u64_63(uint64_t a, uint64_t b)
4736
0
{
4737
0
  return libcrux_sha3_simd_portable_rotate_left_63(a ^ b);
4738
0
}
4739
4740
/**
4741
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4742
*/
4743
/**
4744
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4745
with const generics
4746
- LEFT= 45
4747
- RIGHT= 19
4748
*/
4749
static KRML_MUSTINLINE uint64_t
4750
libcrux_sha3_simd_portable_xor_and_rotate_d2_63(uint64_t a, uint64_t b)
4751
0
{
4752
0
  return libcrux_sha3_simd_portable__vxarq_u64_63(a, b);
4753
0
}
4754
4755
/**
4756
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4757
with const generics
4758
- LEFT= 2
4759
- RIGHT= 62
4760
*/
4761
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_6a(uint64_t x)
4762
0
{
4763
0
  return core_num__u64__rotate_left(x, (uint32_t)2);
4764
0
}
4765
4766
/**
4767
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4768
with const generics
4769
- LEFT= 2
4770
- RIGHT= 62
4771
*/
4772
static KRML_MUSTINLINE uint64_t
4773
libcrux_sha3_simd_portable__vxarq_u64_6a(uint64_t a, uint64_t b)
4774
0
{
4775
0
  return libcrux_sha3_simd_portable_rotate_left_6a(a ^ b);
4776
0
}
4777
4778
/**
4779
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4780
*/
4781
/**
4782
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4783
with const generics
4784
- LEFT= 2
4785
- RIGHT= 62
4786
*/
4787
static KRML_MUSTINLINE uint64_t
4788
libcrux_sha3_simd_portable_xor_and_rotate_d2_6a(uint64_t a, uint64_t b)
4789
0
{
4790
0
  return libcrux_sha3_simd_portable__vxarq_u64_6a(a, b);
4791
0
}
4792
4793
/**
4794
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
4795
*/
4796
/**
4797
A monomorphic instance of libcrux_sha3.generic_keccak.rho_1_80
4798
with types uint64_t
4799
with const generics
4800
- N= 1
4801
*/
4802
static KRML_MUSTINLINE void
4803
libcrux_sha3_generic_keccak_rho_1_80_71(Eurydice_arr_7c *self, Eurydice_arr_84 t)
4804
0
{
4805
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4806
0
    (size_t)0U,
4807
0
    (size_t)1U,
4808
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_76(libcrux_sha3_generic_keccak_index_c2_71(self,
4809
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)1U }))[0U],
4810
0
      t.data[1U]));
4811
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4812
0
    (size_t)1U,
4813
0
    (size_t)1U,
4814
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_58(libcrux_sha3_generic_keccak_index_c2_71(self,
4815
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)1U }))[0U],
4816
0
      t.data[1U]));
4817
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4818
0
    (size_t)2U,
4819
0
    (size_t)1U,
4820
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_e0(libcrux_sha3_generic_keccak_index_c2_71(self,
4821
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)1U }))[0U],
4822
0
      t.data[1U]));
4823
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4824
0
    (size_t)3U,
4825
0
    (size_t)1U,
4826
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_63(libcrux_sha3_generic_keccak_index_c2_71(self,
4827
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)1U }))[0U],
4828
0
      t.data[1U]));
4829
0
  libcrux_sha3_generic_keccak_set_80_71(self,
4830
0
    (size_t)4U,
4831
0
    (size_t)1U,
4832
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_6a(libcrux_sha3_generic_keccak_index_c2_71(self,
4833
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)1U }))[0U],
4834
0
      t.data[1U]));
4835
0
}
4836
4837
/**
4838
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4839
with const generics
4840
- LEFT= 62
4841
- RIGHT= 2
4842
*/
4843
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_ab(uint64_t x)
4844
0
{
4845
0
  return core_num__u64__rotate_left(x, (uint32_t)62);
4846
0
}
4847
4848
/**
4849
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4850
with const generics
4851
- LEFT= 62
4852
- RIGHT= 2
4853
*/
4854
static KRML_MUSTINLINE uint64_t
4855
libcrux_sha3_simd_portable__vxarq_u64_ab(uint64_t a, uint64_t b)
4856
0
{
4857
0
  return libcrux_sha3_simd_portable_rotate_left_ab(a ^ b);
4858
0
}
4859
4860
/**
4861
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4862
*/
4863
/**
4864
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4865
with const generics
4866
- LEFT= 62
4867
- RIGHT= 2
4868
*/
4869
static KRML_MUSTINLINE uint64_t
4870
libcrux_sha3_simd_portable_xor_and_rotate_d2_ab(uint64_t a, uint64_t b)
4871
0
{
4872
0
  return libcrux_sha3_simd_portable__vxarq_u64_ab(a, b);
4873
0
}
4874
4875
/**
4876
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4877
with const generics
4878
- LEFT= 6
4879
- RIGHT= 58
4880
*/
4881
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_5b(uint64_t x)
4882
0
{
4883
0
  return core_num__u64__rotate_left(x, (uint32_t)6);
4884
0
}
4885
4886
/**
4887
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4888
with const generics
4889
- LEFT= 6
4890
- RIGHT= 58
4891
*/
4892
static KRML_MUSTINLINE uint64_t
4893
libcrux_sha3_simd_portable__vxarq_u64_5b(uint64_t a, uint64_t b)
4894
0
{
4895
0
  return libcrux_sha3_simd_portable_rotate_left_5b(a ^ b);
4896
0
}
4897
4898
/**
4899
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4900
*/
4901
/**
4902
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4903
with const generics
4904
- LEFT= 6
4905
- RIGHT= 58
4906
*/
4907
static KRML_MUSTINLINE uint64_t
4908
libcrux_sha3_simd_portable_xor_and_rotate_d2_5b(uint64_t a, uint64_t b)
4909
0
{
4910
0
  return libcrux_sha3_simd_portable__vxarq_u64_5b(a, b);
4911
0
}
4912
4913
/**
4914
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4915
with const generics
4916
- LEFT= 43
4917
- RIGHT= 21
4918
*/
4919
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_6f(uint64_t x)
4920
0
{
4921
0
  return core_num__u64__rotate_left(x, (uint32_t)43);
4922
0
}
4923
4924
/**
4925
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4926
with const generics
4927
- LEFT= 43
4928
- RIGHT= 21
4929
*/
4930
static KRML_MUSTINLINE uint64_t
4931
libcrux_sha3_simd_portable__vxarq_u64_6f(uint64_t a, uint64_t b)
4932
0
{
4933
0
  return libcrux_sha3_simd_portable_rotate_left_6f(a ^ b);
4934
0
}
4935
4936
/**
4937
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4938
*/
4939
/**
4940
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4941
with const generics
4942
- LEFT= 43
4943
- RIGHT= 21
4944
*/
4945
static KRML_MUSTINLINE uint64_t
4946
libcrux_sha3_simd_portable_xor_and_rotate_d2_6f(uint64_t a, uint64_t b)
4947
0
{
4948
0
  return libcrux_sha3_simd_portable__vxarq_u64_6f(a, b);
4949
0
}
4950
4951
/**
4952
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4953
with const generics
4954
- LEFT= 15
4955
- RIGHT= 49
4956
*/
4957
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_62(uint64_t x)
4958
0
{
4959
0
  return core_num__u64__rotate_left(x, (uint32_t)15);
4960
0
}
4961
4962
/**
4963
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
4964
with const generics
4965
- LEFT= 15
4966
- RIGHT= 49
4967
*/
4968
static KRML_MUSTINLINE uint64_t
4969
libcrux_sha3_simd_portable__vxarq_u64_62(uint64_t a, uint64_t b)
4970
0
{
4971
0
  return libcrux_sha3_simd_portable_rotate_left_62(a ^ b);
4972
0
}
4973
4974
/**
4975
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
4976
*/
4977
/**
4978
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
4979
with const generics
4980
- LEFT= 15
4981
- RIGHT= 49
4982
*/
4983
static KRML_MUSTINLINE uint64_t
4984
libcrux_sha3_simd_portable_xor_and_rotate_d2_62(uint64_t a, uint64_t b)
4985
0
{
4986
0
  return libcrux_sha3_simd_portable__vxarq_u64_62(a, b);
4987
0
}
4988
4989
/**
4990
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
4991
with const generics
4992
- LEFT= 61
4993
- RIGHT= 3
4994
*/
4995
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_23(uint64_t x)
4996
0
{
4997
0
  return core_num__u64__rotate_left(x, (uint32_t)61);
4998
0
}
4999
5000
/**
5001
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5002
with const generics
5003
- LEFT= 61
5004
- RIGHT= 3
5005
*/
5006
static KRML_MUSTINLINE uint64_t
5007
libcrux_sha3_simd_portable__vxarq_u64_23(uint64_t a, uint64_t b)
5008
0
{
5009
0
  return libcrux_sha3_simd_portable_rotate_left_23(a ^ b);
5010
0
}
5011
5012
/**
5013
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5014
*/
5015
/**
5016
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5017
with const generics
5018
- LEFT= 61
5019
- RIGHT= 3
5020
*/
5021
static KRML_MUSTINLINE uint64_t
5022
libcrux_sha3_simd_portable_xor_and_rotate_d2_23(uint64_t a, uint64_t b)
5023
0
{
5024
0
  return libcrux_sha3_simd_portable__vxarq_u64_23(a, b);
5025
0
}
5026
5027
/**
5028
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5029
*/
5030
/**
5031
A monomorphic instance of libcrux_sha3.generic_keccak.rho_2_80
5032
with types uint64_t
5033
with const generics
5034
- N= 1
5035
*/
5036
static KRML_MUSTINLINE void
5037
libcrux_sha3_generic_keccak_rho_2_80_71(Eurydice_arr_7c *self, Eurydice_arr_84 t)
5038
0
{
5039
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5040
0
    (size_t)0U,
5041
0
    (size_t)2U,
5042
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_ab(libcrux_sha3_generic_keccak_index_c2_71(self,
5043
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)2U }))[0U],
5044
0
      t.data[2U]));
5045
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5046
0
    (size_t)1U,
5047
0
    (size_t)2U,
5048
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_5b(libcrux_sha3_generic_keccak_index_c2_71(self,
5049
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)2U }))[0U],
5050
0
      t.data[2U]));
5051
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5052
0
    (size_t)2U,
5053
0
    (size_t)2U,
5054
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_6f(libcrux_sha3_generic_keccak_index_c2_71(self,
5055
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)2U }))[0U],
5056
0
      t.data[2U]));
5057
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5058
0
    (size_t)3U,
5059
0
    (size_t)2U,
5060
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_62(libcrux_sha3_generic_keccak_index_c2_71(self,
5061
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)2U }))[0U],
5062
0
      t.data[2U]));
5063
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5064
0
    (size_t)4U,
5065
0
    (size_t)2U,
5066
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_23(libcrux_sha3_generic_keccak_index_c2_71(self,
5067
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)2U }))[0U],
5068
0
      t.data[2U]));
5069
0
}
5070
5071
/**
5072
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5073
with const generics
5074
- LEFT= 28
5075
- RIGHT= 36
5076
*/
5077
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_37(uint64_t x)
5078
0
{
5079
0
  return core_num__u64__rotate_left(x, (uint32_t)28);
5080
0
}
5081
5082
/**
5083
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5084
with const generics
5085
- LEFT= 28
5086
- RIGHT= 36
5087
*/
5088
static KRML_MUSTINLINE uint64_t
5089
libcrux_sha3_simd_portable__vxarq_u64_37(uint64_t a, uint64_t b)
5090
0
{
5091
0
  return libcrux_sha3_simd_portable_rotate_left_37(a ^ b);
5092
0
}
5093
5094
/**
5095
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5096
*/
5097
/**
5098
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5099
with const generics
5100
- LEFT= 28
5101
- RIGHT= 36
5102
*/
5103
static KRML_MUSTINLINE uint64_t
5104
libcrux_sha3_simd_portable_xor_and_rotate_d2_37(uint64_t a, uint64_t b)
5105
0
{
5106
0
  return libcrux_sha3_simd_portable__vxarq_u64_37(a, b);
5107
0
}
5108
5109
/**
5110
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5111
with const generics
5112
- LEFT= 55
5113
- RIGHT= 9
5114
*/
5115
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_bb(uint64_t x)
5116
0
{
5117
0
  return core_num__u64__rotate_left(x, (uint32_t)55);
5118
0
}
5119
5120
/**
5121
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5122
with const generics
5123
- LEFT= 55
5124
- RIGHT= 9
5125
*/
5126
static KRML_MUSTINLINE uint64_t
5127
libcrux_sha3_simd_portable__vxarq_u64_bb(uint64_t a, uint64_t b)
5128
0
{
5129
0
  return libcrux_sha3_simd_portable_rotate_left_bb(a ^ b);
5130
0
}
5131
5132
/**
5133
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5134
*/
5135
/**
5136
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5137
with const generics
5138
- LEFT= 55
5139
- RIGHT= 9
5140
*/
5141
static KRML_MUSTINLINE uint64_t
5142
libcrux_sha3_simd_portable_xor_and_rotate_d2_bb(uint64_t a, uint64_t b)
5143
0
{
5144
0
  return libcrux_sha3_simd_portable__vxarq_u64_bb(a, b);
5145
0
}
5146
5147
/**
5148
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5149
with const generics
5150
- LEFT= 25
5151
- RIGHT= 39
5152
*/
5153
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_b9(uint64_t x)
5154
0
{
5155
0
  return core_num__u64__rotate_left(x, (uint32_t)25);
5156
0
}
5157
5158
/**
5159
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5160
with const generics
5161
- LEFT= 25
5162
- RIGHT= 39
5163
*/
5164
static KRML_MUSTINLINE uint64_t
5165
libcrux_sha3_simd_portable__vxarq_u64_b9(uint64_t a, uint64_t b)
5166
0
{
5167
0
  return libcrux_sha3_simd_portable_rotate_left_b9(a ^ b);
5168
0
}
5169
5170
/**
5171
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5172
*/
5173
/**
5174
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5175
with const generics
5176
- LEFT= 25
5177
- RIGHT= 39
5178
*/
5179
static KRML_MUSTINLINE uint64_t
5180
libcrux_sha3_simd_portable_xor_and_rotate_d2_b9(uint64_t a, uint64_t b)
5181
0
{
5182
0
  return libcrux_sha3_simd_portable__vxarq_u64_b9(a, b);
5183
0
}
5184
5185
/**
5186
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5187
with const generics
5188
- LEFT= 21
5189
- RIGHT= 43
5190
*/
5191
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_54(uint64_t x)
5192
0
{
5193
0
  return core_num__u64__rotate_left(x, (uint32_t)21);
5194
0
}
5195
5196
/**
5197
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5198
with const generics
5199
- LEFT= 21
5200
- RIGHT= 43
5201
*/
5202
static KRML_MUSTINLINE uint64_t
5203
libcrux_sha3_simd_portable__vxarq_u64_54(uint64_t a, uint64_t b)
5204
0
{
5205
0
  return libcrux_sha3_simd_portable_rotate_left_54(a ^ b);
5206
0
}
5207
5208
/**
5209
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5210
*/
5211
/**
5212
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5213
with const generics
5214
- LEFT= 21
5215
- RIGHT= 43
5216
*/
5217
static KRML_MUSTINLINE uint64_t
5218
libcrux_sha3_simd_portable_xor_and_rotate_d2_54(uint64_t a, uint64_t b)
5219
0
{
5220
0
  return libcrux_sha3_simd_portable__vxarq_u64_54(a, b);
5221
0
}
5222
5223
/**
5224
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5225
with const generics
5226
- LEFT= 56
5227
- RIGHT= 8
5228
*/
5229
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_4c(uint64_t x)
5230
0
{
5231
0
  return core_num__u64__rotate_left(x, (uint32_t)56);
5232
0
}
5233
5234
/**
5235
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5236
with const generics
5237
- LEFT= 56
5238
- RIGHT= 8
5239
*/
5240
static KRML_MUSTINLINE uint64_t
5241
libcrux_sha3_simd_portable__vxarq_u64_4c(uint64_t a, uint64_t b)
5242
0
{
5243
0
  return libcrux_sha3_simd_portable_rotate_left_4c(a ^ b);
5244
0
}
5245
5246
/**
5247
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5248
*/
5249
/**
5250
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5251
with const generics
5252
- LEFT= 56
5253
- RIGHT= 8
5254
*/
5255
static KRML_MUSTINLINE uint64_t
5256
libcrux_sha3_simd_portable_xor_and_rotate_d2_4c(uint64_t a, uint64_t b)
5257
0
{
5258
0
  return libcrux_sha3_simd_portable__vxarq_u64_4c(a, b);
5259
0
}
5260
5261
/**
5262
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5263
*/
5264
/**
5265
A monomorphic instance of libcrux_sha3.generic_keccak.rho_3_80
5266
with types uint64_t
5267
with const generics
5268
- N= 1
5269
*/
5270
static KRML_MUSTINLINE void
5271
libcrux_sha3_generic_keccak_rho_3_80_71(Eurydice_arr_7c *self, Eurydice_arr_84 t)
5272
0
{
5273
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5274
0
    (size_t)0U,
5275
0
    (size_t)3U,
5276
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_37(libcrux_sha3_generic_keccak_index_c2_71(self,
5277
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)3U }))[0U],
5278
0
      t.data[3U]));
5279
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5280
0
    (size_t)1U,
5281
0
    (size_t)3U,
5282
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_bb(libcrux_sha3_generic_keccak_index_c2_71(self,
5283
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)3U }))[0U],
5284
0
      t.data[3U]));
5285
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5286
0
    (size_t)2U,
5287
0
    (size_t)3U,
5288
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_b9(libcrux_sha3_generic_keccak_index_c2_71(self,
5289
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)3U }))[0U],
5290
0
      t.data[3U]));
5291
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5292
0
    (size_t)3U,
5293
0
    (size_t)3U,
5294
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_54(libcrux_sha3_generic_keccak_index_c2_71(self,
5295
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)3U }))[0U],
5296
0
      t.data[3U]));
5297
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5298
0
    (size_t)4U,
5299
0
    (size_t)3U,
5300
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_4c(libcrux_sha3_generic_keccak_index_c2_71(self,
5301
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)3U }))[0U],
5302
0
      t.data[3U]));
5303
0
}
5304
5305
/**
5306
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5307
with const generics
5308
- LEFT= 27
5309
- RIGHT= 37
5310
*/
5311
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_ce(uint64_t x)
5312
0
{
5313
0
  return core_num__u64__rotate_left(x, (uint32_t)27);
5314
0
}
5315
5316
/**
5317
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5318
with const generics
5319
- LEFT= 27
5320
- RIGHT= 37
5321
*/
5322
static KRML_MUSTINLINE uint64_t
5323
libcrux_sha3_simd_portable__vxarq_u64_ce(uint64_t a, uint64_t b)
5324
0
{
5325
0
  return libcrux_sha3_simd_portable_rotate_left_ce(a ^ b);
5326
0
}
5327
5328
/**
5329
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5330
*/
5331
/**
5332
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5333
with const generics
5334
- LEFT= 27
5335
- RIGHT= 37
5336
*/
5337
static KRML_MUSTINLINE uint64_t
5338
libcrux_sha3_simd_portable_xor_and_rotate_d2_ce(uint64_t a, uint64_t b)
5339
0
{
5340
0
  return libcrux_sha3_simd_portable__vxarq_u64_ce(a, b);
5341
0
}
5342
5343
/**
5344
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5345
with const generics
5346
- LEFT= 20
5347
- RIGHT= 44
5348
*/
5349
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_77(uint64_t x)
5350
0
{
5351
0
  return core_num__u64__rotate_left(x, (uint32_t)20);
5352
0
}
5353
5354
/**
5355
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5356
with const generics
5357
- LEFT= 20
5358
- RIGHT= 44
5359
*/
5360
static KRML_MUSTINLINE uint64_t
5361
libcrux_sha3_simd_portable__vxarq_u64_77(uint64_t a, uint64_t b)
5362
0
{
5363
0
  return libcrux_sha3_simd_portable_rotate_left_77(a ^ b);
5364
0
}
5365
5366
/**
5367
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5368
*/
5369
/**
5370
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5371
with const generics
5372
- LEFT= 20
5373
- RIGHT= 44
5374
*/
5375
static KRML_MUSTINLINE uint64_t
5376
libcrux_sha3_simd_portable_xor_and_rotate_d2_77(uint64_t a, uint64_t b)
5377
0
{
5378
0
  return libcrux_sha3_simd_portable__vxarq_u64_77(a, b);
5379
0
}
5380
5381
/**
5382
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5383
with const generics
5384
- LEFT= 39
5385
- RIGHT= 25
5386
*/
5387
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_25(uint64_t x)
5388
0
{
5389
0
  return core_num__u64__rotate_left(x, (uint32_t)39);
5390
0
}
5391
5392
/**
5393
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5394
with const generics
5395
- LEFT= 39
5396
- RIGHT= 25
5397
*/
5398
static KRML_MUSTINLINE uint64_t
5399
libcrux_sha3_simd_portable__vxarq_u64_25(uint64_t a, uint64_t b)
5400
0
{
5401
0
  return libcrux_sha3_simd_portable_rotate_left_25(a ^ b);
5402
0
}
5403
5404
/**
5405
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5406
*/
5407
/**
5408
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5409
with const generics
5410
- LEFT= 39
5411
- RIGHT= 25
5412
*/
5413
static KRML_MUSTINLINE uint64_t
5414
libcrux_sha3_simd_portable_xor_and_rotate_d2_25(uint64_t a, uint64_t b)
5415
0
{
5416
0
  return libcrux_sha3_simd_portable__vxarq_u64_25(a, b);
5417
0
}
5418
5419
/**
5420
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5421
with const generics
5422
- LEFT= 8
5423
- RIGHT= 56
5424
*/
5425
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_af(uint64_t x)
5426
0
{
5427
0
  return core_num__u64__rotate_left(x, (uint32_t)8);
5428
0
}
5429
5430
/**
5431
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5432
with const generics
5433
- LEFT= 8
5434
- RIGHT= 56
5435
*/
5436
static KRML_MUSTINLINE uint64_t
5437
libcrux_sha3_simd_portable__vxarq_u64_af(uint64_t a, uint64_t b)
5438
0
{
5439
0
  return libcrux_sha3_simd_portable_rotate_left_af(a ^ b);
5440
0
}
5441
5442
/**
5443
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5444
*/
5445
/**
5446
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5447
with const generics
5448
- LEFT= 8
5449
- RIGHT= 56
5450
*/
5451
static KRML_MUSTINLINE uint64_t
5452
libcrux_sha3_simd_portable_xor_and_rotate_d2_af(uint64_t a, uint64_t b)
5453
0
{
5454
0
  return libcrux_sha3_simd_portable__vxarq_u64_af(a, b);
5455
0
}
5456
5457
/**
5458
A monomorphic instance of libcrux_sha3.simd.portable.rotate_left
5459
with const generics
5460
- LEFT= 14
5461
- RIGHT= 50
5462
*/
5463
static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_rotate_left_fd(uint64_t x)
5464
0
{
5465
0
  return core_num__u64__rotate_left(x, (uint32_t)14);
5466
0
}
5467
5468
/**
5469
A monomorphic instance of libcrux_sha3.simd.portable._vxarq_u64
5470
with const generics
5471
- LEFT= 14
5472
- RIGHT= 50
5473
*/
5474
static KRML_MUSTINLINE uint64_t
5475
libcrux_sha3_simd_portable__vxarq_u64_fd(uint64_t a, uint64_t b)
5476
0
{
5477
0
  return libcrux_sha3_simd_portable_rotate_left_fd(a ^ b);
5478
0
}
5479
5480
/**
5481
This function found in impl {libcrux_sha3::traits::KeccakItem<1usize> for u64}
5482
*/
5483
/**
5484
A monomorphic instance of libcrux_sha3.simd.portable.xor_and_rotate_d2
5485
with const generics
5486
- LEFT= 14
5487
- RIGHT= 50
5488
*/
5489
static KRML_MUSTINLINE uint64_t
5490
libcrux_sha3_simd_portable_xor_and_rotate_d2_fd(uint64_t a, uint64_t b)
5491
0
{
5492
0
  return libcrux_sha3_simd_portable__vxarq_u64_fd(a, b);
5493
0
}
5494
5495
/**
5496
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5497
*/
5498
/**
5499
A monomorphic instance of libcrux_sha3.generic_keccak.rho_4_80
5500
with types uint64_t
5501
with const generics
5502
- N= 1
5503
*/
5504
static KRML_MUSTINLINE void
5505
libcrux_sha3_generic_keccak_rho_4_80_71(Eurydice_arr_7c *self, Eurydice_arr_84 t)
5506
0
{
5507
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5508
0
    (size_t)0U,
5509
0
    (size_t)4U,
5510
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_ce(libcrux_sha3_generic_keccak_index_c2_71(self,
5511
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)4U }))[0U],
5512
0
      t.data[4U]));
5513
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5514
0
    (size_t)1U,
5515
0
    (size_t)4U,
5516
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_77(libcrux_sha3_generic_keccak_index_c2_71(self,
5517
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)4U }))[0U],
5518
0
      t.data[4U]));
5519
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5520
0
    (size_t)2U,
5521
0
    (size_t)4U,
5522
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_25(libcrux_sha3_generic_keccak_index_c2_71(self,
5523
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)4U }))[0U],
5524
0
      t.data[4U]));
5525
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5526
0
    (size_t)3U,
5527
0
    (size_t)4U,
5528
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_af(libcrux_sha3_generic_keccak_index_c2_71(self,
5529
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)4U }))[0U],
5530
0
      t.data[4U]));
5531
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5532
0
    (size_t)4U,
5533
0
    (size_t)4U,
5534
0
    libcrux_sha3_simd_portable_xor_and_rotate_d2_fd(libcrux_sha3_generic_keccak_index_c2_71(self,
5535
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)4U }))[0U],
5536
0
      t.data[4U]));
5537
0
}
5538
5539
/**
5540
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5541
*/
5542
/**
5543
A monomorphic instance of libcrux_sha3.generic_keccak.rho_80
5544
with types uint64_t
5545
with const generics
5546
- N= 1
5547
*/
5548
static KRML_MUSTINLINE void
5549
libcrux_sha3_generic_keccak_rho_80_71(Eurydice_arr_7c *self, Eurydice_arr_84 t)
5550
0
{
5551
0
  libcrux_sha3_generic_keccak_rho_0_80_71(self, t);
5552
0
  libcrux_sha3_generic_keccak_rho_1_80_71(self, t);
5553
0
  libcrux_sha3_generic_keccak_rho_2_80_71(self, t);
5554
0
  libcrux_sha3_generic_keccak_rho_3_80_71(self, t);
5555
0
  libcrux_sha3_generic_keccak_rho_4_80_71(self, t);
5556
0
}
5557
5558
/**
5559
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5560
*/
5561
/**
5562
A monomorphic instance of libcrux_sha3.generic_keccak.pi_0_80
5563
with types uint64_t
5564
with const generics
5565
- N= 1
5566
*/
5567
static KRML_MUSTINLINE void
5568
libcrux_sha3_generic_keccak_pi_0_80_71(Eurydice_arr_7c *self, Eurydice_arr_7c old)
5569
0
{
5570
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5571
0
    (size_t)1U,
5572
0
    (size_t)0U,
5573
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5574
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)3U }))[0U]);
5575
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5576
0
    (size_t)2U,
5577
0
    (size_t)0U,
5578
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5579
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)1U }))[0U]);
5580
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5581
0
    (size_t)3U,
5582
0
    (size_t)0U,
5583
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5584
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)4U }))[0U]);
5585
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5586
0
    (size_t)4U,
5587
0
    (size_t)0U,
5588
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5589
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)2U }))[0U]);
5590
0
}
5591
5592
/**
5593
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5594
*/
5595
/**
5596
A monomorphic instance of libcrux_sha3.generic_keccak.pi_1_80
5597
with types uint64_t
5598
with const generics
5599
- N= 1
5600
*/
5601
static KRML_MUSTINLINE void
5602
libcrux_sha3_generic_keccak_pi_1_80_71(Eurydice_arr_7c *self, Eurydice_arr_7c old)
5603
0
{
5604
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5605
0
    (size_t)0U,
5606
0
    (size_t)1U,
5607
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5608
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)1U }))[0U]);
5609
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5610
0
    (size_t)1U,
5611
0
    (size_t)1U,
5612
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5613
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)4U }))[0U]);
5614
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5615
0
    (size_t)2U,
5616
0
    (size_t)1U,
5617
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5618
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)2U }))[0U]);
5619
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5620
0
    (size_t)3U,
5621
0
    (size_t)1U,
5622
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5623
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)0U }))[0U]);
5624
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5625
0
    (size_t)4U,
5626
0
    (size_t)1U,
5627
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5628
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)1U, .snd = (size_t)3U }))[0U]);
5629
0
}
5630
5631
/**
5632
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5633
*/
5634
/**
5635
A monomorphic instance of libcrux_sha3.generic_keccak.pi_2_80
5636
with types uint64_t
5637
with const generics
5638
- N= 1
5639
*/
5640
static KRML_MUSTINLINE void
5641
libcrux_sha3_generic_keccak_pi_2_80_71(Eurydice_arr_7c *self, Eurydice_arr_7c old)
5642
0
{
5643
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5644
0
    (size_t)0U,
5645
0
    (size_t)2U,
5646
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5647
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)2U }))[0U]);
5648
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5649
0
    (size_t)1U,
5650
0
    (size_t)2U,
5651
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5652
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)0U }))[0U]);
5653
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5654
0
    (size_t)2U,
5655
0
    (size_t)2U,
5656
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5657
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)3U }))[0U]);
5658
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5659
0
    (size_t)3U,
5660
0
    (size_t)2U,
5661
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5662
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)1U }))[0U]);
5663
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5664
0
    (size_t)4U,
5665
0
    (size_t)2U,
5666
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5667
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)2U, .snd = (size_t)4U }))[0U]);
5668
0
}
5669
5670
/**
5671
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5672
*/
5673
/**
5674
A monomorphic instance of libcrux_sha3.generic_keccak.pi_3_80
5675
with types uint64_t
5676
with const generics
5677
- N= 1
5678
*/
5679
static KRML_MUSTINLINE void
5680
libcrux_sha3_generic_keccak_pi_3_80_71(Eurydice_arr_7c *self, Eurydice_arr_7c old)
5681
0
{
5682
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5683
0
    (size_t)0U,
5684
0
    (size_t)3U,
5685
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5686
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)3U }))[0U]);
5687
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5688
0
    (size_t)1U,
5689
0
    (size_t)3U,
5690
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5691
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)1U }))[0U]);
5692
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5693
0
    (size_t)2U,
5694
0
    (size_t)3U,
5695
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5696
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)4U }))[0U]);
5697
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5698
0
    (size_t)3U,
5699
0
    (size_t)3U,
5700
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5701
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)2U }))[0U]);
5702
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5703
0
    (size_t)4U,
5704
0
    (size_t)3U,
5705
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5706
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)3U, .snd = (size_t)0U }))[0U]);
5707
0
}
5708
5709
/**
5710
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5711
*/
5712
/**
5713
A monomorphic instance of libcrux_sha3.generic_keccak.pi_4_80
5714
with types uint64_t
5715
with const generics
5716
- N= 1
5717
*/
5718
static KRML_MUSTINLINE void
5719
libcrux_sha3_generic_keccak_pi_4_80_71(Eurydice_arr_7c *self, Eurydice_arr_7c old)
5720
0
{
5721
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5722
0
    (size_t)0U,
5723
0
    (size_t)4U,
5724
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5725
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)4U }))[0U]);
5726
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5727
0
    (size_t)1U,
5728
0
    (size_t)4U,
5729
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5730
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)2U }))[0U]);
5731
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5732
0
    (size_t)2U,
5733
0
    (size_t)4U,
5734
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5735
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)0U }))[0U]);
5736
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5737
0
    (size_t)3U,
5738
0
    (size_t)4U,
5739
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5740
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)3U }))[0U]);
5741
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5742
0
    (size_t)4U,
5743
0
    (size_t)4U,
5744
0
    libcrux_sha3_generic_keccak_index_c2_71(&old,
5745
0
      (KRML_CLITERAL(size_t_x2){ .fst = (size_t)4U, .snd = (size_t)1U }))[0U]);
5746
0
}
5747
5748
/**
5749
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5750
*/
5751
/**
5752
A monomorphic instance of libcrux_sha3.generic_keccak.pi_80
5753
with types uint64_t
5754
with const generics
5755
- N= 1
5756
*/
5757
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_pi_80_71(Eurydice_arr_7c *self)
5758
0
{
5759
0
  Eurydice_arr_7c old = self[0U];
5760
0
  libcrux_sha3_generic_keccak_pi_0_80_71(self, old);
5761
0
  libcrux_sha3_generic_keccak_pi_1_80_71(self, old);
5762
0
  libcrux_sha3_generic_keccak_pi_2_80_71(self, old);
5763
0
  libcrux_sha3_generic_keccak_pi_3_80_71(self, old);
5764
0
  libcrux_sha3_generic_keccak_pi_4_80_71(self, old);
5765
0
}
5766
5767
/**
5768
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5769
*/
5770
/**
5771
A monomorphic instance of libcrux_sha3.generic_keccak.chi_80
5772
with types uint64_t
5773
with const generics
5774
- N= 1
5775
*/
5776
static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_chi_80_71(Eurydice_arr_7c *self)
5777
0
{
5778
0
  Eurydice_arr_7c old = self[0U];
5779
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)5U; i0++)
5780
0
  {
5781
0
    size_t i1 = i0;
5782
0
    for (size_t i = (size_t)0U; i < (size_t)5U; i++)
5783
0
    {
5784
0
      size_t j = i;
5785
0
      libcrux_sha3_generic_keccak_set_80_71(self,
5786
0
        i1,
5787
0
        j,
5788
0
        libcrux_sha3_simd_portable_and_not_xor_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
5789
0
            (KRML_CLITERAL(size_t_x2){ .fst = i1, .snd = j }))[0U],
5790
0
          libcrux_sha3_generic_keccak_index_c2_71(&old,
5791
0
            (KRML_CLITERAL(size_t_x2){ .fst = i1, .snd = (j + (size_t)2U) % (size_t)5U }))[0U],
5792
0
          libcrux_sha3_generic_keccak_index_c2_71(&old,
5793
0
            (KRML_CLITERAL(size_t_x2){ .fst = i1, .snd = (j + (size_t)1U) % (size_t)5U }))[0U]));
5794
0
    }
5795
0
  }
5796
0
}
5797
5798
/**
5799
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5800
*/
5801
/**
5802
A monomorphic instance of libcrux_sha3.generic_keccak.iota_80
5803
with types uint64_t
5804
with const generics
5805
- N= 1
5806
*/
5807
static KRML_MUSTINLINE void
5808
libcrux_sha3_generic_keccak_iota_80_71(Eurydice_arr_7c *self, size_t i)
5809
0
{
5810
0
  libcrux_sha3_generic_keccak_set_80_71(self,
5811
0
    (size_t)0U,
5812
0
    (size_t)0U,
5813
0
    libcrux_sha3_simd_portable_xor_constant_d2(libcrux_sha3_generic_keccak_index_c2_71(self,
5814
0
        (KRML_CLITERAL(size_t_x2){ .fst = (size_t)0U, .snd = (size_t)0U }))[0U],
5815
0
      LIBCRUX_SHA3_GENERIC_KECCAK_CONSTANTS_ROUNDCONSTANTS.data[i]));
5816
0
}
5817
5818
/**
5819
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5820
*/
5821
/**
5822
A monomorphic instance of libcrux_sha3.generic_keccak.keccakf1600_80
5823
with types uint64_t
5824
with const generics
5825
- N= 1
5826
*/
5827
static KRML_MUSTINLINE void
5828
libcrux_sha3_generic_keccak_keccakf1600_80_71(Eurydice_arr_7c *self)
5829
0
{
5830
0
  for (size_t i = (size_t)0U; i < (size_t)24U; i++)
5831
0
  {
5832
0
    size_t i0 = i;
5833
0
    Eurydice_arr_84 t = libcrux_sha3_generic_keccak_theta_80_71(self);
5834
0
    libcrux_sha3_generic_keccak_rho_80_71(self, t);
5835
0
    libcrux_sha3_generic_keccak_pi_80_71(self);
5836
0
    libcrux_sha3_generic_keccak_chi_80_71(self);
5837
0
    libcrux_sha3_generic_keccak_iota_80_71(self, i0);
5838
0
  }
5839
0
}
5840
5841
/**
5842
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5843
*/
5844
/**
5845
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_80
5846
with types uint64_t
5847
with const generics
5848
- N= 1
5849
- RATE= 168
5850
- DELIM= 31
5851
*/
5852
static KRML_MUSTINLINE void
5853
libcrux_sha3_generic_keccak_absorb_final_80_bd(
5854
  Eurydice_arr_7c *self,
5855
  const Eurydice_arr_dc *input,
5856
  size_t start,
5857
  size_t len
5858
)
5859
0
{
5860
0
  libcrux_sha3_simd_portable_load_last_a1_37(self, input, start, len);
5861
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
5862
0
}
5863
5864
/**
5865
 Absorb
5866
*/
5867
static KRML_MUSTINLINE void
5868
libcrux_sha3_portable_incremental_shake128_absorb_final(
5869
  Eurydice_arr_7c *s,
5870
  Eurydice_borrow_slice_u8 data0
5871
)
5872
0
{
5873
  /* original Rust expression is not an lvalue in C */
5874
0
  Eurydice_arr_dc lvalue = { .data = { data0 } };
5875
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd(s, &lvalue, (size_t)0U, data0.meta);
5876
0
}
5877
5878
/**
5879
 Create a new SHAKE-256 state object.
5880
*/
5881
static KRML_MUSTINLINE Eurydice_arr_7c libcrux_sha3_portable_incremental_shake256_init(void)
5882
0
{
5883
0
  return libcrux_sha3_generic_keccak_new_80_71();
5884
0
}
5885
5886
/**
5887
A monomorphic instance of libcrux_sha3.simd.portable.load_block
5888
with const generics
5889
- RATE= 136
5890
*/
5891
static KRML_MUSTINLINE void
5892
libcrux_sha3_simd_portable_load_block_b2(
5893
  Eurydice_arr_7c *state,
5894
  Eurydice_borrow_slice_u8 blocks,
5895
  size_t start
5896
)
5897
0
{
5898
0
  Eurydice_arr_7c state_flat = { .data = { 0U } };
5899
0
  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++)
5900
0
  {
5901
0
    size_t i0 = i;
5902
0
    size_t offset = start + (size_t)8U * i0;
5903
0
    Eurydice_array_u8x8 arr;
5904
0
    memcpy(arr.data,
5905
0
      Eurydice_slice_subslice_shared_c8(blocks,
5906
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = offset, .end = offset + (size_t)8U })).ptr,
5907
0
      (size_t)8U * sizeof (uint8_t));
5908
0
    Eurydice_array_u8x8
5909
0
    uu____0 =
5910
0
      core_result_unwrap_26_e0((
5911
0
          KRML_CLITERAL(core_result_Result_8e){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
5912
0
        ));
5913
0
    state_flat.data[i0] = core_num__u64__from_le_bytes(uu____0);
5914
0
  }
5915
0
  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++)
5916
0
  {
5917
0
    size_t i0 = i;
5918
0
    libcrux_sha3_traits_set_ij_71(state,
5919
0
      i0 / (size_t)5U,
5920
0
      i0 % (size_t)5U,
5921
0
      libcrux_sha3_traits_get_ij_71(state, i0 / (size_t)5U, i0 % (size_t)5U)[0U] ^
5922
0
        state_flat.data[i0]);
5923
0
  }
5924
0
}
5925
5926
/**
5927
A monomorphic instance of libcrux_sha3.simd.portable.load_last
5928
with const generics
5929
- RATE= 136
5930
- DELIMITER= 31
5931
*/
5932
static KRML_MUSTINLINE void
5933
libcrux_sha3_simd_portable_load_last_22(
5934
  Eurydice_arr_7c *state,
5935
  Eurydice_borrow_slice_u8 blocks,
5936
  size_t start,
5937
  size_t len
5938
)
5939
0
{
5940
0
  Eurydice_arr_ff buffer = { .data = { 0U } };
5941
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d42(&buffer,
5942
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = len })),
5943
0
    Eurydice_slice_subslice_shared_c8(blocks,
5944
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = start, .end = start + len })),
5945
0
    uint8_t);
5946
0
  buffer.data[len] = 31U;
5947
0
  size_t uu____0 = (size_t)136U - (size_t)1U;
5948
0
  buffer.data[uu____0] = (uint32_t)buffer.data[uu____0] | 128U;
5949
0
  libcrux_sha3_simd_portable_load_block_b2(state,
5950
0
    Eurydice_array_to_slice_shared_58(&buffer),
5951
0
    (size_t)0U);
5952
0
}
5953
5954
/**
5955
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
5956
*/
5957
/**
5958
A monomorphic instance of libcrux_sha3.simd.portable.load_last_a1
5959
with const generics
5960
- RATE= 136
5961
- DELIMITER= 31
5962
*/
5963
static inline void
5964
libcrux_sha3_simd_portable_load_last_a1_22(
5965
  Eurydice_arr_7c *self,
5966
  const Eurydice_arr_dc *input,
5967
  size_t start,
5968
  size_t len
5969
)
5970
0
{
5971
0
  libcrux_sha3_simd_portable_load_last_22(self, input->data[0U], start, len);
5972
0
}
5973
5974
/**
5975
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
5976
*/
5977
/**
5978
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_80
5979
with types uint64_t
5980
with const generics
5981
- N= 1
5982
- RATE= 136
5983
- DELIM= 31
5984
*/
5985
static KRML_MUSTINLINE void
5986
libcrux_sha3_generic_keccak_absorb_final_80_bd0(
5987
  Eurydice_arr_7c *self,
5988
  const Eurydice_arr_dc *input,
5989
  size_t start,
5990
  size_t len
5991
)
5992
0
{
5993
0
  libcrux_sha3_simd_portable_load_last_a1_22(self, input, start, len);
5994
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
5995
0
}
5996
5997
/**
5998
 Absorb some data for SHAKE-256 for the last time
5999
*/
6000
static KRML_MUSTINLINE void
6001
libcrux_sha3_portable_incremental_shake256_absorb_final(
6002
  Eurydice_arr_7c *s,
6003
  Eurydice_borrow_slice_u8 data
6004
)
6005
0
{
6006
  /* original Rust expression is not an lvalue in C */
6007
0
  Eurydice_arr_dc lvalue = { .data = { data } };
6008
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd0(s, &lvalue, (size_t)0U, data.meta);
6009
0
}
6010
6011
/**
6012
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6013
*/
6014
/**
6015
A monomorphic instance of libcrux_sha3.simd.portable.load_block_a1
6016
with const generics
6017
- RATE= 168
6018
*/
6019
static inline void
6020
libcrux_sha3_simd_portable_load_block_a1_60(
6021
  Eurydice_arr_7c *self,
6022
  const Eurydice_arr_dc *input,
6023
  size_t start
6024
)
6025
0
{
6026
0
  libcrux_sha3_simd_portable_load_block_60(self, input->data[0U], start);
6027
0
}
6028
6029
/**
6030
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
6031
*/
6032
/**
6033
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block_80
6034
with types uint64_t
6035
with const generics
6036
- N= 1
6037
- RATE= 168
6038
*/
6039
static KRML_MUSTINLINE void
6040
libcrux_sha3_generic_keccak_absorb_block_80_e9(
6041
  Eurydice_arr_7c *self,
6042
  const Eurydice_arr_dc *input,
6043
  size_t start
6044
)
6045
0
{
6046
0
  libcrux_sha3_simd_portable_load_block_a1_60(self, input, start);
6047
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6048
0
}
6049
6050
/**
6051
A monomorphic instance of libcrux_sha3.simd.portable.store_block
6052
with const generics
6053
- RATE= 168
6054
*/
6055
static KRML_MUSTINLINE void
6056
libcrux_sha3_simd_portable_store_block_60(
6057
  const Eurydice_arr_7c *s,
6058
  Eurydice_mut_borrow_slice_u8 out,
6059
  size_t start,
6060
  size_t len
6061
)
6062
0
{
6063
0
  size_t octets = len / (size_t)8U;
6064
0
  for (size_t i = (size_t)0U; i < octets; i++)
6065
0
  {
6066
0
    size_t i0 = i;
6067
0
    Eurydice_array_u8x8
6068
0
    bytes =
6069
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
6070
0
          i0 / (size_t)5U,
6071
0
          i0 % (size_t)5U)[0U]);
6072
0
    size_t out_pos = start + (size_t)8U * i0;
6073
0
    Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(out,
6074
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + (size_t)8U })),
6075
0
      Eurydice_array_to_slice_shared_6e(&bytes),
6076
0
      uint8_t);
6077
0
  }
6078
0
  size_t remaining = len % (size_t)8U;
6079
0
  if (remaining > (size_t)0U)
6080
0
  {
6081
0
    Eurydice_array_u8x8
6082
0
    bytes =
6083
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
6084
0
          octets / (size_t)5U,
6085
0
          octets % (size_t)5U)[0U]);
6086
0
    size_t out_pos = start + len - remaining;
6087
0
    Eurydice_mut_borrow_slice_u8
6088
0
    uu____0 =
6089
0
      Eurydice_slice_subslice_mut_c8(out,
6090
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + remaining }));
6091
0
    Eurydice_slice_copy(uu____0,
6092
0
      Eurydice_array_to_subslice_to_shared_21(&bytes, remaining),
6093
0
      uint8_t);
6094
0
  }
6095
0
}
6096
6097
/**
6098
This function found in impl {libcrux_sha3::traits::Squeeze<u64> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6099
*/
6100
/**
6101
A monomorphic instance of libcrux_sha3.simd.portable.squeeze_9b
6102
with const generics
6103
- RATE= 168
6104
*/
6105
static inline void
6106
libcrux_sha3_simd_portable_squeeze_9b_60(
6107
  const Eurydice_arr_7c *self,
6108
  Eurydice_mut_borrow_slice_u8 out,
6109
  size_t start,
6110
  size_t len
6111
)
6112
0
{
6113
0
  libcrux_sha3_simd_portable_store_block_60(self, out, start, len);
6114
0
}
6115
6116
/**
6117
A monomorphic instance of libcrux_sha3.generic_keccak.portable.keccak1
6118
with const generics
6119
- RATE= 168
6120
- DELIM= 31
6121
*/
6122
static inline void
6123
libcrux_sha3_generic_keccak_portable_keccak1_37(
6124
  Eurydice_borrow_slice_u8 input,
6125
  Eurydice_mut_borrow_slice_u8 output
6126
)
6127
0
{
6128
0
  Eurydice_arr_7c s = libcrux_sha3_generic_keccak_new_80_71();
6129
0
  size_t input_len = input.meta;
6130
0
  size_t input_blocks = input_len / (size_t)168U;
6131
0
  size_t input_rem = input_len % (size_t)168U;
6132
0
  for (size_t i = (size_t)0U; i < input_blocks; i++)
6133
0
  {
6134
0
    size_t i0 = i;
6135
0
    /* original Rust expression is not an lvalue in C */
6136
0
    Eurydice_arr_dc lvalue = { .data = { input } };
6137
0
    libcrux_sha3_generic_keccak_absorb_block_80_e9(&s, &lvalue, i0 * (size_t)168U);
6138
0
  }
6139
0
  /* original Rust expression is not an lvalue in C */
6140
0
  Eurydice_arr_dc lvalue = { .data = { input } };
6141
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd(&s, &lvalue, input_len - input_rem, input_rem);
6142
0
  size_t output_len = output.meta;
6143
0
  size_t output_blocks = output_len / (size_t)168U;
6144
0
  size_t output_rem = output_len % (size_t)168U;
6145
0
  if (output_blocks == (size_t)0U)
6146
0
  {
6147
0
    libcrux_sha3_simd_portable_squeeze_9b_60(&s, output, (size_t)0U, output_len);
6148
0
  }
6149
0
  else
6150
0
  {
6151
0
    libcrux_sha3_simd_portable_squeeze_9b_60(&s, output, (size_t)0U, (size_t)168U);
6152
0
    for (size_t i = (size_t)1U; i < output_blocks; i++)
6153
0
    {
6154
0
      size_t i0 = i;
6155
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
6156
0
      libcrux_sha3_simd_portable_squeeze_9b_60(&s, output, i0 * (size_t)168U, (size_t)168U);
6157
0
    }
6158
0
    if (output_rem != (size_t)0U)
6159
0
    {
6160
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
6161
0
      libcrux_sha3_simd_portable_squeeze_9b_60(&s, output, output_len - output_rem, output_rem);
6162
0
    }
6163
0
  }
6164
0
}
6165
6166
/**
6167
 A portable SHAKE128 implementation.
6168
*/
6169
static KRML_MUSTINLINE void
6170
libcrux_sha3_portable_shake128(
6171
  Eurydice_mut_borrow_slice_u8 digest,
6172
  Eurydice_borrow_slice_u8 data
6173
)
6174
0
{
6175
0
  libcrux_sha3_generic_keccak_portable_keccak1_37(data, digest);
6176
0
}
6177
6178
/**
6179
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6180
*/
6181
/**
6182
A monomorphic instance of libcrux_sha3.simd.portable.load_block_a1
6183
with const generics
6184
- RATE= 136
6185
*/
6186
static inline void
6187
libcrux_sha3_simd_portable_load_block_a1_b2(
6188
  Eurydice_arr_7c *self,
6189
  const Eurydice_arr_dc *input,
6190
  size_t start
6191
)
6192
0
{
6193
0
  libcrux_sha3_simd_portable_load_block_b2(self, input->data[0U], start);
6194
0
}
6195
6196
/**
6197
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
6198
*/
6199
/**
6200
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block_80
6201
with types uint64_t
6202
with const generics
6203
- N= 1
6204
- RATE= 136
6205
*/
6206
static KRML_MUSTINLINE void
6207
libcrux_sha3_generic_keccak_absorb_block_80_e90(
6208
  Eurydice_arr_7c *self,
6209
  const Eurydice_arr_dc *input,
6210
  size_t start
6211
)
6212
0
{
6213
0
  libcrux_sha3_simd_portable_load_block_a1_b2(self, input, start);
6214
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6215
0
}
6216
6217
/**
6218
A monomorphic instance of libcrux_sha3.simd.portable.store_block
6219
with const generics
6220
- RATE= 136
6221
*/
6222
static KRML_MUSTINLINE void
6223
libcrux_sha3_simd_portable_store_block_b2(
6224
  const Eurydice_arr_7c *s,
6225
  Eurydice_mut_borrow_slice_u8 out,
6226
  size_t start,
6227
  size_t len
6228
)
6229
0
{
6230
0
  size_t octets = len / (size_t)8U;
6231
0
  for (size_t i = (size_t)0U; i < octets; i++)
6232
0
  {
6233
0
    size_t i0 = i;
6234
0
    Eurydice_array_u8x8
6235
0
    bytes =
6236
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
6237
0
          i0 / (size_t)5U,
6238
0
          i0 % (size_t)5U)[0U]);
6239
0
    size_t out_pos = start + (size_t)8U * i0;
6240
0
    Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(out,
6241
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + (size_t)8U })),
6242
0
      Eurydice_array_to_slice_shared_6e(&bytes),
6243
0
      uint8_t);
6244
0
  }
6245
0
  size_t remaining = len % (size_t)8U;
6246
0
  if (remaining > (size_t)0U)
6247
0
  {
6248
0
    Eurydice_array_u8x8
6249
0
    bytes =
6250
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
6251
0
          octets / (size_t)5U,
6252
0
          octets % (size_t)5U)[0U]);
6253
0
    size_t out_pos = start + len - remaining;
6254
0
    Eurydice_mut_borrow_slice_u8
6255
0
    uu____0 =
6256
0
      Eurydice_slice_subslice_mut_c8(out,
6257
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + remaining }));
6258
0
    Eurydice_slice_copy(uu____0,
6259
0
      Eurydice_array_to_subslice_to_shared_21(&bytes, remaining),
6260
0
      uint8_t);
6261
0
  }
6262
0
}
6263
6264
/**
6265
This function found in impl {libcrux_sha3::traits::Squeeze<u64> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6266
*/
6267
/**
6268
A monomorphic instance of libcrux_sha3.simd.portable.squeeze_9b
6269
with const generics
6270
- RATE= 136
6271
*/
6272
static inline void
6273
libcrux_sha3_simd_portable_squeeze_9b_b2(
6274
  const Eurydice_arr_7c *self,
6275
  Eurydice_mut_borrow_slice_u8 out,
6276
  size_t start,
6277
  size_t len
6278
)
6279
0
{
6280
0
  libcrux_sha3_simd_portable_store_block_b2(self, out, start, len);
6281
0
}
6282
6283
/**
6284
A monomorphic instance of libcrux_sha3.generic_keccak.portable.keccak1
6285
with const generics
6286
- RATE= 136
6287
- DELIM= 31
6288
*/
6289
static inline void
6290
libcrux_sha3_generic_keccak_portable_keccak1_22(
6291
  Eurydice_borrow_slice_u8 input,
6292
  Eurydice_mut_borrow_slice_u8 output
6293
)
6294
0
{
6295
0
  Eurydice_arr_7c s = libcrux_sha3_generic_keccak_new_80_71();
6296
0
  size_t input_len = input.meta;
6297
0
  size_t input_blocks = input_len / (size_t)136U;
6298
0
  size_t input_rem = input_len % (size_t)136U;
6299
0
  for (size_t i = (size_t)0U; i < input_blocks; i++)
6300
0
  {
6301
0
    size_t i0 = i;
6302
    /* original Rust expression is not an lvalue in C */
6303
0
    Eurydice_arr_dc lvalue = { .data = { input } };
6304
0
    libcrux_sha3_generic_keccak_absorb_block_80_e90(&s, &lvalue, i0 * (size_t)136U);
6305
0
  }
6306
  /* original Rust expression is not an lvalue in C */
6307
0
  Eurydice_arr_dc lvalue = { .data = { input } };
6308
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd0(&s, &lvalue, input_len - input_rem, input_rem);
6309
0
  size_t output_len = output.meta;
6310
0
  size_t output_blocks = output_len / (size_t)136U;
6311
0
  size_t output_rem = output_len % (size_t)136U;
6312
0
  if (output_blocks == (size_t)0U)
6313
0
  {
6314
0
    libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, (size_t)0U, output_len);
6315
0
  }
6316
0
  else
6317
0
  {
6318
0
    libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, (size_t)0U, (size_t)136U);
6319
0
    for (size_t i = (size_t)1U; i < output_blocks; i++)
6320
0
    {
6321
0
      size_t i0 = i;
6322
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
6323
0
      libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, i0 * (size_t)136U, (size_t)136U);
6324
0
    }
6325
0
    if (output_rem != (size_t)0U)
6326
0
    {
6327
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
6328
0
      libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, output_len - output_rem, output_rem);
6329
0
    }
6330
0
  }
6331
0
}
6332
6333
/**
6334
 A portable SHAKE256 implementation.
6335
*/
6336
static KRML_MUSTINLINE void
6337
libcrux_sha3_portable_shake256(
6338
  Eurydice_mut_borrow_slice_u8 digest,
6339
  Eurydice_borrow_slice_u8 data
6340
)
6341
0
{
6342
0
  libcrux_sha3_generic_keccak_portable_keccak1_22(data, digest);
6343
0
}
6344
6345
/**
6346
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6347
*/
6348
/**
6349
A monomorphic instance of libcrux_sha3.generic_keccak.portable.squeeze_first_block_b4
6350
with const generics
6351
- RATE= 136
6352
*/
6353
static KRML_MUSTINLINE void
6354
libcrux_sha3_generic_keccak_portable_squeeze_first_block_b4_b2(
6355
  const Eurydice_arr_7c *self,
6356
  Eurydice_mut_borrow_slice_u8 out
6357
)
6358
0
{
6359
0
  libcrux_sha3_simd_portable_squeeze_9b_b2(self, out, (size_t)0U, (size_t)136U);
6360
0
}
6361
6362
/**
6363
 Squeeze the first SHAKE-256 block
6364
*/
6365
static KRML_MUSTINLINE void
6366
libcrux_sha3_portable_incremental_shake256_squeeze_first_block(
6367
  Eurydice_arr_7c *s,
6368
  Eurydice_mut_borrow_slice_u8 out
6369
)
6370
0
{
6371
0
  libcrux_sha3_generic_keccak_portable_squeeze_first_block_b4_b2(&s[0U], out);
6372
0
}
6373
6374
/**
6375
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6376
*/
6377
/**
6378
A monomorphic instance of libcrux_sha3.generic_keccak.portable.squeeze_first_five_blocks_b4
6379
with const generics
6380
- RATE= 168
6381
*/
6382
static KRML_MUSTINLINE void
6383
libcrux_sha3_generic_keccak_portable_squeeze_first_five_blocks_b4_60(
6384
  Eurydice_arr_7c *self,
6385
  Eurydice_mut_borrow_slice_u8 out
6386
)
6387
0
{
6388
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)0U, (size_t)168U);
6389
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6390
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)168U, (size_t)168U);
6391
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6392
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)2U * (size_t)168U, (size_t)168U);
6393
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6394
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)3U * (size_t)168U, (size_t)168U);
6395
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6396
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)4U * (size_t)168U, (size_t)168U);
6397
0
}
6398
6399
/**
6400
 Squeeze five blocks
6401
*/
6402
static KRML_MUSTINLINE void
6403
libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks(
6404
  Eurydice_arr_7c *s,
6405
  Eurydice_mut_borrow_slice_u8 out0
6406
)
6407
0
{
6408
0
  libcrux_sha3_generic_keccak_portable_squeeze_first_five_blocks_b4_60(s, out0);
6409
0
}
6410
6411
/**
6412
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6413
*/
6414
/**
6415
A monomorphic instance of libcrux_sha3.generic_keccak.portable.squeeze_next_block_b4
6416
with const generics
6417
- RATE= 168
6418
*/
6419
static KRML_MUSTINLINE void
6420
libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_60(
6421
  Eurydice_arr_7c *self,
6422
  Eurydice_mut_borrow_slice_u8 out,
6423
  size_t start
6424
)
6425
0
{
6426
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6427
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, start, (size_t)168U);
6428
0
}
6429
6430
/**
6431
 Squeeze another block
6432
*/
6433
static KRML_MUSTINLINE void
6434
libcrux_sha3_portable_incremental_shake128_squeeze_next_block(
6435
  Eurydice_arr_7c *s,
6436
  Eurydice_mut_borrow_slice_u8 out0
6437
)
6438
0
{
6439
0
  libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_60(s, out0, (size_t)0U);
6440
0
}
6441
6442
/**
6443
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6444
*/
6445
/**
6446
A monomorphic instance of libcrux_sha3.generic_keccak.portable.squeeze_next_block_b4
6447
with const generics
6448
- RATE= 136
6449
*/
6450
static KRML_MUSTINLINE void
6451
libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_b2(
6452
  Eurydice_arr_7c *self,
6453
  Eurydice_mut_borrow_slice_u8 out,
6454
  size_t start
6455
)
6456
0
{
6457
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6458
0
  libcrux_sha3_simd_portable_squeeze_9b_b2(self, out, start, (size_t)136U);
6459
0
}
6460
6461
/**
6462
 Squeeze the next SHAKE-256 block
6463
*/
6464
static KRML_MUSTINLINE void
6465
libcrux_sha3_portable_incremental_shake256_squeeze_next_block(
6466
  Eurydice_arr_7c *s,
6467
  Eurydice_mut_borrow_slice_u8 out
6468
)
6469
0
{
6470
0
  libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_b2(s, out, (size_t)0U);
6471
0
}
6472
6473
/**
6474
 Try to complete the internal partial buffer by consuming the minimum required
6475
 number of bytes from the provided `inputs` so that `self.buf` becomes exactly
6476
 one full block of size `RATE`.
6477
6478
 Behaviour:
6479
 - If `self.buf_len` is 0 (no buffered bytes) or already equal to `RATE`
6480
   (already a full block), or if the combined available bytes in `inputs` are
6481
   not enough to reach `RATE`, the function does nothing and returns 0.
6482
 - If `0 < self.buf_len < RATE` and `inputs[..]` contain at least
6483
   `RATE - self.buf_len` bytes, the function copies exactly
6484
   `consumed = RATE - self.buf_len` bytes from each lane `inputs[i]` into
6485
   `self.buf[i]` starting at the current `self.buf_len` offset, sets
6486
   `self.buf_len = RATE`, and returns `consumed`.
6487
6488
 Returns the `consumed` bytes from `inputs` if there's enough buffered
6489
 content to consume, and `0` otherwise.
6490
 If `consumed > 0` is returned, `self.buf` contains a full block to be
6491
 loaded.
6492
*/
6493
/**
6494
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
6495
*/
6496
/**
6497
A monomorphic instance of libcrux_sha3.generic_keccak.xof.fill_buffer_35
6498
with types uint64_t
6499
with const generics
6500
- PARALLEL_LANES= 1
6501
- RATE= 136
6502
*/
6503
static inline size_t
6504
libcrux_sha3_generic_keccak_xof_fill_buffer_35_e9(
6505
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6506
  const Eurydice_arr_dc *inputs
6507
)
6508
0
{
6509
0
  size_t input_len = inputs->data->meta;
6510
0
  size_t uu____0;
6511
0
  if (self->buf_len != (size_t)0U)
6512
0
  {
6513
0
    if (input_len >= (size_t)136U - self->buf_len)
6514
0
    {
6515
0
      size_t consumed = (size_t)136U - self->buf_len;
6516
0
      for (size_t i = (size_t)0U; i < (size_t)1U; i++)
6517
0
      {
6518
0
        size_t i0 = i;
6519
0
        Eurydice_slice_copy(Eurydice_array_to_subslice_from_mut_5f(&self->buf.data[i0],
6520
0
            self->buf_len),
6521
0
          Eurydice_slice_subslice_to_shared_72(inputs->data[i0], consumed),
6522
0
          uint8_t);
6523
0
      }
6524
0
      self->buf_len = (size_t)136U;
6525
0
      uu____0 = consumed;
6526
0
    }
6527
0
    else
6528
0
    {
6529
0
      uu____0 = (size_t)0U;
6530
0
    }
6531
0
  }
6532
0
  else
6533
0
  {
6534
0
    uu____0 = (size_t)0U;
6535
0
  }
6536
0
  return uu____0;
6537
0
}
6538
6539
/**
6540
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices.closure
6541
with const generics
6542
- $1size_t
6543
- $136size_t
6544
*/
6545
typedef const Eurydice_arr_0b *libcrux_sha3_generic_keccak_xof_buf_to_slices_closure_94;
6546
6547
/**
6548
This function found in impl {core::ops::function::FnMut<(usize), &'_ ([u8])> for libcrux_sha3::generic_keccak::xof::buf_to_slices::closure<0, PARALLEL_LANES, RATE>}
6549
*/
6550
/**
6551
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices.call_mut_2a
6552
with const generics
6553
- PARALLEL_LANES= 1
6554
- RATE= 136
6555
*/
6556
static inline Eurydice_borrow_slice_u8
6557
libcrux_sha3_generic_keccak_xof_buf_to_slices_call_mut_2a_81(
6558
  const Eurydice_arr_0b **_,
6559
  size_t tupled_args
6560
)
6561
0
{
6562
0
  size_t i = tupled_args;
6563
0
  return
6564
0
    core_array___T__N___as_slice((size_t)136U,
6565
0
      &_[0U]->data[i],
6566
0
      uint8_t,
6567
0
      Eurydice_borrow_slice_u8);
6568
0
}
6569
6570
/**
6571
This function found in impl {core::ops::function::FnOnce<(usize), &'_ ([u8])> for libcrux_sha3::generic_keccak::xof::buf_to_slices::closure<0, PARALLEL_LANES, RATE>}
6572
*/
6573
/**
6574
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices.call_once_fa
6575
with const generics
6576
- PARALLEL_LANES= 1
6577
- RATE= 136
6578
*/
6579
static inline Eurydice_borrow_slice_u8
6580
libcrux_sha3_generic_keccak_xof_buf_to_slices_call_once_fa_81(
6581
  const Eurydice_arr_0b *_,
6582
  size_t _0
6583
)
6584
0
{
6585
0
  return libcrux_sha3_generic_keccak_xof_buf_to_slices_call_mut_2a_81(&_, _0);
6586
0
}
6587
6588
/**
6589
 Note: This function exists to work around a hax bug where `core::array::from_fn`
6590
 is extracted with an incorrect explicit type parameter `#(usize -> t_Slice u8)`
6591
 instead of using the typeclass-based implicit parameter `#v_F` from
6592
 `Core_models.Array.from_fn`.
6593
 See: https://github.com/cryspen/hax/issues/1920
6594
*/
6595
/**
6596
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices
6597
with const generics
6598
- PARALLEL_LANES= 1
6599
- RATE= 136
6600
*/
6601
static KRML_MUSTINLINE Eurydice_arr_dc
6602
libcrux_sha3_generic_keccak_xof_buf_to_slices_81(const Eurydice_arr_0b *buf)
6603
0
{
6604
0
  Eurydice_arr_dc arr_struct;
6605
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++)
6606
0
  {
6607
0
    arr_struct.data[i] = libcrux_sha3_generic_keccak_xof_buf_to_slices_call_mut_2a_81(&buf, i);
6608
0
  }
6609
0
  return arr_struct;
6610
0
}
6611
6612
/**
6613
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
6614
*/
6615
/**
6616
A monomorphic instance of libcrux_sha3.generic_keccak.xof.absorb_full_35
6617
with types uint64_t
6618
with const generics
6619
- PARALLEL_LANES= 1
6620
- RATE= 136
6621
*/
6622
static inline size_t
6623
libcrux_sha3_generic_keccak_xof_absorb_full_35_e9(
6624
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6625
  const Eurydice_arr_dc *inputs
6626
)
6627
0
{
6628
0
  size_t consumed = libcrux_sha3_generic_keccak_xof_fill_buffer_35_e9(self, inputs);
6629
0
  if (self->buf_len == (size_t)136U)
6630
0
  {
6631
0
    Eurydice_arr_dc borrowed = libcrux_sha3_generic_keccak_xof_buf_to_slices_81(&self->buf);
6632
0
    libcrux_sha3_simd_portable_load_block_a1_b2(&self->inner, &borrowed, (size_t)0U);
6633
0
    libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
6634
0
    self->buf_len = (size_t)0U;
6635
0
  }
6636
0
  size_t input_to_consume = inputs->data->meta - consumed;
6637
0
  size_t num_blocks = input_to_consume / (size_t)136U;
6638
0
  size_t remainder = input_to_consume % (size_t)136U;
6639
0
  for (size_t i = (size_t)0U; i < num_blocks; i++)
6640
0
  {
6641
0
    size_t i0 = i;
6642
0
    size_t start = i0 * (size_t)136U + consumed;
6643
0
    libcrux_sha3_simd_portable_load_block_a1_b2(&self->inner, inputs, start);
6644
0
    libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
6645
0
  }
6646
0
  return remainder;
6647
0
}
6648
6649
/**
6650
 Absorb
6651
6652
 This function takes any number of bytes to absorb and buffers if it's not enough.
6653
 The function assumes that all input slices in `inputs` have the same length.
6654
6655
 Only a multiple of `RATE` blocks are absorbed.
6656
 For the remaining bytes [`absorb_final`] needs to be called.
6657
6658
 This works best with relatively small `inputs`.
6659
*/
6660
/**
6661
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
6662
*/
6663
/**
6664
A monomorphic instance of libcrux_sha3.generic_keccak.xof.absorb_35
6665
with types uint64_t
6666
with const generics
6667
- PARALLEL_LANES= 1
6668
- RATE= 136
6669
*/
6670
static KRML_MUSTINLINE void
6671
libcrux_sha3_generic_keccak_xof_absorb_35_e9(
6672
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6673
  const Eurydice_arr_dc *inputs
6674
)
6675
0
{
6676
0
  size_t remainder = libcrux_sha3_generic_keccak_xof_absorb_full_35_e9(self, inputs);
6677
0
  if (remainder > (size_t)0U)
6678
0
  {
6679
0
    size_t input_len = inputs->data->meta;
6680
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++)
6681
0
    {
6682
0
      size_t i0 = i;
6683
0
      Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d42(&self->buf.data[i0],
6684
0
          (
6685
0
            KRML_CLITERAL(core_ops_range_Range_87){
6686
0
              .start = self->buf_len,
6687
0
              .end = self->buf_len + remainder
6688
0
            }
6689
0
          )),
6690
0
        Eurydice_slice_subslice_shared_c8(inputs->data[i0],
6691
0
          (
6692
0
            KRML_CLITERAL(core_ops_range_Range_87){
6693
0
              .start = input_len - remainder,
6694
0
              .end = input_len
6695
0
            }
6696
0
          )),
6697
0
        uint8_t);
6698
0
    }
6699
0
    self->buf_len += remainder;
6700
0
  }
6701
0
}
6702
6703
/**
6704
 Shake256 absorb
6705
*/
6706
/**
6707
This function found in impl {libcrux_sha3::portable::incremental::Xof<136usize> for libcrux_sha3::portable::incremental::Shake256Xof}
6708
*/
6709
static inline void
6710
libcrux_sha3_portable_incremental_absorb_42(
6711
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6712
  Eurydice_borrow_slice_u8 input
6713
)
6714
0
{
6715
  /* original Rust expression is not an lvalue in C */
6716
0
  Eurydice_arr_dc lvalue = { .data = { input } };
6717
0
  libcrux_sha3_generic_keccak_xof_absorb_35_e9(self, &lvalue);
6718
0
}
6719
6720
/**
6721
 Absorb a final block.
6722
6723
 The `inputs` block may be empty. Everything in the `inputs` block beyond
6724
 `RATE` bytes is ignored.
6725
*/
6726
/**
6727
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
6728
*/
6729
/**
6730
A monomorphic instance of libcrux_sha3.generic_keccak.xof.absorb_final_35
6731
with types uint64_t
6732
with const generics
6733
- PARALLEL_LANES= 1
6734
- RATE= 136
6735
- DELIMITER= 31
6736
*/
6737
static KRML_MUSTINLINE void
6738
libcrux_sha3_generic_keccak_xof_absorb_final_35_bd(
6739
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6740
  const Eurydice_arr_dc *inputs
6741
)
6742
0
{
6743
0
  libcrux_sha3_generic_keccak_xof_absorb_35_e9(self, inputs);
6744
0
  Eurydice_arr_dc borrowed = libcrux_sha3_generic_keccak_xof_buf_to_slices_81(&self->buf);
6745
0
  libcrux_sha3_simd_portable_load_last_a1_22(&self->inner, &borrowed, (size_t)0U, self->buf_len);
6746
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
6747
0
}
6748
6749
/**
6750
 Shake256 absorb final
6751
*/
6752
/**
6753
This function found in impl {libcrux_sha3::portable::incremental::Xof<136usize> for libcrux_sha3::portable::incremental::Shake256Xof}
6754
*/
6755
static inline void
6756
libcrux_sha3_portable_incremental_absorb_final_42(
6757
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6758
  Eurydice_borrow_slice_u8 input
6759
)
6760
0
{
6761
  /* original Rust expression is not an lvalue in C */
6762
0
  Eurydice_arr_dc lvalue = { .data = { input } };
6763
0
  libcrux_sha3_generic_keccak_xof_absorb_final_35_bd(self, &lvalue);
6764
0
}
6765
6766
/**
6767
 An all zero block
6768
*/
6769
/**
6770
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
6771
*/
6772
/**
6773
A monomorphic instance of libcrux_sha3.generic_keccak.xof.zero_block_35
6774
with types uint64_t
6775
with const generics
6776
- PARALLEL_LANES= 1
6777
- RATE= 136
6778
*/
6779
static inline Eurydice_arr_ff libcrux_sha3_generic_keccak_xof_zero_block_35_e9(void)
6780
0
{
6781
0
  return (KRML_CLITERAL(Eurydice_arr_ff){ .data = { 0U } });
6782
0
}
6783
6784
/**
6785
 Generate a new keccak xof state.
6786
*/
6787
/**
6788
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
6789
*/
6790
/**
6791
A monomorphic instance of libcrux_sha3.generic_keccak.xof.new_35
6792
with types uint64_t
6793
with const generics
6794
- PARALLEL_LANES= 1
6795
- RATE= 136
6796
*/
6797
static inline libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
6798
libcrux_sha3_generic_keccak_xof_new_35_e9(void)
6799
0
{
6800
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d lit;
6801
0
  lit.inner = libcrux_sha3_generic_keccak_new_80_71();
6802
0
  Eurydice_arr_ff repeat_expression[1U];
6803
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++)
6804
0
  {
6805
0
    repeat_expression[i] = libcrux_sha3_generic_keccak_xof_zero_block_35_e9();
6806
0
  }
6807
0
  memcpy(lit.buf.data, repeat_expression, (size_t)1U * sizeof (Eurydice_arr_ff));
6808
0
  lit.buf_len = (size_t)0U;
6809
0
  lit.sponge = false;
6810
0
  return lit;
6811
0
}
6812
6813
/**
6814
 Shake256 new state
6815
*/
6816
/**
6817
This function found in impl {libcrux_sha3::portable::incremental::Xof<136usize> for libcrux_sha3::portable::incremental::Shake256Xof}
6818
*/
6819
static inline libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
6820
libcrux_sha3_portable_incremental_new_42(void)
6821
0
{
6822
0
  return libcrux_sha3_generic_keccak_xof_new_35_e9();
6823
0
}
6824
6825
/**
6826
 Squeeze `N` x `LEN` bytes. Only `N = 1` for now.
6827
*/
6828
/**
6829
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, 1usize, RATE>[TraitClause@0, TraitClause@1]}
6830
*/
6831
/**
6832
A monomorphic instance of libcrux_sha3.generic_keccak.xof.squeeze_85
6833
with types uint64_t
6834
with const generics
6835
- RATE= 136
6836
*/
6837
static KRML_MUSTINLINE void
6838
libcrux_sha3_generic_keccak_xof_squeeze_85_76(
6839
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6840
  Eurydice_mut_borrow_slice_u8 out
6841
)
6842
0
{
6843
0
  size_t out_len = out.meta;
6844
0
  if (!(out_len == (size_t)0U))
6845
0
  {
6846
0
    if (self->sponge)
6847
0
    {
6848
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
6849
0
    }
6850
0
    if (out_len > (size_t)0U)
6851
0
    {
6852
0
      size_t blocks = out_len / (size_t)136U;
6853
0
      size_t last = out_len - out_len % (size_t)136U;
6854
0
      if (blocks == (size_t)0U)
6855
0
      {
6856
0
        libcrux_sha3_simd_portable_squeeze_9b_b2(&self->inner, out, (size_t)0U, out_len);
6857
0
      }
6858
0
      else
6859
0
      {
6860
0
        libcrux_sha3_simd_portable_squeeze_9b_b2(&self->inner, out, (size_t)0U, (size_t)136U);
6861
0
        for (size_t i = (size_t)1U; i < blocks; i++)
6862
0
        {
6863
0
          size_t i0 = i;
6864
0
          libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
6865
0
          libcrux_sha3_simd_portable_squeeze_9b_b2(&self->inner,
6866
0
            out,
6867
0
            i0 * (size_t)136U,
6868
0
            (size_t)136U);
6869
0
        }
6870
0
        if (last < out_len)
6871
0
        {
6872
0
          libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
6873
0
          libcrux_sha3_simd_portable_squeeze_9b_b2(&self->inner, out, last, out_len - last);
6874
0
        }
6875
0
      }
6876
0
    }
6877
0
    self->sponge = true;
6878
0
  }
6879
0
}
6880
6881
/**
6882
 Shake256 squeeze
6883
*/
6884
/**
6885
This function found in impl {libcrux_sha3::portable::incremental::Xof<136usize> for libcrux_sha3::portable::incremental::Shake256Xof}
6886
*/
6887
static inline void
6888
libcrux_sha3_portable_incremental_squeeze_42(
6889
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
6890
  Eurydice_mut_borrow_slice_u8 out
6891
)
6892
0
{
6893
0
  libcrux_sha3_generic_keccak_xof_squeeze_85_76(self, out);
6894
0
}
6895
6896
/**
6897
A monomorphic instance of libcrux_sha3.simd.portable.load_block
6898
with const generics
6899
- RATE= 72
6900
*/
6901
static KRML_MUSTINLINE void
6902
libcrux_sha3_simd_portable_load_block_c6(
6903
  Eurydice_arr_7c *state,
6904
  Eurydice_borrow_slice_u8 blocks,
6905
  size_t start
6906
)
6907
0
{
6908
0
  Eurydice_arr_7c state_flat = { .data = { 0U } };
6909
0
  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++)
6910
0
  {
6911
0
    size_t i0 = i;
6912
0
    size_t offset = start + (size_t)8U * i0;
6913
0
    Eurydice_array_u8x8 arr;
6914
0
    memcpy(arr.data,
6915
0
      Eurydice_slice_subslice_shared_c8(blocks,
6916
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = offset, .end = offset + (size_t)8U })).ptr,
6917
0
      (size_t)8U * sizeof (uint8_t));
6918
0
    Eurydice_array_u8x8
6919
0
    uu____0 =
6920
0
      core_result_unwrap_26_e0((
6921
0
          KRML_CLITERAL(core_result_Result_8e){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
6922
0
        ));
6923
0
    state_flat.data[i0] = core_num__u64__from_le_bytes(uu____0);
6924
0
  }
6925
0
  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++)
6926
0
  {
6927
0
    size_t i0 = i;
6928
0
    libcrux_sha3_traits_set_ij_71(state,
6929
0
      i0 / (size_t)5U,
6930
0
      i0 % (size_t)5U,
6931
0
      libcrux_sha3_traits_get_ij_71(state, i0 / (size_t)5U, i0 % (size_t)5U)[0U] ^
6932
0
        state_flat.data[i0]);
6933
0
  }
6934
0
}
6935
6936
/**
6937
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
6938
*/
6939
/**
6940
A monomorphic instance of libcrux_sha3.simd.portable.load_block_a1
6941
with const generics
6942
- RATE= 72
6943
*/
6944
static inline void
6945
libcrux_sha3_simd_portable_load_block_a1_c6(
6946
  Eurydice_arr_7c *self,
6947
  const Eurydice_arr_dc *input,
6948
  size_t start
6949
)
6950
0
{
6951
0
  libcrux_sha3_simd_portable_load_block_c6(self, input->data[0U], start);
6952
0
}
6953
6954
/**
6955
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
6956
*/
6957
/**
6958
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block_80
6959
with types uint64_t
6960
with const generics
6961
- N= 1
6962
- RATE= 72
6963
*/
6964
static KRML_MUSTINLINE void
6965
libcrux_sha3_generic_keccak_absorb_block_80_e91(
6966
  Eurydice_arr_7c *self,
6967
  const Eurydice_arr_dc *input,
6968
  size_t start
6969
)
6970
0
{
6971
0
  libcrux_sha3_simd_portable_load_block_a1_c6(self, input, start);
6972
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
6973
0
}
6974
6975
/**
6976
A monomorphic instance of libcrux_sha3.simd.portable.load_last
6977
with const generics
6978
- RATE= 72
6979
- DELIMITER= 6
6980
*/
6981
static KRML_MUSTINLINE void
6982
libcrux_sha3_simd_portable_load_last_dc(
6983
  Eurydice_arr_7c *state,
6984
  Eurydice_borrow_slice_u8 blocks,
6985
  size_t start,
6986
  size_t len
6987
)
6988
0
{
6989
0
  Eurydice_arr_ab buffer = { .data = { 0U } };
6990
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d43(&buffer,
6991
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = len })),
6992
0
    Eurydice_slice_subslice_shared_c8(blocks,
6993
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = start, .end = start + len })),
6994
0
    uint8_t);
6995
0
  buffer.data[len] = 6U;
6996
0
  size_t uu____0 = (size_t)72U - (size_t)1U;
6997
0
  buffer.data[uu____0] = (uint32_t)buffer.data[uu____0] | 128U;
6998
0
  libcrux_sha3_simd_portable_load_block_c6(state,
6999
0
    Eurydice_array_to_slice_shared_e2(&buffer),
7000
0
    (size_t)0U);
7001
0
}
7002
7003
/**
7004
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7005
*/
7006
/**
7007
A monomorphic instance of libcrux_sha3.simd.portable.load_last_a1
7008
with const generics
7009
- RATE= 72
7010
- DELIMITER= 6
7011
*/
7012
static inline void
7013
libcrux_sha3_simd_portable_load_last_a1_dc(
7014
  Eurydice_arr_7c *self,
7015
  const Eurydice_arr_dc *input,
7016
  size_t start,
7017
  size_t len
7018
)
7019
0
{
7020
0
  libcrux_sha3_simd_portable_load_last_dc(self, input->data[0U], start, len);
7021
0
}
7022
7023
/**
7024
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
7025
*/
7026
/**
7027
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_80
7028
with types uint64_t
7029
with const generics
7030
- N= 1
7031
- RATE= 72
7032
- DELIM= 6
7033
*/
7034
static KRML_MUSTINLINE void
7035
libcrux_sha3_generic_keccak_absorb_final_80_bd1(
7036
  Eurydice_arr_7c *self,
7037
  const Eurydice_arr_dc *input,
7038
  size_t start,
7039
  size_t len
7040
)
7041
0
{
7042
0
  libcrux_sha3_simd_portable_load_last_a1_dc(self, input, start, len);
7043
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7044
0
}
7045
7046
/**
7047
A monomorphic instance of libcrux_sha3.simd.portable.store_block
7048
with const generics
7049
- RATE= 72
7050
*/
7051
static KRML_MUSTINLINE void
7052
libcrux_sha3_simd_portable_store_block_c6(
7053
  const Eurydice_arr_7c *s,
7054
  Eurydice_mut_borrow_slice_u8 out,
7055
  size_t start,
7056
  size_t len
7057
)
7058
0
{
7059
0
  size_t octets = len / (size_t)8U;
7060
0
  for (size_t i = (size_t)0U; i < octets; i++)
7061
0
  {
7062
0
    size_t i0 = i;
7063
0
    Eurydice_array_u8x8
7064
0
    bytes =
7065
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
7066
0
          i0 / (size_t)5U,
7067
0
          i0 % (size_t)5U)[0U]);
7068
0
    size_t out_pos = start + (size_t)8U * i0;
7069
0
    Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(out,
7070
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + (size_t)8U })),
7071
0
      Eurydice_array_to_slice_shared_6e(&bytes),
7072
0
      uint8_t);
7073
0
  }
7074
0
  size_t remaining = len % (size_t)8U;
7075
0
  if (remaining > (size_t)0U)
7076
0
  {
7077
0
    Eurydice_array_u8x8
7078
0
    bytes =
7079
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
7080
0
          octets / (size_t)5U,
7081
0
          octets % (size_t)5U)[0U]);
7082
0
    size_t out_pos = start + len - remaining;
7083
0
    Eurydice_mut_borrow_slice_u8
7084
0
    uu____0 =
7085
0
      Eurydice_slice_subslice_mut_c8(out,
7086
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + remaining }));
7087
0
    Eurydice_slice_copy(uu____0,
7088
0
      Eurydice_array_to_subslice_to_shared_21(&bytes, remaining),
7089
0
      uint8_t);
7090
0
  }
7091
0
}
7092
7093
/**
7094
This function found in impl {libcrux_sha3::traits::Squeeze<u64> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7095
*/
7096
/**
7097
A monomorphic instance of libcrux_sha3.simd.portable.squeeze_9b
7098
with const generics
7099
- RATE= 72
7100
*/
7101
static inline void
7102
libcrux_sha3_simd_portable_squeeze_9b_c6(
7103
  const Eurydice_arr_7c *self,
7104
  Eurydice_mut_borrow_slice_u8 out,
7105
  size_t start,
7106
  size_t len
7107
)
7108
0
{
7109
0
  libcrux_sha3_simd_portable_store_block_c6(self, out, start, len);
7110
0
}
7111
7112
/**
7113
A monomorphic instance of libcrux_sha3.generic_keccak.portable.keccak1
7114
with const generics
7115
- RATE= 72
7116
- DELIM= 6
7117
*/
7118
static inline void
7119
libcrux_sha3_generic_keccak_portable_keccak1_dc(
7120
  Eurydice_borrow_slice_u8 input,
7121
  Eurydice_mut_borrow_slice_u8 output
7122
)
7123
0
{
7124
0
  Eurydice_arr_7c s = libcrux_sha3_generic_keccak_new_80_71();
7125
0
  size_t input_len = input.meta;
7126
0
  size_t input_blocks = input_len / (size_t)72U;
7127
0
  size_t input_rem = input_len % (size_t)72U;
7128
0
  for (size_t i = (size_t)0U; i < input_blocks; i++)
7129
0
  {
7130
0
    size_t i0 = i;
7131
    /* original Rust expression is not an lvalue in C */
7132
0
    Eurydice_arr_dc lvalue = { .data = { input } };
7133
0
    libcrux_sha3_generic_keccak_absorb_block_80_e91(&s, &lvalue, i0 * (size_t)72U);
7134
0
  }
7135
  /* original Rust expression is not an lvalue in C */
7136
0
  Eurydice_arr_dc lvalue = { .data = { input } };
7137
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd1(&s, &lvalue, input_len - input_rem, input_rem);
7138
0
  size_t output_len = output.meta;
7139
0
  size_t output_blocks = output_len / (size_t)72U;
7140
0
  size_t output_rem = output_len % (size_t)72U;
7141
0
  if (output_blocks == (size_t)0U)
7142
0
  {
7143
0
    libcrux_sha3_simd_portable_squeeze_9b_c6(&s, output, (size_t)0U, output_len);
7144
0
  }
7145
0
  else
7146
0
  {
7147
0
    libcrux_sha3_simd_portable_squeeze_9b_c6(&s, output, (size_t)0U, (size_t)72U);
7148
0
    for (size_t i = (size_t)1U; i < output_blocks; i++)
7149
0
    {
7150
0
      size_t i0 = i;
7151
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7152
0
      libcrux_sha3_simd_portable_squeeze_9b_c6(&s, output, i0 * (size_t)72U, (size_t)72U);
7153
0
    }
7154
0
    if (output_rem != (size_t)0U)
7155
0
    {
7156
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7157
0
      libcrux_sha3_simd_portable_squeeze_9b_c6(&s, output, output_len - output_rem, output_rem);
7158
0
    }
7159
0
  }
7160
0
}
7161
7162
/**
7163
 A portable SHA3 512 implementation.
7164
*/
7165
static KRML_MUSTINLINE void
7166
libcrux_sha3_portable_sha512(
7167
  Eurydice_mut_borrow_slice_u8 digest,
7168
  Eurydice_borrow_slice_u8 data
7169
)
7170
0
{
7171
0
  libcrux_sha3_generic_keccak_portable_keccak1_dc(data, digest);
7172
0
}
7173
7174
/**
7175
A monomorphic instance of libcrux_sha3.simd.portable.load_last
7176
with const generics
7177
- RATE= 136
7178
- DELIMITER= 6
7179
*/
7180
static KRML_MUSTINLINE void
7181
libcrux_sha3_simd_portable_load_last_220(
7182
  Eurydice_arr_7c *state,
7183
  Eurydice_borrow_slice_u8 blocks,
7184
  size_t start,
7185
  size_t len
7186
)
7187
0
{
7188
0
  Eurydice_arr_ff buffer = { .data = { 0U } };
7189
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d42(&buffer,
7190
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = len })),
7191
0
    Eurydice_slice_subslice_shared_c8(blocks,
7192
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = start, .end = start + len })),
7193
0
    uint8_t);
7194
0
  buffer.data[len] = 6U;
7195
0
  size_t uu____0 = (size_t)136U - (size_t)1U;
7196
0
  buffer.data[uu____0] = (uint32_t)buffer.data[uu____0] | 128U;
7197
0
  libcrux_sha3_simd_portable_load_block_b2(state,
7198
0
    Eurydice_array_to_slice_shared_58(&buffer),
7199
0
    (size_t)0U);
7200
0
}
7201
7202
/**
7203
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7204
*/
7205
/**
7206
A monomorphic instance of libcrux_sha3.simd.portable.load_last_a1
7207
with const generics
7208
- RATE= 136
7209
- DELIMITER= 6
7210
*/
7211
static inline void
7212
libcrux_sha3_simd_portable_load_last_a1_220(
7213
  Eurydice_arr_7c *self,
7214
  const Eurydice_arr_dc *input,
7215
  size_t start,
7216
  size_t len
7217
)
7218
0
{
7219
0
  libcrux_sha3_simd_portable_load_last_220(self, input->data[0U], start, len);
7220
0
}
7221
7222
/**
7223
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
7224
*/
7225
/**
7226
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_80
7227
with types uint64_t
7228
with const generics
7229
- N= 1
7230
- RATE= 136
7231
- DELIM= 6
7232
*/
7233
static KRML_MUSTINLINE void
7234
libcrux_sha3_generic_keccak_absorb_final_80_bd2(
7235
  Eurydice_arr_7c *self,
7236
  const Eurydice_arr_dc *input,
7237
  size_t start,
7238
  size_t len
7239
)
7240
0
{
7241
0
  libcrux_sha3_simd_portable_load_last_a1_220(self, input, start, len);
7242
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7243
0
}
7244
7245
/**
7246
A monomorphic instance of libcrux_sha3.generic_keccak.portable.keccak1
7247
with const generics
7248
- RATE= 136
7249
- DELIM= 6
7250
*/
7251
static inline void
7252
libcrux_sha3_generic_keccak_portable_keccak1_220(
7253
  Eurydice_borrow_slice_u8 input,
7254
  Eurydice_mut_borrow_slice_u8 output
7255
)
7256
0
{
7257
0
  Eurydice_arr_7c s = libcrux_sha3_generic_keccak_new_80_71();
7258
0
  size_t input_len = input.meta;
7259
0
  size_t input_blocks = input_len / (size_t)136U;
7260
0
  size_t input_rem = input_len % (size_t)136U;
7261
0
  for (size_t i = (size_t)0U; i < input_blocks; i++)
7262
0
  {
7263
0
    size_t i0 = i;
7264
    /* original Rust expression is not an lvalue in C */
7265
0
    Eurydice_arr_dc lvalue = { .data = { input } };
7266
0
    libcrux_sha3_generic_keccak_absorb_block_80_e90(&s, &lvalue, i0 * (size_t)136U);
7267
0
  }
7268
  /* original Rust expression is not an lvalue in C */
7269
0
  Eurydice_arr_dc lvalue = { .data = { input } };
7270
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd2(&s, &lvalue, input_len - input_rem, input_rem);
7271
0
  size_t output_len = output.meta;
7272
0
  size_t output_blocks = output_len / (size_t)136U;
7273
0
  size_t output_rem = output_len % (size_t)136U;
7274
0
  if (output_blocks == (size_t)0U)
7275
0
  {
7276
0
    libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, (size_t)0U, output_len);
7277
0
  }
7278
0
  else
7279
0
  {
7280
0
    libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, (size_t)0U, (size_t)136U);
7281
0
    for (size_t i = (size_t)1U; i < output_blocks; i++)
7282
0
    {
7283
0
      size_t i0 = i;
7284
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7285
0
      libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, i0 * (size_t)136U, (size_t)136U);
7286
0
    }
7287
0
    if (output_rem != (size_t)0U)
7288
0
    {
7289
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7290
0
      libcrux_sha3_simd_portable_squeeze_9b_b2(&s, output, output_len - output_rem, output_rem);
7291
0
    }
7292
0
  }
7293
0
}
7294
7295
/**
7296
 A portable SHA3 256 implementation.
7297
*/
7298
static KRML_MUSTINLINE void
7299
libcrux_sha3_portable_sha256(
7300
  Eurydice_mut_borrow_slice_u8 digest,
7301
  Eurydice_borrow_slice_u8 data
7302
)
7303
0
{
7304
0
  libcrux_sha3_generic_keccak_portable_keccak1_220(data, digest);
7305
0
}
7306
7307
/**
7308
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7309
*/
7310
/**
7311
A monomorphic instance of libcrux_sha3.generic_keccak.portable.squeeze_first_three_blocks_b4
7312
with const generics
7313
- RATE= 168
7314
*/
7315
static KRML_MUSTINLINE void
7316
libcrux_sha3_generic_keccak_portable_squeeze_first_three_blocks_b4_60(
7317
  Eurydice_arr_7c *self,
7318
  Eurydice_mut_borrow_slice_u8 out
7319
)
7320
0
{
7321
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)0U, (size_t)168U);
7322
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7323
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)168U, (size_t)168U);
7324
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7325
0
  libcrux_sha3_simd_portable_squeeze_9b_60(self, out, (size_t)2U * (size_t)168U, (size_t)168U);
7326
0
}
7327
7328
/**
7329
 Squeeze three blocks
7330
*/
7331
static KRML_MUSTINLINE void
7332
libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(
7333
  Eurydice_arr_7c *s,
7334
  Eurydice_mut_borrow_slice_u8 out0
7335
)
7336
0
{
7337
0
  libcrux_sha3_generic_keccak_portable_squeeze_first_three_blocks_b4_60(s, out0);
7338
0
}
7339
7340
#define libcrux_sha3_Algorithm_Sha224 1
7341
#define libcrux_sha3_Algorithm_Sha256 2
7342
#define libcrux_sha3_Algorithm_Sha384 3
7343
#define libcrux_sha3_Algorithm_Sha512 4
7344
7345
typedef uint8_t libcrux_sha3_Algorithm;
7346
7347
#define LIBCRUX_SHA3_SHA3_224_DIGEST_SIZE ((size_t)28U)
7348
7349
#define LIBCRUX_SHA3_SHA3_256_DIGEST_SIZE ((size_t)32U)
7350
7351
#define LIBCRUX_SHA3_SHA3_384_DIGEST_SIZE ((size_t)48U)
7352
7353
#define LIBCRUX_SHA3_SHA3_512_DIGEST_SIZE ((size_t)64U)
7354
7355
/**
7356
 Returns the output size of a digest.
7357
*/
7358
static inline size_t libcrux_sha3_digest_size(libcrux_sha3_Algorithm mode)
7359
0
{
7360
0
  switch (mode)
7361
0
  {
7362
0
    case libcrux_sha3_Algorithm_Sha224:
7363
0
      {
7364
0
        break;
7365
0
      }
7366
0
    case libcrux_sha3_Algorithm_Sha256:
7367
0
      {
7368
0
        return LIBCRUX_SHA3_SHA3_256_DIGEST_SIZE;
7369
0
      }
7370
0
    case libcrux_sha3_Algorithm_Sha384:
7371
0
      {
7372
0
        return LIBCRUX_SHA3_SHA3_384_DIGEST_SIZE;
7373
0
      }
7374
0
    case libcrux_sha3_Algorithm_Sha512:
7375
0
      {
7376
0
        return LIBCRUX_SHA3_SHA3_512_DIGEST_SIZE;
7377
0
      }
7378
0
    default:
7379
0
      {
7380
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
7381
0
        KRML_HOST_EXIT(253U);
7382
0
      }
7383
0
  }
7384
0
  return LIBCRUX_SHA3_SHA3_224_DIGEST_SIZE;
7385
0
}
7386
7387
/**
7388
A monomorphic instance of libcrux_sha3.simd.portable.load_block
7389
with const generics
7390
- RATE= 144
7391
*/
7392
static KRML_MUSTINLINE void
7393
libcrux_sha3_simd_portable_load_block_9e(
7394
  Eurydice_arr_7c *state,
7395
  Eurydice_borrow_slice_u8 blocks,
7396
  size_t start
7397
)
7398
0
{
7399
0
  Eurydice_arr_7c state_flat = { .data = { 0U } };
7400
0
  for (size_t i = (size_t)0U; i < (size_t)144U / (size_t)8U; i++)
7401
0
  {
7402
0
    size_t i0 = i;
7403
0
    size_t offset = start + (size_t)8U * i0;
7404
0
    Eurydice_array_u8x8 arr;
7405
0
    memcpy(arr.data,
7406
0
      Eurydice_slice_subslice_shared_c8(blocks,
7407
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = offset, .end = offset + (size_t)8U })).ptr,
7408
0
      (size_t)8U * sizeof (uint8_t));
7409
0
    Eurydice_array_u8x8
7410
0
    uu____0 =
7411
0
      core_result_unwrap_26_e0((
7412
0
          KRML_CLITERAL(core_result_Result_8e){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
7413
0
        ));
7414
0
    state_flat.data[i0] = core_num__u64__from_le_bytes(uu____0);
7415
0
  }
7416
0
  for (size_t i = (size_t)0U; i < (size_t)144U / (size_t)8U; i++)
7417
0
  {
7418
0
    size_t i0 = i;
7419
0
    libcrux_sha3_traits_set_ij_71(state,
7420
0
      i0 / (size_t)5U,
7421
0
      i0 % (size_t)5U,
7422
0
      libcrux_sha3_traits_get_ij_71(state, i0 / (size_t)5U, i0 % (size_t)5U)[0U] ^
7423
0
        state_flat.data[i0]);
7424
0
  }
7425
0
}
7426
7427
/**
7428
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7429
*/
7430
/**
7431
A monomorphic instance of libcrux_sha3.simd.portable.load_block_a1
7432
with const generics
7433
- RATE= 144
7434
*/
7435
static inline void
7436
libcrux_sha3_simd_portable_load_block_a1_9e(
7437
  Eurydice_arr_7c *self,
7438
  const Eurydice_arr_dc *input,
7439
  size_t start
7440
)
7441
0
{
7442
0
  libcrux_sha3_simd_portable_load_block_9e(self, input->data[0U], start);
7443
0
}
7444
7445
/**
7446
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
7447
*/
7448
/**
7449
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block_80
7450
with types uint64_t
7451
with const generics
7452
- N= 1
7453
- RATE= 144
7454
*/
7455
static KRML_MUSTINLINE void
7456
libcrux_sha3_generic_keccak_absorb_block_80_e92(
7457
  Eurydice_arr_7c *self,
7458
  const Eurydice_arr_dc *input,
7459
  size_t start
7460
)
7461
0
{
7462
0
  libcrux_sha3_simd_portable_load_block_a1_9e(self, input, start);
7463
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7464
0
}
7465
7466
/**
7467
A monomorphic instance of libcrux_sha3.simd.portable.load_last
7468
with const generics
7469
- RATE= 144
7470
- DELIMITER= 6
7471
*/
7472
static KRML_MUSTINLINE void
7473
libcrux_sha3_simd_portable_load_last_3a(
7474
  Eurydice_arr_7c *state,
7475
  Eurydice_borrow_slice_u8 blocks,
7476
  size_t start,
7477
  size_t len
7478
)
7479
0
{
7480
0
  Eurydice_arr_f4 buffer = { .data = { 0U } };
7481
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d44(&buffer,
7482
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = len })),
7483
0
    Eurydice_slice_subslice_shared_c8(blocks,
7484
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = start, .end = start + len })),
7485
0
    uint8_t);
7486
0
  buffer.data[len] = 6U;
7487
0
  size_t uu____0 = (size_t)144U - (size_t)1U;
7488
0
  buffer.data[uu____0] = (uint32_t)buffer.data[uu____0] | 128U;
7489
0
  libcrux_sha3_simd_portable_load_block_9e(state,
7490
0
    Eurydice_array_to_slice_shared_38(&buffer),
7491
0
    (size_t)0U);
7492
0
}
7493
7494
/**
7495
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7496
*/
7497
/**
7498
A monomorphic instance of libcrux_sha3.simd.portable.load_last_a1
7499
with const generics
7500
- RATE= 144
7501
- DELIMITER= 6
7502
*/
7503
static inline void
7504
libcrux_sha3_simd_portable_load_last_a1_3a(
7505
  Eurydice_arr_7c *self,
7506
  const Eurydice_arr_dc *input,
7507
  size_t start,
7508
  size_t len
7509
)
7510
0
{
7511
0
  libcrux_sha3_simd_portable_load_last_3a(self, input->data[0U], start, len);
7512
0
}
7513
7514
/**
7515
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
7516
*/
7517
/**
7518
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_80
7519
with types uint64_t
7520
with const generics
7521
- N= 1
7522
- RATE= 144
7523
- DELIM= 6
7524
*/
7525
static KRML_MUSTINLINE void
7526
libcrux_sha3_generic_keccak_absorb_final_80_bd3(
7527
  Eurydice_arr_7c *self,
7528
  const Eurydice_arr_dc *input,
7529
  size_t start,
7530
  size_t len
7531
)
7532
0
{
7533
0
  libcrux_sha3_simd_portable_load_last_a1_3a(self, input, start, len);
7534
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7535
0
}
7536
7537
/**
7538
A monomorphic instance of libcrux_sha3.simd.portable.store_block
7539
with const generics
7540
- RATE= 144
7541
*/
7542
static KRML_MUSTINLINE void
7543
libcrux_sha3_simd_portable_store_block_9e(
7544
  const Eurydice_arr_7c *s,
7545
  Eurydice_mut_borrow_slice_u8 out,
7546
  size_t start,
7547
  size_t len
7548
)
7549
0
{
7550
0
  size_t octets = len / (size_t)8U;
7551
0
  for (size_t i = (size_t)0U; i < octets; i++)
7552
0
  {
7553
0
    size_t i0 = i;
7554
0
    Eurydice_array_u8x8
7555
0
    bytes =
7556
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
7557
0
          i0 / (size_t)5U,
7558
0
          i0 % (size_t)5U)[0U]);
7559
0
    size_t out_pos = start + (size_t)8U * i0;
7560
0
    Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(out,
7561
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + (size_t)8U })),
7562
0
      Eurydice_array_to_slice_shared_6e(&bytes),
7563
0
      uint8_t);
7564
0
  }
7565
0
  size_t remaining = len % (size_t)8U;
7566
0
  if (remaining > (size_t)0U)
7567
0
  {
7568
0
    Eurydice_array_u8x8
7569
0
    bytes =
7570
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
7571
0
          octets / (size_t)5U,
7572
0
          octets % (size_t)5U)[0U]);
7573
0
    size_t out_pos = start + len - remaining;
7574
0
    Eurydice_mut_borrow_slice_u8
7575
0
    uu____0 =
7576
0
      Eurydice_slice_subslice_mut_c8(out,
7577
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + remaining }));
7578
0
    Eurydice_slice_copy(uu____0,
7579
0
      Eurydice_array_to_subslice_to_shared_21(&bytes, remaining),
7580
0
      uint8_t);
7581
0
  }
7582
0
}
7583
7584
/**
7585
This function found in impl {libcrux_sha3::traits::Squeeze<u64> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7586
*/
7587
/**
7588
A monomorphic instance of libcrux_sha3.simd.portable.squeeze_9b
7589
with const generics
7590
- RATE= 144
7591
*/
7592
static inline void
7593
libcrux_sha3_simd_portable_squeeze_9b_9e(
7594
  const Eurydice_arr_7c *self,
7595
  Eurydice_mut_borrow_slice_u8 out,
7596
  size_t start,
7597
  size_t len
7598
)
7599
0
{
7600
0
  libcrux_sha3_simd_portable_store_block_9e(self, out, start, len);
7601
0
}
7602
7603
/**
7604
A monomorphic instance of libcrux_sha3.generic_keccak.portable.keccak1
7605
with const generics
7606
- RATE= 144
7607
- DELIM= 6
7608
*/
7609
static inline void
7610
libcrux_sha3_generic_keccak_portable_keccak1_3a(
7611
  Eurydice_borrow_slice_u8 input,
7612
  Eurydice_mut_borrow_slice_u8 output
7613
)
7614
0
{
7615
0
  Eurydice_arr_7c s = libcrux_sha3_generic_keccak_new_80_71();
7616
0
  size_t input_len = input.meta;
7617
0
  size_t input_blocks = input_len / (size_t)144U;
7618
0
  size_t input_rem = input_len % (size_t)144U;
7619
0
  for (size_t i = (size_t)0U; i < input_blocks; i++)
7620
0
  {
7621
0
    size_t i0 = i;
7622
0
    /* original Rust expression is not an lvalue in C */
7623
0
    Eurydice_arr_dc lvalue = { .data = { input } };
7624
0
    libcrux_sha3_generic_keccak_absorb_block_80_e92(&s, &lvalue, i0 * (size_t)144U);
7625
0
  }
7626
0
  /* original Rust expression is not an lvalue in C */
7627
0
  Eurydice_arr_dc lvalue = { .data = { input } };
7628
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd3(&s, &lvalue, input_len - input_rem, input_rem);
7629
0
  size_t output_len = output.meta;
7630
0
  size_t output_blocks = output_len / (size_t)144U;
7631
0
  size_t output_rem = output_len % (size_t)144U;
7632
0
  if (output_blocks == (size_t)0U)
7633
0
  {
7634
0
    libcrux_sha3_simd_portable_squeeze_9b_9e(&s, output, (size_t)0U, output_len);
7635
0
  }
7636
0
  else
7637
0
  {
7638
0
    libcrux_sha3_simd_portable_squeeze_9b_9e(&s, output, (size_t)0U, (size_t)144U);
7639
0
    for (size_t i = (size_t)1U; i < output_blocks; i++)
7640
0
    {
7641
0
      size_t i0 = i;
7642
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7643
0
      libcrux_sha3_simd_portable_squeeze_9b_9e(&s, output, i0 * (size_t)144U, (size_t)144U);
7644
0
    }
7645
0
    if (output_rem != (size_t)0U)
7646
0
    {
7647
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7648
0
      libcrux_sha3_simd_portable_squeeze_9b_9e(&s, output, output_len - output_rem, output_rem);
7649
0
    }
7650
0
  }
7651
0
}
7652
7653
/**
7654
 A portable SHA3 224 implementation.
7655
*/
7656
static KRML_MUSTINLINE void
7657
libcrux_sha3_portable_sha224(
7658
  Eurydice_mut_borrow_slice_u8 digest,
7659
  Eurydice_borrow_slice_u8 data
7660
)
7661
0
{
7662
0
  libcrux_sha3_generic_keccak_portable_keccak1_3a(data, digest);
7663
0
}
7664
7665
/**
7666
A monomorphic instance of libcrux_sha3.simd.portable.load_block
7667
with const generics
7668
- RATE= 104
7669
*/
7670
static KRML_MUSTINLINE void
7671
libcrux_sha3_simd_portable_load_block_53(
7672
  Eurydice_arr_7c *state,
7673
  Eurydice_borrow_slice_u8 blocks,
7674
  size_t start
7675
)
7676
0
{
7677
0
  Eurydice_arr_7c state_flat = { .data = { 0U } };
7678
0
  for (size_t i = (size_t)0U; i < (size_t)104U / (size_t)8U; i++)
7679
0
  {
7680
0
    size_t i0 = i;
7681
0
    size_t offset = start + (size_t)8U * i0;
7682
0
    Eurydice_array_u8x8 arr;
7683
0
    memcpy(arr.data,
7684
0
      Eurydice_slice_subslice_shared_c8(blocks,
7685
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = offset, .end = offset + (size_t)8U })).ptr,
7686
0
      (size_t)8U * sizeof (uint8_t));
7687
0
    Eurydice_array_u8x8
7688
0
    uu____0 =
7689
0
      core_result_unwrap_26_e0((
7690
0
          KRML_CLITERAL(core_result_Result_8e){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
7691
0
        ));
7692
0
    state_flat.data[i0] = core_num__u64__from_le_bytes(uu____0);
7693
0
  }
7694
0
  for (size_t i = (size_t)0U; i < (size_t)104U / (size_t)8U; i++)
7695
0
  {
7696
0
    size_t i0 = i;
7697
0
    libcrux_sha3_traits_set_ij_71(state,
7698
0
      i0 / (size_t)5U,
7699
0
      i0 % (size_t)5U,
7700
0
      libcrux_sha3_traits_get_ij_71(state, i0 / (size_t)5U, i0 % (size_t)5U)[0U] ^
7701
0
        state_flat.data[i0]);
7702
0
  }
7703
0
}
7704
7705
/**
7706
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7707
*/
7708
/**
7709
A monomorphic instance of libcrux_sha3.simd.portable.load_block_a1
7710
with const generics
7711
- RATE= 104
7712
*/
7713
static inline void
7714
libcrux_sha3_simd_portable_load_block_a1_53(
7715
  Eurydice_arr_7c *self,
7716
  const Eurydice_arr_dc *input,
7717
  size_t start
7718
)
7719
0
{
7720
0
  libcrux_sha3_simd_portable_load_block_53(self, input->data[0U], start);
7721
0
}
7722
7723
/**
7724
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
7725
*/
7726
/**
7727
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block_80
7728
with types uint64_t
7729
with const generics
7730
- N= 1
7731
- RATE= 104
7732
*/
7733
static KRML_MUSTINLINE void
7734
libcrux_sha3_generic_keccak_absorb_block_80_e93(
7735
  Eurydice_arr_7c *self,
7736
  const Eurydice_arr_dc *input,
7737
  size_t start
7738
)
7739
0
{
7740
0
  libcrux_sha3_simd_portable_load_block_a1_53(self, input, start);
7741
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7742
0
}
7743
7744
/**
7745
A monomorphic instance of libcrux_sha3.simd.portable.load_last
7746
with const generics
7747
- RATE= 104
7748
- DELIMITER= 6
7749
*/
7750
static KRML_MUSTINLINE void
7751
libcrux_sha3_simd_portable_load_last_dc0(
7752
  Eurydice_arr_7c *state,
7753
  Eurydice_borrow_slice_u8 blocks,
7754
  size_t start,
7755
  size_t len
7756
)
7757
0
{
7758
0
  Eurydice_arr_c4 buffer = { .data = { 0U } };
7759
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d45(&buffer,
7760
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = len })),
7761
0
    Eurydice_slice_subslice_shared_c8(blocks,
7762
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = start, .end = start + len })),
7763
0
    uint8_t);
7764
0
  buffer.data[len] = 6U;
7765
0
  size_t uu____0 = (size_t)104U - (size_t)1U;
7766
0
  buffer.data[uu____0] = (uint32_t)buffer.data[uu____0] | 128U;
7767
0
  libcrux_sha3_simd_portable_load_block_53(state,
7768
0
    Eurydice_array_to_slice_shared_72(&buffer),
7769
0
    (size_t)0U);
7770
0
}
7771
7772
/**
7773
This function found in impl {libcrux_sha3::traits::Absorb<1usize> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7774
*/
7775
/**
7776
A monomorphic instance of libcrux_sha3.simd.portable.load_last_a1
7777
with const generics
7778
- RATE= 104
7779
- DELIMITER= 6
7780
*/
7781
static inline void
7782
libcrux_sha3_simd_portable_load_last_a1_dc0(
7783
  Eurydice_arr_7c *self,
7784
  const Eurydice_arr_dc *input,
7785
  size_t start,
7786
  size_t len
7787
)
7788
0
{
7789
0
  libcrux_sha3_simd_portable_load_last_dc0(self, input->data[0U], start, len);
7790
0
}
7791
7792
/**
7793
This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, N>[TraitClause@0, TraitClause@1]}
7794
*/
7795
/**
7796
A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_80
7797
with types uint64_t
7798
with const generics
7799
- N= 1
7800
- RATE= 104
7801
- DELIM= 6
7802
*/
7803
static KRML_MUSTINLINE void
7804
libcrux_sha3_generic_keccak_absorb_final_80_bd4(
7805
  Eurydice_arr_7c *self,
7806
  const Eurydice_arr_dc *input,
7807
  size_t start,
7808
  size_t len
7809
)
7810
0
{
7811
0
  libcrux_sha3_simd_portable_load_last_a1_dc0(self, input, start, len);
7812
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(self);
7813
0
}
7814
7815
/**
7816
A monomorphic instance of libcrux_sha3.simd.portable.store_block
7817
with const generics
7818
- RATE= 104
7819
*/
7820
static KRML_MUSTINLINE void
7821
libcrux_sha3_simd_portable_store_block_53(
7822
  const Eurydice_arr_7c *s,
7823
  Eurydice_mut_borrow_slice_u8 out,
7824
  size_t start,
7825
  size_t len
7826
)
7827
0
{
7828
0
  size_t octets = len / (size_t)8U;
7829
0
  for (size_t i = (size_t)0U; i < octets; i++)
7830
0
  {
7831
0
    size_t i0 = i;
7832
0
    Eurydice_array_u8x8
7833
0
    bytes =
7834
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
7835
0
          i0 / (size_t)5U,
7836
0
          i0 % (size_t)5U)[0U]);
7837
0
    size_t out_pos = start + (size_t)8U * i0;
7838
0
    Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(out,
7839
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + (size_t)8U })),
7840
0
      Eurydice_array_to_slice_shared_6e(&bytes),
7841
0
      uint8_t);
7842
0
  }
7843
0
  size_t remaining = len % (size_t)8U;
7844
0
  if (remaining > (size_t)0U)
7845
0
  {
7846
0
    Eurydice_array_u8x8
7847
0
    bytes =
7848
0
      core_num__u64__to_le_bytes(libcrux_sha3_traits_get_ij_71(s,
7849
0
          octets / (size_t)5U,
7850
0
          octets % (size_t)5U)[0U]);
7851
0
    size_t out_pos = start + len - remaining;
7852
0
    Eurydice_mut_borrow_slice_u8
7853
0
    uu____0 =
7854
0
      Eurydice_slice_subslice_mut_c8(out,
7855
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = out_pos, .end = out_pos + remaining }));
7856
0
    Eurydice_slice_copy(uu____0,
7857
0
      Eurydice_array_to_subslice_to_shared_21(&bytes, remaining),
7858
0
      uint8_t);
7859
0
  }
7860
0
}
7861
7862
/**
7863
This function found in impl {libcrux_sha3::traits::Squeeze<u64> for libcrux_sha3::generic_keccak::KeccakState<u64, 1usize>[core::marker::Sized<u64>, libcrux_sha3::simd::portable::{libcrux_sha3::traits::KeccakItem<1usize> for u64}]}
7864
*/
7865
/**
7866
A monomorphic instance of libcrux_sha3.simd.portable.squeeze_9b
7867
with const generics
7868
- RATE= 104
7869
*/
7870
static inline void
7871
libcrux_sha3_simd_portable_squeeze_9b_53(
7872
  const Eurydice_arr_7c *self,
7873
  Eurydice_mut_borrow_slice_u8 out,
7874
  size_t start,
7875
  size_t len
7876
)
7877
0
{
7878
0
  libcrux_sha3_simd_portable_store_block_53(self, out, start, len);
7879
0
}
7880
7881
/**
7882
A monomorphic instance of libcrux_sha3.generic_keccak.portable.keccak1
7883
with const generics
7884
- RATE= 104
7885
- DELIM= 6
7886
*/
7887
static inline void
7888
libcrux_sha3_generic_keccak_portable_keccak1_dc0(
7889
  Eurydice_borrow_slice_u8 input,
7890
  Eurydice_mut_borrow_slice_u8 output
7891
)
7892
0
{
7893
0
  Eurydice_arr_7c s = libcrux_sha3_generic_keccak_new_80_71();
7894
0
  size_t input_len = input.meta;
7895
0
  size_t input_blocks = input_len / (size_t)104U;
7896
0
  size_t input_rem = input_len % (size_t)104U;
7897
0
  for (size_t i = (size_t)0U; i < input_blocks; i++)
7898
0
  {
7899
0
    size_t i0 = i;
7900
0
    /* original Rust expression is not an lvalue in C */
7901
0
    Eurydice_arr_dc lvalue = { .data = { input } };
7902
0
    libcrux_sha3_generic_keccak_absorb_block_80_e93(&s, &lvalue, i0 * (size_t)104U);
7903
0
  }
7904
0
  /* original Rust expression is not an lvalue in C */
7905
0
  Eurydice_arr_dc lvalue = { .data = { input } };
7906
0
  libcrux_sha3_generic_keccak_absorb_final_80_bd4(&s, &lvalue, input_len - input_rem, input_rem);
7907
0
  size_t output_len = output.meta;
7908
0
  size_t output_blocks = output_len / (size_t)104U;
7909
0
  size_t output_rem = output_len % (size_t)104U;
7910
0
  if (output_blocks == (size_t)0U)
7911
0
  {
7912
0
    libcrux_sha3_simd_portable_squeeze_9b_53(&s, output, (size_t)0U, output_len);
7913
0
  }
7914
0
  else
7915
0
  {
7916
0
    libcrux_sha3_simd_portable_squeeze_9b_53(&s, output, (size_t)0U, (size_t)104U);
7917
0
    for (size_t i = (size_t)1U; i < output_blocks; i++)
7918
0
    {
7919
0
      size_t i0 = i;
7920
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7921
0
      libcrux_sha3_simd_portable_squeeze_9b_53(&s, output, i0 * (size_t)104U, (size_t)104U);
7922
0
    }
7923
0
    if (output_rem != (size_t)0U)
7924
0
    {
7925
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&s);
7926
0
      libcrux_sha3_simd_portable_squeeze_9b_53(&s, output, output_len - output_rem, output_rem);
7927
0
    }
7928
0
  }
7929
0
}
7930
7931
/**
7932
 A portable SHA3 384 implementation.
7933
*/
7934
static KRML_MUSTINLINE void
7935
libcrux_sha3_portable_sha384(
7936
  Eurydice_mut_borrow_slice_u8 digest,
7937
  Eurydice_borrow_slice_u8 data
7938
)
7939
0
{
7940
0
  libcrux_sha3_generic_keccak_portable_keccak1_dc0(data, digest);
7941
0
}
7942
7943
/**
7944
 SHA3 224
7945
7946
 Preconditions:
7947
 - `digest.len() == 28`
7948
*/
7949
static inline void
7950
libcrux_sha3_sha224_ema(Eurydice_mut_borrow_slice_u8 digest, Eurydice_borrow_slice_u8 payload)
7951
0
{
7952
0
  libcrux_sha3_portable_sha224(digest, payload);
7953
0
}
7954
7955
/**
7956
 SHA3 224
7957
*/
7958
static inline Eurydice_arr_a2 libcrux_sha3_sha224(Eurydice_borrow_slice_u8 data)
7959
0
{
7960
0
  Eurydice_arr_a2 out = { .data = { 0U } };
7961
0
  libcrux_sha3_sha224_ema(Eurydice_array_to_slice_mut_5e(&out), data);
7962
0
  return out;
7963
0
}
7964
7965
/**
7966
 SHA3 256
7967
*/
7968
static inline void
7969
libcrux_sha3_sha256_ema(Eurydice_mut_borrow_slice_u8 digest, Eurydice_borrow_slice_u8 payload)
7970
0
{
7971
0
  libcrux_sha3_portable_sha256(digest, payload);
7972
0
}
7973
7974
/**
7975
 SHA3 256
7976
*/
7977
static inline Eurydice_arr_ec libcrux_sha3_sha256(Eurydice_borrow_slice_u8 data)
7978
0
{
7979
0
  Eurydice_arr_ec out = { .data = { 0U } };
7980
0
  libcrux_sha3_sha256_ema(Eurydice_array_to_slice_mut_01(&out), data);
7981
0
  return out;
7982
0
}
7983
7984
/**
7985
 SHA3 384
7986
*/
7987
static inline void
7988
libcrux_sha3_sha384_ema(Eurydice_mut_borrow_slice_u8 digest, Eurydice_borrow_slice_u8 payload)
7989
0
{
7990
0
  libcrux_sha3_portable_sha384(digest, payload);
7991
0
}
7992
7993
/**
7994
 SHA3 384
7995
*/
7996
static inline Eurydice_arr_65 libcrux_sha3_sha384(Eurydice_borrow_slice_u8 data)
7997
0
{
7998
0
  Eurydice_arr_65 out = { .data = { 0U } };
7999
0
  libcrux_sha3_sha384_ema(Eurydice_array_to_slice_mut_9f(&out), data);
8000
0
  return out;
8001
0
}
8002
8003
/**
8004
 SHA3 512
8005
*/
8006
static inline void
8007
libcrux_sha3_sha512_ema(Eurydice_mut_borrow_slice_u8 digest, Eurydice_borrow_slice_u8 payload)
8008
0
{
8009
0
  libcrux_sha3_portable_sha512(digest, payload);
8010
0
}
8011
8012
/**
8013
 SHA3 512
8014
*/
8015
static inline Eurydice_arr_c7 libcrux_sha3_sha512(Eurydice_borrow_slice_u8 data)
8016
0
{
8017
0
  Eurydice_arr_c7 out = { .data = { 0U } };
8018
0
  libcrux_sha3_sha512_ema(Eurydice_array_to_slice_mut_17(&out), data);
8019
0
  return out;
8020
0
}
8021
8022
/**
8023
 SHAKE 128
8024
8025
 Writes `out.len()` bytes.
8026
*/
8027
static inline void
8028
libcrux_sha3_shake128_ema(Eurydice_mut_borrow_slice_u8 out, Eurydice_borrow_slice_u8 data)
8029
0
{
8030
0
  libcrux_sha3_portable_shake128(out, data);
8031
0
}
8032
8033
/**
8034
 SHAKE 256
8035
8036
 Writes `out.len()` bytes.
8037
*/
8038
static inline void
8039
libcrux_sha3_shake256_ema(Eurydice_mut_borrow_slice_u8 out, Eurydice_borrow_slice_u8 data)
8040
0
{
8041
0
  libcrux_sha3_portable_shake256(out, data);
8042
0
}
8043
8044
/**
8045
A monomorphic instance of libcrux_sha3.generic_keccak.xof.KeccakXofState
8046
with types uint64_t
8047
with const generics
8048
- $1size_t
8049
- $168size_t
8050
*/
8051
typedef struct libcrux_sha3_generic_keccak_xof_KeccakXofState_55_s
8052
{
8053
  Eurydice_arr_7c inner;
8054
  Eurydice_arr_88 buf;
8055
  size_t buf_len;
8056
  bool sponge;
8057
}
8058
libcrux_sha3_generic_keccak_xof_KeccakXofState_55;
8059
8060
typedef libcrux_sha3_generic_keccak_xof_KeccakXofState_55
8061
libcrux_sha3_portable_incremental_Shake128Xof;
8062
8063
/**
8064
 Try to complete the internal partial buffer by consuming the minimum required
8065
 number of bytes from the provided `inputs` so that `self.buf` becomes exactly
8066
 one full block of size `RATE`.
8067
8068
 Behaviour:
8069
 - If `self.buf_len` is 0 (no buffered bytes) or already equal to `RATE`
8070
   (already a full block), or if the combined available bytes in `inputs` are
8071
   not enough to reach `RATE`, the function does nothing and returns 0.
8072
 - If `0 < self.buf_len < RATE` and `inputs[..]` contain at least
8073
   `RATE - self.buf_len` bytes, the function copies exactly
8074
   `consumed = RATE - self.buf_len` bytes from each lane `inputs[i]` into
8075
   `self.buf[i]` starting at the current `self.buf_len` offset, sets
8076
   `self.buf_len = RATE`, and returns `consumed`.
8077
8078
 Returns the `consumed` bytes from `inputs` if there's enough buffered
8079
 content to consume, and `0` otherwise.
8080
 If `consumed > 0` is returned, `self.buf` contains a full block to be
8081
 loaded.
8082
*/
8083
/**
8084
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
8085
*/
8086
/**
8087
A monomorphic instance of libcrux_sha3.generic_keccak.xof.fill_buffer_35
8088
with types uint64_t
8089
with const generics
8090
- PARALLEL_LANES= 1
8091
- RATE= 168
8092
*/
8093
static inline size_t
8094
libcrux_sha3_generic_keccak_xof_fill_buffer_35_e90(
8095
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8096
  const Eurydice_arr_dc *inputs
8097
)
8098
0
{
8099
0
  size_t input_len = inputs->data->meta;
8100
0
  size_t uu____0;
8101
0
  if (self->buf_len != (size_t)0U)
8102
0
  {
8103
0
    if (input_len >= (size_t)168U - self->buf_len)
8104
0
    {
8105
0
      size_t consumed = (size_t)168U - self->buf_len;
8106
0
      for (size_t i = (size_t)0U; i < (size_t)1U; i++)
8107
0
      {
8108
0
        size_t i0 = i;
8109
0
        Eurydice_slice_copy(Eurydice_array_to_subslice_from_mut_5f0(&self->buf.data[i0],
8110
0
            self->buf_len),
8111
0
          Eurydice_slice_subslice_to_shared_72(inputs->data[i0], consumed),
8112
0
          uint8_t);
8113
0
      }
8114
0
      self->buf_len = (size_t)168U;
8115
0
      uu____0 = consumed;
8116
0
    }
8117
0
    else
8118
0
    {
8119
0
      uu____0 = (size_t)0U;
8120
0
    }
8121
0
  }
8122
0
  else
8123
0
  {
8124
0
    uu____0 = (size_t)0U;
8125
0
  }
8126
0
  return uu____0;
8127
0
}
8128
8129
/**
8130
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices.closure
8131
with const generics
8132
- $1size_t
8133
- $168size_t
8134
*/
8135
typedef const Eurydice_arr_88 *libcrux_sha3_generic_keccak_xof_buf_to_slices_closure_48;
8136
8137
/**
8138
This function found in impl {core::ops::function::FnMut<(usize), &'_ ([u8])> for libcrux_sha3::generic_keccak::xof::buf_to_slices::closure<0, PARALLEL_LANES, RATE>}
8139
*/
8140
/**
8141
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices.call_mut_2a
8142
with const generics
8143
- PARALLEL_LANES= 1
8144
- RATE= 168
8145
*/
8146
static inline Eurydice_borrow_slice_u8
8147
libcrux_sha3_generic_keccak_xof_buf_to_slices_call_mut_2a_810(
8148
  const Eurydice_arr_88 **_,
8149
  size_t tupled_args
8150
)
8151
0
{
8152
0
  size_t i = tupled_args;
8153
0
  return
8154
0
    core_array___T__N___as_slice((size_t)168U,
8155
0
      &_[0U]->data[i],
8156
0
      uint8_t,
8157
0
      Eurydice_borrow_slice_u8);
8158
0
}
8159
8160
/**
8161
This function found in impl {core::ops::function::FnOnce<(usize), &'_ ([u8])> for libcrux_sha3::generic_keccak::xof::buf_to_slices::closure<0, PARALLEL_LANES, RATE>}
8162
*/
8163
/**
8164
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices.call_once_fa
8165
with const generics
8166
- PARALLEL_LANES= 1
8167
- RATE= 168
8168
*/
8169
static inline Eurydice_borrow_slice_u8
8170
libcrux_sha3_generic_keccak_xof_buf_to_slices_call_once_fa_810(
8171
  const Eurydice_arr_88 *_,
8172
  size_t _0
8173
)
8174
0
{
8175
0
  return libcrux_sha3_generic_keccak_xof_buf_to_slices_call_mut_2a_810(&_, _0);
8176
0
}
8177
8178
/**
8179
 Note: This function exists to work around a hax bug where `core::array::from_fn`
8180
 is extracted with an incorrect explicit type parameter `#(usize -> t_Slice u8)`
8181
 instead of using the typeclass-based implicit parameter `#v_F` from
8182
 `Core_models.Array.from_fn`.
8183
 See: https://github.com/cryspen/hax/issues/1920
8184
*/
8185
/**
8186
A monomorphic instance of libcrux_sha3.generic_keccak.xof.buf_to_slices
8187
with const generics
8188
- PARALLEL_LANES= 1
8189
- RATE= 168
8190
*/
8191
static KRML_MUSTINLINE Eurydice_arr_dc
8192
libcrux_sha3_generic_keccak_xof_buf_to_slices_810(const Eurydice_arr_88 *buf)
8193
0
{
8194
0
  Eurydice_arr_dc arr_struct;
8195
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++)
8196
0
  {
8197
0
    arr_struct.data[i] = libcrux_sha3_generic_keccak_xof_buf_to_slices_call_mut_2a_810(&buf, i);
8198
0
  }
8199
0
  return arr_struct;
8200
0
}
8201
8202
/**
8203
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
8204
*/
8205
/**
8206
A monomorphic instance of libcrux_sha3.generic_keccak.xof.absorb_full_35
8207
with types uint64_t
8208
with const generics
8209
- PARALLEL_LANES= 1
8210
- RATE= 168
8211
*/
8212
static inline size_t
8213
libcrux_sha3_generic_keccak_xof_absorb_full_35_e90(
8214
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8215
  const Eurydice_arr_dc *inputs
8216
)
8217
0
{
8218
0
  size_t consumed = libcrux_sha3_generic_keccak_xof_fill_buffer_35_e90(self, inputs);
8219
0
  if (self->buf_len == (size_t)168U)
8220
0
  {
8221
0
    Eurydice_arr_dc borrowed = libcrux_sha3_generic_keccak_xof_buf_to_slices_810(&self->buf);
8222
0
    libcrux_sha3_simd_portable_load_block_a1_60(&self->inner, &borrowed, (size_t)0U);
8223
0
    libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
8224
0
    self->buf_len = (size_t)0U;
8225
0
  }
8226
0
  size_t input_to_consume = inputs->data->meta - consumed;
8227
0
  size_t num_blocks = input_to_consume / (size_t)168U;
8228
0
  size_t remainder = input_to_consume % (size_t)168U;
8229
0
  for (size_t i = (size_t)0U; i < num_blocks; i++)
8230
0
  {
8231
0
    size_t i0 = i;
8232
0
    size_t start = i0 * (size_t)168U + consumed;
8233
0
    libcrux_sha3_simd_portable_load_block_a1_60(&self->inner, inputs, start);
8234
0
    libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
8235
0
  }
8236
0
  return remainder;
8237
0
}
8238
8239
/**
8240
 Absorb
8241
8242
 This function takes any number of bytes to absorb and buffers if it's not enough.
8243
 The function assumes that all input slices in `inputs` have the same length.
8244
8245
 Only a multiple of `RATE` blocks are absorbed.
8246
 For the remaining bytes [`absorb_final`] needs to be called.
8247
8248
 This works best with relatively small `inputs`.
8249
*/
8250
/**
8251
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
8252
*/
8253
/**
8254
A monomorphic instance of libcrux_sha3.generic_keccak.xof.absorb_35
8255
with types uint64_t
8256
with const generics
8257
- PARALLEL_LANES= 1
8258
- RATE= 168
8259
*/
8260
static KRML_MUSTINLINE void
8261
libcrux_sha3_generic_keccak_xof_absorb_35_e90(
8262
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8263
  const Eurydice_arr_dc *inputs
8264
)
8265
0
{
8266
0
  size_t remainder = libcrux_sha3_generic_keccak_xof_absorb_full_35_e90(self, inputs);
8267
0
  if (remainder > (size_t)0U)
8268
0
  {
8269
0
    size_t input_len = inputs->data->meta;
8270
0
    for (size_t i = (size_t)0U; i < (size_t)1U; i++)
8271
0
    {
8272
0
      size_t i0 = i;
8273
0
      Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d41(&self->buf.data[i0],
8274
0
          (
8275
0
            KRML_CLITERAL(core_ops_range_Range_87){
8276
0
              .start = self->buf_len,
8277
0
              .end = self->buf_len + remainder
8278
0
            }
8279
0
          )),
8280
0
        Eurydice_slice_subslice_shared_c8(inputs->data[i0],
8281
0
          (
8282
0
            KRML_CLITERAL(core_ops_range_Range_87){
8283
0
              .start = input_len - remainder,
8284
0
              .end = input_len
8285
0
            }
8286
0
          )),
8287
0
        uint8_t);
8288
0
    }
8289
0
    self->buf_len += remainder;
8290
0
  }
8291
0
}
8292
8293
/**
8294
This function found in impl {libcrux_sha3::portable::incremental::Xof<168usize> for libcrux_sha3::portable::incremental::Shake128Xof}
8295
*/
8296
static inline void
8297
libcrux_sha3_portable_incremental_absorb_26(
8298
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8299
  Eurydice_borrow_slice_u8 input
8300
)
8301
0
{
8302
0
  /* original Rust expression is not an lvalue in C */
8303
0
  Eurydice_arr_dc lvalue = { .data = { input } };
8304
0
  libcrux_sha3_generic_keccak_xof_absorb_35_e90(self, &lvalue);
8305
0
}
8306
8307
/**
8308
 Absorb a final block.
8309
8310
 The `inputs` block may be empty. Everything in the `inputs` block beyond
8311
 `RATE` bytes is ignored.
8312
*/
8313
/**
8314
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
8315
*/
8316
/**
8317
A monomorphic instance of libcrux_sha3.generic_keccak.xof.absorb_final_35
8318
with types uint64_t
8319
with const generics
8320
- PARALLEL_LANES= 1
8321
- RATE= 168
8322
- DELIMITER= 31
8323
*/
8324
static KRML_MUSTINLINE void
8325
libcrux_sha3_generic_keccak_xof_absorb_final_35_bd0(
8326
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8327
  const Eurydice_arr_dc *inputs
8328
)
8329
0
{
8330
0
  libcrux_sha3_generic_keccak_xof_absorb_35_e90(self, inputs);
8331
0
  Eurydice_arr_dc borrowed = libcrux_sha3_generic_keccak_xof_buf_to_slices_810(&self->buf);
8332
0
  libcrux_sha3_simd_portable_load_last_a1_37(&self->inner, &borrowed, (size_t)0U, self->buf_len);
8333
0
  libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
8334
0
}
8335
8336
/**
8337
This function found in impl {libcrux_sha3::portable::incremental::Xof<168usize> for libcrux_sha3::portable::incremental::Shake128Xof}
8338
*/
8339
static inline void
8340
libcrux_sha3_portable_incremental_absorb_final_26(
8341
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8342
  Eurydice_borrow_slice_u8 input
8343
)
8344
0
{
8345
0
  /* original Rust expression is not an lvalue in C */
8346
0
  Eurydice_arr_dc lvalue = { .data = { input } };
8347
0
  libcrux_sha3_generic_keccak_xof_absorb_final_35_bd0(self, &lvalue);
8348
0
}
8349
8350
/**
8351
 An all zero block
8352
*/
8353
/**
8354
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
8355
*/
8356
/**
8357
A monomorphic instance of libcrux_sha3.generic_keccak.xof.zero_block_35
8358
with types uint64_t
8359
with const generics
8360
- PARALLEL_LANES= 1
8361
- RATE= 168
8362
*/
8363
static inline Eurydice_arr_c5 libcrux_sha3_generic_keccak_xof_zero_block_35_e90(void)
8364
0
{
8365
0
  return (KRML_CLITERAL(Eurydice_arr_c5){ .data = { 0U } });
8366
0
}
8367
8368
/**
8369
 Generate a new keccak xof state.
8370
*/
8371
/**
8372
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, PARALLEL_LANES, RATE>[TraitClause@0, TraitClause@1]}
8373
*/
8374
/**
8375
A monomorphic instance of libcrux_sha3.generic_keccak.xof.new_35
8376
with types uint64_t
8377
with const generics
8378
- PARALLEL_LANES= 1
8379
- RATE= 168
8380
*/
8381
static inline libcrux_sha3_generic_keccak_xof_KeccakXofState_55
8382
libcrux_sha3_generic_keccak_xof_new_35_e90(void)
8383
0
{
8384
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 lit;
8385
0
  lit.inner = libcrux_sha3_generic_keccak_new_80_71();
8386
0
  Eurydice_arr_c5 repeat_expression[1U];
8387
0
  for (size_t i = (size_t)0U; i < (size_t)1U; i++)
8388
0
  {
8389
0
    repeat_expression[i] = libcrux_sha3_generic_keccak_xof_zero_block_35_e90();
8390
0
  }
8391
0
  memcpy(lit.buf.data, repeat_expression, (size_t)1U * sizeof (Eurydice_arr_c5));
8392
0
  lit.buf_len = (size_t)0U;
8393
0
  lit.sponge = false;
8394
0
  return lit;
8395
0
}
8396
8397
/**
8398
This function found in impl {libcrux_sha3::portable::incremental::Xof<168usize> for libcrux_sha3::portable::incremental::Shake128Xof}
8399
*/
8400
static inline libcrux_sha3_generic_keccak_xof_KeccakXofState_55
8401
libcrux_sha3_portable_incremental_new_26(void)
8402
0
{
8403
0
  return libcrux_sha3_generic_keccak_xof_new_35_e90();
8404
0
}
8405
8406
/**
8407
 Squeeze `N` x `LEN` bytes. Only `N = 1` for now.
8408
*/
8409
/**
8410
This function found in impl {libcrux_sha3::generic_keccak::xof::KeccakXofState<STATE, 1usize, RATE>[TraitClause@0, TraitClause@1]}
8411
*/
8412
/**
8413
A monomorphic instance of libcrux_sha3.generic_keccak.xof.squeeze_85
8414
with types uint64_t
8415
with const generics
8416
- RATE= 168
8417
*/
8418
static KRML_MUSTINLINE void
8419
libcrux_sha3_generic_keccak_xof_squeeze_85_2a(
8420
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8421
  Eurydice_mut_borrow_slice_u8 out
8422
)
8423
0
{
8424
0
  size_t out_len = out.meta;
8425
0
  if (!(out_len == (size_t)0U))
8426
0
  {
8427
0
    if (self->sponge)
8428
0
    {
8429
0
      libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
8430
0
    }
8431
0
    if (out_len > (size_t)0U)
8432
0
    {
8433
0
      size_t blocks = out_len / (size_t)168U;
8434
0
      size_t last = out_len - out_len % (size_t)168U;
8435
0
      if (blocks == (size_t)0U)
8436
0
      {
8437
0
        libcrux_sha3_simd_portable_squeeze_9b_60(&self->inner, out, (size_t)0U, out_len);
8438
0
      }
8439
0
      else
8440
0
      {
8441
0
        libcrux_sha3_simd_portable_squeeze_9b_60(&self->inner, out, (size_t)0U, (size_t)168U);
8442
0
        for (size_t i = (size_t)1U; i < blocks; i++)
8443
0
        {
8444
0
          size_t i0 = i;
8445
0
          libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
8446
0
          libcrux_sha3_simd_portable_squeeze_9b_60(&self->inner,
8447
0
            out,
8448
0
            i0 * (size_t)168U,
8449
0
            (size_t)168U);
8450
0
        }
8451
0
        if (last < out_len)
8452
0
        {
8453
0
          libcrux_sha3_generic_keccak_keccakf1600_80_71(&self->inner);
8454
0
          libcrux_sha3_simd_portable_squeeze_9b_60(&self->inner, out, last, out_len - last);
8455
0
        }
8456
0
      }
8457
0
    }
8458
0
    self->sponge = true;
8459
0
  }
8460
0
}
8461
8462
/**
8463
 Shake128 squeeze
8464
*/
8465
/**
8466
This function found in impl {libcrux_sha3::portable::incremental::Xof<168usize> for libcrux_sha3::portable::incremental::Shake128Xof}
8467
*/
8468
static inline void
8469
libcrux_sha3_portable_incremental_squeeze_26(
8470
  libcrux_sha3_generic_keccak_xof_KeccakXofState_55 *self,
8471
  Eurydice_mut_borrow_slice_u8 out
8472
)
8473
0
{
8474
0
  libcrux_sha3_generic_keccak_xof_squeeze_85_2a(self, out);
8475
0
}
8476
8477
/**
8478
This function found in impl {core::clone::Clone for libcrux_sha3::portable::KeccakState}
8479
*/
8480
static inline Eurydice_arr_7c libcrux_sha3_portable_clone_fe(const Eurydice_arr_7c *self)
8481
0
{
8482
0
  return self[0U];
8483
0
}
8484
8485
/**
8486
This function found in impl {core::clone::Clone for libcrux_sha3::Algorithm}
8487
*/
8488
static inline libcrux_sha3_Algorithm libcrux_sha3_clone_e6(const libcrux_sha3_Algorithm *self)
8489
0
{
8490
0
  return self[0U];
8491
0
}
8492
8493
/**
8494
This function found in impl {core::convert::From<libcrux_sha3::Algorithm> for u32}
8495
*/
8496
static inline uint32_t libcrux_sha3_from_6c(libcrux_sha3_Algorithm v)
8497
0
{
8498
0
  switch (v)
8499
0
  {
8500
0
    case libcrux_sha3_Algorithm_Sha224:
8501
0
      {
8502
0
        break;
8503
0
      }
8504
0
    case libcrux_sha3_Algorithm_Sha256:
8505
0
      {
8506
0
        return 2U;
8507
0
      }
8508
0
    case libcrux_sha3_Algorithm_Sha384:
8509
0
      {
8510
0
        return 3U;
8511
0
      }
8512
0
    case libcrux_sha3_Algorithm_Sha512:
8513
0
      {
8514
0
        return 4U;
8515
0
      }
8516
0
    default:
8517
0
      {
8518
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
8519
0
        KRML_HOST_EXIT(253U);
8520
0
      }
8521
0
  }
8522
0
  return 1U;
8523
0
}
8524
8525
/**
8526
A monomorphic instance of Eurydice.arr
8527
with types libcrux_sha3_portable_KeccakState
8528
with const generics
8529
- $3size_t
8530
*/
8531
typedef struct Eurydice_arr_1b0_s { Eurydice_arr_7c data[3U]; } Eurydice_arr_1b0;
8532
8533
#if defined(__cplusplus)
8534
}
8535
#endif
8536
8537
#define libcrux_sha3_portable_H_DEFINED
8538
#endif /* libcrux_sha3_portable_H */
8539
8540
/* from libcrux/combined_extraction/generated/libcrux_mlkem_core.h */
8541
/*
8542
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
8543
 *
8544
 * SPDX-License-Identifier: MIT or Apache-2.0
8545
 *
8546
 * This code was generated with the following revisions:
8547
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
8548
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
8549
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
8550
 * F*: unset
8551
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
8552
 */
8553
8554
8555
#ifndef libcrux_mlkem_core_H
8556
#define libcrux_mlkem_core_H
8557
8558
8559
8560
#if defined(__cplusplus)
8561
extern "C" {
8562
#endif
8563
8564
8565
0
#define LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE ((size_t)32U)
8566
8567
#define LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT ((size_t)12U)
8568
8569
0
#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
8570
8571
0
#define LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)12U)
8572
8573
0
#define LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT (LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U)
8574
8575
0
#define LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE ((size_t)32U)
8576
8577
#define LIBCRUX_ML_KEM_CONSTANTS_G_DIGEST_SIZE ((size_t)64U)
8578
8579
0
#define LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE ((size_t)32U)
8580
8581
/**
8582
 K * BITS_PER_RING_ELEMENT / 8
8583
8584
 [eurydice] Note that we can't use const generics here because that breaks
8585
            C extraction with eurydice.
8586
*/
8587
static inline size_t libcrux_ml_kem_constants_ranked_bytes_per_ring_element(size_t rank)
8588
0
{
8589
0
  return rank * LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U;
8590
0
}
8591
8592
/**
8593
This function found in impl {libcrux_secrets::int::CastOps for i16}
8594
*/
8595
static KRML_MUSTINLINE uint8_t libcrux_secrets_int_as_u8_f5(int16_t self)
8596
0
{
8597
0
  return
8598
0
    libcrux_secrets_int_public_integers_classify_27_90((uint8_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
8599
0
}
8600
8601
/**
8602
This function found in impl {libcrux_secrets::int::CastOps for u8}
8603
*/
8604
static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_59(uint8_t self)
8605
0
{
8606
0
  return
8607
0
    libcrux_secrets_int_public_integers_classify_27_39((int16_t)(uint32_t)libcrux_secrets_int_public_integers_declassify_d8_90(self));
8608
0
}
8609
8610
/**
8611
This function found in impl {libcrux_secrets::int::CastOps for i16}
8612
*/
8613
static KRML_MUSTINLINE int32_t libcrux_secrets_int_as_i32_f5(int16_t self)
8614
0
{
8615
0
  return
8616
0
    libcrux_secrets_int_public_integers_classify_27_a8((int32_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
8617
0
}
8618
8619
/**
8620
This function found in impl {libcrux_secrets::int::CastOps for i32}
8621
*/
8622
static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_36(int32_t self)
8623
0
{
8624
0
  return
8625
0
    libcrux_secrets_int_public_integers_classify_27_39((int16_t)libcrux_secrets_int_public_integers_declassify_d8_a8(self));
8626
0
}
8627
8628
/**
8629
This function found in impl {libcrux_secrets::int::CastOps for u32}
8630
*/
8631
static KRML_MUSTINLINE int32_t libcrux_secrets_int_as_i32_b8(uint32_t self)
8632
0
{
8633
0
  return
8634
0
    libcrux_secrets_int_public_integers_classify_27_a8((int32_t)libcrux_secrets_int_public_integers_declassify_d8_df(self));
8635
0
}
8636
8637
/**
8638
This function found in impl {libcrux_secrets::int::CastOps for i16}
8639
*/
8640
static KRML_MUSTINLINE uint16_t libcrux_secrets_int_as_u16_f5(int16_t self)
8641
0
{
8642
0
  return
8643
0
    libcrux_secrets_int_public_integers_classify_27_de((uint16_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
8644
0
}
8645
8646
/**
8647
This function found in impl {libcrux_secrets::int::CastOps for u16}
8648
*/
8649
static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_ca(uint16_t self)
8650
0
{
8651
0
  return
8652
0
    libcrux_secrets_int_public_integers_classify_27_39((int16_t)(uint32_t)libcrux_secrets_int_public_integers_declassify_d8_de(self));
8653
0
}
8654
8655
/**
8656
This function found in impl {libcrux_secrets::int::CastOps for u16}
8657
*/
8658
static KRML_MUSTINLINE uint64_t libcrux_secrets_int_as_u64_ca(uint16_t self)
8659
0
{
8660
0
  return
8661
0
    libcrux_secrets_int_public_integers_classify_27_49((uint64_t)(uint32_t)libcrux_secrets_int_public_integers_declassify_d8_de(self));
8662
0
}
8663
8664
/**
8665
This function found in impl {libcrux_secrets::int::CastOps for u64}
8666
*/
8667
static KRML_MUSTINLINE uint32_t libcrux_secrets_int_as_u32_a3(uint64_t self)
8668
0
{
8669
0
  return
8670
0
    libcrux_secrets_int_public_integers_classify_27_df((uint32_t)libcrux_secrets_int_public_integers_declassify_d8_49(self));
8671
0
}
8672
8673
/**
8674
This function found in impl {libcrux_secrets::int::CastOps for u32}
8675
*/
8676
static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_b8(uint32_t self)
8677
0
{
8678
0
  return
8679
0
    libcrux_secrets_int_public_integers_classify_27_39((int16_t)libcrux_secrets_int_public_integers_declassify_d8_df(self));
8680
0
}
8681
8682
/**
8683
This function found in impl {libcrux_secrets::int::CastOps for i16}
8684
*/
8685
static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_f5(int16_t self)
8686
0
{
8687
0
  return
8688
0
    libcrux_secrets_int_public_integers_classify_27_39(libcrux_secrets_int_public_integers_declassify_d8_39(self));
8689
0
}
8690
8691
/**
8692
 Pad the `slice` with `0`s at the end.
8693
*/
8694
/**
8695
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
8696
with const generics
8697
- LEN= 32
8698
*/
8699
static KRML_MUSTINLINE Eurydice_arr_ec
8700
libcrux_ml_kem_utils_into_padded_array_ce(Eurydice_borrow_slice_u8 slice)
8701
0
{
8702
0
  Eurydice_arr_ec out = { .data = { 0U } };
8703
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d46(&out,
8704
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
8705
0
    slice,
8706
0
    uint8_t);
8707
0
  return out;
8708
0
}
8709
8710
/**
8711
This function found in impl {core::default::Default for libcrux_ml_kem::types::MlKemPrivateKey<SIZE>}
8712
*/
8713
/**
8714
A monomorphic instance of libcrux_ml_kem.types.default_d3
8715
with const generics
8716
- SIZE= 2400
8717
*/
8718
static inline Eurydice_arr_7d libcrux_ml_kem_types_default_d3_79(void)
8719
0
{
8720
0
  return (KRML_CLITERAL(Eurydice_arr_7d){ .data = { 0U } });
8721
0
}
8722
8723
/**
8724
This function found in impl {core::convert::From<[u8; SIZE]> for libcrux_ml_kem::types::MlKemPublicKey<SIZE>}
8725
*/
8726
/**
8727
A monomorphic instance of libcrux_ml_kem.types.from_51
8728
with const generics
8729
- SIZE= 1184
8730
*/
8731
static inline Eurydice_arr_5f libcrux_ml_kem_types_from_51_3d(Eurydice_arr_5f value)
8732
0
{
8733
0
  return value;
8734
0
}
8735
8736
typedef struct libcrux_ml_kem_mlkem768_MlKem768KeyPair_s
8737
{
8738
  Eurydice_arr_7d sk;
8739
  Eurydice_arr_5f pk;
8740
}
8741
libcrux_ml_kem_mlkem768_MlKem768KeyPair;
8742
8743
/**
8744
 Create a new [`MlKemKeyPair`] from the secret and public key.
8745
*/
8746
/**
8747
This function found in impl {libcrux_ml_kem::types::MlKemKeyPair<PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE>}
8748
*/
8749
/**
8750
A monomorphic instance of libcrux_ml_kem.types.from_17
8751
with const generics
8752
- PRIVATE_KEY_SIZE= 2400
8753
- PUBLIC_KEY_SIZE= 1184
8754
*/
8755
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
8756
libcrux_ml_kem_types_from_17_bc(Eurydice_arr_7d sk, Eurydice_arr_5f pk)
8757
0
{
8758
0
  return (KRML_CLITERAL(libcrux_ml_kem_mlkem768_MlKem768KeyPair){ .sk = sk, .pk = pk });
8759
0
}
8760
8761
/**
8762
This function found in impl {core::convert::From<[u8; SIZE]> for libcrux_ml_kem::types::MlKemPrivateKey<SIZE>}
8763
*/
8764
/**
8765
A monomorphic instance of libcrux_ml_kem.types.from_b2
8766
with const generics
8767
- SIZE= 2400
8768
*/
8769
static inline Eurydice_arr_7d libcrux_ml_kem_types_from_b2_79(Eurydice_arr_7d value)
8770
0
{
8771
0
  return value;
8772
0
}
8773
8774
/**
8775
A monomorphic instance of n-tuple
8776
with types libcrux_ml_kem_mlkem768_MlKem768Ciphertext, Eurydice_arr_ec
8777
8778
*/
8779
typedef struct tuple_f4_s
8780
{
8781
  Eurydice_arr_2b fst;
8782
  Eurydice_arr_ec snd;
8783
}
8784
tuple_f4;
8785
8786
/**
8787
This function found in impl {core::convert::From<[u8; SIZE]> for libcrux_ml_kem::types::MlKemCiphertext<SIZE>}
8788
*/
8789
/**
8790
A monomorphic instance of libcrux_ml_kem.types.from_19
8791
with const generics
8792
- SIZE= 1088
8793
*/
8794
static inline Eurydice_arr_2b libcrux_ml_kem_types_from_19_52(Eurydice_arr_2b value)
8795
0
{
8796
0
  return value;
8797
0
}
8798
8799
/**
8800
 A reference to the raw byte slice.
8801
*/
8802
/**
8803
This function found in impl {libcrux_ml_kem::types::MlKemPublicKey<SIZE>}
8804
*/
8805
/**
8806
A monomorphic instance of libcrux_ml_kem.types.as_slice_e6
8807
with const generics
8808
- SIZE= 1184
8809
*/
8810
static inline const
8811
Eurydice_arr_5f
8812
*libcrux_ml_kem_types_as_slice_e6_3d(const Eurydice_arr_5f *self)
8813
0
{
8814
0
  return self;
8815
0
}
8816
8817
/**
8818
 A reference to the raw byte slice.
8819
*/
8820
/**
8821
This function found in impl {libcrux_ml_kem::types::MlKemCiphertext<SIZE>}
8822
*/
8823
/**
8824
A monomorphic instance of libcrux_ml_kem.types.as_slice_a9
8825
with const generics
8826
- SIZE= 1088
8827
*/
8828
static inline const
8829
Eurydice_arr_2b
8830
*libcrux_ml_kem_types_as_slice_a9_52(const Eurydice_arr_2b *self)
8831
0
{
8832
0
  return self;
8833
0
}
8834
8835
/**
8836
A monomorphic instance of libcrux_ml_kem.utils.prf_input_inc
8837
with const generics
8838
- K= 3
8839
*/
8840
static KRML_MUSTINLINE uint8_t
8841
libcrux_ml_kem_utils_prf_input_inc_78(Eurydice_arr_fd *prf_inputs, uint8_t domain_separator)
8842
0
{
8843
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
8844
0
  {
8845
0
    size_t i0 = i;
8846
0
    prf_inputs->data[i0].data[32U] = domain_separator;
8847
0
    domain_separator = (uint32_t)domain_separator + 1U;
8848
0
  }
8849
0
  return domain_separator;
8850
0
}
8851
8852
/**
8853
 Pad the `slice` with `0`s at the end.
8854
*/
8855
/**
8856
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
8857
with const generics
8858
- LEN= 33
8859
*/
8860
static KRML_MUSTINLINE Eurydice_arr_fa0
8861
libcrux_ml_kem_utils_into_padded_array_29(Eurydice_borrow_slice_u8 slice)
8862
0
{
8863
0
  Eurydice_arr_fa0 out = { .data = { 0U } };
8864
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d412(&out,
8865
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
8866
0
    slice,
8867
0
    uint8_t);
8868
0
  return out;
8869
0
}
8870
8871
/**
8872
 Pad the `slice` with `0`s at the end.
8873
*/
8874
/**
8875
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
8876
with const generics
8877
- LEN= 34
8878
*/
8879
static KRML_MUSTINLINE Eurydice_arr_31
8880
libcrux_ml_kem_utils_into_padded_array_de(Eurydice_borrow_slice_u8 slice)
8881
0
{
8882
0
  Eurydice_arr_31 out = { .data = { 0U } };
8883
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d40(&out,
8884
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
8885
0
    slice,
8886
0
    uint8_t);
8887
0
  return out;
8888
0
}
8889
8890
/**
8891
This function found in impl {core::convert::AsRef<[u8]> for libcrux_ml_kem::types::MlKemCiphertext<SIZE>}
8892
*/
8893
/**
8894
A monomorphic instance of libcrux_ml_kem.types.as_ref_c1
8895
with const generics
8896
- SIZE= 1088
8897
*/
8898
static inline Eurydice_borrow_slice_u8
8899
libcrux_ml_kem_types_as_ref_c1_52(const Eurydice_arr_2b *self)
8900
0
{
8901
0
  return Eurydice_array_to_slice_shared_06(self);
8902
0
}
8903
8904
/**
8905
 Pad the `slice` with `0`s at the end.
8906
*/
8907
/**
8908
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
8909
with const generics
8910
- LEN= 1120
8911
*/
8912
static KRML_MUSTINLINE Eurydice_arr_af
8913
libcrux_ml_kem_utils_into_padded_array_66(Eurydice_borrow_slice_u8 slice)
8914
0
{
8915
0
  Eurydice_arr_af out = { .data = { 0U } };
8916
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d411(&out,
8917
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
8918
0
    slice,
8919
0
    uint8_t);
8920
0
  return out;
8921
0
}
8922
8923
/**
8924
 Pad the `slice` with `0`s at the end.
8925
*/
8926
/**
8927
A monomorphic instance of libcrux_ml_kem.utils.into_padded_array
8928
with const generics
8929
- LEN= 64
8930
*/
8931
static KRML_MUSTINLINE Eurydice_arr_c7
8932
libcrux_ml_kem_utils_into_padded_array_c9(Eurydice_borrow_slice_u8 slice)
8933
0
{
8934
0
  Eurydice_arr_c7 out = { .data = { 0U } };
8935
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d410(&out,
8936
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
8937
0
    slice,
8938
0
    uint8_t);
8939
0
  return out;
8940
0
}
8941
8942
typedef struct Eurydice_borrow_slice_u8_x4_s
8943
{
8944
  Eurydice_borrow_slice_u8 fst;
8945
  Eurydice_borrow_slice_u8 snd;
8946
  Eurydice_borrow_slice_u8 thd;
8947
  Eurydice_borrow_slice_u8 f3;
8948
}
8949
Eurydice_borrow_slice_u8_x4;
8950
8951
typedef struct Eurydice_borrow_slice_u8_x2_s
8952
{
8953
  Eurydice_borrow_slice_u8 fst;
8954
  Eurydice_borrow_slice_u8 snd;
8955
}
8956
Eurydice_borrow_slice_u8_x2;
8957
8958
/**
8959
 Unpack an incoming private key into it's different parts.
8960
8961
 We have this here in types to extract into a common core for C.
8962
*/
8963
/**
8964
A monomorphic instance of libcrux_ml_kem.types.unpack_private_key
8965
with const generics
8966
- CPA_SECRET_KEY_SIZE= 1152
8967
- PUBLIC_KEY_SIZE= 1184
8968
*/
8969
static inline Eurydice_borrow_slice_u8_x4
8970
libcrux_ml_kem_types_unpack_private_key_64(Eurydice_borrow_slice_u8 private_key)
8971
0
{
8972
0
  Eurydice_borrow_slice_u8_x2
8973
0
  uu____0 =
8974
0
    Eurydice_slice_split_at(private_key,
8975
0
      (size_t)1152U,
8976
0
      uint8_t,
8977
0
      Eurydice_borrow_slice_u8_x2);
8978
0
  Eurydice_borrow_slice_u8 ind_cpa_secret_key = uu____0.fst;
8979
0
  Eurydice_borrow_slice_u8 secret_key0 = uu____0.snd;
8980
0
  Eurydice_borrow_slice_u8_x2
8981
0
  uu____1 =
8982
0
    Eurydice_slice_split_at(secret_key0,
8983
0
      (size_t)1184U,
8984
0
      uint8_t,
8985
0
      Eurydice_borrow_slice_u8_x2);
8986
0
  Eurydice_borrow_slice_u8 ind_cpa_public_key = uu____1.fst;
8987
0
  Eurydice_borrow_slice_u8 secret_key = uu____1.snd;
8988
0
  Eurydice_borrow_slice_u8_x2
8989
0
  uu____2 =
8990
0
    Eurydice_slice_split_at(secret_key,
8991
0
      LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE,
8992
0
      uint8_t,
8993
0
      Eurydice_borrow_slice_u8_x2);
8994
0
  Eurydice_borrow_slice_u8 ind_cpa_public_key_hash = uu____2.fst;
8995
0
  Eurydice_borrow_slice_u8 implicit_rejection_value = uu____2.snd;
8996
0
  return
8997
0
    (
8998
0
      KRML_CLITERAL(Eurydice_borrow_slice_u8_x4){
8999
0
        .fst = ind_cpa_secret_key,
9000
0
        .snd = ind_cpa_public_key,
9001
0
        .thd = ind_cpa_public_key_hash,
9002
0
        .f3 = implicit_rejection_value
9003
0
      }
9004
0
    );
9005
0
}
9006
9007
#if defined(__cplusplus)
9008
}
9009
#endif
9010
9011
#define libcrux_mlkem_core_H_DEFINED
9012
#endif /* libcrux_mlkem_core_H */
9013
9014
/* from libcrux/combined_extraction/generated/libcrux_mldsa_core.h */
9015
/*
9016
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
9017
 *
9018
 * SPDX-License-Identifier: MIT or Apache-2.0
9019
 *
9020
 * This code was generated with the following revisions:
9021
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
9022
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
9023
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
9024
 * F*: unset
9025
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
9026
 */
9027
9028
9029
#ifndef libcrux_mldsa_core_H
9030
#define libcrux_mldsa_core_H
9031
9032
9033
9034
#if defined(__cplusplus)
9035
extern "C" {
9036
#endif
9037
9038
9039
0
#define libcrux_ml_dsa_constants_Eta_Two 2
9040
0
#define libcrux_ml_dsa_constants_Eta_Four 4
9041
9042
typedef uint8_t libcrux_ml_dsa_constants_Eta;
9043
9044
0
#define LIBCRUX_ML_DSA_SIMD_TRAITS_COEFFICIENTS_IN_SIMD_UNIT ((size_t)8U)
9045
9046
0
#define LIBCRUX_ML_DSA_SIMD_TRAITS_SIMD_UNITS_IN_RING_ELEMENT ((size_t)32U)
9047
9048
0
#define LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T ((size_t)13U)
9049
9050
0
#define LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS_MINUS_ONE_BIT_LENGTH ((size_t)23U)
9051
9052
0
#define LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_UPPER_PART_OF_T (LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS_MINUS_ONE_BIT_LENGTH - LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T)
9053
9054
0
#define LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH ((size_t)64U)
9055
9056
0
#define LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
9057
9058
0
#define LIBCRUX_ML_DSA_CONSTANTS_CONTEXT_MAX_LEN ((size_t)255U)
9059
9060
0
#define LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS (8380417)
9061
9062
#define LIBCRUX_ML_DSA_CONSTANTS_GAMMA2_V261_888 (261888)
9063
9064
#define LIBCRUX_ML_DSA_CONSTANTS_GAMMA2_V95_232 (95232)
9065
9066
typedef int32_t libcrux_ml_dsa_constants_Gamma2;
9067
9068
#define LIBCRUX_ML_DSA_CONSTANTS_KEY_GENERATION_RANDOMNESS_SIZE ((size_t)32U)
9069
9070
#define LIBCRUX_ML_DSA_CONSTANTS_MASK_SEED_SIZE ((size_t)64U)
9071
9072
#define LIBCRUX_ML_DSA_CONSTANTS_MESSAGE_REPRESENTATIVE_SIZE ((size_t)64U)
9073
9074
0
#define LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN ((size_t)814U)
9075
9076
0
#define LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE (LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T * LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)8U)
9077
9078
0
#define LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T1S_SIZE (LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_UPPER_PART_OF_T * LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)8U)
9079
9080
0
#define LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE ((size_t)32U)
9081
9082
#define LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_ERROR_VECTORS_SIZE ((size_t)64U)
9083
9084
0
#define LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE ((size_t)32U)
9085
9086
#define LIBCRUX_ML_DSA_CONSTANTS_SIGNING_RANDOMNESS_SIZE ((size_t)32U)
9087
9088
static inline int32_t
9089
libcrux_ml_dsa_constants_beta(
9090
  size_t ones_in_verifier_challenge,
9091
  libcrux_ml_dsa_constants_Eta eta
9092
)
9093
0
{
9094
0
  size_t eta_val;
9095
0
  switch (eta)
9096
0
  {
9097
0
    case libcrux_ml_dsa_constants_Eta_Two:
9098
0
      {
9099
0
        eta_val = (size_t)2U;
9100
0
        break;
9101
0
      }
9102
0
    case libcrux_ml_dsa_constants_Eta_Four:
9103
0
      {
9104
0
        eta_val = (size_t)4U;
9105
0
        break;
9106
0
      }
9107
0
    default:
9108
0
      {
9109
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
9110
0
        KRML_HOST_EXIT(253U);
9111
0
      }
9112
0
  }
9113
0
  return (int32_t)(ones_in_verifier_challenge * eta_val);
9114
0
}
9115
9116
static inline size_t
9117
libcrux_ml_dsa_constants_commitment_ring_element_size(size_t bits_per_commitment_coefficient)
9118
0
{
9119
0
  return
9120
0
    bits_per_commitment_coefficient * LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT /
9121
0
      (size_t)8U;
9122
0
}
9123
9124
static inline size_t
9125
libcrux_ml_dsa_constants_commitment_vector_size(
9126
  size_t bits_per_commitment_coefficient,
9127
  size_t rows_in_a
9128
)
9129
0
{
9130
0
  return
9131
0
    libcrux_ml_dsa_constants_commitment_ring_element_size(bits_per_commitment_coefficient) *
9132
0
      rows_in_a;
9133
0
}
9134
9135
static inline size_t
9136
libcrux_ml_dsa_constants_error_ring_element_size(size_t bits_per_error_coefficient)
9137
0
{
9138
0
  return
9139
0
    bits_per_error_coefficient * LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)8U;
9140
0
}
9141
9142
static inline size_t
9143
libcrux_ml_dsa_constants_gamma1_ring_element_size(size_t bits_per_gamma1_coefficient)
9144
0
{
9145
0
  return
9146
0
    bits_per_gamma1_coefficient * LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT /
9147
0
      (size_t)8U;
9148
0
}
9149
9150
static inline size_t
9151
libcrux_ml_dsa_constants_signature_size(
9152
  size_t rows_in_a,
9153
  size_t columns_in_a,
9154
  size_t max_ones_in_hint,
9155
  size_t commitment_hash_size,
9156
  size_t bits_per_gamma1_coefficient
9157
)
9158
0
{
9159
0
  return
9160
0
    commitment_hash_size +
9161
0
      columns_in_a * libcrux_ml_dsa_constants_gamma1_ring_element_size(bits_per_gamma1_coefficient)
9162
0
    + max_ones_in_hint
9163
0
    + rows_in_a;
9164
0
}
9165
9166
static inline size_t
9167
libcrux_ml_dsa_constants_signing_key_size(
9168
  size_t rows_in_a,
9169
  size_t columns_in_a,
9170
  size_t error_ring_element_size
9171
)
9172
0
{
9173
0
  return
9174
0
    LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE + LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE +
9175
0
      LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH
9176
0
    + (rows_in_a + columns_in_a) * error_ring_element_size
9177
0
    + rows_in_a * LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE;
9178
0
}
9179
9180
static inline size_t libcrux_ml_dsa_constants_verification_key_size(size_t rows_in_a)
9181
0
{
9182
0
  return
9183
0
    LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE +
9184
0
      LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * rows_in_a *
9185
0
        (LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS_MINUS_ONE_BIT_LENGTH -
9186
0
          LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T)
9187
0
      / (size_t)8U;
9188
0
}
9189
9190
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_COMMITMENT_COEFFICIENT ((size_t)6U)
9191
9192
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_ERROR_COEFFICIENT ((size_t)3U)
9193
9194
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_GAMMA1_COEFFICIENT ((size_t)18U)
9195
9196
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A ((size_t)4U)
9197
9198
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COMMITMENT_HASH_SIZE ((size_t)32U)
9199
9200
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ETA (libcrux_ml_dsa_constants_Eta_Two)
9201
9202
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA1_EXPONENT ((size_t)17U)
9203
9204
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA2 ((LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS - 1) / 88)
9205
9206
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_MAX_ONES_IN_HINT ((size_t)80U)
9207
9208
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ONES_IN_VERIFIER_CHALLENGE ((size_t)39U)
9209
9210
0
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A ((size_t)4U)
9211
9212
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_COMMITMENT_COEFFICIENT ((size_t)4U)
9213
9214
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_ERROR_COEFFICIENT ((size_t)4U)
9215
9216
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_GAMMA1_COEFFICIENT ((size_t)20U)
9217
9218
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A ((size_t)5U)
9219
9220
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COMMITMENT_HASH_SIZE ((size_t)48U)
9221
9222
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ETA (libcrux_ml_dsa_constants_Eta_Four)
9223
9224
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA1_EXPONENT ((size_t)19U)
9225
9226
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA2 ((LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS - 1) / 32)
9227
9228
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_MAX_ONES_IN_HINT ((size_t)55U)
9229
9230
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ONES_IN_VERIFIER_CHALLENGE ((size_t)49U)
9231
9232
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A ((size_t)6U)
9233
9234
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_COMMITMENT_COEFFICIENT ((size_t)4U)
9235
9236
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_ERROR_COEFFICIENT ((size_t)3U)
9237
9238
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_GAMMA1_COEFFICIENT ((size_t)20U)
9239
9240
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A ((size_t)7U)
9241
9242
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COMMITMENT_HASH_SIZE ((size_t)64U)
9243
9244
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ETA (libcrux_ml_dsa_constants_Eta_Two)
9245
9246
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA1_EXPONENT ((size_t)19U)
9247
9248
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA2 ((LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS - 1) / 32)
9249
9250
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_MAX_ONES_IN_HINT ((size_t)75U)
9251
9252
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ONES_IN_VERIFIER_CHALLENGE ((size_t)60U)
9253
9254
#define LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A ((size_t)8U)
9255
9256
/**
9257
This function found in impl {core::clone::Clone for libcrux_ml_dsa::constants::Eta}
9258
*/
9259
static inline libcrux_ml_dsa_constants_Eta
9260
libcrux_ml_dsa_constants_clone_54(const libcrux_ml_dsa_constants_Eta *self)
9261
0
{
9262
0
  return self[0U];
9263
0
}
9264
9265
static KRML_MUSTINLINE size_t
9266
libcrux_ml_dsa_encoding_error_chunk_size(libcrux_ml_dsa_constants_Eta eta)
9267
0
{
9268
0
  switch (eta)
9269
0
  {
9270
0
    case libcrux_ml_dsa_constants_Eta_Two:
9271
0
      {
9272
0
        break;
9273
0
      }
9274
0
    case libcrux_ml_dsa_constants_Eta_Four:
9275
0
      {
9276
0
        return (size_t)4U;
9277
0
      }
9278
0
    default:
9279
0
      {
9280
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
9281
0
        KRML_HOST_EXIT(253U);
9282
0
      }
9283
0
  }
9284
0
  return (size_t)3U;
9285
0
}
9286
9287
0
#define libcrux_ml_dsa_types_VerificationError_MalformedHintError 0
9288
0
#define libcrux_ml_dsa_types_VerificationError_SignerResponseExceedsBoundError 1
9289
0
#define libcrux_ml_dsa_types_VerificationError_CommitmentHashesDontMatchError 2
9290
0
#define libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError 3
9291
9292
typedef uint8_t libcrux_ml_dsa_types_VerificationError;
9293
9294
static KRML_MUSTINLINE void
9295
libcrux_ml_dsa_encoding_signature_set_hint(
9296
  Eurydice_dst_ref_mut_20 out_hint,
9297
  size_t i,
9298
  size_t j
9299
)
9300
0
{
9301
0
  out_hint.ptr[i].data[j] = 1;
9302
0
}
9303
9304
0
#define LIBCRUX_ML_DSA_ENCODING_T0_OUTPUT_BYTES_PER_SIMD_UNIT ((size_t)13U)
9305
9306
0
#define LIBCRUX_ML_DSA_ENCODING_T1_DESERIALIZE_WINDOW ((size_t)10U)
9307
9308
0
#define LIBCRUX_ML_DSA_ENCODING_T1_SERIALIZE_OUTPUT_BYTES_PER_SIMD_UNIT ((size_t)10U)
9309
9310
#define LIBCRUX_ML_DSA_HASH_FUNCTIONS_SHAKE128_BLOCK_SIZE ((size_t)168U)
9311
9312
#define LIBCRUX_ML_DSA_HASH_FUNCTIONS_SHAKE128_FIVE_BLOCKS_SIZE (LIBCRUX_ML_DSA_HASH_FUNCTIONS_SHAKE128_BLOCK_SIZE * (size_t)5U)
9313
9314
#define LIBCRUX_ML_DSA_HASH_FUNCTIONS_SHAKE256_BLOCK_SIZE ((size_t)136U)
9315
9316
static KRML_MUSTINLINE Eurydice_arr_91
9317
libcrux_ml_dsa_sample_add_error_domain_separator(
9318
  Eurydice_borrow_slice_u8 slice,
9319
  uint16_t domain_separator
9320
)
9321
0
{
9322
0
  Eurydice_arr_91 out = { .data = { 0U } };
9323
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d4(&out,
9324
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
9325
0
    slice,
9326
0
    uint8_t);
9327
0
  out.data[64U] = (uint8_t)(uint32_t)domain_separator;
9328
0
  out.data[65U] = (uint8_t)((uint32_t)domain_separator >> 8U & 0xFFFFU);
9329
0
  return out;
9330
0
}
9331
9332
0
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_error_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_ERROR_COEFFICIENT))
9333
9334
0
#define LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS (8380417)
9335
9336
0
#define LIBCRUX_ML_DSA_SIMD_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R (58728449ULL)
9337
9338
static inline uint8_t_x2
9339
libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_xy(size_t index, size_t width)
9340
0
{
9341
0
  return
9342
0
    (KRML_CLITERAL(uint8_t_x2){ .fst = (uint8_t)(index / width), .snd = (uint8_t)(index % width) });
9343
0
}
9344
9345
static KRML_MUSTINLINE uint16_t libcrux_ml_dsa_sample_generate_domain_separator(uint8_t_x2 _)
9346
0
{
9347
0
  uint8_t row = _.fst;
9348
0
  uint8_t column = _.snd;
9349
0
  return (uint32_t)(uint16_t)(uint32_t)column | (uint32_t)(uint16_t)(uint32_t)row << 8U;
9350
0
}
9351
9352
static KRML_MUSTINLINE Eurydice_arr_31
9353
libcrux_ml_dsa_sample_add_domain_separator(Eurydice_borrow_slice_u8 slice, uint8_t_x2 indices)
9354
0
{
9355
0
  Eurydice_arr_31 out = { .data = { 0U } };
9356
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d40(&out,
9357
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = slice.meta })),
9358
0
    slice,
9359
0
    uint8_t);
9360
0
  uint16_t domain_separator = libcrux_ml_dsa_sample_generate_domain_separator(indices);
9361
0
  out.data[32U] = (uint8_t)(uint32_t)domain_separator;
9362
0
  out.data[33U] = (uint8_t)((uint32_t)domain_separator >> 8U & 0xFFFFU);
9363
0
  return out;
9364
0
}
9365
9366
0
#define libcrux_ml_dsa_types_SigningError_RejectionSamplingError 0
9367
0
#define libcrux_ml_dsa_types_SigningError_ContextTooLongError 1
9368
9369
typedef uint8_t libcrux_ml_dsa_types_SigningError;
9370
9371
typedef struct libcrux_ml_dsa_pre_hash_DomainSeparationContext_s
9372
{
9373
  Eurydice_borrow_slice_u8 context;
9374
  core_option_Option_57 pre_hash_oid;
9375
}
9376
libcrux_ml_dsa_pre_hash_DomainSeparationContext;
9377
9378
0
#define libcrux_ml_dsa_pre_hash_DomainSeparationError_ContextTooLongError 0
9379
9380
typedef uint8_t libcrux_ml_dsa_pre_hash_DomainSeparationError;
9381
9382
/**
9383
A monomorphic instance of core.result.Result
9384
with types libcrux_ml_dsa_pre_hash_DomainSeparationContext, libcrux_ml_dsa_pre_hash_DomainSeparationError
9385
9386
*/
9387
typedef struct core_result_Result_a8_s
9388
{
9389
  core_result_Result_57_tags tag;
9390
  union {
9391
    libcrux_ml_dsa_pre_hash_DomainSeparationContext case_Ok;
9392
    libcrux_ml_dsa_pre_hash_DomainSeparationError case_Err;
9393
  }
9394
  val;
9395
}
9396
core_result_Result_a8;
9397
9398
/**
9399
 `context` must be at most 255 bytes long.
9400
*/
9401
/**
9402
This function found in impl {libcrux_ml_dsa::pre_hash::DomainSeparationContext<'a>}
9403
*/
9404
static inline core_result_Result_a8
9405
libcrux_ml_dsa_pre_hash_new_88(
9406
  Eurydice_borrow_slice_u8 context,
9407
  core_option_Option_57 pre_hash_oid
9408
)
9409
0
{
9410
0
  if (!(context.meta > LIBCRUX_ML_DSA_CONSTANTS_CONTEXT_MAX_LEN))
9411
0
  {
9412
0
    return
9413
0
      (
9414
0
        KRML_CLITERAL(core_result_Result_a8){
9415
0
          .tag = core_result_Ok,
9416
0
          .val = { .case_Ok = { .context = context, .pre_hash_oid = pre_hash_oid } }
9417
0
        }
9418
0
      );
9419
0
  }
9420
0
  return
9421
0
    (
9422
0
      KRML_CLITERAL(core_result_Result_a8){
9423
0
        .tag = core_result_Err,
9424
0
        .val = { .case_Err = libcrux_ml_dsa_pre_hash_DomainSeparationError_ContextTooLongError }
9425
0
      }
9426
0
    );
9427
0
}
9428
9429
/**
9430
 Returns the pre-hash OID, if any.
9431
*/
9432
/**
9433
This function found in impl {libcrux_ml_dsa::pre_hash::DomainSeparationContext<'a>}
9434
*/
9435
static inline const
9436
core_option_Option_57
9437
*libcrux_ml_dsa_pre_hash_pre_hash_oid_88(
9438
  const libcrux_ml_dsa_pre_hash_DomainSeparationContext *self
9439
)
9440
0
{
9441
0
  return &self->pre_hash_oid;
9442
0
}
9443
9444
/**
9445
 Returns the context, guaranteed to be at most 255 bytes long.
9446
*/
9447
/**
9448
This function found in impl {libcrux_ml_dsa::pre_hash::DomainSeparationContext<'a>}
9449
*/
9450
static inline Eurydice_borrow_slice_u8
9451
libcrux_ml_dsa_pre_hash_context_88(const libcrux_ml_dsa_pre_hash_DomainSeparationContext *self)
9452
0
{
9453
0
  return self->context;
9454
0
}
9455
9456
0
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_COMMITMENT_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_commitment_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_COMMITMENT_COEFFICIENT))
9457
9458
static KRML_MUSTINLINE bool
9459
libcrux_ml_dsa_sample_inside_out_shuffle(
9460
  Eurydice_borrow_slice_u8 randomness,
9461
  size_t *out_index,
9462
  uint64_t *signs,
9463
  Eurydice_arr_6c *result
9464
)
9465
0
{
9466
0
  bool done = false;
9467
0
  for (size_t i = (size_t)0U; i < randomness.meta; i++)
9468
0
  {
9469
0
    size_t _cloop_j = i;
9470
0
    const uint8_t *byte = &randomness.ptr[_cloop_j];
9471
0
    if (!done)
9472
0
    {
9473
0
      size_t sample_at = (size_t)(uint32_t)byte[0U];
9474
0
      if (sample_at <= out_index[0U])
9475
0
      {
9476
0
        result->data[out_index[0U]] = result->data[sample_at];
9477
0
        out_index[0U]++;
9478
0
        result->data[sample_at] = 1 - 2 * (int32_t)(signs[0U] & 1ULL);
9479
0
        signs[0U] >>= 1U;
9480
0
      }
9481
0
      done = out_index[0U] == (size_t)256U;
9482
0
    }
9483
0
  }
9484
0
  return done;
9485
0
}
9486
9487
0
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_BETA (libcrux_ml_dsa_constants_beta(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ONES_IN_VERIFIER_CHALLENGE, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ETA))
9488
9489
0
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_GAMMA1_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_gamma1_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_GAMMA1_COEFFICIENT))
9490
9491
#define LIBCRUX_ML_DSA_PRE_HASH_SHAKE128_OID ((KRML_CLITERAL(Eurydice_arr_c9){ .data = { 6U, 9U, 96U, 134U, 72U, 1U, 101U, 3U, 4U, 2U, 11U } }))
9492
9493
/**
9494
This function found in impl {libcrux_ml_dsa::pre_hash::PreHash for libcrux_ml_dsa::pre_hash::SHAKE128_PH}
9495
*/
9496
static inline Eurydice_arr_c9 libcrux_ml_dsa_pre_hash_oid_30(void)
9497
0
{
9498
0
  return LIBCRUX_ML_DSA_PRE_HASH_SHAKE128_OID;
9499
0
}
9500
9501
0
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_VERIFICATION_KEY_SIZE (libcrux_ml_dsa_constants_verification_key_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A))
9502
9503
0
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_SIGNATURE_SIZE (libcrux_ml_dsa_constants_signature_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_MAX_ONES_IN_HINT, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COMMITMENT_HASH_SIZE, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_GAMMA1_COEFFICIENT))
9504
9505
typedef Eurydice_arr_4d libcrux_ml_dsa_simd_portable_vector_type_Coefficients;
9506
9507
static KRML_MUSTINLINE Eurydice_arr_4d libcrux_ml_dsa_simd_portable_vector_type_zero(void)
9508
0
{
9509
0
  return (KRML_CLITERAL(Eurydice_arr_4d){ .data = { 0U } });
9510
0
}
9511
9512
/**
9513
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9514
*/
9515
static inline Eurydice_arr_4d libcrux_ml_dsa_simd_portable_zero_65(void)
9516
0
{
9517
0
  return libcrux_ml_dsa_simd_portable_vector_type_zero();
9518
0
}
9519
9520
static KRML_MUSTINLINE void
9521
libcrux_ml_dsa_simd_portable_vector_type_from_coefficient_array(
9522
  Eurydice_dst_ref_shared_83 array,
9523
  Eurydice_arr_4d *out
9524
)
9525
0
{
9526
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_fd(out),
9527
0
    Eurydice_slice_subslice_shared_47(array,
9528
0
      (
9529
0
        KRML_CLITERAL(core_ops_range_Range_87){
9530
0
          .start = (size_t)0U,
9531
0
          .end = LIBCRUX_ML_DSA_SIMD_TRAITS_COEFFICIENTS_IN_SIMD_UNIT
9532
0
        }
9533
0
      )),
9534
0
    int32_t);
9535
0
}
9536
9537
/**
9538
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9539
*/
9540
static inline void
9541
libcrux_ml_dsa_simd_portable_from_coefficient_array_65(
9542
  Eurydice_dst_ref_shared_83 array,
9543
  Eurydice_arr_4d *out
9544
)
9545
0
{
9546
0
  libcrux_ml_dsa_simd_portable_vector_type_from_coefficient_array(array, out);
9547
0
}
9548
9549
static KRML_MUSTINLINE void
9550
libcrux_ml_dsa_simd_portable_vector_type_to_coefficient_array(
9551
  const Eurydice_arr_4d *value,
9552
  Eurydice_dst_ref_mut_83 out
9553
)
9554
0
{
9555
0
  Eurydice_slice_copy(out, Eurydice_array_to_slice_shared_fd(value), int32_t);
9556
0
}
9557
9558
/**
9559
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9560
*/
9561
static inline void
9562
libcrux_ml_dsa_simd_portable_to_coefficient_array_65(
9563
  const Eurydice_arr_4d *value,
9564
  Eurydice_dst_ref_mut_83 out
9565
)
9566
0
{
9567
0
  libcrux_ml_dsa_simd_portable_vector_type_to_coefficient_array(value, out);
9568
0
}
9569
9570
static KRML_MUSTINLINE void
9571
libcrux_ml_dsa_simd_portable_arithmetic_add(Eurydice_arr_4d *lhs, const Eurydice_arr_4d *rhs)
9572
0
{
9573
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9574
0
  {
9575
0
    size_t i0 = i;
9576
0
    size_t uu____0 = i0;
9577
0
    lhs->data[uu____0] += rhs->data[i0];
9578
0
  }
9579
0
}
9580
9581
/**
9582
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9583
*/
9584
static inline void
9585
libcrux_ml_dsa_simd_portable_add_65(Eurydice_arr_4d *lhs, const Eurydice_arr_4d *rhs)
9586
0
{
9587
0
  libcrux_ml_dsa_simd_portable_arithmetic_add(lhs, rhs);
9588
0
}
9589
9590
static KRML_MUSTINLINE void
9591
libcrux_ml_dsa_simd_portable_arithmetic_subtract(
9592
  Eurydice_arr_4d *lhs,
9593
  const Eurydice_arr_4d *rhs
9594
)
9595
0
{
9596
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9597
0
  {
9598
0
    size_t i0 = i;
9599
0
    size_t uu____0 = i0;
9600
0
    lhs->data[uu____0] -= rhs->data[i0];
9601
0
  }
9602
0
}
9603
9604
/**
9605
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9606
*/
9607
static inline void
9608
libcrux_ml_dsa_simd_portable_subtract_65(Eurydice_arr_4d *lhs, const Eurydice_arr_4d *rhs)
9609
0
{
9610
0
  libcrux_ml_dsa_simd_portable_arithmetic_subtract(lhs, rhs);
9611
0
}
9612
9613
static KRML_MUSTINLINE bool
9614
libcrux_ml_dsa_simd_portable_arithmetic_infinity_norm_exceeds(
9615
  const Eurydice_arr_4d *simd_unit,
9616
  int32_t bound
9617
)
9618
0
{
9619
0
  bool result = false;
9620
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9621
0
  {
9622
0
    size_t i0 = i;
9623
0
    int32_t coefficient = simd_unit->data[i0];
9624
0
    int32_t sign = coefficient >> 31U;
9625
0
    int32_t normalized = coefficient - (sign & 2 * coefficient);
9626
0
    bool uu____0;
9627
0
    if (result)
9628
0
    {
9629
0
      uu____0 = true;
9630
0
    }
9631
0
    else
9632
0
    {
9633
0
      uu____0 = normalized >= bound;
9634
0
    }
9635
0
    result = uu____0;
9636
0
  }
9637
0
  return result;
9638
0
}
9639
9640
/**
9641
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9642
*/
9643
static inline bool
9644
libcrux_ml_dsa_simd_portable_infinity_norm_exceeds_65(
9645
  const Eurydice_arr_4d *simd_unit,
9646
  int32_t bound
9647
)
9648
0
{
9649
0
  return libcrux_ml_dsa_simd_portable_arithmetic_infinity_norm_exceeds(simd_unit, bound);
9650
0
}
9651
9652
static KRML_MUSTINLINE int32_t_x2
9653
libcrux_ml_dsa_simd_portable_arithmetic_decompose_element(int32_t gamma2, int32_t r)
9654
0
{
9655
0
  int32_t r0 = r + (r >> 31U & LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS);
9656
0
  int32_t ceil_of_r_by_128 = (r0 + 127) >> 7U;
9657
0
  int32_t r1;
9658
0
  switch (gamma2)
9659
0
  {
9660
0
    case 95232:
9661
0
      {
9662
0
        int32_t result = (ceil_of_r_by_128 * 11275 + (int32_t)((uint32_t)1 << 23U)) >> 24U;
9663
0
        int32_t result_0 = (result ^ (43 - result) >> 31U) & result;
9664
0
        r1 = result_0;
9665
0
        break;
9666
0
      }
9667
0
    case 261888:
9668
0
      {
9669
0
        int32_t result = (ceil_of_r_by_128 * 1025 + (int32_t)((uint32_t)1 << 21U)) >> 22U;
9670
0
        int32_t result_0 = result & 15;
9671
0
        r1 = result_0;
9672
0
        break;
9673
0
      }
9674
0
    default:
9675
0
      {
9676
0
        KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
9677
0
        KRML_HOST_EXIT(255U);
9678
0
      }
9679
0
  }
9680
0
  int32_t alpha = gamma2 * 2;
9681
0
  int32_t r00 = r0 - r1 * alpha;
9682
0
  r00 -=
9683
0
    ((LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS - 1) / 2 - r00) >> 31U &
9684
0
      LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS;
9685
0
  return (KRML_CLITERAL(int32_t_x2){ .fst = r00, .snd = r1 });
9686
0
}
9687
9688
static KRML_MUSTINLINE void
9689
libcrux_ml_dsa_simd_portable_arithmetic_decompose(
9690
  int32_t gamma2,
9691
  const Eurydice_arr_4d *simd_unit,
9692
  Eurydice_arr_4d *low,
9693
  Eurydice_arr_4d *high
9694
)
9695
0
{
9696
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9697
0
  {
9698
0
    size_t i0 = i;
9699
0
    int32_t_x2
9700
0
    uu____0 =
9701
0
      libcrux_ml_dsa_simd_portable_arithmetic_decompose_element(gamma2,
9702
0
        simd_unit->data[i0]);
9703
0
    int32_t uu____1 = uu____0.snd;
9704
0
    low->data[i0] = uu____0.fst;
9705
0
    high->data[i0] = uu____1;
9706
0
  }
9707
0
}
9708
9709
/**
9710
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9711
*/
9712
static inline void
9713
libcrux_ml_dsa_simd_portable_decompose_65(
9714
  int32_t gamma2,
9715
  const Eurydice_arr_4d *simd_unit,
9716
  Eurydice_arr_4d *low,
9717
  Eurydice_arr_4d *high
9718
)
9719
0
{
9720
0
  libcrux_ml_dsa_simd_portable_arithmetic_decompose(gamma2, simd_unit, low, high);
9721
0
}
9722
9723
static KRML_MUSTINLINE int32_t
9724
libcrux_ml_dsa_simd_portable_arithmetic_compute_one_hint(
9725
  int32_t low,
9726
  int32_t high,
9727
  int32_t gamma2
9728
)
9729
0
{
9730
0
  int32_t uu____0;
9731
0
  if (low > gamma2)
9732
0
  {
9733
0
    uu____0 = 1;
9734
0
  }
9735
0
  else if (low < -gamma2)
9736
0
  {
9737
0
    uu____0 = 1;
9738
0
  }
9739
0
  else if (low == -gamma2)
9740
0
  {
9741
0
    if (high != 0)
9742
0
    {
9743
0
      uu____0 = 1;
9744
0
    }
9745
0
    else
9746
0
    {
9747
0
      uu____0 = 0;
9748
0
    }
9749
0
  }
9750
0
  else
9751
0
  {
9752
0
    uu____0 = 0;
9753
0
  }
9754
0
  return uu____0;
9755
0
}
9756
9757
static KRML_MUSTINLINE size_t
9758
libcrux_ml_dsa_simd_portable_arithmetic_compute_hint(
9759
  const Eurydice_arr_4d *low,
9760
  const Eurydice_arr_4d *high,
9761
  int32_t gamma2,
9762
  Eurydice_arr_4d *hint
9763
)
9764
0
{
9765
0
  size_t one_hints_count = (size_t)0U;
9766
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9767
0
  {
9768
0
    size_t i0 = i;
9769
0
    hint->data[i0] =
9770
0
      libcrux_ml_dsa_simd_portable_arithmetic_compute_one_hint(low->data[i0],
9771
0
        high->data[i0],
9772
0
        gamma2);
9773
0
    one_hints_count += (size_t)hint->data[i0];
9774
0
  }
9775
0
  return one_hints_count;
9776
0
}
9777
9778
/**
9779
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9780
*/
9781
static inline size_t
9782
libcrux_ml_dsa_simd_portable_compute_hint_65(
9783
  const Eurydice_arr_4d *low,
9784
  const Eurydice_arr_4d *high,
9785
  int32_t gamma2,
9786
  Eurydice_arr_4d *hint
9787
)
9788
0
{
9789
0
  return libcrux_ml_dsa_simd_portable_arithmetic_compute_hint(low, high, gamma2, hint);
9790
0
}
9791
9792
static KRML_MUSTINLINE int32_t
9793
libcrux_ml_dsa_simd_portable_arithmetic_use_one_hint(int32_t gamma2, int32_t r, int32_t hint)
9794
0
{
9795
0
  int32_t_x2 uu____0 = libcrux_ml_dsa_simd_portable_arithmetic_decompose_element(gamma2, r);
9796
0
  int32_t r0 = uu____0.fst;
9797
0
  int32_t r1 = uu____0.snd;
9798
0
  int32_t uu____1;
9799
0
  if (!(hint == 0))
9800
0
  {
9801
0
    switch (gamma2)
9802
0
    {
9803
0
      case 95232:
9804
0
        {
9805
0
          if (r0 > 0)
9806
0
          {
9807
0
            if (r1 == 43)
9808
0
            {
9809
0
              uu____1 = 0;
9810
0
            }
9811
0
            else
9812
0
            {
9813
0
              uu____1 = r1 + hint;
9814
0
            }
9815
0
          }
9816
0
          else if (r1 == 0)
9817
0
          {
9818
0
            uu____1 = 43;
9819
0
          }
9820
0
          else
9821
0
          {
9822
0
            uu____1 = r1 - hint;
9823
0
          }
9824
0
          break;
9825
0
        }
9826
0
      case 261888:
9827
0
        {
9828
0
          if (r0 > 0)
9829
0
          {
9830
0
            uu____1 = (r1 + hint) & 15;
9831
0
          }
9832
0
          else
9833
0
          {
9834
0
            uu____1 = (r1 - hint) & 15;
9835
0
          }
9836
0
          break;
9837
0
        }
9838
0
      default:
9839
0
        {
9840
0
          KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
9841
0
          KRML_HOST_EXIT(255U);
9842
0
        }
9843
0
    }
9844
0
    return uu____1;
9845
0
  }
9846
0
  return r1;
9847
0
}
9848
9849
static KRML_MUSTINLINE void
9850
libcrux_ml_dsa_simd_portable_arithmetic_use_hint(
9851
  int32_t gamma2,
9852
  const Eurydice_arr_4d *simd_unit,
9853
  Eurydice_arr_4d *hint
9854
)
9855
0
{
9856
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9857
0
  {
9858
0
    size_t i0 = i;
9859
0
    int32_t
9860
0
    uu____0 =
9861
0
      libcrux_ml_dsa_simd_portable_arithmetic_use_one_hint(gamma2,
9862
0
        simd_unit->data[i0],
9863
0
        hint->data[i0]);
9864
0
    hint->data[i0] = uu____0;
9865
0
  }
9866
0
}
9867
9868
/**
9869
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9870
*/
9871
static inline void
9872
libcrux_ml_dsa_simd_portable_use_hint_65(
9873
  int32_t gamma2,
9874
  const Eurydice_arr_4d *simd_unit,
9875
  Eurydice_arr_4d *hint
9876
)
9877
0
{
9878
0
  libcrux_ml_dsa_simd_portable_arithmetic_use_hint(gamma2, simd_unit, hint);
9879
0
}
9880
9881
static KRML_MUSTINLINE uint64_t
9882
libcrux_ml_dsa_simd_portable_arithmetic_get_n_least_significant_bits(uint8_t n, uint64_t value)
9883
0
{
9884
0
  return value & ((1ULL << (uint32_t)n) - 1ULL);
9885
0
}
9886
9887
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (32U)
9888
9889
static KRML_MUSTINLINE int32_t
9890
libcrux_ml_dsa_simd_portable_arithmetic_montgomery_reduce_element(int64_t value)
9891
0
{
9892
0
  uint64_t
9893
0
  t =
9894
0
    libcrux_ml_dsa_simd_portable_arithmetic_get_n_least_significant_bits(LIBCRUX_ML_DSA_SIMD_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT,
9895
0
      (uint64_t)value)
9896
0
    * LIBCRUX_ML_DSA_SIMD_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R;
9897
0
  int32_t
9898
0
  k =
9899
0
    (int32_t)libcrux_ml_dsa_simd_portable_arithmetic_get_n_least_significant_bits(LIBCRUX_ML_DSA_SIMD_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT,
9900
0
      t);
9901
0
  int64_t k_times_modulus = (int64_t)k * (int64_t)LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS;
9902
0
  int32_t
9903
0
  c =
9904
0
    (int32_t)(k_times_modulus >> (uint32_t)LIBCRUX_ML_DSA_SIMD_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
9905
0
  int32_t
9906
0
  value_high =
9907
0
    (int32_t)(value >> (uint32_t)LIBCRUX_ML_DSA_SIMD_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
9908
0
  return value_high - c;
9909
0
}
9910
9911
static KRML_MUSTINLINE void
9912
libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply(
9913
  Eurydice_arr_4d *lhs,
9914
  const Eurydice_arr_4d *rhs
9915
)
9916
0
{
9917
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9918
0
  {
9919
0
    size_t i0 = i;
9920
0
    lhs->data[i0] =
9921
0
      libcrux_ml_dsa_simd_portable_arithmetic_montgomery_reduce_element((int64_t)lhs->data[i0] *
9922
0
          (int64_t)rhs->data[i0]);
9923
0
  }
9924
0
}
9925
9926
/**
9927
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9928
*/
9929
static inline void
9930
libcrux_ml_dsa_simd_portable_montgomery_multiply_65(
9931
  Eurydice_arr_4d *lhs,
9932
  const Eurydice_arr_4d *rhs
9933
)
9934
0
{
9935
0
  libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply(lhs, rhs);
9936
0
}
9937
9938
static KRML_MUSTINLINE int32_t
9939
libcrux_ml_dsa_simd_portable_arithmetic_barrett_reduce_element(int32_t fe)
9940
0
{
9941
0
  int32_t quotient = (fe + (int32_t)((uint32_t)1 << 22U)) >> 23U;
9942
0
  return fe - quotient * LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS;
9943
0
}
9944
9945
static inline void
9946
libcrux_ml_dsa_simd_portable_arithmetic_barrett_reduce_simd_unit(Eurydice_arr_4d *simd_unit)
9947
0
{
9948
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9949
0
  {
9950
0
    size_t i0 = i;
9951
0
    simd_unit->data[i0] =
9952
0
      libcrux_ml_dsa_simd_portable_arithmetic_barrett_reduce_element(simd_unit->data[i0]);
9953
0
  }
9954
0
}
9955
9956
static KRML_MUSTINLINE int32_t_x2
9957
libcrux_ml_dsa_simd_portable_arithmetic_power2round_element(int32_t t)
9958
0
{
9959
0
  int32_t t2 = t + (t >> 31U & LIBCRUX_ML_DSA_SIMD_TRAITS_FIELD_MODULUS);
9960
0
  int32_t
9961
0
  t1 =
9962
0
    (t2 - 1 +
9963
0
      (int32_t)((uint32_t)1 <<
9964
0
        (uint32_t)(LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T - (size_t)1U)))
9965
0
    >> (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T;
9966
0
  int32_t
9967
0
  t0 = t2 - (int32_t)((uint32_t)t1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T);
9968
0
  return (KRML_CLITERAL(int32_t_x2){ .fst = t0, .snd = t1 });
9969
0
}
9970
9971
static KRML_MUSTINLINE void
9972
libcrux_ml_dsa_simd_portable_arithmetic_power2round(Eurydice_arr_4d *t0, Eurydice_arr_4d *t1)
9973
0
{
9974
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
9975
0
  {
9976
0
    size_t i0 = i;
9977
0
    int32_t_x2 uu____0 = libcrux_ml_dsa_simd_portable_arithmetic_power2round_element(t0->data[i0]);
9978
0
    int32_t uu____1 = uu____0.snd;
9979
0
    t0->data[i0] = uu____0.fst;
9980
0
    t1->data[i0] = uu____1;
9981
0
  }
9982
0
}
9983
9984
/**
9985
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
9986
*/
9987
static inline void
9988
libcrux_ml_dsa_simd_portable_power2round_65(Eurydice_arr_4d *t0, Eurydice_arr_4d *t1)
9989
0
{
9990
0
  libcrux_ml_dsa_simd_portable_arithmetic_power2round(t0, t1);
9991
0
}
9992
9993
static KRML_MUSTINLINE size_t
9994
libcrux_ml_dsa_simd_portable_sample_rejection_sample_less_than_field_modulus(
9995
  Eurydice_borrow_slice_u8 randomness,
9996
  Eurydice_dst_ref_mut_83 out
9997
)
9998
0
{
9999
0
  size_t sampled = (size_t)0U;
10000
0
  for (size_t i = (size_t)0U; i < randomness.meta / (size_t)3U; i++)
10001
0
  {
10002
0
    size_t i0 = i;
10003
0
    int32_t b0 = (int32_t)(uint32_t)randomness.ptr[i0 * (size_t)3U];
10004
0
    int32_t b1 = (int32_t)(uint32_t)randomness.ptr[i0 * (size_t)3U + (size_t)1U];
10005
0
    int32_t b2 = (int32_t)(uint32_t)randomness.ptr[i0 * (size_t)3U + (size_t)2U];
10006
0
    int32_t
10007
0
    coefficient = (((int32_t)((uint32_t)b2 << 16U) | (int32_t)((uint32_t)b1 << 8U)) | b0) & 8388607;
10008
0
    if (coefficient < LIBCRUX_ML_DSA_CONSTANTS_FIELD_MODULUS)
10009
0
    {
10010
0
      out.ptr[sampled] = coefficient;
10011
0
      sampled++;
10012
0
    }
10013
0
  }
10014
0
  return sampled;
10015
0
}
10016
10017
/**
10018
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10019
*/
10020
static inline size_t
10021
libcrux_ml_dsa_simd_portable_rejection_sample_less_than_field_modulus_65(
10022
  Eurydice_borrow_slice_u8 randomness,
10023
  Eurydice_dst_ref_mut_83 out
10024
)
10025
0
{
10026
0
  return
10027
0
    libcrux_ml_dsa_simd_portable_sample_rejection_sample_less_than_field_modulus(randomness,
10028
0
      out);
10029
0
}
10030
10031
static KRML_MUSTINLINE size_t
10032
libcrux_ml_dsa_simd_portable_sample_rejection_sample_less_than_eta_equals_2(
10033
  Eurydice_borrow_slice_u8 randomness,
10034
  Eurydice_dst_ref_mut_83 out
10035
)
10036
0
{
10037
0
  size_t sampled = (size_t)0U;
10038
0
  for (size_t i = (size_t)0U; i < randomness.meta; i++)
10039
0
  {
10040
0
    size_t i0 = i;
10041
0
    uint8_t byte = randomness.ptr[i0];
10042
0
    uint8_t try_0 = (uint32_t)byte & 15U;
10043
0
    uint8_t try_1 = (uint32_t)byte >> 4U;
10044
0
    bool try_0_comp = try_0 < 15U;
10045
0
    bool try_1_comp = try_1 < 15U;
10046
0
    if (try_0_comp)
10047
0
    {
10048
0
      int32_t try_00 = (int32_t)(uint32_t)try_0;
10049
0
      int32_t try_0_mod_5 = try_00 - (try_00 * 26 >> 7U) * 5;
10050
0
      out.ptr[sampled] = 2 - try_0_mod_5;
10051
0
      sampled++;
10052
0
    }
10053
0
    if (try_1_comp)
10054
0
    {
10055
0
      int32_t try_10 = (int32_t)(uint32_t)try_1;
10056
0
      int32_t try_1_mod_5 = try_10 - (try_10 * 26 >> 7U) * 5;
10057
0
      out.ptr[sampled] = 2 - try_1_mod_5;
10058
0
      sampled++;
10059
0
    }
10060
0
  }
10061
0
  return sampled;
10062
0
}
10063
10064
/**
10065
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10066
*/
10067
static inline size_t
10068
libcrux_ml_dsa_simd_portable_rejection_sample_less_than_eta_equals_2_65(
10069
  Eurydice_borrow_slice_u8 randomness,
10070
  Eurydice_dst_ref_mut_83 out
10071
)
10072
0
{
10073
0
  return
10074
0
    libcrux_ml_dsa_simd_portable_sample_rejection_sample_less_than_eta_equals_2(randomness,
10075
0
      out);
10076
0
}
10077
10078
static KRML_MUSTINLINE size_t
10079
libcrux_ml_dsa_simd_portable_sample_rejection_sample_less_than_eta_equals_4(
10080
  Eurydice_borrow_slice_u8 randomness,
10081
  Eurydice_dst_ref_mut_83 out
10082
)
10083
0
{
10084
0
  size_t sampled = (size_t)0U;
10085
0
  for (size_t i = (size_t)0U; i < randomness.meta; i++)
10086
0
  {
10087
0
    size_t i0 = i;
10088
0
    uint8_t byte = randomness.ptr[i0];
10089
0
    uint8_t try_0 = (uint32_t)byte & 15U;
10090
0
    uint8_t try_1 = (uint32_t)byte >> 4U;
10091
0
    bool try_0_comp = try_0 < 9U;
10092
0
    bool try_1_comp = try_1 < 9U;
10093
0
    if (try_0_comp)
10094
0
    {
10095
0
      out.ptr[sampled] = 4 - (int32_t)(uint32_t)try_0;
10096
0
      sampled++;
10097
0
    }
10098
0
    if (try_1_comp)
10099
0
    {
10100
0
      out.ptr[sampled] = 4 - (int32_t)(uint32_t)try_1;
10101
0
      sampled++;
10102
0
    }
10103
0
  }
10104
0
  return sampled;
10105
0
}
10106
10107
/**
10108
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10109
*/
10110
static inline size_t
10111
libcrux_ml_dsa_simd_portable_rejection_sample_less_than_eta_equals_4_65(
10112
  Eurydice_borrow_slice_u8 randomness,
10113
  Eurydice_dst_ref_mut_83 out
10114
)
10115
0
{
10116
0
  return
10117
0
    libcrux_ml_dsa_simd_portable_sample_rejection_sample_less_than_eta_equals_4(randomness,
10118
0
      out);
10119
0
}
10120
10121
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 ((int32_t)((uint32_t)1 << 19U))
10122
10123
static KRML_MUSTINLINE void
10124
libcrux_ml_dsa_simd_portable_encoding_gamma1_serialize_when_gamma1_is_2_pow_19(
10125
  const Eurydice_arr_4d *simd_unit,
10126
  Eurydice_mut_borrow_slice_u8 serialized
10127
)
10128
0
{
10129
0
  for (size_t i = (size_t)0U; i < (size_t)8U / (size_t)2U; i++)
10130
0
  {
10131
0
    size_t i0 = i;
10132
0
    Eurydice_dst_ref_shared_83
10133
0
    coefficients =
10134
0
      Eurydice_array_to_subslice_shared_44(simd_unit,
10135
0
        (
10136
0
          KRML_CLITERAL(core_ops_range_Range_87){
10137
0
            .start = i0 * (size_t)2U,
10138
0
            .end = i0 * (size_t)2U + (size_t)2U
10139
0
          }
10140
0
        ));
10141
0
    int32_t
10142
0
    coefficient0 =
10143
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 -
10144
0
        coefficients.ptr[0U];
10145
0
    int32_t
10146
0
    coefficient1 =
10147
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 -
10148
0
        coefficients.ptr[1U];
10149
0
    serialized.ptr[(size_t)5U * i0] = (uint8_t)coefficient0;
10150
0
    serialized.ptr[(size_t)5U * i0 + (size_t)1U] = (uint8_t)(coefficient0 >> 8U);
10151
0
    serialized.ptr[(size_t)5U * i0 + (size_t)2U] = (uint8_t)(coefficient0 >> 16U);
10152
0
    size_t uu____0 = (size_t)5U * i0 + (size_t)2U;
10153
0
    serialized.ptr[uu____0] =
10154
0
      (uint32_t)serialized.ptr[uu____0] | (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient1 << 4U);
10155
0
    serialized.ptr[(size_t)5U * i0 + (size_t)3U] = (uint8_t)(coefficient1 >> 4U);
10156
0
    serialized.ptr[(size_t)5U * i0 + (size_t)4U] = (uint8_t)(coefficient1 >> 12U);
10157
0
  }
10158
0
}
10159
10160
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 ((int32_t)((uint32_t)1 << 17U))
10161
10162
static KRML_MUSTINLINE void
10163
libcrux_ml_dsa_simd_portable_encoding_gamma1_serialize_when_gamma1_is_2_pow_17(
10164
  const Eurydice_arr_4d *simd_unit,
10165
  Eurydice_mut_borrow_slice_u8 serialized
10166
)
10167
0
{
10168
0
  for (size_t i = (size_t)0U; i < (size_t)8U / (size_t)4U; i++)
10169
0
  {
10170
0
    size_t i0 = i;
10171
0
    Eurydice_dst_ref_shared_83
10172
0
    coefficients =
10173
0
      Eurydice_array_to_subslice_shared_44(simd_unit,
10174
0
        (
10175
0
          KRML_CLITERAL(core_ops_range_Range_87){
10176
0
            .start = i0 * (size_t)4U,
10177
0
            .end = i0 * (size_t)4U + (size_t)4U
10178
0
          }
10179
0
        ));
10180
0
    int32_t
10181
0
    coefficient0 =
10182
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10183
0
        coefficients.ptr[0U];
10184
0
    int32_t
10185
0
    coefficient1 =
10186
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10187
0
        coefficients.ptr[1U];
10188
0
    int32_t
10189
0
    coefficient2 =
10190
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10191
0
        coefficients.ptr[2U];
10192
0
    int32_t
10193
0
    coefficient3 =
10194
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_SERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10195
0
        coefficients.ptr[3U];
10196
0
    serialized.ptr[(size_t)9U * i0] = (uint8_t)coefficient0;
10197
0
    serialized.ptr[(size_t)9U * i0 + (size_t)1U] = (uint8_t)(coefficient0 >> 8U);
10198
0
    serialized.ptr[(size_t)9U * i0 + (size_t)2U] = (uint8_t)(coefficient0 >> 16U);
10199
0
    size_t uu____0 = (size_t)9U * i0 + (size_t)2U;
10200
0
    serialized.ptr[uu____0] =
10201
0
      (uint32_t)serialized.ptr[uu____0] | (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient1 << 2U);
10202
0
    serialized.ptr[(size_t)9U * i0 + (size_t)3U] = (uint8_t)(coefficient1 >> 6U);
10203
0
    serialized.ptr[(size_t)9U * i0 + (size_t)4U] = (uint8_t)(coefficient1 >> 14U);
10204
0
    size_t uu____1 = (size_t)9U * i0 + (size_t)4U;
10205
0
    serialized.ptr[uu____1] =
10206
0
      (uint32_t)serialized.ptr[uu____1] | (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient2 << 4U);
10207
0
    serialized.ptr[(size_t)9U * i0 + (size_t)5U] = (uint8_t)(coefficient2 >> 4U);
10208
0
    serialized.ptr[(size_t)9U * i0 + (size_t)6U] = (uint8_t)(coefficient2 >> 12U);
10209
0
    size_t uu____2 = (size_t)9U * i0 + (size_t)6U;
10210
0
    serialized.ptr[uu____2] =
10211
0
      (uint32_t)serialized.ptr[uu____2] | (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient3 << 6U);
10212
0
    serialized.ptr[(size_t)9U * i0 + (size_t)7U] = (uint8_t)(coefficient3 >> 2U);
10213
0
    serialized.ptr[(size_t)9U * i0 + (size_t)8U] = (uint8_t)(coefficient3 >> 10U);
10214
0
  }
10215
0
}
10216
10217
static KRML_MUSTINLINE void
10218
libcrux_ml_dsa_simd_portable_encoding_gamma1_serialize(
10219
  const Eurydice_arr_4d *simd_unit,
10220
  Eurydice_mut_borrow_slice_u8 serialized,
10221
  size_t gamma1_exponent
10222
)
10223
0
{
10224
0
  switch (gamma1_exponent)
10225
0
  {
10226
0
    case 17U:
10227
0
      {
10228
0
        break;
10229
0
      }
10230
0
    case 19U:
10231
0
      {
10232
0
        libcrux_ml_dsa_simd_portable_encoding_gamma1_serialize_when_gamma1_is_2_pow_19(simd_unit,
10233
0
          serialized);
10234
0
        return;
10235
0
      }
10236
0
    default:
10237
0
      {
10238
0
        KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
10239
0
        KRML_HOST_EXIT(255U);
10240
0
      }
10241
0
  }
10242
0
  libcrux_ml_dsa_simd_portable_encoding_gamma1_serialize_when_gamma1_is_2_pow_17(simd_unit,
10243
0
    serialized);
10244
0
}
10245
10246
/**
10247
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10248
*/
10249
static inline void
10250
libcrux_ml_dsa_simd_portable_gamma1_serialize_65(
10251
  const Eurydice_arr_4d *simd_unit,
10252
  Eurydice_mut_borrow_slice_u8 serialized,
10253
  size_t gamma1_exponent
10254
)
10255
0
{
10256
0
  libcrux_ml_dsa_simd_portable_encoding_gamma1_serialize(simd_unit, serialized, gamma1_exponent);
10257
0
}
10258
10259
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 ((int32_t)((uint32_t)1 << 19U))
10260
10261
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1_TIMES_2_BITMASK ((int32_t)((uint32_t)LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 << 1U) - 1)
10262
10263
static KRML_MUSTINLINE void
10264
libcrux_ml_dsa_simd_portable_encoding_gamma1_deserialize_when_gamma1_is_2_pow_19(
10265
  Eurydice_borrow_slice_u8 serialized,
10266
  Eurydice_arr_4d *simd_unit
10267
)
10268
0
{
10269
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)5U; i++)
10270
0
  {
10271
0
    size_t i0 = i;
10272
0
    Eurydice_borrow_slice_u8
10273
0
    bytes =
10274
0
      Eurydice_slice_subslice_shared_c8(serialized,
10275
0
        (
10276
0
          KRML_CLITERAL(core_ops_range_Range_87){
10277
0
            .start = i0 * (size_t)5U,
10278
0
            .end = i0 * (size_t)5U + (size_t)5U
10279
0
          }
10280
0
        ));
10281
0
    int32_t coefficient0 = (int32_t)(uint32_t)bytes.ptr[0U];
10282
0
    coefficient0 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[1U] << 8U);
10283
0
    coefficient0 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[2U] << 16U);
10284
0
    coefficient0 &=
10285
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1_TIMES_2_BITMASK;
10286
0
    int32_t coefficient1 = (int32_t)(uint32_t)bytes.ptr[2U] >> 4U;
10287
0
    coefficient1 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[3U] << 4U);
10288
0
    coefficient1 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[4U] << 12U);
10289
0
    simd_unit->data[(size_t)2U * i0] =
10290
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 -
10291
0
        coefficient0;
10292
0
    simd_unit->data[(size_t)2U * i0 + (size_t)1U] =
10293
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_19_GAMMA1 -
10294
0
        coefficient1;
10295
0
  }
10296
0
}
10297
10298
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 ((int32_t)((uint32_t)1 << 17U))
10299
10300
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1_TIMES_2_BITMASK ((int32_t)((uint32_t)LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 << 1U) - 1)
10301
10302
static KRML_MUSTINLINE void
10303
libcrux_ml_dsa_simd_portable_encoding_gamma1_deserialize_when_gamma1_is_2_pow_17(
10304
  Eurydice_borrow_slice_u8 serialized,
10305
  Eurydice_arr_4d *simd_unit
10306
)
10307
0
{
10308
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)9U; i++)
10309
0
  {
10310
0
    size_t i0 = i;
10311
0
    Eurydice_borrow_slice_u8
10312
0
    bytes =
10313
0
      Eurydice_slice_subslice_shared_c8(serialized,
10314
0
        (
10315
0
          KRML_CLITERAL(core_ops_range_Range_87){
10316
0
            .start = i0 * (size_t)9U,
10317
0
            .end = i0 * (size_t)9U + (size_t)9U
10318
0
          }
10319
0
        ));
10320
0
    int32_t coefficient0 = (int32_t)(uint32_t)bytes.ptr[0U];
10321
0
    coefficient0 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[1U] << 8U);
10322
0
    coefficient0 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[2U] << 16U);
10323
0
    coefficient0 &=
10324
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1_TIMES_2_BITMASK;
10325
0
    int32_t coefficient1 = (int32_t)(uint32_t)bytes.ptr[2U] >> 2U;
10326
0
    coefficient1 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[3U] << 6U);
10327
0
    coefficient1 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[4U] << 14U);
10328
0
    coefficient1 &=
10329
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1_TIMES_2_BITMASK;
10330
0
    int32_t coefficient2 = (int32_t)(uint32_t)bytes.ptr[4U] >> 4U;
10331
0
    coefficient2 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[5U] << 4U);
10332
0
    coefficient2 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[6U] << 12U);
10333
0
    coefficient2 &=
10334
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1_TIMES_2_BITMASK;
10335
0
    int32_t coefficient3 = (int32_t)(uint32_t)bytes.ptr[6U] >> 6U;
10336
0
    coefficient3 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[7U] << 2U);
10337
0
    coefficient3 |= (int32_t)((uint32_t)(int32_t)(uint32_t)bytes.ptr[8U] << 10U);
10338
0
    coefficient3 &=
10339
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1_TIMES_2_BITMASK;
10340
0
    simd_unit->data[(size_t)4U * i0] =
10341
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10342
0
        coefficient0;
10343
0
    simd_unit->data[(size_t)4U * i0 + (size_t)1U] =
10344
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10345
0
        coefficient1;
10346
0
    simd_unit->data[(size_t)4U * i0 + (size_t)2U] =
10347
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10348
0
        coefficient2;
10349
0
    simd_unit->data[(size_t)4U * i0 + (size_t)3U] =
10350
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_GAMMA1_DESERIALIZE_WHEN_GAMMA1_IS_2_POW_17_GAMMA1 -
10351
0
        coefficient3;
10352
0
  }
10353
0
}
10354
10355
static KRML_MUSTINLINE void
10356
libcrux_ml_dsa_simd_portable_encoding_gamma1_deserialize(
10357
  Eurydice_borrow_slice_u8 serialized,
10358
  Eurydice_arr_4d *out,
10359
  size_t gamma1_exponent
10360
)
10361
0
{
10362
0
  switch (gamma1_exponent)
10363
0
  {
10364
0
    case 17U:
10365
0
      {
10366
0
        break;
10367
0
      }
10368
0
    case 19U:
10369
0
      {
10370
0
        libcrux_ml_dsa_simd_portable_encoding_gamma1_deserialize_when_gamma1_is_2_pow_19(serialized,
10371
0
          out);
10372
0
        return;
10373
0
      }
10374
0
    default:
10375
0
      {
10376
0
        KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
10377
0
        KRML_HOST_EXIT(255U);
10378
0
      }
10379
0
  }
10380
0
  libcrux_ml_dsa_simd_portable_encoding_gamma1_deserialize_when_gamma1_is_2_pow_17(serialized,
10381
0
    out);
10382
0
}
10383
10384
/**
10385
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10386
*/
10387
static inline void
10388
libcrux_ml_dsa_simd_portable_gamma1_deserialize_65(
10389
  Eurydice_borrow_slice_u8 serialized,
10390
  Eurydice_arr_4d *out,
10391
  size_t gamma1_exponent
10392
)
10393
0
{
10394
0
  libcrux_ml_dsa_simd_portable_encoding_gamma1_deserialize(serialized, out, gamma1_exponent);
10395
0
}
10396
10397
static KRML_MUSTINLINE void
10398
libcrux_ml_dsa_simd_portable_encoding_commitment_serialize_4(
10399
  const Eurydice_arr_4d *simd_unit,
10400
  Eurydice_mut_borrow_slice_u8 serialized
10401
)
10402
0
{
10403
0
  uint8_t coefficient0 = (uint8_t)simd_unit->data[0U];
10404
0
  uint8_t coefficient1 = (uint8_t)simd_unit->data[1U];
10405
0
  uint8_t coefficient2 = (uint8_t)simd_unit->data[2U];
10406
0
  uint8_t coefficient3 = (uint8_t)simd_unit->data[3U];
10407
0
  uint8_t coefficient4 = (uint8_t)simd_unit->data[4U];
10408
0
  uint8_t coefficient5 = (uint8_t)simd_unit->data[5U];
10409
0
  uint8_t coefficient6 = (uint8_t)simd_unit->data[6U];
10410
0
  uint8_t coefficient7 = (uint8_t)simd_unit->data[7U];
10411
0
  uint8_t byte0 = (uint32_t)coefficient1 << 4U | (uint32_t)coefficient0;
10412
0
  uint8_t byte1 = (uint32_t)coefficient3 << 4U | (uint32_t)coefficient2;
10413
0
  uint8_t byte2 = (uint32_t)coefficient5 << 4U | (uint32_t)coefficient4;
10414
0
  uint8_t byte3 = (uint32_t)coefficient7 << 4U | (uint32_t)coefficient6;
10415
0
  serialized.ptr[0U] = byte0;
10416
0
  serialized.ptr[1U] = byte1;
10417
0
  serialized.ptr[2U] = byte2;
10418
0
  serialized.ptr[3U] = byte3;
10419
0
}
10420
10421
static KRML_MUSTINLINE void
10422
libcrux_ml_dsa_simd_portable_encoding_commitment_serialize_6(
10423
  const Eurydice_arr_4d *simd_unit,
10424
  Eurydice_mut_borrow_slice_u8 serialized
10425
)
10426
0
{
10427
0
  uint8_t coefficient0 = (uint8_t)simd_unit->data[0U];
10428
0
  uint8_t coefficient1 = (uint8_t)simd_unit->data[1U];
10429
0
  uint8_t coefficient2 = (uint8_t)simd_unit->data[2U];
10430
0
  uint8_t coefficient3 = (uint8_t)simd_unit->data[3U];
10431
0
  uint8_t coefficient4 = (uint8_t)simd_unit->data[4U];
10432
0
  uint8_t coefficient5 = (uint8_t)simd_unit->data[5U];
10433
0
  uint8_t coefficient6 = (uint8_t)simd_unit->data[6U];
10434
0
  uint8_t coefficient7 = (uint8_t)simd_unit->data[7U];
10435
0
  uint8_t byte0 = (uint32_t)coefficient1 << 6U | (uint32_t)coefficient0;
10436
0
  uint8_t byte1 = (uint32_t)coefficient2 << 4U | (uint32_t)coefficient1 >> 2U;
10437
0
  uint8_t byte2 = (uint32_t)coefficient3 << 2U | (uint32_t)coefficient2 >> 4U;
10438
0
  uint8_t byte3 = (uint32_t)coefficient5 << 6U | (uint32_t)coefficient4;
10439
0
  uint8_t byte4 = (uint32_t)coefficient6 << 4U | (uint32_t)coefficient5 >> 2U;
10440
0
  uint8_t byte5 = (uint32_t)coefficient7 << 2U | (uint32_t)coefficient6 >> 4U;
10441
0
  serialized.ptr[0U] = byte0;
10442
0
  serialized.ptr[1U] = byte1;
10443
0
  serialized.ptr[2U] = byte2;
10444
0
  serialized.ptr[3U] = byte3;
10445
0
  serialized.ptr[4U] = byte4;
10446
0
  serialized.ptr[5U] = byte5;
10447
0
}
10448
10449
static KRML_MUSTINLINE void
10450
libcrux_ml_dsa_simd_portable_encoding_commitment_serialize(
10451
  const Eurydice_arr_4d *simd_unit,
10452
  Eurydice_mut_borrow_slice_u8 serialized
10453
)
10454
0
{
10455
0
  switch ((uint32_t)(uint8_t)serialized.meta)
10456
0
  {
10457
0
    case 4U:
10458
0
      {
10459
0
        libcrux_ml_dsa_simd_portable_encoding_commitment_serialize_4(simd_unit, serialized);
10460
0
        break;
10461
0
      }
10462
0
    case 6U:
10463
0
      {
10464
0
        libcrux_ml_dsa_simd_portable_encoding_commitment_serialize_6(simd_unit, serialized);
10465
0
        break;
10466
0
      }
10467
0
    default:
10468
0
      {
10469
0
        KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
10470
0
        KRML_HOST_EXIT(255U);
10471
0
      }
10472
0
  }
10473
0
}
10474
10475
/**
10476
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10477
*/
10478
static inline void
10479
libcrux_ml_dsa_simd_portable_commitment_serialize_65(
10480
  const Eurydice_arr_4d *simd_unit,
10481
  Eurydice_mut_borrow_slice_u8 serialized
10482
)
10483
0
{
10484
0
  libcrux_ml_dsa_simd_portable_encoding_commitment_serialize(simd_unit, serialized);
10485
0
}
10486
10487
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_4_ETA (4)
10488
10489
static KRML_MUSTINLINE void
10490
libcrux_ml_dsa_simd_portable_encoding_error_serialize_when_eta_is_4(
10491
  const Eurydice_arr_4d *simd_unit,
10492
  Eurydice_mut_borrow_slice_u8 serialized
10493
)
10494
0
{
10495
0
  for (size_t i = (size_t)0U; i < (size_t)8U / (size_t)2U; i++)
10496
0
  {
10497
0
    size_t i0 = i;
10498
0
    Eurydice_dst_ref_shared_83
10499
0
    coefficients =
10500
0
      Eurydice_array_to_subslice_shared_44(simd_unit,
10501
0
        (
10502
0
          KRML_CLITERAL(core_ops_range_Range_87){
10503
0
            .start = i0 * (size_t)2U,
10504
0
            .end = i0 * (size_t)2U + (size_t)2U
10505
0
          }
10506
0
        ));
10507
0
    uint8_t
10508
0
    coefficient0 =
10509
0
      (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_4_ETA -
10510
0
        coefficients.ptr[0U]);
10511
0
    uint8_t
10512
0
    coefficient1 =
10513
0
      (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_4_ETA -
10514
0
        coefficients.ptr[1U]);
10515
0
    serialized.ptr[i0] = (uint32_t)coefficient1 << 4U | (uint32_t)coefficient0;
10516
0
  }
10517
0
}
10518
10519
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA (2)
10520
10521
static KRML_MUSTINLINE void
10522
libcrux_ml_dsa_simd_portable_encoding_error_serialize_when_eta_is_2(
10523
  const Eurydice_arr_4d *simd_unit,
10524
  Eurydice_mut_borrow_slice_u8 serialized
10525
)
10526
0
{
10527
0
  uint8_t
10528
0
  coefficient0 =
10529
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10530
0
      simd_unit->data[0U]);
10531
0
  uint8_t
10532
0
  coefficient1 =
10533
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10534
0
      simd_unit->data[1U]);
10535
0
  uint8_t
10536
0
  coefficient2 =
10537
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10538
0
      simd_unit->data[2U]);
10539
0
  uint8_t
10540
0
  coefficient3 =
10541
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10542
0
      simd_unit->data[3U]);
10543
0
  uint8_t
10544
0
  coefficient4 =
10545
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10546
0
      simd_unit->data[4U]);
10547
0
  uint8_t
10548
0
  coefficient5 =
10549
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10550
0
      simd_unit->data[5U]);
10551
0
  uint8_t
10552
0
  coefficient6 =
10553
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10554
0
      simd_unit->data[6U]);
10555
0
  uint8_t
10556
0
  coefficient7 =
10557
0
    (uint8_t)(LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_SERIALIZE_WHEN_ETA_IS_2_ETA -
10558
0
      simd_unit->data[7U]);
10559
0
  serialized.ptr[0U] =
10560
0
    ((uint32_t)coefficient2 << 6U | (uint32_t)coefficient1 << 3U) | (uint32_t)coefficient0;
10561
0
  serialized.ptr[1U] =
10562
0
    (((uint32_t)coefficient5 << 7U | (uint32_t)coefficient4 << 4U) | (uint32_t)coefficient3 << 1U)
10563
0
    | (uint32_t)coefficient2 >> 2U;
10564
0
  serialized.ptr[2U] =
10565
0
    ((uint32_t)coefficient7 << 5U | (uint32_t)coefficient6 << 2U) | (uint32_t)coefficient5 >> 1U;
10566
0
}
10567
10568
static KRML_MUSTINLINE void
10569
libcrux_ml_dsa_simd_portable_encoding_error_serialize(
10570
  libcrux_ml_dsa_constants_Eta eta,
10571
  const Eurydice_arr_4d *simd_unit,
10572
  Eurydice_mut_borrow_slice_u8 serialized
10573
)
10574
0
{
10575
0
  switch (eta)
10576
0
  {
10577
0
    case libcrux_ml_dsa_constants_Eta_Two:
10578
0
      {
10579
0
        break;
10580
0
      }
10581
0
    case libcrux_ml_dsa_constants_Eta_Four:
10582
0
      {
10583
0
        libcrux_ml_dsa_simd_portable_encoding_error_serialize_when_eta_is_4(simd_unit, serialized);
10584
0
        return;
10585
0
      }
10586
0
    default:
10587
0
      {
10588
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
10589
0
        KRML_HOST_EXIT(253U);
10590
0
      }
10591
0
  }
10592
0
  libcrux_ml_dsa_simd_portable_encoding_error_serialize_when_eta_is_2(simd_unit, serialized);
10593
0
}
10594
10595
/**
10596
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10597
*/
10598
static inline void
10599
libcrux_ml_dsa_simd_portable_error_serialize_65(
10600
  libcrux_ml_dsa_constants_Eta eta,
10601
  const Eurydice_arr_4d *simd_unit,
10602
  Eurydice_mut_borrow_slice_u8 serialized
10603
)
10604
0
{
10605
0
  libcrux_ml_dsa_simd_portable_encoding_error_serialize(eta, simd_unit, serialized);
10606
0
}
10607
10608
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_4_ETA (4)
10609
10610
static KRML_MUSTINLINE void
10611
libcrux_ml_dsa_simd_portable_encoding_error_deserialize_when_eta_is_4(
10612
  Eurydice_borrow_slice_u8 serialized,
10613
  Eurydice_arr_4d *simd_units
10614
)
10615
0
{
10616
0
  for (size_t i = (size_t)0U; i < serialized.meta; i++)
10617
0
  {
10618
0
    size_t i0 = i;
10619
0
    const uint8_t *byte = &serialized.ptr[i0];
10620
0
    uint8_t uu____0 = core_ops_bit__core__ops__bit__BitAnd_u8__u8__for__0__u8___bitand(byte, 15U);
10621
0
    simd_units->data[(size_t)2U * i0] =
10622
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_4_ETA -
10623
0
        (int32_t)(uint32_t)uu____0;
10624
0
    uint8_t uu____1 = core_ops_bit__core__ops__bit__Shr_i32__u8__for__0__u8___shr(byte, 4);
10625
0
    simd_units->data[(size_t)2U * i0 + (size_t)1U] =
10626
0
      LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_4_ETA -
10627
0
        (int32_t)(uint32_t)uu____1;
10628
0
  }
10629
0
}
10630
10631
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA (2)
10632
10633
static KRML_MUSTINLINE void
10634
libcrux_ml_dsa_simd_portable_encoding_error_deserialize_when_eta_is_2(
10635
  Eurydice_borrow_slice_u8 serialized,
10636
  Eurydice_arr_4d *simd_unit
10637
)
10638
0
{
10639
0
  int32_t byte0 = (int32_t)(uint32_t)serialized.ptr[0U];
10640
0
  int32_t byte1 = (int32_t)(uint32_t)serialized.ptr[1U];
10641
0
  int32_t byte2 = (int32_t)(uint32_t)serialized.ptr[2U];
10642
0
  simd_unit->data[0U] =
10643
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA - (byte0 & 7);
10644
0
  simd_unit->data[1U] =
10645
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA - (byte0 >> 3U & 7);
10646
0
  simd_unit->data[2U] =
10647
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA -
10648
0
      ((byte0 >> 6U | (int32_t)((uint32_t)byte1 << 2U)) & 7);
10649
0
  simd_unit->data[3U] =
10650
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA - (byte1 >> 1U & 7);
10651
0
  simd_unit->data[4U] =
10652
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA - (byte1 >> 4U & 7);
10653
0
  simd_unit->data[5U] =
10654
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA -
10655
0
      ((byte1 >> 7U | (int32_t)((uint32_t)byte2 << 1U)) & 7);
10656
0
  simd_unit->data[6U] =
10657
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA - (byte2 >> 2U & 7);
10658
0
  simd_unit->data[7U] =
10659
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_ERROR_DESERIALIZE_WHEN_ETA_IS_2_ETA - (byte2 >> 5U & 7);
10660
0
}
10661
10662
static KRML_MUSTINLINE void
10663
libcrux_ml_dsa_simd_portable_encoding_error_deserialize(
10664
  libcrux_ml_dsa_constants_Eta eta,
10665
  Eurydice_borrow_slice_u8 serialized,
10666
  Eurydice_arr_4d *out
10667
)
10668
0
{
10669
0
  switch (eta)
10670
0
  {
10671
0
    case libcrux_ml_dsa_constants_Eta_Two:
10672
0
      {
10673
0
        break;
10674
0
      }
10675
0
    case libcrux_ml_dsa_constants_Eta_Four:
10676
0
      {
10677
0
        libcrux_ml_dsa_simd_portable_encoding_error_deserialize_when_eta_is_4(serialized, out);
10678
0
        return;
10679
0
      }
10680
0
    default:
10681
0
      {
10682
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
10683
0
        KRML_HOST_EXIT(253U);
10684
0
      }
10685
0
  }
10686
0
  libcrux_ml_dsa_simd_portable_encoding_error_deserialize_when_eta_is_2(serialized, out);
10687
0
}
10688
10689
/**
10690
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10691
*/
10692
static inline void
10693
libcrux_ml_dsa_simd_portable_error_deserialize_65(
10694
  libcrux_ml_dsa_constants_Eta eta,
10695
  Eurydice_borrow_slice_u8 serialized,
10696
  Eurydice_arr_4d *out
10697
)
10698
0
{
10699
0
  libcrux_ml_dsa_simd_portable_encoding_error_deserialize(eta, serialized, out);
10700
0
}
10701
10702
static KRML_MUSTINLINE int32_t
10703
libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(int32_t t0)
10704
0
{
10705
0
  return
10706
0
    (int32_t)((uint32_t)1 <<
10707
0
      (uint32_t)(LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T - (size_t)1U))
10708
0
    - t0;
10709
0
}
10710
10711
static KRML_MUSTINLINE void
10712
libcrux_ml_dsa_simd_portable_encoding_t0_serialize(
10713
  const Eurydice_arr_4d *simd_unit,
10714
  Eurydice_mut_borrow_slice_u8 serialized
10715
)
10716
0
{
10717
0
  int32_t
10718
0
  coefficient0 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[0U]);
10719
0
  int32_t
10720
0
  coefficient1 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[1U]);
10721
0
  int32_t
10722
0
  coefficient2 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[2U]);
10723
0
  int32_t
10724
0
  coefficient3 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[3U]);
10725
0
  int32_t
10726
0
  coefficient4 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[4U]);
10727
0
  int32_t
10728
0
  coefficient5 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[5U]);
10729
0
  int32_t
10730
0
  coefficient6 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[6U]);
10731
0
  int32_t
10732
0
  coefficient7 = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(simd_unit->data[7U]);
10733
0
  serialized.ptr[0U] = (uint8_t)coefficient0;
10734
0
  serialized.ptr[1U] =
10735
0
    (uint32_t)(uint8_t)(coefficient0 >> 8U) |
10736
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient1 << 5U);
10737
0
  serialized.ptr[2U] = (uint8_t)(coefficient1 >> 3U);
10738
0
  serialized.ptr[3U] =
10739
0
    (uint32_t)(uint8_t)(coefficient1 >> 11U) |
10740
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient2 << 2U);
10741
0
  serialized.ptr[4U] =
10742
0
    (uint32_t)(uint8_t)(coefficient2 >> 6U) |
10743
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient3 << 7U);
10744
0
  serialized.ptr[5U] = (uint8_t)(coefficient3 >> 1U);
10745
0
  serialized.ptr[6U] =
10746
0
    (uint32_t)(uint8_t)(coefficient3 >> 9U) |
10747
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient4 << 4U);
10748
0
  serialized.ptr[7U] = (uint8_t)(coefficient4 >> 4U);
10749
0
  serialized.ptr[8U] =
10750
0
    (uint32_t)(uint8_t)(coefficient4 >> 12U) |
10751
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient5 << 1U);
10752
0
  serialized.ptr[9U] =
10753
0
    (uint32_t)(uint8_t)(coefficient5 >> 7U) |
10754
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient6 << 6U);
10755
0
  serialized.ptr[10U] = (uint8_t)(coefficient6 >> 2U);
10756
0
  serialized.ptr[11U] =
10757
0
    (uint32_t)(uint8_t)(coefficient6 >> 10U) |
10758
0
      (uint32_t)(uint8_t)(int32_t)((uint32_t)coefficient7 << 3U);
10759
0
  serialized.ptr[12U] = (uint8_t)(coefficient7 >> 5U);
10760
0
}
10761
10762
/**
10763
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10764
*/
10765
static inline void
10766
libcrux_ml_dsa_simd_portable_t0_serialize_65(
10767
  const Eurydice_arr_4d *simd_unit,
10768
  Eurydice_mut_borrow_slice_u8 out
10769
)
10770
0
{
10771
0
  libcrux_ml_dsa_simd_portable_encoding_t0_serialize(simd_unit, out);
10772
0
}
10773
10774
0
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK ((int32_t)((uint32_t)1 << (uint32_t)(int32_t)LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_LOWER_PART_OF_T) - 1)
10775
10776
static KRML_MUSTINLINE void
10777
libcrux_ml_dsa_simd_portable_encoding_t0_deserialize(
10778
  Eurydice_borrow_slice_u8 serialized,
10779
  Eurydice_arr_4d *simd_unit
10780
)
10781
0
{
10782
0
  int32_t byte0 = (int32_t)(uint32_t)serialized.ptr[0U];
10783
0
  int32_t byte1 = (int32_t)(uint32_t)serialized.ptr[1U];
10784
0
  int32_t byte2 = (int32_t)(uint32_t)serialized.ptr[2U];
10785
0
  int32_t byte3 = (int32_t)(uint32_t)serialized.ptr[3U];
10786
0
  int32_t byte4 = (int32_t)(uint32_t)serialized.ptr[4U];
10787
0
  int32_t byte5 = (int32_t)(uint32_t)serialized.ptr[5U];
10788
0
  int32_t byte6 = (int32_t)(uint32_t)serialized.ptr[6U];
10789
0
  int32_t byte7 = (int32_t)(uint32_t)serialized.ptr[7U];
10790
0
  int32_t byte8 = (int32_t)(uint32_t)serialized.ptr[8U];
10791
0
  int32_t byte9 = (int32_t)(uint32_t)serialized.ptr[9U];
10792
0
  int32_t byte10 = (int32_t)(uint32_t)serialized.ptr[10U];
10793
0
  int32_t byte11 = (int32_t)(uint32_t)serialized.ptr[11U];
10794
0
  int32_t byte12 = (int32_t)(uint32_t)serialized.ptr[12U];
10795
0
  int32_t coefficient0 = byte0;
10796
0
  coefficient0 |= (int32_t)((uint32_t)byte1 << 8U);
10797
0
  coefficient0 &=
10798
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10799
0
  int32_t coefficient1 = byte1 >> 5U;
10800
0
  coefficient1 |= (int32_t)((uint32_t)byte2 << 3U);
10801
0
  coefficient1 |= (int32_t)((uint32_t)byte3 << 11U);
10802
0
  coefficient1 &=
10803
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10804
0
  int32_t coefficient2 = byte3 >> 2U;
10805
0
  coefficient2 |= (int32_t)((uint32_t)byte4 << 6U);
10806
0
  coefficient2 &=
10807
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10808
0
  int32_t coefficient3 = byte4 >> 7U;
10809
0
  coefficient3 |= (int32_t)((uint32_t)byte5 << 1U);
10810
0
  coefficient3 |= (int32_t)((uint32_t)byte6 << 9U);
10811
0
  coefficient3 &=
10812
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10813
0
  int32_t coefficient4 = byte6 >> 4U;
10814
0
  coefficient4 |= (int32_t)((uint32_t)byte7 << 4U);
10815
0
  coefficient4 |= (int32_t)((uint32_t)byte8 << 12U);
10816
0
  coefficient4 &=
10817
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10818
0
  int32_t coefficient5 = byte8 >> 1U;
10819
0
  coefficient5 |= (int32_t)((uint32_t)byte9 << 7U);
10820
0
  coefficient5 &=
10821
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10822
0
  int32_t coefficient6 = byte9 >> 6U;
10823
0
  coefficient6 |= (int32_t)((uint32_t)byte10 << 2U);
10824
0
  coefficient6 |= (int32_t)((uint32_t)byte11 << 10U);
10825
0
  coefficient6 &=
10826
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10827
0
  int32_t coefficient7 = byte11 >> 3U;
10828
0
  coefficient7 |= (int32_t)((uint32_t)byte12 << 5U);
10829
0
  coefficient7 &=
10830
0
    LIBCRUX_ML_DSA_SIMD_PORTABLE_ENCODING_T0_DESERIALIZE_BITS_IN_LOWER_PART_OF_T_MASK;
10831
0
  simd_unit->data[0U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient0);
10832
0
  simd_unit->data[1U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient1);
10833
0
  simd_unit->data[2U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient2);
10834
0
  simd_unit->data[3U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient3);
10835
0
  simd_unit->data[4U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient4);
10836
0
  simd_unit->data[5U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient5);
10837
0
  simd_unit->data[6U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient6);
10838
0
  simd_unit->data[7U] = libcrux_ml_dsa_simd_portable_encoding_t0_change_t0_interval(coefficient7);
10839
0
}
10840
10841
/**
10842
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10843
*/
10844
static inline void
10845
libcrux_ml_dsa_simd_portable_t0_deserialize_65(
10846
  Eurydice_borrow_slice_u8 serialized,
10847
  Eurydice_arr_4d *out
10848
)
10849
0
{
10850
0
  libcrux_ml_dsa_simd_portable_encoding_t0_deserialize(serialized, out);
10851
0
}
10852
10853
static KRML_MUSTINLINE void
10854
libcrux_ml_dsa_simd_portable_encoding_t1_serialize(
10855
  const Eurydice_arr_4d *simd_unit,
10856
  Eurydice_mut_borrow_slice_u8 serialized
10857
)
10858
0
{
10859
0
  for (size_t i = (size_t)0U; i < (size_t)8U / (size_t)4U; i++)
10860
0
  {
10861
0
    size_t i0 = i;
10862
0
    Eurydice_dst_ref_shared_83
10863
0
    coefficients =
10864
0
      Eurydice_array_to_subslice_shared_44(simd_unit,
10865
0
        (
10866
0
          KRML_CLITERAL(core_ops_range_Range_87){
10867
0
            .start = i0 * (size_t)4U,
10868
0
            .end = i0 * (size_t)4U + (size_t)4U
10869
0
          }
10870
0
        ));
10871
0
    serialized.ptr[(size_t)5U * i0] = (uint8_t)(coefficients.ptr[0U] & 255);
10872
0
    serialized.ptr[(size_t)5U * i0 + (size_t)1U] =
10873
0
      (uint32_t)(uint8_t)(coefficients.ptr[1U] & 63) << 2U |
10874
0
        (uint32_t)(uint8_t)(coefficients.ptr[0U] >> 8U & 3);
10875
0
    serialized.ptr[(size_t)5U * i0 + (size_t)2U] =
10876
0
      (uint32_t)(uint8_t)(coefficients.ptr[2U] & 15) << 4U |
10877
0
        (uint32_t)(uint8_t)(coefficients.ptr[1U] >> 6U & 15);
10878
0
    serialized.ptr[(size_t)5U * i0 + (size_t)3U] =
10879
0
      (uint32_t)(uint8_t)(coefficients.ptr[3U] & 3) << 6U |
10880
0
        (uint32_t)(uint8_t)(coefficients.ptr[2U] >> 4U & 63);
10881
0
    serialized.ptr[(size_t)5U * i0 + (size_t)4U] = (uint8_t)(coefficients.ptr[3U] >> 2U & 255);
10882
0
  }
10883
0
}
10884
10885
/**
10886
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10887
*/
10888
static inline void
10889
libcrux_ml_dsa_simd_portable_t1_serialize_65(
10890
  const Eurydice_arr_4d *simd_unit,
10891
  Eurydice_mut_borrow_slice_u8 out
10892
)
10893
0
{
10894
0
  libcrux_ml_dsa_simd_portable_encoding_t1_serialize(simd_unit, out);
10895
0
}
10896
10897
static KRML_MUSTINLINE void
10898
libcrux_ml_dsa_simd_portable_encoding_t1_deserialize(
10899
  Eurydice_borrow_slice_u8 serialized,
10900
  Eurydice_arr_4d *simd_unit
10901
)
10902
0
{
10903
0
  int32_t
10904
0
  mask = (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_BITS_IN_UPPER_PART_OF_T) - 1;
10905
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)5U; i++)
10906
0
  {
10907
0
    size_t i0 = i;
10908
0
    Eurydice_borrow_slice_u8
10909
0
    bytes =
10910
0
      Eurydice_slice_subslice_shared_c8(serialized,
10911
0
        (
10912
0
          KRML_CLITERAL(core_ops_range_Range_87){
10913
0
            .start = i0 * (size_t)5U,
10914
0
            .end = i0 * (size_t)5U + (size_t)5U
10915
0
          }
10916
0
        ));
10917
0
    int32_t byte0 = (int32_t)(uint32_t)bytes.ptr[0U];
10918
0
    int32_t byte1 = (int32_t)(uint32_t)bytes.ptr[1U];
10919
0
    int32_t byte2 = (int32_t)(uint32_t)bytes.ptr[2U];
10920
0
    int32_t byte3 = (int32_t)(uint32_t)bytes.ptr[3U];
10921
0
    int32_t byte4 = (int32_t)(uint32_t)bytes.ptr[4U];
10922
0
    simd_unit->data[(size_t)4U * i0] = (byte0 | (int32_t)((uint32_t)byte1 << 8U)) & mask;
10923
0
    simd_unit->data[(size_t)4U * i0 + (size_t)1U] =
10924
0
      (byte1 >> 2U | (int32_t)((uint32_t)byte2 << 6U)) & mask;
10925
0
    simd_unit->data[(size_t)4U * i0 + (size_t)2U] =
10926
0
      (byte2 >> 4U | (int32_t)((uint32_t)byte3 << 4U)) & mask;
10927
0
    simd_unit->data[(size_t)4U * i0 + (size_t)3U] =
10928
0
      (byte3 >> 6U | (int32_t)((uint32_t)byte4 << 2U)) & mask;
10929
0
  }
10930
0
}
10931
10932
/**
10933
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
10934
*/
10935
static inline void
10936
libcrux_ml_dsa_simd_portable_t1_deserialize_65(
10937
  Eurydice_borrow_slice_u8 serialized,
10938
  Eurydice_arr_4d *out
10939
)
10940
0
{
10941
0
  libcrux_ml_dsa_simd_portable_encoding_t1_deserialize(serialized, out);
10942
0
}
10943
10944
static KRML_MUSTINLINE void
10945
libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(
10946
  Eurydice_arr_4d *simd_unit,
10947
  int32_t c
10948
)
10949
0
{
10950
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
10951
0
  {
10952
0
    size_t i0 = i;
10953
0
    simd_unit->data[i0] =
10954
0
      libcrux_ml_dsa_simd_portable_arithmetic_montgomery_reduce_element((int64_t)simd_unit->data[i0]
10955
0
        * (int64_t)c);
10956
0
  }
10957
0
}
10958
10959
/**
10960
A monomorphic instance of Eurydice.arr
10961
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
10962
with const generics
10963
- $32size_t
10964
*/
10965
typedef struct Eurydice_arr_a3_s { Eurydice_arr_4d data[32U]; } Eurydice_arr_a3;
10966
10967
static KRML_MUSTINLINE void
10968
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(
10969
  Eurydice_arr_a3 *re,
10970
  size_t index,
10971
  size_t step_by,
10972
  int32_t zeta
10973
)
10974
0
{
10975
0
  Eurydice_arr_4d tmp = re->data[index + step_by];
10976
0
  libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&tmp, zeta);
10977
0
  re->data[index + step_by] = re->data[index];
10978
0
  libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[index + step_by], &tmp);
10979
0
  libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[index], &tmp);
10980
0
}
10981
10982
/**
10983
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
10984
with const generics
10985
- OFFSET= 0
10986
- STEP_BY= 16
10987
- ZETA= 25847
10988
*/
10989
static KRML_MUSTINLINE void
10990
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_30(Eurydice_arr_a3 *re)
10991
0
{
10992
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)16U; i++)
10993
0
  {
10994
0
    size_t j = i;
10995
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)16U, 25847);
10996
0
  }
10997
0
}
10998
10999
static KRML_MUSTINLINE void
11000
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_7(Eurydice_arr_a3 *re)
11001
0
{
11002
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_30(re);
11003
0
}
11004
11005
/**
11006
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11007
with const generics
11008
- OFFSET= 0
11009
- STEP_BY= 8
11010
- ZETA= -2608894
11011
*/
11012
static KRML_MUSTINLINE void
11013
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_300(Eurydice_arr_a3 *re)
11014
0
{
11015
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)8U; i++)
11016
0
  {
11017
0
    size_t j = i;
11018
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)8U, -2608894);
11019
0
  }
11020
0
}
11021
11022
/**
11023
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11024
with const generics
11025
- OFFSET= 16
11026
- STEP_BY= 8
11027
- ZETA= -518909
11028
*/
11029
static KRML_MUSTINLINE void
11030
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_42(Eurydice_arr_a3 *re)
11031
0
{
11032
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)8U; i++)
11033
0
  {
11034
0
    size_t j = i;
11035
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)8U, -518909);
11036
0
  }
11037
0
}
11038
11039
static KRML_MUSTINLINE void
11040
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_6(Eurydice_arr_a3 *re)
11041
0
{
11042
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_300(re);
11043
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_42(re);
11044
0
}
11045
11046
/**
11047
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11048
with const generics
11049
- OFFSET= 0
11050
- STEP_BY= 4
11051
- ZETA= 237124
11052
*/
11053
static KRML_MUSTINLINE void
11054
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_301(Eurydice_arr_a3 *re)
11055
0
{
11056
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)4U; i++)
11057
0
  {
11058
0
    size_t j = i;
11059
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)4U, 237124);
11060
0
  }
11061
0
}
11062
11063
/**
11064
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11065
with const generics
11066
- OFFSET= 8
11067
- STEP_BY= 4
11068
- ZETA= -777960
11069
*/
11070
static KRML_MUSTINLINE void
11071
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_82(Eurydice_arr_a3 *re)
11072
0
{
11073
0
  for (size_t i = (size_t)8U; i < (size_t)8U + (size_t)4U; i++)
11074
0
  {
11075
0
    size_t j = i;
11076
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)4U, -777960);
11077
0
  }
11078
0
}
11079
11080
/**
11081
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11082
with const generics
11083
- OFFSET= 16
11084
- STEP_BY= 4
11085
- ZETA= -876248
11086
*/
11087
static KRML_MUSTINLINE void
11088
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_420(Eurydice_arr_a3 *re)
11089
0
{
11090
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)4U; i++)
11091
0
  {
11092
0
    size_t j = i;
11093
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)4U, -876248);
11094
0
  }
11095
0
}
11096
11097
/**
11098
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11099
with const generics
11100
- OFFSET= 24
11101
- STEP_BY= 4
11102
- ZETA= 466468
11103
*/
11104
static KRML_MUSTINLINE void
11105
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_fe(Eurydice_arr_a3 *re)
11106
0
{
11107
0
  for (size_t i = (size_t)24U; i < (size_t)24U + (size_t)4U; i++)
11108
0
  {
11109
0
    size_t j = i;
11110
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)4U, 466468);
11111
0
  }
11112
0
}
11113
11114
static KRML_MUSTINLINE void
11115
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_5(Eurydice_arr_a3 *re)
11116
0
{
11117
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_301(re);
11118
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_82(re);
11119
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_420(re);
11120
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_fe(re);
11121
0
}
11122
11123
/**
11124
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11125
with const generics
11126
- OFFSET= 0
11127
- STEP_BY= 2
11128
- ZETA= 1826347
11129
*/
11130
static KRML_MUSTINLINE void
11131
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_302(Eurydice_arr_a3 *re)
11132
0
{
11133
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)2U; i++)
11134
0
  {
11135
0
    size_t j = i;
11136
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, 1826347);
11137
0
  }
11138
0
}
11139
11140
/**
11141
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11142
with const generics
11143
- OFFSET= 4
11144
- STEP_BY= 2
11145
- ZETA= 2353451
11146
*/
11147
static KRML_MUSTINLINE void
11148
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_43(Eurydice_arr_a3 *re)
11149
0
{
11150
0
  for (size_t i = (size_t)4U; i < (size_t)4U + (size_t)2U; i++)
11151
0
  {
11152
0
    size_t j = i;
11153
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, 2353451);
11154
0
  }
11155
0
}
11156
11157
/**
11158
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11159
with const generics
11160
- OFFSET= 8
11161
- STEP_BY= 2
11162
- ZETA= -359251
11163
*/
11164
static KRML_MUSTINLINE void
11165
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_820(Eurydice_arr_a3 *re)
11166
0
{
11167
0
  for (size_t i = (size_t)8U; i < (size_t)8U + (size_t)2U; i++)
11168
0
  {
11169
0
    size_t j = i;
11170
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, -359251);
11171
0
  }
11172
0
}
11173
11174
/**
11175
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11176
with const generics
11177
- OFFSET= 12
11178
- STEP_BY= 2
11179
- ZETA= -2091905
11180
*/
11181
static KRML_MUSTINLINE void
11182
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_ea(Eurydice_arr_a3 *re)
11183
0
{
11184
0
  for (size_t i = (size_t)12U; i < (size_t)12U + (size_t)2U; i++)
11185
0
  {
11186
0
    size_t j = i;
11187
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, -2091905);
11188
0
  }
11189
0
}
11190
11191
/**
11192
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11193
with const generics
11194
- OFFSET= 16
11195
- STEP_BY= 2
11196
- ZETA= 3119733
11197
*/
11198
static KRML_MUSTINLINE void
11199
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_421(Eurydice_arr_a3 *re)
11200
0
{
11201
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)2U; i++)
11202
0
  {
11203
0
    size_t j = i;
11204
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, 3119733);
11205
0
  }
11206
0
}
11207
11208
/**
11209
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11210
with const generics
11211
- OFFSET= 20
11212
- STEP_BY= 2
11213
- ZETA= -2884855
11214
*/
11215
static KRML_MUSTINLINE void
11216
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_61(Eurydice_arr_a3 *re)
11217
0
{
11218
0
  for (size_t i = (size_t)20U; i < (size_t)20U + (size_t)2U; i++)
11219
0
  {
11220
0
    size_t j = i;
11221
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, -2884855);
11222
0
  }
11223
0
}
11224
11225
/**
11226
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11227
with const generics
11228
- OFFSET= 24
11229
- STEP_BY= 2
11230
- ZETA= 3111497
11231
*/
11232
static KRML_MUSTINLINE void
11233
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_fe0(Eurydice_arr_a3 *re)
11234
0
{
11235
0
  for (size_t i = (size_t)24U; i < (size_t)24U + (size_t)2U; i++)
11236
0
  {
11237
0
    size_t j = i;
11238
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, 3111497);
11239
0
  }
11240
0
}
11241
11242
/**
11243
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11244
with const generics
11245
- OFFSET= 28
11246
- STEP_BY= 2
11247
- ZETA= 2680103
11248
*/
11249
static KRML_MUSTINLINE void
11250
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_38(Eurydice_arr_a3 *re)
11251
0
{
11252
0
  for (size_t i = (size_t)28U; i < (size_t)28U + (size_t)2U; i++)
11253
0
  {
11254
0
    size_t j = i;
11255
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)2U, 2680103);
11256
0
  }
11257
0
}
11258
11259
static KRML_MUSTINLINE void
11260
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_4(Eurydice_arr_a3 *re)
11261
0
{
11262
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_302(re);
11263
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_43(re);
11264
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_820(re);
11265
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_ea(re);
11266
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_421(re);
11267
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_61(re);
11268
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_fe0(re);
11269
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_38(re);
11270
0
}
11271
11272
/**
11273
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11274
with const generics
11275
- OFFSET= 0
11276
- STEP_BY= 1
11277
- ZETA= 2725464
11278
*/
11279
static KRML_MUSTINLINE void
11280
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_303(Eurydice_arr_a3 *re)
11281
0
{
11282
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)1U; i++)
11283
0
  {
11284
0
    size_t j = i;
11285
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 2725464);
11286
0
  }
11287
0
}
11288
11289
/**
11290
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11291
with const generics
11292
- OFFSET= 2
11293
- STEP_BY= 1
11294
- ZETA= 1024112
11295
*/
11296
static KRML_MUSTINLINE void
11297
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_25(Eurydice_arr_a3 *re)
11298
0
{
11299
0
  for (size_t i = (size_t)2U; i < (size_t)2U + (size_t)1U; i++)
11300
0
  {
11301
0
    size_t j = i;
11302
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 1024112);
11303
0
  }
11304
0
}
11305
11306
/**
11307
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11308
with const generics
11309
- OFFSET= 4
11310
- STEP_BY= 1
11311
- ZETA= -1079900
11312
*/
11313
static KRML_MUSTINLINE void
11314
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_430(Eurydice_arr_a3 *re)
11315
0
{
11316
0
  for (size_t i = (size_t)4U; i < (size_t)4U + (size_t)1U; i++)
11317
0
  {
11318
0
    size_t j = i;
11319
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -1079900);
11320
0
  }
11321
0
}
11322
11323
/**
11324
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11325
with const generics
11326
- OFFSET= 6
11327
- STEP_BY= 1
11328
- ZETA= 3585928
11329
*/
11330
static KRML_MUSTINLINE void
11331
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_f4(Eurydice_arr_a3 *re)
11332
0
{
11333
0
  for (size_t i = (size_t)6U; i < (size_t)6U + (size_t)1U; i++)
11334
0
  {
11335
0
    size_t j = i;
11336
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 3585928);
11337
0
  }
11338
0
}
11339
11340
/**
11341
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11342
with const generics
11343
- OFFSET= 8
11344
- STEP_BY= 1
11345
- ZETA= -549488
11346
*/
11347
static KRML_MUSTINLINE void
11348
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_821(Eurydice_arr_a3 *re)
11349
0
{
11350
0
  for (size_t i = (size_t)8U; i < (size_t)8U + (size_t)1U; i++)
11351
0
  {
11352
0
    size_t j = i;
11353
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -549488);
11354
0
  }
11355
0
}
11356
11357
/**
11358
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11359
with const generics
11360
- OFFSET= 10
11361
- STEP_BY= 1
11362
- ZETA= -1119584
11363
*/
11364
static KRML_MUSTINLINE void
11365
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_1d(Eurydice_arr_a3 *re)
11366
0
{
11367
0
  for (size_t i = (size_t)10U; i < (size_t)10U + (size_t)1U; i++)
11368
0
  {
11369
0
    size_t j = i;
11370
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -1119584);
11371
0
  }
11372
0
}
11373
11374
/**
11375
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11376
with const generics
11377
- OFFSET= 12
11378
- STEP_BY= 1
11379
- ZETA= 2619752
11380
*/
11381
static KRML_MUSTINLINE void
11382
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_ea0(Eurydice_arr_a3 *re)
11383
0
{
11384
0
  for (size_t i = (size_t)12U; i < (size_t)12U + (size_t)1U; i++)
11385
0
  {
11386
0
    size_t j = i;
11387
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 2619752);
11388
0
  }
11389
0
}
11390
11391
/**
11392
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11393
with const generics
11394
- OFFSET= 14
11395
- STEP_BY= 1
11396
- ZETA= -2108549
11397
*/
11398
static KRML_MUSTINLINE void
11399
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_d8(Eurydice_arr_a3 *re)
11400
0
{
11401
0
  for (size_t i = (size_t)14U; i < (size_t)14U + (size_t)1U; i++)
11402
0
  {
11403
0
    size_t j = i;
11404
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -2108549);
11405
0
  }
11406
0
}
11407
11408
/**
11409
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11410
with const generics
11411
- OFFSET= 16
11412
- STEP_BY= 1
11413
- ZETA= -2118186
11414
*/
11415
static KRML_MUSTINLINE void
11416
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_422(Eurydice_arr_a3 *re)
11417
0
{
11418
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)1U; i++)
11419
0
  {
11420
0
    size_t j = i;
11421
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -2118186);
11422
0
  }
11423
0
}
11424
11425
/**
11426
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11427
with const generics
11428
- OFFSET= 18
11429
- STEP_BY= 1
11430
- ZETA= -3859737
11431
*/
11432
static KRML_MUSTINLINE void
11433
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_60(Eurydice_arr_a3 *re)
11434
0
{
11435
0
  for (size_t i = (size_t)18U; i < (size_t)18U + (size_t)1U; i++)
11436
0
  {
11437
0
    size_t j = i;
11438
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -3859737);
11439
0
  }
11440
0
}
11441
11442
/**
11443
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11444
with const generics
11445
- OFFSET= 20
11446
- STEP_BY= 1
11447
- ZETA= -1399561
11448
*/
11449
static KRML_MUSTINLINE void
11450
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_610(Eurydice_arr_a3 *re)
11451
0
{
11452
0
  for (size_t i = (size_t)20U; i < (size_t)20U + (size_t)1U; i++)
11453
0
  {
11454
0
    size_t j = i;
11455
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -1399561);
11456
0
  }
11457
0
}
11458
11459
/**
11460
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11461
with const generics
11462
- OFFSET= 22
11463
- STEP_BY= 1
11464
- ZETA= -3277672
11465
*/
11466
static KRML_MUSTINLINE void
11467
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_29(Eurydice_arr_a3 *re)
11468
0
{
11469
0
  for (size_t i = (size_t)22U; i < (size_t)22U + (size_t)1U; i++)
11470
0
  {
11471
0
    size_t j = i;
11472
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -3277672);
11473
0
  }
11474
0
}
11475
11476
/**
11477
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11478
with const generics
11479
- OFFSET= 24
11480
- STEP_BY= 1
11481
- ZETA= 1757237
11482
*/
11483
static KRML_MUSTINLINE void
11484
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_fe1(Eurydice_arr_a3 *re)
11485
0
{
11486
0
  for (size_t i = (size_t)24U; i < (size_t)24U + (size_t)1U; i++)
11487
0
  {
11488
0
    size_t j = i;
11489
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 1757237);
11490
0
  }
11491
0
}
11492
11493
/**
11494
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11495
with const generics
11496
- OFFSET= 26
11497
- STEP_BY= 1
11498
- ZETA= -19422
11499
*/
11500
static KRML_MUSTINLINE void
11501
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_9d(Eurydice_arr_a3 *re)
11502
0
{
11503
0
  for (size_t i = (size_t)26U; i < (size_t)26U + (size_t)1U; i++)
11504
0
  {
11505
0
    size_t j = i;
11506
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, -19422);
11507
0
  }
11508
0
}
11509
11510
/**
11511
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11512
with const generics
11513
- OFFSET= 28
11514
- STEP_BY= 1
11515
- ZETA= 4010497
11516
*/
11517
static KRML_MUSTINLINE void
11518
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_380(Eurydice_arr_a3 *re)
11519
0
{
11520
0
  for (size_t i = (size_t)28U; i < (size_t)28U + (size_t)1U; i++)
11521
0
  {
11522
0
    size_t j = i;
11523
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 4010497);
11524
0
  }
11525
0
}
11526
11527
/**
11528
A monomorphic instance of libcrux_ml_dsa.simd.portable.ntt.outer_3_plus
11529
with const generics
11530
- OFFSET= 30
11531
- STEP_BY= 1
11532
- ZETA= 280005
11533
*/
11534
static KRML_MUSTINLINE void
11535
libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_5f(Eurydice_arr_a3 *re)
11536
0
{
11537
0
  for (size_t i = (size_t)30U; i < (size_t)30U + (size_t)1U; i++)
11538
0
  {
11539
0
    size_t j = i;
11540
0
    libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_round(re, j, (size_t)1U, 280005);
11541
0
  }
11542
0
}
11543
11544
static KRML_MUSTINLINE void
11545
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_3(Eurydice_arr_a3 *re)
11546
0
{
11547
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_303(re);
11548
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_25(re);
11549
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_430(re);
11550
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_f4(re);
11551
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_821(re);
11552
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_1d(re);
11553
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_ea0(re);
11554
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_d8(re);
11555
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_422(re);
11556
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_60(re);
11557
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_610(re);
11558
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_29(re);
11559
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_fe1(re);
11560
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_9d(re);
11561
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_380(re);
11562
0
  libcrux_ml_dsa_simd_portable_ntt_outer_3_plus_5f(re);
11563
0
}
11564
11565
static KRML_MUSTINLINE int32_t
11566
libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_fe_by_fer(int32_t fe, int32_t fer)
11567
0
{
11568
0
  return
11569
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_reduce_element((int64_t)fe * (int64_t)fer);
11570
0
}
11571
11572
static KRML_MUSTINLINE void
11573
libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(
11574
  Eurydice_arr_4d *simd_unit,
11575
  int32_t zeta,
11576
  size_t index,
11577
  size_t step
11578
)
11579
0
{
11580
0
  int32_t
11581
0
  t =
11582
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_fe_by_fer(simd_unit->data[index +
11583
0
        step],
11584
0
      zeta);
11585
0
  simd_unit->data[index + step] = simd_unit->data[index] - t;
11586
0
  simd_unit->data[index] += t;
11587
0
}
11588
11589
static KRML_MUSTINLINE void
11590
libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_at_layer_2(
11591
  Eurydice_arr_4d *simd_unit,
11592
  int32_t zeta
11593
)
11594
0
{
11595
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta, (size_t)0U, (size_t)4U);
11596
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta, (size_t)1U, (size_t)4U);
11597
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta, (size_t)2U, (size_t)4U);
11598
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta, (size_t)3U, (size_t)4U);
11599
0
}
11600
11601
static KRML_MUSTINLINE void
11602
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(
11603
  Eurydice_arr_a3 *re,
11604
  size_t index,
11605
  int32_t zeta
11606
)
11607
0
{
11608
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_at_layer_2(&re->data[index], zeta);
11609
0
}
11610
11611
static KRML_MUSTINLINE void
11612
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2(Eurydice_arr_a3 *re)
11613
0
{
11614
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)0U, 2706023);
11615
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)1U, 95776);
11616
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)2U, 3077325);
11617
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)3U, 3530437);
11618
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)4U, -1661693);
11619
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)5U, -3592148);
11620
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)6U, -2537516);
11621
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)7U, 3915439);
11622
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)8U, -3861115);
11623
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)9U, -3043716);
11624
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)10U, 3574422);
11625
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)11U, -2867647);
11626
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)12U, 3539968);
11627
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)13U, -300467);
11628
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)14U, 2348700);
11629
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)15U, -539299);
11630
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)16U, -1699267);
11631
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)17U, -1643818);
11632
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)18U, 3505694);
11633
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)19U, -3821735);
11634
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)20U, 3507263);
11635
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)21U, -2140649);
11636
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)22U, -1600420);
11637
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)23U, 3699596);
11638
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)24U, 811944);
11639
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)25U, 531354);
11640
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)26U, 954230);
11641
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)27U, 3881043);
11642
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)28U, 3900724);
11643
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)29U, -2556880);
11644
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)30U, 2071892);
11645
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2_round(re, (size_t)31U, -2797779);
11646
0
}
11647
11648
static KRML_MUSTINLINE void
11649
libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_at_layer_1(
11650
  Eurydice_arr_4d *simd_unit,
11651
  int32_t zeta1,
11652
  int32_t zeta2
11653
)
11654
0
{
11655
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta1, (size_t)0U, (size_t)2U);
11656
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta1, (size_t)1U, (size_t)2U);
11657
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta2, (size_t)4U, (size_t)2U);
11658
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta2, (size_t)5U, (size_t)2U);
11659
0
}
11660
11661
static KRML_MUSTINLINE void
11662
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(
11663
  Eurydice_arr_a3 *re,
11664
  size_t index,
11665
  int32_t zeta_0,
11666
  int32_t zeta_1
11667
)
11668
0
{
11669
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_at_layer_1(&re->data[index], zeta_0, zeta_1);
11670
0
}
11671
11672
static KRML_MUSTINLINE void
11673
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1(Eurydice_arr_a3 *re)
11674
0
{
11675
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)0U, -3930395, -1528703);
11676
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)1U, -3677745, -3041255);
11677
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)2U, -1452451, 3475950);
11678
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)3U, 2176455, -1585221);
11679
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)4U, -1257611, 1939314);
11680
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)5U, -4083598, -1000202);
11681
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)6U, -3190144, -3157330);
11682
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)7U, -3632928, 126922);
11683
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)8U, 3412210, -983419);
11684
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)9U, 2147896, 2715295);
11685
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)10U, -2967645, -3693493);
11686
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)11U, -411027, -2477047);
11687
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)12U, -671102, -1228525);
11688
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)13U, -22981, -1308169);
11689
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)14U, -381987, 1349076);
11690
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)15U, 1852771, -1430430);
11691
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)16U, -3343383, 264944);
11692
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)17U, 508951, 3097992);
11693
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)18U, 44288, -1100098);
11694
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)19U, 904516, 3958618);
11695
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)20U, -3724342, -8578);
11696
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)21U, 1653064, -3249728);
11697
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)22U, 2389356, -210977);
11698
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)23U, 759969, -1316856);
11699
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)24U, 189548, -3553272);
11700
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)25U, 3159746, -1851402);
11701
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)26U, -2409325, -177440);
11702
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)27U, 1315589, 1341330);
11703
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)28U, 1285669, -1584928);
11704
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)29U, -812732, -1439742);
11705
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)30U, -3019102, -3881060);
11706
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1_round(re, (size_t)31U, -3628969, 3839961);
11707
0
}
11708
11709
static KRML_MUSTINLINE void
11710
libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_at_layer_0(
11711
  Eurydice_arr_4d *simd_unit,
11712
  int32_t zeta0,
11713
  int32_t zeta1,
11714
  int32_t zeta2,
11715
  int32_t zeta3
11716
)
11717
0
{
11718
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta0, (size_t)0U, (size_t)1U);
11719
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta1, (size_t)2U, (size_t)1U);
11720
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta2, (size_t)4U, (size_t)1U);
11721
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_step(simd_unit, zeta3, (size_t)6U, (size_t)1U);
11722
0
}
11723
11724
static KRML_MUSTINLINE void
11725
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(
11726
  Eurydice_arr_a3 *re,
11727
  size_t index,
11728
  int32_t zeta_0,
11729
  int32_t zeta_1,
11730
  int32_t zeta_2,
11731
  int32_t zeta_3
11732
)
11733
0
{
11734
0
  libcrux_ml_dsa_simd_portable_ntt_simd_unit_ntt_at_layer_0(&re->data[index],
11735
0
    zeta_0,
11736
0
    zeta_1,
11737
0
    zeta_2,
11738
0
    zeta_3);
11739
0
}
11740
11741
static KRML_MUSTINLINE void
11742
libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0(Eurydice_arr_a3 *re)
11743
0
{
11744
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11745
0
    (size_t)0U,
11746
0
    2091667,
11747
0
    3407706,
11748
0
    2316500,
11749
0
    3817976);
11750
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11751
0
    (size_t)1U,
11752
0
    -3342478,
11753
0
    2244091,
11754
0
    -2446433,
11755
0
    -3562462);
11756
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11757
0
    (size_t)2U,
11758
0
    266997,
11759
0
    2434439,
11760
0
    -1235728,
11761
0
    3513181);
11762
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11763
0
    (size_t)3U,
11764
0
    -3520352,
11765
0
    -3759364,
11766
0
    -1197226,
11767
0
    -3193378);
11768
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11769
0
    (size_t)4U,
11770
0
    900702,
11771
0
    1859098,
11772
0
    909542,
11773
0
    819034);
11774
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11775
0
    (size_t)5U,
11776
0
    495491,
11777
0
    -1613174,
11778
0
    -43260,
11779
0
    -522500);
11780
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11781
0
    (size_t)6U,
11782
0
    -655327,
11783
0
    -3122442,
11784
0
    2031748,
11785
0
    3207046);
11786
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11787
0
    (size_t)7U,
11788
0
    -3556995,
11789
0
    -525098,
11790
0
    -768622,
11791
0
    -3595838);
11792
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11793
0
    (size_t)8U,
11794
0
    342297,
11795
0
    286988,
11796
0
    -2437823,
11797
0
    4108315);
11798
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11799
0
    (size_t)9U,
11800
0
    3437287,
11801
0
    -3342277,
11802
0
    1735879,
11803
0
    203044);
11804
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11805
0
    (size_t)10U,
11806
0
    2842341,
11807
0
    2691481,
11808
0
    -2590150,
11809
0
    1265009);
11810
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11811
0
    (size_t)11U,
11812
0
    4055324,
11813
0
    1247620,
11814
0
    2486353,
11815
0
    1595974);
11816
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11817
0
    (size_t)12U,
11818
0
    -3767016,
11819
0
    1250494,
11820
0
    2635921,
11821
0
    -3548272);
11822
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11823
0
    (size_t)13U,
11824
0
    -2994039,
11825
0
    1869119,
11826
0
    1903435,
11827
0
    -1050970);
11828
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11829
0
    (size_t)14U,
11830
0
    -1333058,
11831
0
    1237275,
11832
0
    -3318210,
11833
0
    -1430225);
11834
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11835
0
    (size_t)15U,
11836
0
    -451100,
11837
0
    1312455,
11838
0
    3306115,
11839
0
    -1962642);
11840
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11841
0
    (size_t)16U,
11842
0
    -1279661,
11843
0
    1917081,
11844
0
    -2546312,
11845
0
    -1374803);
11846
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11847
0
    (size_t)17U,
11848
0
    1500165,
11849
0
    777191,
11850
0
    2235880,
11851
0
    3406031);
11852
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11853
0
    (size_t)18U,
11854
0
    -542412,
11855
0
    -2831860,
11856
0
    -1671176,
11857
0
    -1846953);
11858
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11859
0
    (size_t)19U,
11860
0
    -2584293,
11861
0
    -3724270,
11862
0
    594136,
11863
0
    -3776993);
11864
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11865
0
    (size_t)20U,
11866
0
    -2013608,
11867
0
    2432395,
11868
0
    2454455,
11869
0
    -164721);
11870
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11871
0
    (size_t)21U,
11872
0
    1957272,
11873
0
    3369112,
11874
0
    185531,
11875
0
    -1207385);
11876
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11877
0
    (size_t)22U,
11878
0
    -3183426,
11879
0
    162844,
11880
0
    1616392,
11881
0
    3014001);
11882
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11883
0
    (size_t)23U,
11884
0
    810149,
11885
0
    1652634,
11886
0
    -3694233,
11887
0
    -1799107);
11888
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11889
0
    (size_t)24U,
11890
0
    -3038916,
11891
0
    3523897,
11892
0
    3866901,
11893
0
    269760);
11894
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11895
0
    (size_t)25U,
11896
0
    2213111,
11897
0
    -975884,
11898
0
    1717735,
11899
0
    472078);
11900
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11901
0
    (size_t)26U,
11902
0
    -426683,
11903
0
    1723600,
11904
0
    -1803090,
11905
0
    1910376);
11906
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11907
0
    (size_t)27U,
11908
0
    -1667432,
11909
0
    -1104333,
11910
0
    -260646,
11911
0
    -3833893);
11912
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11913
0
    (size_t)28U,
11914
0
    -2939036,
11915
0
    -2235985,
11916
0
    -420899,
11917
0
    -2286327);
11918
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11919
0
    (size_t)29U,
11920
0
    183443,
11921
0
    -976891,
11922
0
    1612842,
11923
0
    -3545687);
11924
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11925
0
    (size_t)30U,
11926
0
    -554416,
11927
0
    3919660,
11928
0
    -48306,
11929
0
    -1362209);
11930
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0_round(re,
11931
0
    (size_t)31U,
11932
0
    3937738,
11933
0
    1400424,
11934
0
    -846154,
11935
0
    1976782);
11936
0
}
11937
11938
static KRML_MUSTINLINE void libcrux_ml_dsa_simd_portable_ntt_ntt(Eurydice_arr_a3 *re)
11939
0
{
11940
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_7(re);
11941
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_6(re);
11942
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_5(re);
11943
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_4(re);
11944
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_3(re);
11945
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_2(re);
11946
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_1(re);
11947
0
  libcrux_ml_dsa_simd_portable_ntt_ntt_at_layer_0(re);
11948
0
}
11949
11950
/**
11951
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
11952
*/
11953
static inline void libcrux_ml_dsa_simd_portable_ntt_65(Eurydice_arr_a3 *simd_units)
11954
0
{
11955
0
  libcrux_ml_dsa_simd_portable_ntt_ntt(simd_units);
11956
0
}
11957
11958
static KRML_MUSTINLINE void
11959
libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(
11960
  Eurydice_arr_4d *simd_unit,
11961
  int32_t zeta,
11962
  size_t index,
11963
  size_t step
11964
)
11965
0
{
11966
0
  int32_t a_minus_b = simd_unit->data[index + step] - simd_unit->data[index];
11967
0
  simd_unit->data[index] += simd_unit->data[index + step];
11968
0
  simd_unit->data[index + step] =
11969
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_fe_by_fer(a_minus_b,
11970
0
      zeta);
11971
0
}
11972
11973
static KRML_MUSTINLINE void
11974
libcrux_ml_dsa_simd_portable_invntt_simd_unit_invert_ntt_at_layer_0(
11975
  Eurydice_arr_4d *simd_unit,
11976
  int32_t zeta0,
11977
  int32_t zeta1,
11978
  int32_t zeta2,
11979
  int32_t zeta3
11980
)
11981
0
{
11982
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
11983
0
    zeta0,
11984
0
    (size_t)0U,
11985
0
    (size_t)1U);
11986
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
11987
0
    zeta1,
11988
0
    (size_t)2U,
11989
0
    (size_t)1U);
11990
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
11991
0
    zeta2,
11992
0
    (size_t)4U,
11993
0
    (size_t)1U);
11994
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
11995
0
    zeta3,
11996
0
    (size_t)6U,
11997
0
    (size_t)1U);
11998
0
}
11999
12000
static KRML_MUSTINLINE void
12001
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(
12002
  Eurydice_arr_a3 *re,
12003
  size_t index,
12004
  int32_t zeta0,
12005
  int32_t zeta1,
12006
  int32_t zeta2,
12007
  int32_t zeta3
12008
)
12009
0
{
12010
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_invert_ntt_at_layer_0(&re->data[index],
12011
0
    zeta0,
12012
0
    zeta1,
12013
0
    zeta2,
12014
0
    zeta3);
12015
0
}
12016
12017
static KRML_MUSTINLINE void
12018
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0(Eurydice_arr_a3 *re)
12019
0
{
12020
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12021
0
    (size_t)0U,
12022
0
    1976782,
12023
0
    -846154,
12024
0
    1400424,
12025
0
    3937738);
12026
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12027
0
    (size_t)1U,
12028
0
    -1362209,
12029
0
    -48306,
12030
0
    3919660,
12031
0
    -554416);
12032
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12033
0
    (size_t)2U,
12034
0
    -3545687,
12035
0
    1612842,
12036
0
    -976891,
12037
0
    183443);
12038
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12039
0
    (size_t)3U,
12040
0
    -2286327,
12041
0
    -420899,
12042
0
    -2235985,
12043
0
    -2939036);
12044
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12045
0
    (size_t)4U,
12046
0
    -3833893,
12047
0
    -260646,
12048
0
    -1104333,
12049
0
    -1667432);
12050
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12051
0
    (size_t)5U,
12052
0
    1910376,
12053
0
    -1803090,
12054
0
    1723600,
12055
0
    -426683);
12056
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12057
0
    (size_t)6U,
12058
0
    472078,
12059
0
    1717735,
12060
0
    -975884,
12061
0
    2213111);
12062
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12063
0
    (size_t)7U,
12064
0
    269760,
12065
0
    3866901,
12066
0
    3523897,
12067
0
    -3038916);
12068
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12069
0
    (size_t)8U,
12070
0
    -1799107,
12071
0
    -3694233,
12072
0
    1652634,
12073
0
    810149);
12074
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12075
0
    (size_t)9U,
12076
0
    3014001,
12077
0
    1616392,
12078
0
    162844,
12079
0
    -3183426);
12080
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12081
0
    (size_t)10U,
12082
0
    -1207385,
12083
0
    185531,
12084
0
    3369112,
12085
0
    1957272);
12086
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12087
0
    (size_t)11U,
12088
0
    -164721,
12089
0
    2454455,
12090
0
    2432395,
12091
0
    -2013608);
12092
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12093
0
    (size_t)12U,
12094
0
    -3776993,
12095
0
    594136,
12096
0
    -3724270,
12097
0
    -2584293);
12098
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12099
0
    (size_t)13U,
12100
0
    -1846953,
12101
0
    -1671176,
12102
0
    -2831860,
12103
0
    -542412);
12104
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12105
0
    (size_t)14U,
12106
0
    3406031,
12107
0
    2235880,
12108
0
    777191,
12109
0
    1500165);
12110
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12111
0
    (size_t)15U,
12112
0
    -1374803,
12113
0
    -2546312,
12114
0
    1917081,
12115
0
    -1279661);
12116
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12117
0
    (size_t)16U,
12118
0
    -1962642,
12119
0
    3306115,
12120
0
    1312455,
12121
0
    -451100);
12122
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12123
0
    (size_t)17U,
12124
0
    -1430225,
12125
0
    -3318210,
12126
0
    1237275,
12127
0
    -1333058);
12128
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12129
0
    (size_t)18U,
12130
0
    -1050970,
12131
0
    1903435,
12132
0
    1869119,
12133
0
    -2994039);
12134
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12135
0
    (size_t)19U,
12136
0
    -3548272,
12137
0
    2635921,
12138
0
    1250494,
12139
0
    -3767016);
12140
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12141
0
    (size_t)20U,
12142
0
    1595974,
12143
0
    2486353,
12144
0
    1247620,
12145
0
    4055324);
12146
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12147
0
    (size_t)21U,
12148
0
    1265009,
12149
0
    -2590150,
12150
0
    2691481,
12151
0
    2842341);
12152
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12153
0
    (size_t)22U,
12154
0
    203044,
12155
0
    1735879,
12156
0
    -3342277,
12157
0
    3437287);
12158
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12159
0
    (size_t)23U,
12160
0
    4108315,
12161
0
    -2437823,
12162
0
    286988,
12163
0
    342297);
12164
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12165
0
    (size_t)24U,
12166
0
    -3595838,
12167
0
    -768622,
12168
0
    -525098,
12169
0
    -3556995);
12170
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12171
0
    (size_t)25U,
12172
0
    3207046,
12173
0
    2031748,
12174
0
    -3122442,
12175
0
    -655327);
12176
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12177
0
    (size_t)26U,
12178
0
    -522500,
12179
0
    -43260,
12180
0
    -1613174,
12181
0
    495491);
12182
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12183
0
    (size_t)27U,
12184
0
    819034,
12185
0
    909542,
12186
0
    1859098,
12187
0
    900702);
12188
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12189
0
    (size_t)28U,
12190
0
    -3193378,
12191
0
    -1197226,
12192
0
    -3759364,
12193
0
    -3520352);
12194
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12195
0
    (size_t)29U,
12196
0
    3513181,
12197
0
    -1235728,
12198
0
    2434439,
12199
0
    266997);
12200
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12201
0
    (size_t)30U,
12202
0
    -3562462,
12203
0
    -2446433,
12204
0
    2244091,
12205
0
    -3342478);
12206
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0_round(re,
12207
0
    (size_t)31U,
12208
0
    3817976,
12209
0
    2316500,
12210
0
    3407706,
12211
0
    2091667);
12212
0
}
12213
12214
static KRML_MUSTINLINE void
12215
libcrux_ml_dsa_simd_portable_invntt_simd_unit_invert_ntt_at_layer_1(
12216
  Eurydice_arr_4d *simd_unit,
12217
  int32_t zeta0,
12218
  int32_t zeta1
12219
)
12220
0
{
12221
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12222
0
    zeta0,
12223
0
    (size_t)0U,
12224
0
    (size_t)2U);
12225
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12226
0
    zeta0,
12227
0
    (size_t)1U,
12228
0
    (size_t)2U);
12229
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12230
0
    zeta1,
12231
0
    (size_t)4U,
12232
0
    (size_t)2U);
12233
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12234
0
    zeta1,
12235
0
    (size_t)5U,
12236
0
    (size_t)2U);
12237
0
}
12238
12239
static KRML_MUSTINLINE void
12240
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(
12241
  Eurydice_arr_a3 *re,
12242
  size_t index,
12243
  int32_t zeta_00,
12244
  int32_t zeta_01
12245
)
12246
0
{
12247
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_invert_ntt_at_layer_1(&re->data[index],
12248
0
    zeta_00,
12249
0
    zeta_01);
12250
0
}
12251
12252
static KRML_MUSTINLINE void
12253
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1(Eurydice_arr_a3 *re)
12254
0
{
12255
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12256
0
    (size_t)0U,
12257
0
    3839961,
12258
0
    -3628969);
12259
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12260
0
    (size_t)1U,
12261
0
    -3881060,
12262
0
    -3019102);
12263
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12264
0
    (size_t)2U,
12265
0
    -1439742,
12266
0
    -812732);
12267
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12268
0
    (size_t)3U,
12269
0
    -1584928,
12270
0
    1285669);
12271
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12272
0
    (size_t)4U,
12273
0
    1341330,
12274
0
    1315589);
12275
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12276
0
    (size_t)5U,
12277
0
    -177440,
12278
0
    -2409325);
12279
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12280
0
    (size_t)6U,
12281
0
    -1851402,
12282
0
    3159746);
12283
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12284
0
    (size_t)7U,
12285
0
    -3553272,
12286
0
    189548);
12287
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12288
0
    (size_t)8U,
12289
0
    -1316856,
12290
0
    759969);
12291
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12292
0
    (size_t)9U,
12293
0
    -210977,
12294
0
    2389356);
12295
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12296
0
    (size_t)10U,
12297
0
    -3249728,
12298
0
    1653064);
12299
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12300
0
    (size_t)11U,
12301
0
    -8578,
12302
0
    -3724342);
12303
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12304
0
    (size_t)12U,
12305
0
    3958618,
12306
0
    904516);
12307
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12308
0
    (size_t)13U,
12309
0
    -1100098,
12310
0
    44288);
12311
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12312
0
    (size_t)14U,
12313
0
    3097992,
12314
0
    508951);
12315
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12316
0
    (size_t)15U,
12317
0
    264944,
12318
0
    -3343383);
12319
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12320
0
    (size_t)16U,
12321
0
    -1430430,
12322
0
    1852771);
12323
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12324
0
    (size_t)17U,
12325
0
    1349076,
12326
0
    -381987);
12327
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12328
0
    (size_t)18U,
12329
0
    -1308169,
12330
0
    -22981);
12331
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12332
0
    (size_t)19U,
12333
0
    -1228525,
12334
0
    -671102);
12335
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12336
0
    (size_t)20U,
12337
0
    -2477047,
12338
0
    -411027);
12339
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12340
0
    (size_t)21U,
12341
0
    -3693493,
12342
0
    -2967645);
12343
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12344
0
    (size_t)22U,
12345
0
    2715295,
12346
0
    2147896);
12347
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12348
0
    (size_t)23U,
12349
0
    -983419,
12350
0
    3412210);
12351
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12352
0
    (size_t)24U,
12353
0
    126922,
12354
0
    -3632928);
12355
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12356
0
    (size_t)25U,
12357
0
    -3157330,
12358
0
    -3190144);
12359
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12360
0
    (size_t)26U,
12361
0
    -1000202,
12362
0
    -4083598);
12363
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12364
0
    (size_t)27U,
12365
0
    1939314,
12366
0
    -1257611);
12367
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12368
0
    (size_t)28U,
12369
0
    -1585221,
12370
0
    2176455);
12371
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12372
0
    (size_t)29U,
12373
0
    3475950,
12374
0
    -1452451);
12375
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12376
0
    (size_t)30U,
12377
0
    -3041255,
12378
0
    -3677745);
12379
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1_round(re,
12380
0
    (size_t)31U,
12381
0
    -1528703,
12382
0
    -3930395);
12383
0
}
12384
12385
static KRML_MUSTINLINE void
12386
libcrux_ml_dsa_simd_portable_invntt_simd_unit_invert_ntt_at_layer_2(
12387
  Eurydice_arr_4d *simd_unit,
12388
  int32_t zeta
12389
)
12390
0
{
12391
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12392
0
    zeta,
12393
0
    (size_t)0U,
12394
0
    (size_t)4U);
12395
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12396
0
    zeta,
12397
0
    (size_t)1U,
12398
0
    (size_t)4U);
12399
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12400
0
    zeta,
12401
0
    (size_t)2U,
12402
0
    (size_t)4U);
12403
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_inv_ntt_step(simd_unit,
12404
0
    zeta,
12405
0
    (size_t)3U,
12406
0
    (size_t)4U);
12407
0
}
12408
12409
static KRML_MUSTINLINE void
12410
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(
12411
  Eurydice_arr_a3 *re,
12412
  size_t index,
12413
  int32_t zeta1
12414
)
12415
0
{
12416
0
  libcrux_ml_dsa_simd_portable_invntt_simd_unit_invert_ntt_at_layer_2(&re->data[index], zeta1);
12417
0
}
12418
12419
static KRML_MUSTINLINE void
12420
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2(Eurydice_arr_a3 *re)
12421
0
{
12422
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)0U, -2797779);
12423
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)1U, 2071892);
12424
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)2U, -2556880);
12425
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)3U, 3900724);
12426
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)4U, 3881043);
12427
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)5U, 954230);
12428
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)6U, 531354);
12429
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)7U, 811944);
12430
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)8U, 3699596);
12431
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)9U, -1600420);
12432
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)10U, -2140649);
12433
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)11U, 3507263);
12434
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)12U, -3821735);
12435
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)13U, 3505694);
12436
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)14U, -1643818);
12437
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)15U, -1699267);
12438
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)16U, -539299);
12439
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)17U, 2348700);
12440
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)18U, -300467);
12441
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)19U, 3539968);
12442
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)20U, -2867647);
12443
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)21U, 3574422);
12444
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)22U, -3043716);
12445
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)23U, -3861115);
12446
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)24U, 3915439);
12447
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)25U, -2537516);
12448
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)26U, -3592148);
12449
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)27U, -1661693);
12450
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)28U, 3530437);
12451
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)29U, 3077325);
12452
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)30U, 95776);
12453
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2_round(re, (size_t)31U, 2706023);
12454
0
}
12455
12456
/**
12457
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12458
with const generics
12459
- OFFSET= 0
12460
- STEP_BY= 1
12461
- ZETA= 280005
12462
*/
12463
static KRML_MUSTINLINE void
12464
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_30(Eurydice_arr_a3 *re)
12465
0
{
12466
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)1U; i++)
12467
0
  {
12468
0
    size_t j = i;
12469
0
    Eurydice_arr_4d rej = re->data[j];
12470
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12471
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12472
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12473
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12474
0
        (size_t)1U],
12475
0
      280005);
12476
0
  }
12477
0
}
12478
12479
/**
12480
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12481
with const generics
12482
- OFFSET= 2
12483
- STEP_BY= 1
12484
- ZETA= 4010497
12485
*/
12486
static KRML_MUSTINLINE void
12487
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_25(Eurydice_arr_a3 *re)
12488
0
{
12489
0
  for (size_t i = (size_t)2U; i < (size_t)2U + (size_t)1U; i++)
12490
0
  {
12491
0
    size_t j = i;
12492
0
    Eurydice_arr_4d rej = re->data[j];
12493
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12494
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12495
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12496
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12497
0
        (size_t)1U],
12498
0
      4010497);
12499
0
  }
12500
0
}
12501
12502
/**
12503
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12504
with const generics
12505
- OFFSET= 4
12506
- STEP_BY= 1
12507
- ZETA= -19422
12508
*/
12509
static KRML_MUSTINLINE void
12510
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_43(Eurydice_arr_a3 *re)
12511
0
{
12512
0
  for (size_t i = (size_t)4U; i < (size_t)4U + (size_t)1U; i++)
12513
0
  {
12514
0
    size_t j = i;
12515
0
    Eurydice_arr_4d rej = re->data[j];
12516
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12517
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12518
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12519
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12520
0
        (size_t)1U],
12521
0
      -19422);
12522
0
  }
12523
0
}
12524
12525
/**
12526
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12527
with const generics
12528
- OFFSET= 6
12529
- STEP_BY= 1
12530
- ZETA= 1757237
12531
*/
12532
static KRML_MUSTINLINE void
12533
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_f4(Eurydice_arr_a3 *re)
12534
0
{
12535
0
  for (size_t i = (size_t)6U; i < (size_t)6U + (size_t)1U; i++)
12536
0
  {
12537
0
    size_t j = i;
12538
0
    Eurydice_arr_4d rej = re->data[j];
12539
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12540
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12541
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12542
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12543
0
        (size_t)1U],
12544
0
      1757237);
12545
0
  }
12546
0
}
12547
12548
/**
12549
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12550
with const generics
12551
- OFFSET= 8
12552
- STEP_BY= 1
12553
- ZETA= -3277672
12554
*/
12555
static KRML_MUSTINLINE void
12556
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_82(Eurydice_arr_a3 *re)
12557
0
{
12558
0
  for (size_t i = (size_t)8U; i < (size_t)8U + (size_t)1U; i++)
12559
0
  {
12560
0
    size_t j = i;
12561
0
    Eurydice_arr_4d rej = re->data[j];
12562
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12563
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12564
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12565
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12566
0
        (size_t)1U],
12567
0
      -3277672);
12568
0
  }
12569
0
}
12570
12571
/**
12572
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12573
with const generics
12574
- OFFSET= 10
12575
- STEP_BY= 1
12576
- ZETA= -1399561
12577
*/
12578
static KRML_MUSTINLINE void
12579
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_1d(Eurydice_arr_a3 *re)
12580
0
{
12581
0
  for (size_t i = (size_t)10U; i < (size_t)10U + (size_t)1U; i++)
12582
0
  {
12583
0
    size_t j = i;
12584
0
    Eurydice_arr_4d rej = re->data[j];
12585
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12586
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12587
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12588
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12589
0
        (size_t)1U],
12590
0
      -1399561);
12591
0
  }
12592
0
}
12593
12594
/**
12595
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12596
with const generics
12597
- OFFSET= 12
12598
- STEP_BY= 1
12599
- ZETA= -3859737
12600
*/
12601
static KRML_MUSTINLINE void
12602
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_ea(Eurydice_arr_a3 *re)
12603
0
{
12604
0
  for (size_t i = (size_t)12U; i < (size_t)12U + (size_t)1U; i++)
12605
0
  {
12606
0
    size_t j = i;
12607
0
    Eurydice_arr_4d rej = re->data[j];
12608
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12609
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12610
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12611
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12612
0
        (size_t)1U],
12613
0
      -3859737);
12614
0
  }
12615
0
}
12616
12617
/**
12618
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12619
with const generics
12620
- OFFSET= 14
12621
- STEP_BY= 1
12622
- ZETA= -2118186
12623
*/
12624
static KRML_MUSTINLINE void
12625
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_d8(Eurydice_arr_a3 *re)
12626
0
{
12627
0
  for (size_t i = (size_t)14U; i < (size_t)14U + (size_t)1U; i++)
12628
0
  {
12629
0
    size_t j = i;
12630
0
    Eurydice_arr_4d rej = re->data[j];
12631
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12632
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12633
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12634
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12635
0
        (size_t)1U],
12636
0
      -2118186);
12637
0
  }
12638
0
}
12639
12640
/**
12641
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12642
with const generics
12643
- OFFSET= 16
12644
- STEP_BY= 1
12645
- ZETA= -2108549
12646
*/
12647
static KRML_MUSTINLINE void
12648
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_42(Eurydice_arr_a3 *re)
12649
0
{
12650
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)1U; i++)
12651
0
  {
12652
0
    size_t j = i;
12653
0
    Eurydice_arr_4d rej = re->data[j];
12654
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12655
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12656
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12657
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12658
0
        (size_t)1U],
12659
0
      -2108549);
12660
0
  }
12661
0
}
12662
12663
/**
12664
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12665
with const generics
12666
- OFFSET= 18
12667
- STEP_BY= 1
12668
- ZETA= 2619752
12669
*/
12670
static KRML_MUSTINLINE void
12671
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_60(Eurydice_arr_a3 *re)
12672
0
{
12673
0
  for (size_t i = (size_t)18U; i < (size_t)18U + (size_t)1U; i++)
12674
0
  {
12675
0
    size_t j = i;
12676
0
    Eurydice_arr_4d rej = re->data[j];
12677
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12678
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12679
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12680
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12681
0
        (size_t)1U],
12682
0
      2619752);
12683
0
  }
12684
0
}
12685
12686
/**
12687
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12688
with const generics
12689
- OFFSET= 20
12690
- STEP_BY= 1
12691
- ZETA= -1119584
12692
*/
12693
static KRML_MUSTINLINE void
12694
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_61(Eurydice_arr_a3 *re)
12695
0
{
12696
0
  for (size_t i = (size_t)20U; i < (size_t)20U + (size_t)1U; i++)
12697
0
  {
12698
0
    size_t j = i;
12699
0
    Eurydice_arr_4d rej = re->data[j];
12700
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12701
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12702
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12703
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12704
0
        (size_t)1U],
12705
0
      -1119584);
12706
0
  }
12707
0
}
12708
12709
/**
12710
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12711
with const generics
12712
- OFFSET= 22
12713
- STEP_BY= 1
12714
- ZETA= -549488
12715
*/
12716
static KRML_MUSTINLINE void
12717
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_29(Eurydice_arr_a3 *re)
12718
0
{
12719
0
  for (size_t i = (size_t)22U; i < (size_t)22U + (size_t)1U; i++)
12720
0
  {
12721
0
    size_t j = i;
12722
0
    Eurydice_arr_4d rej = re->data[j];
12723
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12724
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12725
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12726
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12727
0
        (size_t)1U],
12728
0
      -549488);
12729
0
  }
12730
0
}
12731
12732
/**
12733
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12734
with const generics
12735
- OFFSET= 24
12736
- STEP_BY= 1
12737
- ZETA= 3585928
12738
*/
12739
static KRML_MUSTINLINE void
12740
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_fe(Eurydice_arr_a3 *re)
12741
0
{
12742
0
  for (size_t i = (size_t)24U; i < (size_t)24U + (size_t)1U; i++)
12743
0
  {
12744
0
    size_t j = i;
12745
0
    Eurydice_arr_4d rej = re->data[j];
12746
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12747
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12748
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12749
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12750
0
        (size_t)1U],
12751
0
      3585928);
12752
0
  }
12753
0
}
12754
12755
/**
12756
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12757
with const generics
12758
- OFFSET= 26
12759
- STEP_BY= 1
12760
- ZETA= -1079900
12761
*/
12762
static KRML_MUSTINLINE void
12763
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_9d(Eurydice_arr_a3 *re)
12764
0
{
12765
0
  for (size_t i = (size_t)26U; i < (size_t)26U + (size_t)1U; i++)
12766
0
  {
12767
0
    size_t j = i;
12768
0
    Eurydice_arr_4d rej = re->data[j];
12769
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12770
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12771
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12772
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12773
0
        (size_t)1U],
12774
0
      -1079900);
12775
0
  }
12776
0
}
12777
12778
/**
12779
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12780
with const generics
12781
- OFFSET= 28
12782
- STEP_BY= 1
12783
- ZETA= 1024112
12784
*/
12785
static KRML_MUSTINLINE void
12786
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_38(Eurydice_arr_a3 *re)
12787
0
{
12788
0
  for (size_t i = (size_t)28U; i < (size_t)28U + (size_t)1U; i++)
12789
0
  {
12790
0
    size_t j = i;
12791
0
    Eurydice_arr_4d rej = re->data[j];
12792
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12793
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12794
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12795
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12796
0
        (size_t)1U],
12797
0
      1024112);
12798
0
  }
12799
0
}
12800
12801
/**
12802
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12803
with const generics
12804
- OFFSET= 30
12805
- STEP_BY= 1
12806
- ZETA= 2725464
12807
*/
12808
static KRML_MUSTINLINE void
12809
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_5f(Eurydice_arr_a3 *re)
12810
0
{
12811
0
  for (size_t i = (size_t)30U; i < (size_t)30U + (size_t)1U; i++)
12812
0
  {
12813
0
    size_t j = i;
12814
0
    Eurydice_arr_4d rej = re->data[j];
12815
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)1U];
12816
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12817
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)1U], &rej);
12818
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12819
0
        (size_t)1U],
12820
0
      2725464);
12821
0
  }
12822
0
}
12823
12824
static KRML_MUSTINLINE void
12825
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_3(Eurydice_arr_a3 *re)
12826
0
{
12827
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_30(re);
12828
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_25(re);
12829
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_43(re);
12830
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_f4(re);
12831
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_82(re);
12832
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_1d(re);
12833
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_ea(re);
12834
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_d8(re);
12835
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_42(re);
12836
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_60(re);
12837
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_61(re);
12838
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_29(re);
12839
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_fe(re);
12840
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_9d(re);
12841
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_38(re);
12842
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_5f(re);
12843
0
}
12844
12845
/**
12846
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12847
with const generics
12848
- OFFSET= 0
12849
- STEP_BY= 2
12850
- ZETA= 2680103
12851
*/
12852
static KRML_MUSTINLINE void
12853
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_300(Eurydice_arr_a3 *re)
12854
0
{
12855
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)2U; i++)
12856
0
  {
12857
0
    size_t j = i;
12858
0
    Eurydice_arr_4d rej = re->data[j];
12859
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12860
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12861
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
12862
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12863
0
        (size_t)2U],
12864
0
      2680103);
12865
0
  }
12866
0
}
12867
12868
/**
12869
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12870
with const generics
12871
- OFFSET= 4
12872
- STEP_BY= 2
12873
- ZETA= 3111497
12874
*/
12875
static KRML_MUSTINLINE void
12876
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_430(Eurydice_arr_a3 *re)
12877
0
{
12878
0
  for (size_t i = (size_t)4U; i < (size_t)4U + (size_t)2U; i++)
12879
0
  {
12880
0
    size_t j = i;
12881
0
    Eurydice_arr_4d rej = re->data[j];
12882
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12883
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12884
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
12885
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12886
0
        (size_t)2U],
12887
0
      3111497);
12888
0
  }
12889
0
}
12890
12891
/**
12892
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12893
with const generics
12894
- OFFSET= 8
12895
- STEP_BY= 2
12896
- ZETA= -2884855
12897
*/
12898
static KRML_MUSTINLINE void
12899
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_820(Eurydice_arr_a3 *re)
12900
0
{
12901
0
  for (size_t i = (size_t)8U; i < (size_t)8U + (size_t)2U; i++)
12902
0
  {
12903
0
    size_t j = i;
12904
0
    Eurydice_arr_4d rej = re->data[j];
12905
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12906
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12907
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
12908
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12909
0
        (size_t)2U],
12910
0
      -2884855);
12911
0
  }
12912
0
}
12913
12914
/**
12915
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12916
with const generics
12917
- OFFSET= 12
12918
- STEP_BY= 2
12919
- ZETA= 3119733
12920
*/
12921
static KRML_MUSTINLINE void
12922
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_ea0(Eurydice_arr_a3 *re)
12923
0
{
12924
0
  for (size_t i = (size_t)12U; i < (size_t)12U + (size_t)2U; i++)
12925
0
  {
12926
0
    size_t j = i;
12927
0
    Eurydice_arr_4d rej = re->data[j];
12928
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12929
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12930
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
12931
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12932
0
        (size_t)2U],
12933
0
      3119733);
12934
0
  }
12935
0
}
12936
12937
/**
12938
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12939
with const generics
12940
- OFFSET= 16
12941
- STEP_BY= 2
12942
- ZETA= -2091905
12943
*/
12944
static KRML_MUSTINLINE void
12945
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_420(Eurydice_arr_a3 *re)
12946
0
{
12947
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)2U; i++)
12948
0
  {
12949
0
    size_t j = i;
12950
0
    Eurydice_arr_4d rej = re->data[j];
12951
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12952
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12953
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
12954
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12955
0
        (size_t)2U],
12956
0
      -2091905);
12957
0
  }
12958
0
}
12959
12960
/**
12961
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12962
with const generics
12963
- OFFSET= 20
12964
- STEP_BY= 2
12965
- ZETA= -359251
12966
*/
12967
static KRML_MUSTINLINE void
12968
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_610(Eurydice_arr_a3 *re)
12969
0
{
12970
0
  for (size_t i = (size_t)20U; i < (size_t)20U + (size_t)2U; i++)
12971
0
  {
12972
0
    size_t j = i;
12973
0
    Eurydice_arr_4d rej = re->data[j];
12974
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12975
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12976
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
12977
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
12978
0
        (size_t)2U],
12979
0
      -359251);
12980
0
  }
12981
0
}
12982
12983
/**
12984
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
12985
with const generics
12986
- OFFSET= 24
12987
- STEP_BY= 2
12988
- ZETA= 2353451
12989
*/
12990
static KRML_MUSTINLINE void
12991
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_fe0(Eurydice_arr_a3 *re)
12992
0
{
12993
0
  for (size_t i = (size_t)24U; i < (size_t)24U + (size_t)2U; i++)
12994
0
  {
12995
0
    size_t j = i;
12996
0
    Eurydice_arr_4d rej = re->data[j];
12997
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
12998
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
12999
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
13000
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13001
0
        (size_t)2U],
13002
0
      2353451);
13003
0
  }
13004
0
}
13005
13006
/**
13007
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13008
with const generics
13009
- OFFSET= 28
13010
- STEP_BY= 2
13011
- ZETA= 1826347
13012
*/
13013
static KRML_MUSTINLINE void
13014
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_380(Eurydice_arr_a3 *re)
13015
0
{
13016
0
  for (size_t i = (size_t)28U; i < (size_t)28U + (size_t)2U; i++)
13017
0
  {
13018
0
    size_t j = i;
13019
0
    Eurydice_arr_4d rej = re->data[j];
13020
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)2U];
13021
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13022
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)2U], &rej);
13023
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13024
0
        (size_t)2U],
13025
0
      1826347);
13026
0
  }
13027
0
}
13028
13029
static KRML_MUSTINLINE void
13030
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_4(Eurydice_arr_a3 *re)
13031
0
{
13032
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_300(re);
13033
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_430(re);
13034
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_820(re);
13035
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_ea0(re);
13036
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_420(re);
13037
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_610(re);
13038
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_fe0(re);
13039
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_380(re);
13040
0
}
13041
13042
/**
13043
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13044
with const generics
13045
- OFFSET= 0
13046
- STEP_BY= 4
13047
- ZETA= 466468
13048
*/
13049
static KRML_MUSTINLINE void
13050
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_301(Eurydice_arr_a3 *re)
13051
0
{
13052
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)4U; i++)
13053
0
  {
13054
0
    size_t j = i;
13055
0
    Eurydice_arr_4d rej = re->data[j];
13056
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)4U];
13057
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13058
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)4U], &rej);
13059
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13060
0
        (size_t)4U],
13061
0
      466468);
13062
0
  }
13063
0
}
13064
13065
/**
13066
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13067
with const generics
13068
- OFFSET= 8
13069
- STEP_BY= 4
13070
- ZETA= -876248
13071
*/
13072
static KRML_MUSTINLINE void
13073
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_821(Eurydice_arr_a3 *re)
13074
0
{
13075
0
  for (size_t i = (size_t)8U; i < (size_t)8U + (size_t)4U; i++)
13076
0
  {
13077
0
    size_t j = i;
13078
0
    Eurydice_arr_4d rej = re->data[j];
13079
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)4U];
13080
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13081
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)4U], &rej);
13082
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13083
0
        (size_t)4U],
13084
0
      -876248);
13085
0
  }
13086
0
}
13087
13088
/**
13089
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13090
with const generics
13091
- OFFSET= 16
13092
- STEP_BY= 4
13093
- ZETA= -777960
13094
*/
13095
static KRML_MUSTINLINE void
13096
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_421(Eurydice_arr_a3 *re)
13097
0
{
13098
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)4U; i++)
13099
0
  {
13100
0
    size_t j = i;
13101
0
    Eurydice_arr_4d rej = re->data[j];
13102
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)4U];
13103
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13104
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)4U], &rej);
13105
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13106
0
        (size_t)4U],
13107
0
      -777960);
13108
0
  }
13109
0
}
13110
13111
/**
13112
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13113
with const generics
13114
- OFFSET= 24
13115
- STEP_BY= 4
13116
- ZETA= 237124
13117
*/
13118
static KRML_MUSTINLINE void
13119
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_fe1(Eurydice_arr_a3 *re)
13120
0
{
13121
0
  for (size_t i = (size_t)24U; i < (size_t)24U + (size_t)4U; i++)
13122
0
  {
13123
0
    size_t j = i;
13124
0
    Eurydice_arr_4d rej = re->data[j];
13125
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)4U];
13126
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13127
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)4U], &rej);
13128
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13129
0
        (size_t)4U],
13130
0
      237124);
13131
0
  }
13132
0
}
13133
13134
static KRML_MUSTINLINE void
13135
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_5(Eurydice_arr_a3 *re)
13136
0
{
13137
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_301(re);
13138
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_821(re);
13139
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_421(re);
13140
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_fe1(re);
13141
0
}
13142
13143
/**
13144
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13145
with const generics
13146
- OFFSET= 0
13147
- STEP_BY= 8
13148
- ZETA= -518909
13149
*/
13150
static KRML_MUSTINLINE void
13151
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_302(Eurydice_arr_a3 *re)
13152
0
{
13153
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)8U; i++)
13154
0
  {
13155
0
    size_t j = i;
13156
0
    Eurydice_arr_4d rej = re->data[j];
13157
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)8U];
13158
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13159
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)8U], &rej);
13160
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13161
0
        (size_t)8U],
13162
0
      -518909);
13163
0
  }
13164
0
}
13165
13166
/**
13167
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13168
with const generics
13169
- OFFSET= 16
13170
- STEP_BY= 8
13171
- ZETA= -2608894
13172
*/
13173
static KRML_MUSTINLINE void
13174
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_422(Eurydice_arr_a3 *re)
13175
0
{
13176
0
  for (size_t i = (size_t)16U; i < (size_t)16U + (size_t)8U; i++)
13177
0
  {
13178
0
    size_t j = i;
13179
0
    Eurydice_arr_4d rej = re->data[j];
13180
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)8U];
13181
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13182
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)8U], &rej);
13183
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13184
0
        (size_t)8U],
13185
0
      -2608894);
13186
0
  }
13187
0
}
13188
13189
static KRML_MUSTINLINE void
13190
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_6(Eurydice_arr_a3 *re)
13191
0
{
13192
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_302(re);
13193
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_422(re);
13194
0
}
13195
13196
/**
13197
A monomorphic instance of libcrux_ml_dsa.simd.portable.invntt.outer_3_plus
13198
with const generics
13199
- OFFSET= 0
13200
- STEP_BY= 16
13201
- ZETA= 25847
13202
*/
13203
static KRML_MUSTINLINE void
13204
libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_303(Eurydice_arr_a3 *re)
13205
0
{
13206
0
  for (size_t i = (size_t)0U; i < (size_t)0U + (size_t)16U; i++)
13207
0
  {
13208
0
    size_t j = i;
13209
0
    Eurydice_arr_4d rej = re->data[j];
13210
0
    Eurydice_arr_4d rejs = re->data[j + (size_t)16U];
13211
0
    libcrux_ml_dsa_simd_portable_arithmetic_add(&re->data[j], &rejs);
13212
0
    libcrux_ml_dsa_simd_portable_arithmetic_subtract(&re->data[j + (size_t)16U], &rej);
13213
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[j +
13214
0
        (size_t)16U],
13215
0
      25847);
13216
0
  }
13217
0
}
13218
13219
static KRML_MUSTINLINE void
13220
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_7(Eurydice_arr_a3 *re)
13221
0
{
13222
0
  libcrux_ml_dsa_simd_portable_invntt_outer_3_plus_303(re);
13223
0
}
13224
13225
static KRML_MUSTINLINE void
13226
libcrux_ml_dsa_simd_portable_invntt_invert_ntt_montgomery(Eurydice_arr_a3 *re)
13227
0
{
13228
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_0(re);
13229
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_1(re);
13230
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_2(re);
13231
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_3(re);
13232
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_4(re);
13233
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_5(re);
13234
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_6(re);
13235
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_at_layer_7(re);
13236
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
13237
0
  {
13238
0
    size_t i0 = i;
13239
0
    libcrux_ml_dsa_simd_portable_arithmetic_montgomery_multiply_by_constant(&re->data[i0], 41978);
13240
0
  }
13241
0
}
13242
13243
/**
13244
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
13245
*/
13246
static inline void
13247
libcrux_ml_dsa_simd_portable_invert_ntt_montgomery_65(Eurydice_arr_a3 *simd_units)
13248
0
{
13249
0
  libcrux_ml_dsa_simd_portable_invntt_invert_ntt_montgomery(simd_units);
13250
0
}
13251
13252
/**
13253
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
13254
*/
13255
static inline void
13256
libcrux_ml_dsa_simd_portable_barrett_reduce_simd_unit_65(Eurydice_arr_4d *simd_unit)
13257
0
{
13258
0
  libcrux_ml_dsa_simd_portable_arithmetic_barrett_reduce_simd_unit(simd_unit);
13259
0
}
13260
13261
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_error_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_ERROR_COEFFICIENT))
13262
13263
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_COMMITMENT_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_commitment_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_COMMITMENT_COEFFICIENT))
13264
13265
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_BETA (libcrux_ml_dsa_constants_beta(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ONES_IN_VERIFIER_CHALLENGE, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ETA))
13266
13267
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_GAMMA1_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_gamma1_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_GAMMA1_COEFFICIENT))
13268
13269
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_VERIFICATION_KEY_SIZE (libcrux_ml_dsa_constants_verification_key_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A))
13270
13271
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_SIGNATURE_SIZE (libcrux_ml_dsa_constants_signature_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_MAX_ONES_IN_HINT, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COMMITMENT_HASH_SIZE, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_GAMMA1_COEFFICIENT))
13272
13273
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_error_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_ERROR_COEFFICIENT))
13274
13275
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_COMMITMENT_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_commitment_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_COMMITMENT_COEFFICIENT))
13276
13277
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_BETA (libcrux_ml_dsa_constants_beta(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ONES_IN_VERIFIER_CHALLENGE, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ETA))
13278
13279
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_GAMMA1_RING_ELEMENT_SIZE (libcrux_ml_dsa_constants_gamma1_ring_element_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_GAMMA1_COEFFICIENT))
13280
13281
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_VERIFICATION_KEY_SIZE (libcrux_ml_dsa_constants_verification_key_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A))
13282
13283
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_SIGNATURE_SIZE (libcrux_ml_dsa_constants_signature_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_MAX_ONES_IN_HINT, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COMMITMENT_HASH_SIZE, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_GAMMA1_COEFFICIENT))
13284
13285
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_COMMITMENT_VECTOR_SIZE (libcrux_ml_dsa_constants_commitment_vector_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_BITS_PER_COMMITMENT_COEFFICIENT, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A))
13286
13287
/**
13288
A monomorphic instance of libcrux_ml_dsa.types.MLDSASigningKey
13289
with const generics
13290
- $2560size_t
13291
*/
13292
typedef Eurydice_arr_10 libcrux_ml_dsa_types_MLDSASigningKey_11;
13293
13294
typedef Eurydice_arr_10 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44SigningKey;
13295
13296
/**
13297
A monomorphic instance of libcrux_ml_dsa.types.MLDSAVerificationKey
13298
with const generics
13299
- $1312size_t
13300
*/
13301
typedef Eurydice_arr_02 libcrux_ml_dsa_types_MLDSAVerificationKey_1d;
13302
13303
typedef Eurydice_arr_02 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44VerificationKey;
13304
13305
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ROW_COLUMN (LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A + LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A)
13306
13307
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ROW_X_COLUMN (LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A * LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A)
13308
13309
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_SIGNING_KEY_SIZE (libcrux_ml_dsa_constants_signing_key_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A, LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE))
13310
13311
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_COMMITMENT_VECTOR_SIZE (libcrux_ml_dsa_constants_commitment_vector_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_BITS_PER_COMMITMENT_COEFFICIENT, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A))
13312
13313
/**
13314
A monomorphic instance of libcrux_ml_dsa.types.MLDSASigningKey
13315
with const generics
13316
- $4032size_t
13317
*/
13318
typedef Eurydice_arr_24 libcrux_ml_dsa_types_MLDSASigningKey_8e;
13319
13320
typedef Eurydice_arr_24 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65SigningKey;
13321
13322
/**
13323
A monomorphic instance of libcrux_ml_dsa.types.MLDSAVerificationKey
13324
with const generics
13325
- $1952size_t
13326
*/
13327
typedef Eurydice_arr_29 libcrux_ml_dsa_types_MLDSAVerificationKey_c8;
13328
13329
typedef Eurydice_arr_29 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65VerificationKey;
13330
13331
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ROW_COLUMN (LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A + LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A)
13332
13333
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ROW_X_COLUMN (LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A * LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A)
13334
13335
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_SIGNING_KEY_SIZE (libcrux_ml_dsa_constants_signing_key_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A, LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE))
13336
13337
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_COMMITMENT_VECTOR_SIZE (libcrux_ml_dsa_constants_commitment_vector_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_BITS_PER_COMMITMENT_COEFFICIENT, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A))
13338
13339
/**
13340
A monomorphic instance of libcrux_ml_dsa.types.MLDSASigningKey
13341
with const generics
13342
- $4896size_t
13343
*/
13344
typedef Eurydice_arr_e2 libcrux_ml_dsa_types_MLDSASigningKey_b8;
13345
13346
typedef Eurydice_arr_e2 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87SigningKey;
13347
13348
/**
13349
A monomorphic instance of libcrux_ml_dsa.types.MLDSAVerificationKey
13350
with const generics
13351
- $2592size_t
13352
*/
13353
typedef Eurydice_arr_43 libcrux_ml_dsa_types_MLDSAVerificationKey_e9;
13354
13355
typedef Eurydice_arr_43 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87VerificationKey;
13356
13357
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ROW_COLUMN (LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A + LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A)
13358
13359
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ROW_X_COLUMN (LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A * LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A)
13360
13361
#define LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_SIGNING_KEY_SIZE (libcrux_ml_dsa_constants_signing_key_size(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A, LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A, LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE))
13362
13363
#define LIBCRUX_ML_DSA_PRE_HASH_PRE_HASH_OID_LEN ((size_t)11U)
13364
13365
typedef Eurydice_arr_c9 libcrux_ml_dsa_pre_hash_PreHashOID;
13366
13367
typedef core_result_Result_a8 libcrux_ml_dsa_pre_hash_PreHashResult;
13368
13369
/**
13370
This function found in impl {core::convert::From<libcrux_ml_dsa::pre_hash::DomainSeparationError> for libcrux_ml_dsa::types::SigningError}
13371
*/
13372
static inline libcrux_ml_dsa_types_SigningError
13373
libcrux_ml_dsa_pre_hash_from_96(libcrux_ml_dsa_pre_hash_DomainSeparationError e)
13374
0
{
13375
0
  return libcrux_ml_dsa_types_SigningError_ContextTooLongError;
13376
0
}
13377
13378
/**
13379
This function found in impl {core::convert::From<libcrux_ml_dsa::pre_hash::DomainSeparationError> for libcrux_ml_dsa::types::VerificationError}
13380
*/
13381
static inline libcrux_ml_dsa_types_VerificationError
13382
libcrux_ml_dsa_pre_hash_from_bf(libcrux_ml_dsa_pre_hash_DomainSeparationError e)
13383
0
{
13384
0
  return libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError;
13385
0
}
13386
13387
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_3_STEP ((size_t)8U)
13388
13389
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_3_STEP_BY ((size_t)1U)
13390
13391
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_4_STEP ((size_t)16U)
13392
13393
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_4_STEP_BY ((size_t)2U)
13394
13395
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_5_STEP ((size_t)32U)
13396
13397
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_5_STEP_BY ((size_t)4U)
13398
13399
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_6_STEP ((size_t)64U)
13400
13401
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_6_STEP_BY ((size_t)8U)
13402
13403
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_7_STEP ((size_t)128U)
13404
13405
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_INVNTT_INVERT_NTT_AT_LAYER_7_STEP_BY ((size_t)16U)
13406
13407
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_3_STEP ((size_t)8U)
13408
13409
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_3_STEP_BY ((size_t)1U)
13410
13411
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_4_STEP ((size_t)16U)
13412
13413
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_4_STEP_BY ((size_t)2U)
13414
13415
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_5_STEP ((size_t)32U)
13416
13417
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_5_STEP_BY ((size_t)4U)
13418
13419
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_6_STEP ((size_t)64U)
13420
13421
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_6_STEP_BY ((size_t)8U)
13422
13423
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_7_STEP ((size_t)128U)
13424
13425
#define LIBCRUX_ML_DSA_SIMD_PORTABLE_NTT_NTT_AT_LAYER_7_STEP_BY ((size_t)16U)
13426
13427
typedef int32_t libcrux_ml_dsa_simd_portable_vector_type_FieldElement;
13428
13429
/**
13430
This function found in impl {core::clone::Clone for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
13431
*/
13432
static inline Eurydice_arr_4d
13433
libcrux_ml_dsa_simd_portable_vector_type_clone_a5(const Eurydice_arr_4d *self)
13434
0
{
13435
0
  return self[0U];
13436
0
}
13437
13438
typedef int32_t libcrux_ml_dsa_simd_traits_FieldElementTimesMontgomeryR;
13439
13440
typedef Eurydice_arr_93 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87Signature;
13441
13442
/**
13443
 A reference to the raw byte array.
13444
*/
13445
/**
13446
This function found in impl {libcrux_ml_dsa::types::MLDSASignature<SIZE>}
13447
*/
13448
/**
13449
A monomorphic instance of libcrux_ml_dsa.types.as_ref_c5
13450
with const generics
13451
- SIZE= 4627
13452
*/
13453
static inline const
13454
Eurydice_arr_93
13455
*libcrux_ml_dsa_types_as_ref_c5_f1(const Eurydice_arr_93 *self)
13456
0
{
13457
0
  return self;
13458
0
}
13459
13460
/**
13461
 A reference to the raw byte array.
13462
*/
13463
/**
13464
This function found in impl {libcrux_ml_dsa::types::MLDSAVerificationKey<SIZE>}
13465
*/
13466
/**
13467
A monomorphic instance of libcrux_ml_dsa.types.as_ref_7f
13468
with const generics
13469
- SIZE= 2592
13470
*/
13471
static inline const
13472
Eurydice_arr_43
13473
*libcrux_ml_dsa_types_as_ref_7f_c6(const Eurydice_arr_43 *self)
13474
0
{
13475
0
  return self;
13476
0
}
13477
13478
/**
13479
 A reference to the raw byte array.
13480
*/
13481
/**
13482
This function found in impl {libcrux_ml_dsa::types::MLDSASigningKey<SIZE>}
13483
*/
13484
/**
13485
A monomorphic instance of libcrux_ml_dsa.types.as_ref_9b
13486
with const generics
13487
- SIZE= 4896
13488
*/
13489
static inline const
13490
Eurydice_arr_e2
13491
*libcrux_ml_dsa_types_as_ref_9b_72(const Eurydice_arr_e2 *self)
13492
0
{
13493
0
  return self;
13494
0
}
13495
13496
/**
13497
 Build
13498
*/
13499
/**
13500
This function found in impl {libcrux_ml_dsa::types::MLDSAVerificationKey<SIZE>}
13501
*/
13502
/**
13503
A monomorphic instance of libcrux_ml_dsa.types.new_7f
13504
with const generics
13505
- SIZE= 2592
13506
*/
13507
static inline Eurydice_arr_43 libcrux_ml_dsa_types_new_7f_c6(Eurydice_arr_43 value)
13508
0
{
13509
0
  return value;
13510
0
}
13511
13512
/**
13513
 Build
13514
*/
13515
/**
13516
This function found in impl {libcrux_ml_dsa::types::MLDSASigningKey<SIZE>}
13517
*/
13518
/**
13519
A monomorphic instance of libcrux_ml_dsa.types.new_9b
13520
with const generics
13521
- SIZE= 4896
13522
*/
13523
static inline Eurydice_arr_e2 libcrux_ml_dsa_types_new_9b_72(Eurydice_arr_e2 value)
13524
0
{
13525
0
  return value;
13526
0
}
13527
13528
typedef Eurydice_arr_85 libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44Signature;
13529
13530
/**
13531
 A reference to the raw byte array.
13532
*/
13533
/**
13534
This function found in impl {libcrux_ml_dsa::types::MLDSASignature<SIZE>}
13535
*/
13536
/**
13537
A monomorphic instance of libcrux_ml_dsa.types.as_ref_c5
13538
with const generics
13539
- SIZE= 2420
13540
*/
13541
static inline const
13542
Eurydice_arr_85
13543
*libcrux_ml_dsa_types_as_ref_c5_37(const Eurydice_arr_85 *self)
13544
0
{
13545
0
  return self;
13546
0
}
13547
13548
/**
13549
 A reference to the raw byte array.
13550
*/
13551
/**
13552
This function found in impl {libcrux_ml_dsa::types::MLDSAVerificationKey<SIZE>}
13553
*/
13554
/**
13555
A monomorphic instance of libcrux_ml_dsa.types.as_ref_7f
13556
with const generics
13557
- SIZE= 1312
13558
*/
13559
static inline const
13560
Eurydice_arr_02
13561
*libcrux_ml_dsa_types_as_ref_7f_7d(const Eurydice_arr_02 *self)
13562
0
{
13563
0
  return self;
13564
0
}
13565
13566
/**
13567
 A reference to the raw byte array.
13568
*/
13569
/**
13570
This function found in impl {libcrux_ml_dsa::types::MLDSASigningKey<SIZE>}
13571
*/
13572
/**
13573
A monomorphic instance of libcrux_ml_dsa.types.as_ref_9b
13574
with const generics
13575
- SIZE= 2560
13576
*/
13577
static inline const
13578
Eurydice_arr_10
13579
*libcrux_ml_dsa_types_as_ref_9b_ab(const Eurydice_arr_10 *self)
13580
0
{
13581
0
  return self;
13582
0
}
13583
13584
/**
13585
 Build
13586
*/
13587
/**
13588
This function found in impl {libcrux_ml_dsa::types::MLDSAVerificationKey<SIZE>}
13589
*/
13590
/**
13591
A monomorphic instance of libcrux_ml_dsa.types.new_7f
13592
with const generics
13593
- SIZE= 1312
13594
*/
13595
static inline Eurydice_arr_02 libcrux_ml_dsa_types_new_7f_7d(Eurydice_arr_02 value)
13596
0
{
13597
0
  return value;
13598
0
}
13599
13600
/**
13601
 Build
13602
*/
13603
/**
13604
This function found in impl {libcrux_ml_dsa::types::MLDSASigningKey<SIZE>}
13605
*/
13606
/**
13607
A monomorphic instance of libcrux_ml_dsa.types.new_9b
13608
with const generics
13609
- SIZE= 2560
13610
*/
13611
static inline Eurydice_arr_10 libcrux_ml_dsa_types_new_9b_ab(Eurydice_arr_10 value)
13612
0
{
13613
0
  return value;
13614
0
}
13615
13616
typedef Eurydice_arr_0c libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65Signature;
13617
13618
/**
13619
 A reference to the raw byte array.
13620
*/
13621
/**
13622
This function found in impl {libcrux_ml_dsa::types::MLDSASignature<SIZE>}
13623
*/
13624
/**
13625
A monomorphic instance of libcrux_ml_dsa.types.as_ref_c5
13626
with const generics
13627
- SIZE= 3309
13628
*/
13629
static inline const
13630
Eurydice_arr_0c
13631
*libcrux_ml_dsa_types_as_ref_c5_5c(const Eurydice_arr_0c *self)
13632
0
{
13633
0
  return self;
13634
0
}
13635
13636
/**
13637
 A reference to the raw byte array.
13638
*/
13639
/**
13640
This function found in impl {libcrux_ml_dsa::types::MLDSAVerificationKey<SIZE>}
13641
*/
13642
/**
13643
A monomorphic instance of libcrux_ml_dsa.types.as_ref_7f
13644
with const generics
13645
- SIZE= 1952
13646
*/
13647
static inline const
13648
Eurydice_arr_29
13649
*libcrux_ml_dsa_types_as_ref_7f_a2(const Eurydice_arr_29 *self)
13650
0
{
13651
0
  return self;
13652
0
}
13653
13654
/**
13655
 A reference to the raw byte array.
13656
*/
13657
/**
13658
This function found in impl {libcrux_ml_dsa::types::MLDSASigningKey<SIZE>}
13659
*/
13660
/**
13661
A monomorphic instance of libcrux_ml_dsa.types.as_ref_9b
13662
with const generics
13663
- SIZE= 4032
13664
*/
13665
static inline const
13666
Eurydice_arr_24
13667
*libcrux_ml_dsa_types_as_ref_9b_e5(const Eurydice_arr_24 *self)
13668
0
{
13669
0
  return self;
13670
0
}
13671
13672
/**
13673
 Build
13674
*/
13675
/**
13676
This function found in impl {libcrux_ml_dsa::types::MLDSAVerificationKey<SIZE>}
13677
*/
13678
/**
13679
A monomorphic instance of libcrux_ml_dsa.types.new_7f
13680
with const generics
13681
- SIZE= 1952
13682
*/
13683
static inline Eurydice_arr_29 libcrux_ml_dsa_types_new_7f_a2(Eurydice_arr_29 value)
13684
0
{
13685
0
  return value;
13686
0
}
13687
13688
/**
13689
 Build
13690
*/
13691
/**
13692
This function found in impl {libcrux_ml_dsa::types::MLDSASigningKey<SIZE>}
13693
*/
13694
/**
13695
A monomorphic instance of libcrux_ml_dsa.types.new_9b
13696
with const generics
13697
- SIZE= 4032
13698
*/
13699
static inline Eurydice_arr_24 libcrux_ml_dsa_types_new_9b_e5(Eurydice_arr_24 value)
13700
0
{
13701
0
  return value;
13702
0
}
13703
13704
/**
13705
A monomorphic instance of core.result.Result
13706
with types libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87Signature, libcrux_ml_dsa_types_SigningError
13707
13708
*/
13709
typedef struct core_result_Result_8b_s
13710
{
13711
  core_result_Result_57_tags tag;
13712
  union {
13713
    Eurydice_arr_93 case_Ok;
13714
    libcrux_ml_dsa_types_SigningError case_Err;
13715
  }
13716
  val;
13717
}
13718
core_result_Result_8b;
13719
13720
/**
13721
A monomorphic instance of libcrux_ml_dsa.polynomial.PolynomialRingElement
13722
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13723
13724
*/
13725
typedef Eurydice_arr_a3 libcrux_ml_dsa_polynomial_PolynomialRingElement_e8;
13726
13727
/**
13728
A monomorphic instance of Eurydice.arr
13729
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
13730
with const generics
13731
- $7size_t
13732
*/
13733
typedef struct Eurydice_arr_bb_s { Eurydice_arr_a3 data[7U]; } Eurydice_arr_bb;
13734
13735
/**
13736
A monomorphic instance of core.option.Option
13737
with types Eurydice_arr_bb
13738
13739
*/
13740
typedef struct core_option_Option_2d_s
13741
{
13742
  core_option_Option_45_tags tag;
13743
  Eurydice_arr_bb f0;
13744
}
13745
core_option_Option_2d;
13746
13747
/**
13748
A monomorphic instance of Eurydice.dst_ref_shared
13749
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8, size_t
13750
13751
*/
13752
typedef struct Eurydice_dst_ref_shared_44_s
13753
{
13754
  const Eurydice_arr_a3 *ptr;
13755
  size_t meta;
13756
}
13757
Eurydice_dst_ref_shared_44;
13758
13759
/**
13760
A monomorphic instance of Eurydice.arr
13761
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
13762
with const generics
13763
- $56size_t
13764
*/
13765
typedef struct Eurydice_arr_0f_s { Eurydice_arr_a3 data[56U]; } Eurydice_arr_0f;
13766
13767
/**
13768
A monomorphic instance of Eurydice.array_to_slice_shared
13769
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13770
with const generics
13771
- N= 56
13772
*/
13773
static inline Eurydice_dst_ref_shared_44
13774
Eurydice_array_to_slice_shared_208(const Eurydice_arr_0f *a)
13775
0
{
13776
0
  Eurydice_dst_ref_shared_44 lit;
13777
0
  lit.ptr = a->data;
13778
0
  lit.meta = (size_t)56U;
13779
0
  return lit;
13780
0
}
13781
13782
/**
13783
 Init with zero
13784
*/
13785
/**
13786
This function found in impl {libcrux_ml_dsa::types::MLDSASignature<SIZE>}
13787
*/
13788
/**
13789
A monomorphic instance of libcrux_ml_dsa.types.zero_c5
13790
with const generics
13791
- SIZE= 4627
13792
*/
13793
static inline Eurydice_arr_93 libcrux_ml_dsa_types_zero_c5_f1(void)
13794
0
{
13795
0
  return (KRML_CLITERAL(Eurydice_arr_93){ .data = { 0U } });
13796
0
}
13797
13798
/**
13799
A monomorphic instance of Eurydice.arr
13800
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
13801
with const generics
13802
- $8size_t
13803
*/
13804
typedef struct Eurydice_arr_8f_s { Eurydice_arr_a3 data[8U]; } Eurydice_arr_8f;
13805
13806
/**
13807
 Declassify secret memory.
13808
13809
 No-op if `valgrind_ct_test` cfg is not enabled.
13810
*/
13811
/**
13812
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
13813
with types Eurydice_arr libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients[[$8size_t]]
13814
13815
*/
13816
static KRML_MUSTINLINE void
13817
libcrux_secrets_mem_requests_ct_declassify_6a(const Eurydice_arr_8f *val)
13818
0
{
13819
0
13820
0
}
13821
13822
/**
13823
A monomorphic instance of Eurydice.arr
13824
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
13825
with const generics
13826
- $15size_t
13827
*/
13828
typedef struct Eurydice_arr_92_s { Eurydice_arr_a3 data[15U]; } Eurydice_arr_92;
13829
13830
/**
13831
A monomorphic instance of Eurydice.array_to_slice_shared
13832
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13833
with const generics
13834
- N= 15
13835
*/
13836
static inline Eurydice_dst_ref_shared_44
13837
Eurydice_array_to_slice_shared_207(const Eurydice_arr_92 *a)
13838
0
{
13839
0
  Eurydice_dst_ref_shared_44 lit;
13840
0
  lit.ptr = a->data;
13841
0
  lit.meta = (size_t)15U;
13842
0
  return lit;
13843
0
}
13844
13845
/**
13846
A monomorphic instance of Eurydice.array_to_slice_shared
13847
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13848
with const generics
13849
- N= 7
13850
*/
13851
static inline Eurydice_dst_ref_shared_44
13852
Eurydice_array_to_slice_shared_206(const Eurydice_arr_bb *a)
13853
0
{
13854
0
  Eurydice_dst_ref_shared_44 lit;
13855
0
  lit.ptr = a->data;
13856
0
  lit.meta = (size_t)7U;
13857
0
  return lit;
13858
0
}
13859
13860
/**
13861
A monomorphic instance of Eurydice.array_to_subslice_shared
13862
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients, core_ops_range_Range size_t, Eurydice_derefed_slice libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13863
with const generics
13864
- N= 15
13865
*/
13866
static inline Eurydice_dst_ref_shared_44
13867
Eurydice_array_to_subslice_shared_251(const Eurydice_arr_92 *a, core_ops_range_Range_87 r)
13868
0
{
13869
0
  return
13870
0
    (
13871
0
      KRML_CLITERAL(Eurydice_dst_ref_shared_44){ .ptr = a->data + r.start, .meta = r.end - r.start }
13872
0
    );
13873
0
}
13874
13875
/**
13876
A monomorphic instance of Eurydice.dst_ref_mut
13877
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8, size_t
13878
13879
*/
13880
typedef struct Eurydice_dst_ref_mut_44_s
13881
{
13882
  Eurydice_arr_a3 *ptr;
13883
  size_t meta;
13884
}
13885
Eurydice_dst_ref_mut_44;
13886
13887
/**
13888
A monomorphic instance of Eurydice.array_to_slice_mut
13889
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13890
with const generics
13891
- N= 7
13892
*/
13893
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_208(Eurydice_arr_bb *a)
13894
0
{
13895
0
  Eurydice_dst_ref_mut_44 lit;
13896
0
  lit.ptr = a->data;
13897
0
  lit.meta = (size_t)7U;
13898
0
  return lit;
13899
0
}
13900
13901
/**
13902
A monomorphic instance of Eurydice.array_to_slice_mut
13903
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13904
with const generics
13905
- N= 56
13906
*/
13907
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_207(Eurydice_arr_0f *a)
13908
0
{
13909
0
  Eurydice_dst_ref_mut_44 lit;
13910
0
  lit.ptr = a->data;
13911
0
  lit.meta = (size_t)56U;
13912
0
  return lit;
13913
0
}
13914
13915
/**
13916
A monomorphic instance of Eurydice.array_to_slice_mut
13917
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13918
with const generics
13919
- N= 15
13920
*/
13921
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_206(Eurydice_arr_92 *a)
13922
0
{
13923
0
  Eurydice_dst_ref_mut_44 lit;
13924
0
  lit.ptr = a->data;
13925
0
  lit.meta = (size_t)15U;
13926
0
  return lit;
13927
0
}
13928
13929
/**
13930
A monomorphic instance of core.result.Result
13931
with types libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65Signature, libcrux_ml_dsa_types_SigningError
13932
13933
*/
13934
typedef struct core_result_Result_8c_s
13935
{
13936
  core_result_Result_57_tags tag;
13937
  union {
13938
    Eurydice_arr_0c case_Ok;
13939
    libcrux_ml_dsa_types_SigningError case_Err;
13940
  }
13941
  val;
13942
}
13943
core_result_Result_8c;
13944
13945
/**
13946
A monomorphic instance of Eurydice.arr
13947
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
13948
with const generics
13949
- $5size_t
13950
*/
13951
typedef struct Eurydice_arr_5d_s { Eurydice_arr_a3 data[5U]; } Eurydice_arr_5d;
13952
13953
/**
13954
A monomorphic instance of core.option.Option
13955
with types Eurydice_arr_5d
13956
13957
*/
13958
typedef struct core_option_Option_1e_s
13959
{
13960
  core_option_Option_45_tags tag;
13961
  Eurydice_arr_5d f0;
13962
}
13963
core_option_Option_1e;
13964
13965
/**
13966
A monomorphic instance of Eurydice.arr
13967
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
13968
with const generics
13969
- $30size_t
13970
*/
13971
typedef struct Eurydice_arr_5a_s { Eurydice_arr_a3 data[30U]; } Eurydice_arr_5a;
13972
13973
/**
13974
A monomorphic instance of Eurydice.array_to_slice_shared
13975
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
13976
with const generics
13977
- N= 30
13978
*/
13979
static inline Eurydice_dst_ref_shared_44
13980
Eurydice_array_to_slice_shared_205(const Eurydice_arr_5a *a)
13981
0
{
13982
0
  Eurydice_dst_ref_shared_44 lit;
13983
0
  lit.ptr = a->data;
13984
0
  lit.meta = (size_t)30U;
13985
0
  return lit;
13986
0
}
13987
13988
/**
13989
 Init with zero
13990
*/
13991
/**
13992
This function found in impl {libcrux_ml_dsa::types::MLDSASignature<SIZE>}
13993
*/
13994
/**
13995
A monomorphic instance of libcrux_ml_dsa.types.zero_c5
13996
with const generics
13997
- SIZE= 3309
13998
*/
13999
static inline Eurydice_arr_0c libcrux_ml_dsa_types_zero_c5_5c(void)
14000
0
{
14001
0
  return (KRML_CLITERAL(Eurydice_arr_0c){ .data = { 0U } });
14002
0
}
14003
14004
/**
14005
A monomorphic instance of Eurydice.arr
14006
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
14007
with const generics
14008
- $6size_t
14009
*/
14010
typedef struct Eurydice_arr_dc1_s { Eurydice_arr_a3 data[6U]; } Eurydice_arr_dc1;
14011
14012
/**
14013
A monomorphic instance of Eurydice.array_to_slice_shared
14014
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14015
with const generics
14016
- N= 6
14017
*/
14018
static inline Eurydice_dst_ref_shared_44
14019
Eurydice_array_to_slice_shared_204(const Eurydice_arr_dc1 *a)
14020
0
{
14021
0
  Eurydice_dst_ref_shared_44 lit;
14022
0
  lit.ptr = a->data;
14023
0
  lit.meta = (size_t)6U;
14024
0
  return lit;
14025
0
}
14026
14027
/**
14028
 Declassify secret memory.
14029
14030
 No-op if `valgrind_ct_test` cfg is not enabled.
14031
*/
14032
/**
14033
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
14034
with types Eurydice_arr libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients[[$6size_t]]
14035
14036
*/
14037
static KRML_MUSTINLINE void
14038
libcrux_secrets_mem_requests_ct_declassify_b2(const Eurydice_arr_dc1 *val)
14039
0
{
14040
0
14041
0
}
14042
14043
/**
14044
A monomorphic instance of Eurydice.array_to_slice_mut
14045
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14046
with const generics
14047
- N= 6
14048
*/
14049
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_205(Eurydice_arr_dc1 *a)
14050
0
{
14051
0
  Eurydice_dst_ref_mut_44 lit;
14052
0
  lit.ptr = a->data;
14053
0
  lit.meta = (size_t)6U;
14054
0
  return lit;
14055
0
}
14056
14057
/**
14058
A monomorphic instance of Eurydice.arr
14059
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
14060
with const generics
14061
- $11size_t
14062
*/
14063
typedef struct Eurydice_arr_47_s { Eurydice_arr_a3 data[11U]; } Eurydice_arr_47;
14064
14065
/**
14066
A monomorphic instance of Eurydice.array_to_slice_shared
14067
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14068
with const generics
14069
- N= 11
14070
*/
14071
static inline Eurydice_dst_ref_shared_44
14072
Eurydice_array_to_slice_shared_203(const Eurydice_arr_47 *a)
14073
0
{
14074
0
  Eurydice_dst_ref_shared_44 lit;
14075
0
  lit.ptr = a->data;
14076
0
  lit.meta = (size_t)11U;
14077
0
  return lit;
14078
0
}
14079
14080
/**
14081
A monomorphic instance of Eurydice.array_to_slice_shared
14082
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14083
with const generics
14084
- N= 5
14085
*/
14086
static inline Eurydice_dst_ref_shared_44
14087
Eurydice_array_to_slice_shared_202(const Eurydice_arr_5d *a)
14088
0
{
14089
0
  Eurydice_dst_ref_shared_44 lit;
14090
0
  lit.ptr = a->data;
14091
0
  lit.meta = (size_t)5U;
14092
0
  return lit;
14093
0
}
14094
14095
/**
14096
A monomorphic instance of Eurydice.array_to_subslice_shared
14097
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients, core_ops_range_Range size_t, Eurydice_derefed_slice libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14098
with const generics
14099
- N= 11
14100
*/
14101
static inline Eurydice_dst_ref_shared_44
14102
Eurydice_array_to_subslice_shared_250(const Eurydice_arr_47 *a, core_ops_range_Range_87 r)
14103
0
{
14104
0
  return
14105
0
    (
14106
0
      KRML_CLITERAL(Eurydice_dst_ref_shared_44){ .ptr = a->data + r.start, .meta = r.end - r.start }
14107
0
    );
14108
0
}
14109
14110
/**
14111
A monomorphic instance of Eurydice.array_to_slice_mut
14112
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14113
with const generics
14114
- N= 5
14115
*/
14116
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_204(Eurydice_arr_5d *a)
14117
0
{
14118
0
  Eurydice_dst_ref_mut_44 lit;
14119
0
  lit.ptr = a->data;
14120
0
  lit.meta = (size_t)5U;
14121
0
  return lit;
14122
0
}
14123
14124
/**
14125
A monomorphic instance of Eurydice.array_to_slice_mut
14126
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14127
with const generics
14128
- N= 30
14129
*/
14130
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_203(Eurydice_arr_5a *a)
14131
0
{
14132
0
  Eurydice_dst_ref_mut_44 lit;
14133
0
  lit.ptr = a->data;
14134
0
  lit.meta = (size_t)30U;
14135
0
  return lit;
14136
0
}
14137
14138
/**
14139
A monomorphic instance of Eurydice.array_to_slice_mut
14140
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14141
with const generics
14142
- N= 11
14143
*/
14144
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_202(Eurydice_arr_47 *a)
14145
0
{
14146
0
  Eurydice_dst_ref_mut_44 lit;
14147
0
  lit.ptr = a->data;
14148
0
  lit.meta = (size_t)11U;
14149
0
  return lit;
14150
0
}
14151
14152
/**
14153
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14154
*/
14155
/**
14156
A monomorphic instance of libcrux_ml_dsa.polynomial.zero_ff
14157
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14158
with const generics
14159
14160
*/
14161
static inline Eurydice_arr_a3 libcrux_ml_dsa_polynomial_zero_ff_37(void)
14162
0
{
14163
0
  Eurydice_arr_a3 lit;
14164
0
  Eurydice_arr_4d repeat_expression[32U];
14165
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14166
0
  {
14167
0
    repeat_expression[i] = libcrux_ml_dsa_simd_portable_zero_65();
14168
0
  }
14169
0
  memcpy(lit.data, repeat_expression, (size_t)32U * sizeof (Eurydice_arr_4d));
14170
0
  return lit;
14171
0
}
14172
14173
/**
14174
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14175
*/
14176
/**
14177
A monomorphic instance of libcrux_ml_dsa.polynomial.from_i32_array_ff
14178
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14179
with const generics
14180
14181
*/
14182
static inline void
14183
libcrux_ml_dsa_polynomial_from_i32_array_ff_37(
14184
  Eurydice_dst_ref_shared_83 array,
14185
  Eurydice_arr_a3 *result
14186
)
14187
0
{
14188
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_DSA_SIMD_TRAITS_SIMD_UNITS_IN_RING_ELEMENT; i++)
14189
0
  {
14190
0
    size_t i0 = i;
14191
0
    libcrux_ml_dsa_simd_portable_from_coefficient_array_65(Eurydice_slice_subslice_shared_47(array,
14192
0
        (
14193
0
          KRML_CLITERAL(core_ops_range_Range_87){
14194
0
            .start = i0 * LIBCRUX_ML_DSA_SIMD_TRAITS_COEFFICIENTS_IN_SIMD_UNIT,
14195
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_DSA_SIMD_TRAITS_COEFFICIENTS_IN_SIMD_UNIT
14196
0
          }
14197
0
        )),
14198
0
      &result->data[i0]);
14199
0
  }
14200
0
}
14201
14202
/**
14203
A monomorphic instance of libcrux_ml_dsa.arithmetic.use_hint
14204
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14205
with const generics
14206
14207
*/
14208
static KRML_MUSTINLINE void
14209
libcrux_ml_dsa_arithmetic_use_hint_37(
14210
  int32_t gamma2,
14211
  Eurydice_dst_ref_shared_20 hint,
14212
  Eurydice_dst_ref_mut_44 re_vector
14213
)
14214
0
{
14215
0
  for (size_t i0 = (size_t)0U; i0 < re_vector.meta; i0++)
14216
0
  {
14217
0
    size_t i1 = i0;
14218
0
    Eurydice_arr_a3 tmp = libcrux_ml_dsa_polynomial_zero_ff_37();
14219
0
    libcrux_ml_dsa_polynomial_from_i32_array_ff_37(Eurydice_array_to_slice_shared_af(&hint.ptr[i1]),
14220
0
      &tmp);
14221
0
    for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14222
0
    {
14223
0
      size_t j = i;
14224
0
      libcrux_ml_dsa_simd_portable_use_hint_65(gamma2, &re_vector.ptr[i1].data[j], &tmp.data[j]);
14225
0
    }
14226
0
    re_vector.ptr[i1] = tmp;
14227
0
  }
14228
0
}
14229
14230
/**
14231
A monomorphic instance of libcrux_ml_dsa.ntt.ntt_multiply_montgomery
14232
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14233
with const generics
14234
14235
*/
14236
static KRML_MUSTINLINE void
14237
libcrux_ml_dsa_ntt_ntt_multiply_montgomery_37(Eurydice_arr_a3 *lhs, const Eurydice_arr_a3 *rhs)
14238
0
{
14239
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14240
0
  {
14241
0
    size_t i0 = i;
14242
0
    libcrux_ml_dsa_simd_portable_montgomery_multiply_65(&lhs->data[i0], &rhs->data[i0]);
14243
0
  }
14244
0
}
14245
14246
/**
14247
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14248
*/
14249
/**
14250
A monomorphic instance of libcrux_ml_dsa.polynomial.add_ff
14251
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14252
with const generics
14253
14254
*/
14255
static KRML_MUSTINLINE void
14256
libcrux_ml_dsa_polynomial_add_ff_37(Eurydice_arr_a3 *self, const Eurydice_arr_a3 *rhs)
14257
0
{
14258
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14259
0
  {
14260
0
    size_t i0 = i;
14261
0
    libcrux_ml_dsa_simd_portable_add_65(&self->data[i0], &rhs->data[i0]);
14262
0
  }
14263
0
}
14264
14265
/**
14266
A monomorphic instance of libcrux_ml_dsa.simd.portable.arithmetic.shift_left_then_reduce
14267
with const generics
14268
- SHIFT_BY= 13
14269
*/
14270
static KRML_MUSTINLINE void
14271
libcrux_ml_dsa_simd_portable_arithmetic_shift_left_then_reduce_84(Eurydice_arr_4d *simd_unit)
14272
0
{
14273
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
14274
0
  {
14275
0
    size_t i0 = i;
14276
0
    simd_unit->data[i0] = (int32_t)((uint32_t)simd_unit->data[i0] << (uint32_t)13);
14277
0
  }
14278
0
  libcrux_ml_dsa_simd_portable_arithmetic_barrett_reduce_simd_unit(simd_unit);
14279
0
}
14280
14281
/**
14282
This function found in impl {libcrux_ml_dsa::simd::traits::Operations for libcrux_ml_dsa::simd::portable::vector_type::Coefficients}
14283
*/
14284
/**
14285
A monomorphic instance of libcrux_ml_dsa.simd.portable.shift_left_then_reduce_65
14286
with const generics
14287
- SHIFT_BY= 13
14288
*/
14289
static inline void
14290
libcrux_ml_dsa_simd_portable_shift_left_then_reduce_65_84(Eurydice_arr_4d *simd_unit)
14291
0
{
14292
0
  libcrux_ml_dsa_simd_portable_arithmetic_shift_left_then_reduce_84(simd_unit);
14293
0
}
14294
14295
/**
14296
A monomorphic instance of libcrux_ml_dsa.arithmetic.shift_left_then_reduce
14297
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14298
with const generics
14299
- SHIFT_BY= 13
14300
*/
14301
static KRML_MUSTINLINE void
14302
libcrux_ml_dsa_arithmetic_shift_left_then_reduce_68(Eurydice_arr_a3 *re)
14303
0
{
14304
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14305
0
  {
14306
0
    size_t i0 = i;
14307
0
    libcrux_ml_dsa_simd_portable_shift_left_then_reduce_65_84(&re->data[i0]);
14308
0
  }
14309
0
}
14310
14311
/**
14312
A monomorphic instance of libcrux_ml_dsa.ntt.ntt
14313
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14314
with const generics
14315
14316
*/
14317
static KRML_MUSTINLINE void libcrux_ml_dsa_ntt_ntt_37(Eurydice_arr_a3 *re)
14318
0
{
14319
0
  libcrux_ml_dsa_simd_portable_ntt_65(re);
14320
0
}
14321
14322
/**
14323
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14324
*/
14325
/**
14326
A monomorphic instance of libcrux_ml_dsa.polynomial.subtract_ff
14327
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14328
with const generics
14329
14330
*/
14331
static KRML_MUSTINLINE void
14332
libcrux_ml_dsa_polynomial_subtract_ff_37(Eurydice_arr_a3 *self, const Eurydice_arr_a3 *rhs)
14333
0
{
14334
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14335
0
  {
14336
0
    size_t i0 = i;
14337
0
    libcrux_ml_dsa_simd_portable_subtract_65(&self->data[i0], &rhs->data[i0]);
14338
0
  }
14339
0
}
14340
14341
/**
14342
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14343
*/
14344
/**
14345
A monomorphic instance of libcrux_ml_dsa.polynomial.barrett_reduce_ff
14346
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14347
with const generics
14348
14349
*/
14350
static KRML_MUSTINLINE void
14351
libcrux_ml_dsa_polynomial_barrett_reduce_ff_37(Eurydice_arr_a3 *self)
14352
0
{
14353
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14354
0
  {
14355
0
    size_t i0 = i;
14356
0
    libcrux_ml_dsa_simd_portable_barrett_reduce_simd_unit_65(&self->data[i0]);
14357
0
  }
14358
0
}
14359
14360
/**
14361
A monomorphic instance of libcrux_ml_dsa.ntt.invert_ntt_montgomery
14362
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14363
with const generics
14364
14365
*/
14366
static KRML_MUSTINLINE void libcrux_ml_dsa_ntt_invert_ntt_montgomery_37(Eurydice_arr_a3 *re)
14367
0
{
14368
0
  libcrux_ml_dsa_simd_portable_invert_ntt_montgomery_65(re);
14369
0
}
14370
14371
/**
14372
 Compute InvertNTT(Â ◦ ẑ - ĉ ◦ NTT(t₁2ᵈ))
14373
*/
14374
/**
14375
A monomorphic instance of libcrux_ml_dsa.matrix.compute_w_approx
14376
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14377
with const generics
14378
14379
*/
14380
static KRML_MUSTINLINE void
14381
libcrux_ml_dsa_matrix_compute_w_approx_37(
14382
  size_t rows_in_a,
14383
  size_t columns_in_a,
14384
  Eurydice_dst_ref_shared_44 matrix,
14385
  Eurydice_dst_ref_shared_44 signer_response,
14386
  const Eurydice_arr_a3 *verifier_challenge_as_ntt,
14387
  Eurydice_dst_ref_mut_44 t1
14388
)
14389
0
{
14390
0
  for (size_t i0 = (size_t)0U; i0 < rows_in_a; i0++)
14391
0
  {
14392
0
    size_t i1 = i0;
14393
0
    Eurydice_arr_a3 inner_result = libcrux_ml_dsa_polynomial_zero_ff_37();
14394
0
    for (size_t i = (size_t)0U; i < columns_in_a; i++)
14395
0
    {
14396
0
      size_t j = i;
14397
0
      Eurydice_arr_a3 product = matrix.ptr[i1 * columns_in_a + j];
14398
0
      libcrux_ml_dsa_ntt_ntt_multiply_montgomery_37(&product, &signer_response.ptr[j]);
14399
0
      libcrux_ml_dsa_polynomial_add_ff_37(&inner_result, &product);
14400
0
    }
14401
0
    libcrux_ml_dsa_arithmetic_shift_left_then_reduce_68(&t1.ptr[i1]);
14402
0
    libcrux_ml_dsa_ntt_ntt_37(&t1.ptr[i1]);
14403
0
    libcrux_ml_dsa_ntt_ntt_multiply_montgomery_37(&t1.ptr[i1], verifier_challenge_as_ntt);
14404
0
    libcrux_ml_dsa_polynomial_subtract_ff_37(&inner_result, &t1.ptr[i1]);
14405
0
    t1.ptr[i1] = inner_result;
14406
0
    libcrux_ml_dsa_polynomial_barrett_reduce_ff_37(&t1.ptr[i1]);
14407
0
    libcrux_ml_dsa_ntt_invert_ntt_montgomery_37(&t1.ptr[i1]);
14408
0
  }
14409
0
}
14410
14411
/**
14412
A monomorphic instance of core.result.Result
14413
with types (), libcrux_ml_dsa_types_VerificationError
14414
14415
*/
14416
typedef struct core_result_Result_41_s
14417
{
14418
  core_result_Result_57_tags tag;
14419
  libcrux_ml_dsa_types_VerificationError f0;
14420
}
14421
core_result_Result_41;
14422
14423
/**
14424
A monomorphic instance of libcrux_ml_dsa.encoding.gamma1.deserialize
14425
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14426
with const generics
14427
14428
*/
14429
static KRML_MUSTINLINE void
14430
libcrux_ml_dsa_encoding_gamma1_deserialize_37(
14431
  size_t gamma1_exponent,
14432
  Eurydice_borrow_slice_u8 serialized,
14433
  Eurydice_arr_a3 *result
14434
)
14435
0
{
14436
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14437
0
  {
14438
0
    size_t i0 = i;
14439
0
    libcrux_ml_dsa_simd_portable_gamma1_deserialize_65(Eurydice_slice_subslice_shared_c8(serialized,
14440
0
        (
14441
0
          KRML_CLITERAL(core_ops_range_Range_87){
14442
0
            .start = i0 * (gamma1_exponent + (size_t)1U),
14443
0
            .end = (i0 + (size_t)1U) * (gamma1_exponent + (size_t)1U)
14444
0
          }
14445
0
        )),
14446
0
      &result->data[i0],
14447
0
      gamma1_exponent);
14448
0
  }
14449
0
}
14450
14451
/**
14452
A monomorphic instance of libcrux_ml_dsa.encoding.signature.deserialize
14453
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14454
with const generics
14455
14456
*/
14457
static KRML_MUSTINLINE core_result_Result_41
14458
libcrux_ml_dsa_encoding_signature_deserialize_37(
14459
  size_t columns_in_a,
14460
  size_t rows_in_a,
14461
  size_t commitment_hash_size,
14462
  size_t gamma1_exponent,
14463
  size_t gamma1_ring_element_size,
14464
  size_t max_ones_in_hint,
14465
  size_t signature_size,
14466
  Eurydice_borrow_slice_u8 serialized,
14467
  Eurydice_mut_borrow_slice_u8 out_commitment_hash,
14468
  Eurydice_dst_ref_mut_44 out_signer_response,
14469
  Eurydice_dst_ref_mut_20 out_hint
14470
)
14471
0
{
14472
0
  Eurydice_borrow_slice_u8_x2
14473
0
  uu____0 =
14474
0
    Eurydice_slice_split_at(serialized,
14475
0
      commitment_hash_size,
14476
0
      uint8_t,
14477
0
      Eurydice_borrow_slice_u8_x2);
14478
0
  Eurydice_borrow_slice_u8 commitment_hash = uu____0.fst;
14479
0
  Eurydice_borrow_slice_u8 rest_of_serialized = uu____0.snd;
14480
0
  Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(out_commitment_hash,
14481
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = commitment_hash_size })),
14482
0
    commitment_hash,
14483
0
    uint8_t);
14484
0
  Eurydice_borrow_slice_u8_x2
14485
0
  uu____1 =
14486
0
    Eurydice_slice_split_at(rest_of_serialized,
14487
0
      gamma1_ring_element_size * columns_in_a,
14488
0
      uint8_t,
14489
0
      Eurydice_borrow_slice_u8_x2);
14490
0
  Eurydice_borrow_slice_u8 signer_response_serialized = uu____1.fst;
14491
0
  Eurydice_borrow_slice_u8 hint_serialized = uu____1.snd;
14492
0
  for (size_t i = (size_t)0U; i < columns_in_a; i++)
14493
0
  {
14494
0
    size_t i0 = i;
14495
0
    libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
14496
0
      Eurydice_slice_subslice_shared_c8(signer_response_serialized,
14497
0
        (
14498
0
          KRML_CLITERAL(core_ops_range_Range_87){
14499
0
            .start = i0 * gamma1_ring_element_size,
14500
0
            .end = (i0 + (size_t)1U) * gamma1_ring_element_size
14501
0
          }
14502
0
        )),
14503
0
      &out_signer_response.ptr[i0]);
14504
0
  }
14505
0
  size_t previous_true_hints_seen = (size_t)0U;
14506
0
  bool malformed_hint = false;
14507
0
  for (size_t i0 = (size_t)0U; i0 < rows_in_a; i0++)
14508
0
  {
14509
0
    size_t i1 = i0;
14510
0
    size_t current_true_hints_seen = (size_t)(uint32_t)hint_serialized.ptr[max_ones_in_hint + i1];
14511
0
    if (current_true_hints_seen < previous_true_hints_seen)
14512
0
    {
14513
0
      malformed_hint = true;
14514
0
      break;
14515
0
    }
14516
0
    if (current_true_hints_seen > max_ones_in_hint)
14517
0
    {
14518
0
      malformed_hint = true;
14519
0
      break;
14520
0
    }
14521
0
    for (size_t i = previous_true_hints_seen; i < current_true_hints_seen; i++)
14522
0
    {
14523
0
      size_t j = i;
14524
0
      if (j > previous_true_hints_seen)
14525
0
      {
14526
0
        if (hint_serialized.ptr[j] <= hint_serialized.ptr[j - (size_t)1U])
14527
0
        {
14528
0
          malformed_hint = true;
14529
0
          break;
14530
0
        }
14531
0
      }
14532
0
      libcrux_ml_dsa_encoding_signature_set_hint(out_hint,
14533
0
        i1,
14534
0
        (size_t)(uint32_t)hint_serialized.ptr[j]);
14535
0
    }
14536
0
    if (malformed_hint)
14537
0
    {
14538
0
      break;
14539
0
    }
14540
0
    previous_true_hints_seen = current_true_hints_seen;
14541
0
  }
14542
0
  for (size_t i = previous_true_hints_seen; i < max_ones_in_hint; i++)
14543
0
  {
14544
0
    size_t j = i;
14545
0
    if (hint_serialized.ptr[j] != 0U)
14546
0
    {
14547
0
      malformed_hint = true;
14548
0
      break;
14549
0
    }
14550
0
  }
14551
0
  core_result_Result_41 uu____2;
14552
0
  if (malformed_hint)
14553
0
  {
14554
0
    uu____2 =
14555
0
      (
14556
0
        KRML_CLITERAL(core_result_Result_41){
14557
0
          .tag = core_result_Err,
14558
0
          .f0 = libcrux_ml_dsa_types_VerificationError_MalformedHintError
14559
0
        }
14560
0
      );
14561
0
  }
14562
0
  else
14563
0
  {
14564
0
    uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Ok });
14565
0
  }
14566
0
  return uu____2;
14567
0
}
14568
14569
/**
14570
A monomorphic instance of libcrux_ml_dsa.encoding.t1.deserialize
14571
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14572
with const generics
14573
14574
*/
14575
static inline void
14576
libcrux_ml_dsa_encoding_t1_deserialize_37(
14577
  Eurydice_borrow_slice_u8 serialized,
14578
  Eurydice_arr_a3 *result
14579
)
14580
0
{
14581
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14582
0
  {
14583
0
    size_t i0 = i;
14584
0
    libcrux_ml_dsa_simd_portable_t1_deserialize_65(Eurydice_slice_subslice_shared_c8(serialized,
14585
0
        (
14586
0
          KRML_CLITERAL(core_ops_range_Range_87){
14587
0
            .start = i0 * LIBCRUX_ML_DSA_ENCODING_T1_DESERIALIZE_WINDOW,
14588
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_DSA_ENCODING_T1_DESERIALIZE_WINDOW
14589
0
          }
14590
0
        )),
14591
0
      &result->data[i0]);
14592
0
  }
14593
0
}
14594
14595
/**
14596
A monomorphic instance of libcrux_ml_dsa.encoding.verification_key.deserialize
14597
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14598
with const generics
14599
14600
*/
14601
static KRML_MUSTINLINE void
14602
libcrux_ml_dsa_encoding_verification_key_deserialize_37(
14603
  size_t rows_in_a,
14604
  size_t verification_key_size,
14605
  Eurydice_borrow_slice_u8 serialized,
14606
  Eurydice_dst_ref_mut_44 t1
14607
)
14608
0
{
14609
0
  for (size_t i = (size_t)0U; i < rows_in_a; i++)
14610
0
  {
14611
0
    size_t i0 = i;
14612
0
    libcrux_ml_dsa_encoding_t1_deserialize_37(Eurydice_slice_subslice_shared_c8(serialized,
14613
0
        (
14614
0
          KRML_CLITERAL(core_ops_range_Range_87){
14615
0
            .start = i0 * LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T1S_SIZE,
14616
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T1S_SIZE
14617
0
          }
14618
0
        )),
14619
0
      &t1.ptr[i0]);
14620
0
  }
14621
0
}
14622
14623
/**
14624
A monomorphic instance of core.result.Result
14625
with types libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44Signature, libcrux_ml_dsa_types_SigningError
14626
14627
*/
14628
typedef struct core_result_Result_48_s
14629
{
14630
  core_result_Result_57_tags tag;
14631
  union {
14632
    Eurydice_arr_85 case_Ok;
14633
    libcrux_ml_dsa_types_SigningError case_Err;
14634
  }
14635
  val;
14636
}
14637
core_result_Result_48;
14638
14639
/**
14640
A monomorphic instance of Eurydice.arr
14641
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
14642
with const generics
14643
- $4size_t
14644
*/
14645
typedef struct Eurydice_arr_9d_s { Eurydice_arr_a3 data[4U]; } Eurydice_arr_9d;
14646
14647
/**
14648
A monomorphic instance of core.option.Option
14649
with types Eurydice_arr_9d
14650
14651
*/
14652
typedef struct core_option_Option_d9_s
14653
{
14654
  core_option_Option_45_tags tag;
14655
  Eurydice_arr_9d f0;
14656
}
14657
core_option_Option_d9;
14658
14659
/**
14660
A monomorphic instance of core.result.Result
14661
with types (), libcrux_ml_dsa_types_SigningError
14662
14663
*/
14664
typedef struct core_result_Result_53_s
14665
{
14666
  core_result_Result_57_tags tag;
14667
  libcrux_ml_dsa_types_SigningError f0;
14668
}
14669
core_result_Result_53;
14670
14671
/**
14672
A monomorphic instance of libcrux_ml_dsa.encoding.gamma1.serialize
14673
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14674
with const generics
14675
14676
*/
14677
static KRML_MUSTINLINE void
14678
libcrux_ml_dsa_encoding_gamma1_serialize_37(
14679
  const Eurydice_arr_a3 *re,
14680
  Eurydice_mut_borrow_slice_u8 serialized,
14681
  size_t gamma1_exponent
14682
)
14683
0
{
14684
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14685
0
  {
14686
0
    size_t i0 = i;
14687
0
    const Eurydice_arr_4d *simd_unit = &re->data[i0];
14688
0
    libcrux_ml_dsa_simd_portable_gamma1_serialize_65(simd_unit,
14689
0
      Eurydice_slice_subslice_mut_c8(serialized,
14690
0
        (
14691
0
          KRML_CLITERAL(core_ops_range_Range_87){
14692
0
            .start = i0 * (gamma1_exponent + (size_t)1U),
14693
0
            .end = (i0 + (size_t)1U) * (gamma1_exponent + (size_t)1U)
14694
0
          }
14695
0
        )),
14696
0
      gamma1_exponent);
14697
0
  }
14698
0
}
14699
14700
/**
14701
A monomorphic instance of libcrux_ml_dsa.encoding.signature.serialize
14702
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14703
with const generics
14704
14705
*/
14706
static KRML_MUSTINLINE void
14707
libcrux_ml_dsa_encoding_signature_serialize_37(
14708
  Eurydice_borrow_slice_u8 commitment_hash,
14709
  Eurydice_dst_ref_shared_44 signer_response,
14710
  Eurydice_dst_ref_shared_20 hint,
14711
  size_t commitment_hash_size,
14712
  size_t columns_in_a,
14713
  size_t rows_in_a,
14714
  size_t gamma1_exponent,
14715
  size_t gamma1_ring_element_size,
14716
  size_t max_ones_in_hint,
14717
  Eurydice_mut_borrow_slice_u8 signature
14718
)
14719
0
{
14720
0
  size_t offset = (size_t)0U;
14721
0
  Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(signature,
14722
0
      (
14723
0
        KRML_CLITERAL(core_ops_range_Range_87){
14724
0
          .start = offset,
14725
0
          .end = offset + commitment_hash_size
14726
0
        }
14727
0
      )),
14728
0
    commitment_hash,
14729
0
    uint8_t);
14730
0
  offset += commitment_hash_size;
14731
0
  for (size_t i = (size_t)0U; i < columns_in_a; i++)
14732
0
  {
14733
0
    size_t i0 = i;
14734
0
    libcrux_ml_dsa_encoding_gamma1_serialize_37(&signer_response.ptr[i0],
14735
0
      Eurydice_slice_subslice_mut_c8(signature,
14736
0
        (
14737
0
          KRML_CLITERAL(core_ops_range_Range_87){
14738
0
            .start = offset,
14739
0
            .end = offset + gamma1_ring_element_size
14740
0
          }
14741
0
        )),
14742
0
      gamma1_exponent);
14743
0
    offset += gamma1_ring_element_size;
14744
0
  }
14745
0
  size_t true_hints_seen = (size_t)0U;
14746
0
  for (size_t i0 = (size_t)0U; i0 < rows_in_a; i0++)
14747
0
  {
14748
0
    size_t i1 = i0;
14749
0
    for (size_t i = (size_t)0U; i < (size_t)256U; i++)
14750
0
    {
14751
0
      size_t j = i;
14752
0
      if (hint.ptr[i1].data[j] == 1)
14753
0
      {
14754
0
        signature.ptr[offset + true_hints_seen] = (uint8_t)j;
14755
0
        true_hints_seen++;
14756
0
      }
14757
0
    }
14758
0
    signature.ptr[offset + max_ones_in_hint + i1] = (uint8_t)true_hints_seen;
14759
0
  }
14760
0
}
14761
14762
/**
14763
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14764
*/
14765
/**
14766
A monomorphic instance of libcrux_ml_dsa.polynomial.to_i32_array_ff
14767
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14768
with const generics
14769
14770
*/
14771
static inline Eurydice_arr_6c
14772
libcrux_ml_dsa_polynomial_to_i32_array_ff_37(const Eurydice_arr_a3 *self)
14773
0
{
14774
0
  Eurydice_arr_6c result = { .data = { 0U } };
14775
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14776
0
  {
14777
0
    size_t i0 = i;
14778
0
    libcrux_ml_dsa_simd_portable_to_coefficient_array_65(&self->data[i0],
14779
0
      Eurydice_array_to_subslice_mut_44(&result,
14780
0
        (
14781
0
          KRML_CLITERAL(core_ops_range_Range_87){
14782
0
            .start = i0 * LIBCRUX_ML_DSA_SIMD_TRAITS_COEFFICIENTS_IN_SIMD_UNIT,
14783
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_DSA_SIMD_TRAITS_COEFFICIENTS_IN_SIMD_UNIT
14784
0
          }
14785
0
        )));
14786
0
  }
14787
0
  return result;
14788
0
}
14789
14790
/**
14791
A monomorphic instance of libcrux_ml_dsa.arithmetic.make_hint
14792
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14793
with const generics
14794
14795
*/
14796
static KRML_MUSTINLINE size_t
14797
libcrux_ml_dsa_arithmetic_make_hint_37(
14798
  Eurydice_dst_ref_shared_44 low,
14799
  Eurydice_dst_ref_shared_44 high,
14800
  int32_t gamma2,
14801
  Eurydice_dst_ref_mut_20 hint
14802
)
14803
0
{
14804
0
  size_t true_hints = (size_t)0U;
14805
0
  Eurydice_arr_a3 hint_simd = libcrux_ml_dsa_polynomial_zero_ff_37();
14806
0
  for (size_t i0 = (size_t)0U; i0 < low.meta; i0++)
14807
0
  {
14808
0
    size_t i1 = i0;
14809
0
    for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14810
0
    {
14811
0
      size_t j = i;
14812
0
      size_t
14813
0
      one_hints_count =
14814
0
        libcrux_ml_dsa_simd_portable_compute_hint_65(&low.ptr[i1].data[j],
14815
0
          &high.ptr[i1].data[j],
14816
0
          gamma2,
14817
0
          &hint_simd.data[j]);
14818
0
      true_hints += one_hints_count;
14819
0
    }
14820
0
    Eurydice_arr_6c uu____0 = libcrux_ml_dsa_polynomial_to_i32_array_ff_37(&hint_simd);
14821
0
    hint.ptr[i1] = uu____0;
14822
0
  }
14823
0
  return true_hints;
14824
0
}
14825
14826
/**
14827
 CAUTION: This function must only be called with inputs for
14828
 which it is safe to leak the index of a violating coefficient.
14829
14830
 For all norm checks during ML-DSA signature generation it is
14831
 safe to leak the index of a violating coefficient.
14832
*/
14833
/**
14834
This function found in impl {libcrux_ml_dsa::polynomial::PolynomialRingElement<SIMDUnit>[TraitClause@0, TraitClause@1]}
14835
*/
14836
/**
14837
A monomorphic instance of libcrux_ml_dsa.polynomial.infinity_norm_exceeds_ff
14838
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14839
with const generics
14840
14841
*/
14842
static KRML_MUSTINLINE bool
14843
libcrux_ml_dsa_polynomial_infinity_norm_exceeds_ff_37(
14844
  const Eurydice_arr_a3 *self,
14845
  int32_t bound
14846
)
14847
0
{
14848
0
  bool result = false;
14849
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14850
0
  {
14851
0
    size_t i0 = i;
14852
0
    bool
14853
0
    coeff_exceeds = libcrux_ml_dsa_simd_portable_infinity_norm_exceeds_65(&self->data[i0], bound);
14854
0
    bool uu____0;
14855
0
    if (result)
14856
0
    {
14857
0
      uu____0 = true;
14858
0
    }
14859
0
    else
14860
0
    {
14861
0
      uu____0 = coeff_exceeds;
14862
0
    }
14863
0
    result = uu____0;
14864
0
  }
14865
0
  return result;
14866
0
}
14867
14868
/**
14869
 CAUTION: This function must only be called with inputs for
14870
 which it is safe to leak the index of a violating coefficient.
14871
14872
 For all norm checks during ML-DSA signature generation it is
14873
 safe to leak the index of a violating coefficient.
14874
*/
14875
/**
14876
A monomorphic instance of libcrux_ml_dsa.arithmetic.vector_infinity_norm_exceeds
14877
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14878
with const generics
14879
14880
*/
14881
static KRML_MUSTINLINE bool
14882
libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(
14883
  Eurydice_dst_ref_shared_44 vector,
14884
  int32_t bound
14885
)
14886
0
{
14887
0
  bool result = false;
14888
0
  for (size_t i = (size_t)0U; i < vector.meta; i++)
14889
0
  {
14890
0
    size_t i0 = i;
14891
0
    bool uu____0;
14892
0
    if (result)
14893
0
    {
14894
0
      uu____0 = true;
14895
0
    }
14896
0
    else
14897
0
    {
14898
0
      uu____0 = libcrux_ml_dsa_polynomial_infinity_norm_exceeds_ff_37(&vector.ptr[i0], bound);
14899
0
    }
14900
0
    result = uu____0;
14901
0
  }
14902
0
  return result;
14903
0
}
14904
14905
/**
14906
A monomorphic instance of libcrux_ml_dsa.matrix.subtract_vectors
14907
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14908
with const generics
14909
14910
*/
14911
static KRML_MUSTINLINE void
14912
libcrux_ml_dsa_matrix_subtract_vectors_37(
14913
  size_t dimension,
14914
  Eurydice_dst_ref_mut_44 lhs,
14915
  Eurydice_dst_ref_shared_44 rhs
14916
)
14917
0
{
14918
0
  for (size_t i = (size_t)0U; i < dimension; i++)
14919
0
  {
14920
0
    size_t i0 = i;
14921
0
    libcrux_ml_dsa_polynomial_subtract_ff_37(&lhs.ptr[i0], &rhs.ptr[i0]);
14922
0
  }
14923
0
}
14924
14925
/**
14926
A monomorphic instance of libcrux_ml_dsa.matrix.add_vectors
14927
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14928
with const generics
14929
14930
*/
14931
static KRML_MUSTINLINE void
14932
libcrux_ml_dsa_matrix_add_vectors_37(
14933
  size_t dimension,
14934
  Eurydice_dst_ref_mut_44 lhs,
14935
  Eurydice_dst_ref_shared_44 rhs
14936
)
14937
0
{
14938
0
  for (size_t i = (size_t)0U; i < dimension; i++)
14939
0
  {
14940
0
    size_t i0 = i;
14941
0
    libcrux_ml_dsa_polynomial_add_ff_37(&lhs.ptr[i0], &rhs.ptr[i0]);
14942
0
  }
14943
0
}
14944
14945
/**
14946
A monomorphic instance of libcrux_ml_dsa.matrix.vector_times_ring_element
14947
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14948
with const generics
14949
14950
*/
14951
static KRML_MUSTINLINE void
14952
libcrux_ml_dsa_matrix_vector_times_ring_element_37(
14953
  Eurydice_dst_ref_mut_44 vector,
14954
  const Eurydice_arr_a3 *ring_element
14955
)
14956
0
{
14957
0
  for (size_t i = (size_t)0U; i < vector.meta; i++)
14958
0
  {
14959
0
    size_t i0 = i;
14960
0
    libcrux_ml_dsa_ntt_ntt_multiply_montgomery_37(&vector.ptr[i0], ring_element);
14961
0
    libcrux_ml_dsa_ntt_invert_ntt_montgomery_37(&vector.ptr[i0]);
14962
0
  }
14963
0
}
14964
14965
/**
14966
A monomorphic instance of libcrux_ml_dsa.encoding.commitment.serialize
14967
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14968
with const generics
14969
14970
*/
14971
static KRML_MUSTINLINE void
14972
libcrux_ml_dsa_encoding_commitment_serialize_37(
14973
  const Eurydice_arr_a3 *re,
14974
  Eurydice_mut_borrow_slice_u8 serialized
14975
)
14976
0
{
14977
0
  size_t output_bytes_per_simd_unit = serialized.meta / ((size_t)8U * (size_t)4U);
14978
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
14979
0
  {
14980
0
    size_t i0 = i;
14981
0
    const Eurydice_arr_4d *simd_unit = &re->data[i0];
14982
0
    libcrux_ml_dsa_simd_portable_commitment_serialize_65(simd_unit,
14983
0
      Eurydice_slice_subslice_mut_c8(serialized,
14984
0
        (
14985
0
          KRML_CLITERAL(core_ops_range_Range_87){
14986
0
            .start = i0 * output_bytes_per_simd_unit,
14987
0
            .end = (i0 + (size_t)1U) * output_bytes_per_simd_unit
14988
0
          }
14989
0
        )));
14990
0
  }
14991
0
}
14992
14993
/**
14994
A monomorphic instance of libcrux_ml_dsa.encoding.commitment.serialize_vector
14995
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
14996
with const generics
14997
14998
*/
14999
static KRML_MUSTINLINE void
15000
libcrux_ml_dsa_encoding_commitment_serialize_vector_37(
15001
  size_t ring_element_size,
15002
  Eurydice_dst_ref_shared_44 vector,
15003
  Eurydice_mut_borrow_slice_u8 serialized
15004
)
15005
0
{
15006
0
  size_t offset = (size_t)0U;
15007
0
  for (size_t i = (size_t)0U; i < vector.meta; i++)
15008
0
  {
15009
0
    size_t _cloop_j = i;
15010
0
    const Eurydice_arr_a3 *ring_element = &vector.ptr[_cloop_j];
15011
0
    libcrux_ml_dsa_encoding_commitment_serialize_37(ring_element,
15012
0
      Eurydice_slice_subslice_mut_c8(serialized,
15013
0
        (
15014
0
          KRML_CLITERAL(core_ops_range_Range_87){
15015
0
            .start = offset,
15016
0
            .end = offset + ring_element_size
15017
0
          }
15018
0
        )));
15019
0
    offset += ring_element_size;
15020
0
  }
15021
0
}
15022
15023
/**
15024
A monomorphic instance of libcrux_ml_dsa.arithmetic.decompose_vector
15025
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15026
with const generics
15027
15028
*/
15029
static KRML_MUSTINLINE void
15030
libcrux_ml_dsa_arithmetic_decompose_vector_37(
15031
  size_t dimension,
15032
  int32_t gamma2,
15033
  Eurydice_dst_ref_shared_44 t,
15034
  Eurydice_dst_ref_mut_44 low,
15035
  Eurydice_dst_ref_mut_44 high
15036
)
15037
0
{
15038
0
  for (size_t i0 = (size_t)0U; i0 < dimension; i0++)
15039
0
  {
15040
0
    size_t i1 = i0;
15041
0
    for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15042
0
    {
15043
0
      size_t j = i;
15044
0
      libcrux_ml_dsa_simd_portable_decompose_65(gamma2,
15045
0
        &t.ptr[i1].data[j],
15046
0
        &low.ptr[i1].data[j],
15047
0
        &high.ptr[i1].data[j]);
15048
0
    }
15049
0
  }
15050
0
}
15051
15052
/**
15053
A monomorphic instance of Eurydice.arr
15054
with types libcrux_ml_dsa_polynomial_PolynomialRingElement_e8
15055
with const generics
15056
- $16size_t
15057
*/
15058
typedef struct Eurydice_arr_2f_s { Eurydice_arr_a3 data[16U]; } Eurydice_arr_2f;
15059
15060
/**
15061
A monomorphic instance of Eurydice.array_to_slice_shared
15062
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15063
with const generics
15064
- N= 16
15065
*/
15066
static inline Eurydice_dst_ref_shared_44
15067
Eurydice_array_to_slice_shared_201(const Eurydice_arr_2f *a)
15068
0
{
15069
0
  Eurydice_dst_ref_shared_44 lit;
15070
0
  lit.ptr = a->data;
15071
0
  lit.meta = (size_t)16U;
15072
0
  return lit;
15073
0
}
15074
15075
/**
15076
 Compute InvertNTT(Â ◦ ŷ)
15077
*/
15078
/**
15079
A monomorphic instance of libcrux_ml_dsa.matrix.compute_matrix_x_mask
15080
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15081
with const generics
15082
15083
*/
15084
static KRML_MUSTINLINE void
15085
libcrux_ml_dsa_matrix_compute_matrix_x_mask_37(
15086
  size_t rows_in_a,
15087
  size_t columns_in_a,
15088
  Eurydice_dst_ref_shared_44 matrix,
15089
  Eurydice_dst_ref_shared_44 mask,
15090
  Eurydice_dst_ref_mut_44 result
15091
)
15092
0
{
15093
0
  for (size_t i0 = (size_t)0U; i0 < rows_in_a; i0++)
15094
0
  {
15095
0
    size_t i1 = i0;
15096
0
    for (size_t i = (size_t)0U; i < columns_in_a; i++)
15097
0
    {
15098
0
      size_t j = i;
15099
0
      Eurydice_arr_a3 product = mask.ptr[j];
15100
0
      libcrux_ml_dsa_ntt_ntt_multiply_montgomery_37(&product, &matrix.ptr[i1 * columns_in_a + j]);
15101
0
      libcrux_ml_dsa_polynomial_add_ff_37(&result.ptr[i1], &product);
15102
0
    }
15103
0
    libcrux_ml_dsa_polynomial_barrett_reduce_ff_37(&result.ptr[i1]);
15104
0
    libcrux_ml_dsa_ntt_invert_ntt_montgomery_37(&result.ptr[i1]);
15105
0
  }
15106
0
}
15107
15108
/**
15109
A monomorphic instance of core.option.Option
15110
with types libcrux_ml_dsa_pre_hash_DomainSeparationContext
15111
15112
*/
15113
typedef struct core_option_Option_84_s
15114
{
15115
  core_option_Option_45_tags tag;
15116
  libcrux_ml_dsa_pre_hash_DomainSeparationContext f0;
15117
}
15118
core_option_Option_84;
15119
15120
/**
15121
A monomorphic instance of libcrux_ml_dsa.encoding.t0.deserialize
15122
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15123
with const generics
15124
15125
*/
15126
static KRML_MUSTINLINE void
15127
libcrux_ml_dsa_encoding_t0_deserialize_37(
15128
  Eurydice_borrow_slice_u8 serialized,
15129
  Eurydice_arr_a3 *result
15130
)
15131
0
{
15132
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15133
0
  {
15134
0
    size_t i0 = i;
15135
0
    libcrux_ml_dsa_simd_portable_t0_deserialize_65(Eurydice_slice_subslice_shared_c8(serialized,
15136
0
        (
15137
0
          KRML_CLITERAL(core_ops_range_Range_87){
15138
0
            .start = i0 * LIBCRUX_ML_DSA_ENCODING_T0_OUTPUT_BYTES_PER_SIMD_UNIT,
15139
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_DSA_ENCODING_T0_OUTPUT_BYTES_PER_SIMD_UNIT
15140
0
          }
15141
0
        )),
15142
0
      &result->data[i0]);
15143
0
  }
15144
0
}
15145
15146
/**
15147
A monomorphic instance of libcrux_ml_dsa.encoding.t0.deserialize_to_vector_then_ntt
15148
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15149
with const generics
15150
15151
*/
15152
static KRML_MUSTINLINE void
15153
libcrux_ml_dsa_encoding_t0_deserialize_to_vector_then_ntt_37(
15154
  Eurydice_borrow_slice_u8 serialized,
15155
  Eurydice_dst_ref_mut_44 ring_elements
15156
)
15157
0
{
15158
0
  for
15159
0
  (size_t
15160
0
    i = (size_t)0U;
15161
0
    i < serialized.meta / LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE;
15162
0
    i++)
15163
0
  {
15164
0
    size_t i0 = i;
15165
0
    Eurydice_borrow_slice_u8
15166
0
    bytes =
15167
0
      Eurydice_slice_subslice_shared_c8(serialized,
15168
0
        (
15169
0
          KRML_CLITERAL(core_ops_range_Range_87){
15170
0
            .start = i0 * LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE,
15171
0
            .end = i0 * LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE +
15172
0
              LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE
15173
0
          }
15174
0
        ));
15175
0
    libcrux_ml_dsa_encoding_t0_deserialize_37(bytes, &ring_elements.ptr[i0]);
15176
0
    libcrux_ml_dsa_ntt_ntt_37(&ring_elements.ptr[i0]);
15177
0
  }
15178
0
}
15179
15180
/**
15181
A monomorphic instance of libcrux_ml_dsa.encoding.error.deserialize
15182
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15183
with const generics
15184
15185
*/
15186
static KRML_MUSTINLINE void
15187
libcrux_ml_dsa_encoding_error_deserialize_37(
15188
  libcrux_ml_dsa_constants_Eta eta,
15189
  Eurydice_borrow_slice_u8 serialized,
15190
  Eurydice_arr_a3 *result
15191
)
15192
0
{
15193
0
  size_t chunk_size = libcrux_ml_dsa_encoding_error_chunk_size(eta);
15194
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15195
0
  {
15196
0
    size_t i0 = i;
15197
0
    libcrux_ml_dsa_simd_portable_error_deserialize_65(eta,
15198
0
      Eurydice_slice_subslice_shared_c8(serialized,
15199
0
        (
15200
0
          KRML_CLITERAL(core_ops_range_Range_87){
15201
0
            .start = i0 * chunk_size,
15202
0
            .end = (i0 + (size_t)1U) * chunk_size
15203
0
          }
15204
0
        )),
15205
0
      &result->data[i0]);
15206
0
  }
15207
0
}
15208
15209
/**
15210
A monomorphic instance of libcrux_ml_dsa.encoding.error.deserialize_to_vector_then_ntt
15211
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15212
with const generics
15213
15214
*/
15215
static KRML_MUSTINLINE void
15216
libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(
15217
  libcrux_ml_dsa_constants_Eta eta,
15218
  size_t ring_element_size,
15219
  Eurydice_borrow_slice_u8 serialized,
15220
  Eurydice_dst_ref_mut_44 ring_elements
15221
)
15222
0
{
15223
0
  for (size_t i = (size_t)0U; i < serialized.meta / ring_element_size; i++)
15224
0
  {
15225
0
    size_t i0 = i;
15226
0
    Eurydice_borrow_slice_u8
15227
0
    bytes =
15228
0
      Eurydice_slice_subslice_shared_c8(serialized,
15229
0
        (
15230
0
          KRML_CLITERAL(core_ops_range_Range_87){
15231
0
            .start = i0 * ring_element_size,
15232
0
            .end = i0 * ring_element_size + ring_element_size
15233
0
          }
15234
0
        ));
15235
0
    libcrux_ml_dsa_encoding_error_deserialize_37(eta, bytes, &ring_elements.ptr[i0]);
15236
0
    libcrux_ml_dsa_ntt_ntt_37(&ring_elements.ptr[i0]);
15237
0
  }
15238
0
}
15239
15240
/**
15241
 Init with zero
15242
*/
15243
/**
15244
This function found in impl {libcrux_ml_dsa::types::MLDSASignature<SIZE>}
15245
*/
15246
/**
15247
A monomorphic instance of libcrux_ml_dsa.types.zero_c5
15248
with const generics
15249
- SIZE= 2420
15250
*/
15251
static inline Eurydice_arr_85 libcrux_ml_dsa_types_zero_c5_37(void)
15252
0
{
15253
0
  return (KRML_CLITERAL(Eurydice_arr_85){ .data = { 0U } });
15254
0
}
15255
15256
/**
15257
A monomorphic instance of libcrux_ml_dsa.encoding.t0.serialize
15258
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15259
with const generics
15260
15261
*/
15262
static KRML_MUSTINLINE void
15263
libcrux_ml_dsa_encoding_t0_serialize_37(
15264
  const Eurydice_arr_a3 *re,
15265
  Eurydice_mut_borrow_slice_u8 serialized
15266
)
15267
0
{
15268
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15269
0
  {
15270
0
    size_t i0 = i;
15271
0
    const Eurydice_arr_4d *simd_unit = &re->data[i0];
15272
0
    libcrux_ml_dsa_simd_portable_t0_serialize_65(simd_unit,
15273
0
      Eurydice_slice_subslice_mut_c8(serialized,
15274
0
        (
15275
0
          KRML_CLITERAL(core_ops_range_Range_87){
15276
0
            .start = i0 * LIBCRUX_ML_DSA_ENCODING_T0_OUTPUT_BYTES_PER_SIMD_UNIT,
15277
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_DSA_ENCODING_T0_OUTPUT_BYTES_PER_SIMD_UNIT
15278
0
          }
15279
0
        )));
15280
0
  }
15281
0
}
15282
15283
/**
15284
A monomorphic instance of libcrux_ml_dsa.encoding.error.serialize
15285
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15286
with const generics
15287
15288
*/
15289
static KRML_MUSTINLINE void
15290
libcrux_ml_dsa_encoding_error_serialize_37(
15291
  libcrux_ml_dsa_constants_Eta eta,
15292
  const Eurydice_arr_a3 *re,
15293
  Eurydice_mut_borrow_slice_u8 serialized
15294
)
15295
0
{
15296
0
  size_t output_bytes_per_simd_unit = libcrux_ml_dsa_encoding_error_chunk_size(eta);
15297
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15298
0
  {
15299
0
    size_t i0 = i;
15300
0
    const Eurydice_arr_4d *simd_unit = &re->data[i0];
15301
0
    libcrux_ml_dsa_simd_portable_error_serialize_65(eta,
15302
0
      simd_unit,
15303
0
      Eurydice_slice_subslice_mut_c8(serialized,
15304
0
        (
15305
0
          KRML_CLITERAL(core_ops_range_Range_87){
15306
0
            .start = i0 * output_bytes_per_simd_unit,
15307
0
            .end = (i0 + (size_t)1U) * output_bytes_per_simd_unit
15308
0
          }
15309
0
        )));
15310
0
  }
15311
0
}
15312
15313
/**
15314
A monomorphic instance of libcrux_ml_dsa.encoding.t1.serialize
15315
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15316
with const generics
15317
15318
*/
15319
static KRML_MUSTINLINE void
15320
libcrux_ml_dsa_encoding_t1_serialize_37(
15321
  const Eurydice_arr_a3 *re,
15322
  Eurydice_mut_borrow_slice_u8 serialized
15323
)
15324
0
{
15325
0
  for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15326
0
  {
15327
0
    size_t i0 = i;
15328
0
    const Eurydice_arr_4d *simd_unit = &re->data[i0];
15329
0
    libcrux_ml_dsa_simd_portable_t1_serialize_65(simd_unit,
15330
0
      Eurydice_slice_subslice_mut_c8(serialized,
15331
0
        (
15332
0
          KRML_CLITERAL(core_ops_range_Range_87){
15333
0
            .start = i0 * LIBCRUX_ML_DSA_ENCODING_T1_SERIALIZE_OUTPUT_BYTES_PER_SIMD_UNIT,
15334
0
            .end = (i0 + (size_t)1U) *
15335
0
              LIBCRUX_ML_DSA_ENCODING_T1_SERIALIZE_OUTPUT_BYTES_PER_SIMD_UNIT
15336
0
          }
15337
0
        )));
15338
0
  }
15339
0
}
15340
15341
/**
15342
A monomorphic instance of libcrux_ml_dsa.encoding.verification_key.generate_serialized
15343
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15344
with const generics
15345
15346
*/
15347
static KRML_MUSTINLINE void
15348
libcrux_ml_dsa_encoding_verification_key_generate_serialized_37(
15349
  Eurydice_borrow_slice_u8 seed,
15350
  Eurydice_dst_ref_shared_44 t1,
15351
  Eurydice_mut_borrow_slice_u8 verification_key_serialized
15352
)
15353
0
{
15354
0
  Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(verification_key_serialized,
15355
0
      (
15356
0
        KRML_CLITERAL(core_ops_range_Range_87){
15357
0
          .start = (size_t)0U,
15358
0
          .end = LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE
15359
0
        }
15360
0
      )),
15361
0
    seed,
15362
0
    uint8_t);
15363
0
  for (size_t i = (size_t)0U; i < t1.meta; i++)
15364
0
  {
15365
0
    size_t i0 = i;
15366
0
    const Eurydice_arr_a3 *ring_element = &t1.ptr[i0];
15367
0
    size_t
15368
0
    offset =
15369
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE +
15370
0
        i0 * LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T1S_SIZE;
15371
0
    libcrux_ml_dsa_encoding_t1_serialize_37(ring_element,
15372
0
      Eurydice_slice_subslice_mut_c8(verification_key_serialized,
15373
0
        (
15374
0
          KRML_CLITERAL(core_ops_range_Range_87){
15375
0
            .start = offset,
15376
0
            .end = offset + LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T1S_SIZE
15377
0
          }
15378
0
        )));
15379
0
  }
15380
0
}
15381
15382
/**
15383
A monomorphic instance of libcrux_ml_dsa.arithmetic.power2round_vector
15384
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15385
with const generics
15386
15387
*/
15388
static KRML_MUSTINLINE void
15389
libcrux_ml_dsa_arithmetic_power2round_vector_37(
15390
  Eurydice_dst_ref_mut_44 t,
15391
  Eurydice_dst_ref_mut_44 t1
15392
)
15393
0
{
15394
0
  for (size_t i0 = (size_t)0U; i0 < t.meta; i0++)
15395
0
  {
15396
0
    size_t i1 = i0;
15397
0
    for (size_t i = (size_t)0U; i < (size_t)32U; i++)
15398
0
    {
15399
0
      size_t j = i;
15400
0
      libcrux_ml_dsa_simd_portable_power2round_65(&t.ptr[i1].data[j], &t1.ptr[i1].data[j]);
15401
0
    }
15402
0
  }
15403
0
}
15404
15405
/**
15406
 Declassify secret memory.
15407
15408
 No-op if `valgrind_ct_test` cfg is not enabled.
15409
*/
15410
/**
15411
A monomorphic instance of libcrux_secrets.mem_requests.ct_declassify
15412
with types Eurydice_arr libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients[[$4size_t]]
15413
15414
*/
15415
static KRML_MUSTINLINE void
15416
libcrux_secrets_mem_requests_ct_declassify_f5(const Eurydice_arr_9d *val)
15417
0
{
15418
0
15419
0
}
15420
15421
/**
15422
A monomorphic instance of Eurydice.array_to_slice_shared
15423
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15424
with const generics
15425
- N= 8
15426
*/
15427
static inline Eurydice_dst_ref_shared_44
15428
Eurydice_array_to_slice_shared_200(const Eurydice_arr_8f *a)
15429
0
{
15430
0
  Eurydice_dst_ref_shared_44 lit;
15431
0
  lit.ptr = a->data;
15432
0
  lit.meta = (size_t)8U;
15433
0
  return lit;
15434
0
}
15435
15436
/**
15437
A monomorphic instance of Eurydice.array_to_slice_shared
15438
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15439
with const generics
15440
- N= 4
15441
*/
15442
static inline Eurydice_dst_ref_shared_44
15443
Eurydice_array_to_slice_shared_20(const Eurydice_arr_9d *a)
15444
0
{
15445
0
  Eurydice_dst_ref_shared_44 lit;
15446
0
  lit.ptr = a->data;
15447
0
  lit.meta = (size_t)4U;
15448
0
  return lit;
15449
0
}
15450
15451
/**
15452
 Compute InvertNTT(Â ◦ ŝ₁) + s₂
15453
*/
15454
/**
15455
A monomorphic instance of libcrux_ml_dsa.matrix.compute_as1_plus_s2
15456
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15457
with const generics
15458
15459
*/
15460
static KRML_MUSTINLINE void
15461
libcrux_ml_dsa_matrix_compute_as1_plus_s2_37(
15462
  size_t rows_in_a,
15463
  size_t columns_in_a,
15464
  Eurydice_dst_ref_mut_44 a_as_ntt,
15465
  Eurydice_dst_ref_shared_44 s1_ntt,
15466
  Eurydice_dst_ref_shared_44 s1_s2,
15467
  Eurydice_dst_ref_mut_44 result
15468
)
15469
0
{
15470
0
  for (size_t i0 = (size_t)0U; i0 < rows_in_a; i0++)
15471
0
  {
15472
0
    size_t i1 = i0;
15473
0
    for (size_t i = (size_t)0U; i < columns_in_a; i++)
15474
0
    {
15475
0
      size_t j = i;
15476
0
      libcrux_ml_dsa_ntt_ntt_multiply_montgomery_37(&a_as_ntt.ptr[i1 * columns_in_a + j],
15477
0
        &s1_ntt.ptr[j]);
15478
0
      libcrux_ml_dsa_polynomial_add_ff_37(&result.ptr[i1], &a_as_ntt.ptr[i1 * columns_in_a + j]);
15479
0
    }
15480
0
  }
15481
0
  for (size_t i = (size_t)0U; i < result.meta; i++)
15482
0
  {
15483
0
    size_t i0 = i;
15484
0
    libcrux_ml_dsa_polynomial_barrett_reduce_ff_37(&result.ptr[i0]);
15485
0
    libcrux_ml_dsa_ntt_invert_ntt_montgomery_37(&result.ptr[i0]);
15486
0
    libcrux_ml_dsa_polynomial_add_ff_37(&result.ptr[i0], &s1_s2.ptr[columns_in_a + i0]);
15487
0
  }
15488
0
}
15489
15490
/**
15491
A monomorphic instance of Eurydice.array_to_subslice_shared
15492
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients, core_ops_range_Range size_t, Eurydice_derefed_slice libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15493
with const generics
15494
- N= 8
15495
*/
15496
static inline Eurydice_dst_ref_shared_44
15497
Eurydice_array_to_subslice_shared_25(const Eurydice_arr_8f *a, core_ops_range_Range_87 r)
15498
0
{
15499
0
  return
15500
0
    (
15501
0
      KRML_CLITERAL(Eurydice_dst_ref_shared_44){ .ptr = a->data + r.start, .meta = r.end - r.start }
15502
0
    );
15503
0
}
15504
15505
/**
15506
A monomorphic instance of Eurydice.array_to_slice_mut
15507
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15508
with const generics
15509
- N= 4
15510
*/
15511
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_201(Eurydice_arr_9d *a)
15512
0
{
15513
0
  Eurydice_dst_ref_mut_44 lit;
15514
0
  lit.ptr = a->data;
15515
0
  lit.meta = (size_t)4U;
15516
0
  return lit;
15517
0
}
15518
15519
/**
15520
A monomorphic instance of Eurydice.array_to_slice_mut
15521
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15522
with const generics
15523
- N= 16
15524
*/
15525
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_200(Eurydice_arr_2f *a)
15526
0
{
15527
0
  Eurydice_dst_ref_mut_44 lit;
15528
0
  lit.ptr = a->data;
15529
0
  lit.meta = (size_t)16U;
15530
0
  return lit;
15531
0
}
15532
15533
/**
15534
A monomorphic instance of libcrux_ml_dsa.sample.rejection_sample_less_than_field_modulus
15535
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15536
with const generics
15537
15538
*/
15539
static KRML_MUSTINLINE bool
15540
libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(
15541
  Eurydice_borrow_slice_u8 randomness,
15542
  size_t *sampled_coefficients,
15543
  Eurydice_arr_d0 *out
15544
)
15545
0
{
15546
0
  bool done = false;
15547
0
  for (size_t i = (size_t)0U; i < randomness.meta / (size_t)24U; i++)
15548
0
  {
15549
0
    size_t _cloop_i = i;
15550
0
    Eurydice_borrow_slice_u8
15551
0
    random_bytes =
15552
0
      Eurydice_slice_subslice_shared_c8(randomness,
15553
0
        (
15554
0
          KRML_CLITERAL(core_ops_range_Range_87){
15555
0
            .start = _cloop_i * (size_t)24U,
15556
0
            .end = _cloop_i * (size_t)24U + (size_t)24U
15557
0
          }
15558
0
        ));
15559
0
    if (!done)
15560
0
    {
15561
0
      size_t
15562
0
      sampled =
15563
0
        libcrux_ml_dsa_simd_portable_rejection_sample_less_than_field_modulus_65(random_bytes,
15564
0
          Eurydice_array_to_subslice_from_mut_11(out, sampled_coefficients[0U]));
15565
0
      sampled_coefficients[0U] += sampled;
15566
0
      if (sampled_coefficients[0U] >= LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
15567
0
      {
15568
0
        done = true;
15569
0
      }
15570
0
    }
15571
0
  }
15572
0
  return done;
15573
0
}
15574
15575
/**
15576
A monomorphic instance of Eurydice.array_to_slice_mut
15577
with types libcrux_ml_dsa_polynomial_PolynomialRingElement libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15578
with const generics
15579
- N= 8
15580
*/
15581
static inline Eurydice_dst_ref_mut_44 Eurydice_array_to_slice_mut_20(Eurydice_arr_8f *a)
15582
0
{
15583
0
  Eurydice_dst_ref_mut_44 lit;
15584
0
  lit.ptr = a->data;
15585
0
  lit.meta = (size_t)8U;
15586
0
  return lit;
15587
0
}
15588
15589
/**
15590
A monomorphic instance of libcrux_ml_dsa.sample.rejection_sample_less_than_eta_equals_4
15591
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15592
with const generics
15593
15594
*/
15595
static KRML_MUSTINLINE bool
15596
libcrux_ml_dsa_sample_rejection_sample_less_than_eta_equals_4_37(
15597
  Eurydice_borrow_slice_u8 randomness,
15598
  size_t *sampled_coefficients,
15599
  Eurydice_arr_d0 *out
15600
)
15601
0
{
15602
0
  bool done = false;
15603
0
  for (size_t i = (size_t)0U; i < randomness.meta / (size_t)4U; i++)
15604
0
  {
15605
0
    size_t _cloop_i = i;
15606
0
    Eurydice_borrow_slice_u8
15607
0
    random_bytes =
15608
0
      Eurydice_slice_subslice_shared_c8(randomness,
15609
0
        (
15610
0
          KRML_CLITERAL(core_ops_range_Range_87){
15611
0
            .start = _cloop_i * (size_t)4U,
15612
0
            .end = _cloop_i * (size_t)4U + (size_t)4U
15613
0
          }
15614
0
        ));
15615
0
    if (!done)
15616
0
    {
15617
0
      size_t
15618
0
      sampled =
15619
0
        libcrux_ml_dsa_simd_portable_rejection_sample_less_than_eta_equals_4_65(random_bytes,
15620
0
          Eurydice_array_to_subslice_from_mut_11(out, sampled_coefficients[0U]));
15621
0
      sampled_coefficients[0U] += sampled;
15622
0
      if (sampled_coefficients[0U] >= LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
15623
0
      {
15624
0
        done = true;
15625
0
      }
15626
0
    }
15627
0
  }
15628
0
  return done;
15629
0
}
15630
15631
/**
15632
A monomorphic instance of libcrux_ml_dsa.sample.rejection_sample_less_than_eta_equals_2
15633
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15634
with const generics
15635
15636
*/
15637
static KRML_MUSTINLINE bool
15638
libcrux_ml_dsa_sample_rejection_sample_less_than_eta_equals_2_37(
15639
  Eurydice_borrow_slice_u8 randomness,
15640
  size_t *sampled_coefficients,
15641
  Eurydice_arr_d0 *out
15642
)
15643
0
{
15644
0
  bool done = false;
15645
0
  for (size_t i = (size_t)0U; i < randomness.meta / (size_t)4U; i++)
15646
0
  {
15647
0
    size_t _cloop_i = i;
15648
0
    Eurydice_borrow_slice_u8
15649
0
    random_bytes =
15650
0
      Eurydice_slice_subslice_shared_c8(randomness,
15651
0
        (
15652
0
          KRML_CLITERAL(core_ops_range_Range_87){
15653
0
            .start = _cloop_i * (size_t)4U,
15654
0
            .end = _cloop_i * (size_t)4U + (size_t)4U
15655
0
          }
15656
0
        ));
15657
0
    if (!done)
15658
0
    {
15659
0
      size_t
15660
0
      sampled =
15661
0
        libcrux_ml_dsa_simd_portable_rejection_sample_less_than_eta_equals_2_65(random_bytes,
15662
0
          Eurydice_array_to_subslice_from_mut_11(out, sampled_coefficients[0U]));
15663
0
      sampled_coefficients[0U] += sampled;
15664
0
      if (sampled_coefficients[0U] >= LIBCRUX_ML_DSA_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
15665
0
      {
15666
0
        done = true;
15667
0
      }
15668
0
    }
15669
0
  }
15670
0
  return done;
15671
0
}
15672
15673
/**
15674
A monomorphic instance of libcrux_ml_dsa.sample.rejection_sample_less_than_eta
15675
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
15676
with const generics
15677
15678
*/
15679
static KRML_MUSTINLINE bool
15680
libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(
15681
  libcrux_ml_dsa_constants_Eta eta,
15682
  Eurydice_borrow_slice_u8 randomness,
15683
  size_t *sampled,
15684
  Eurydice_arr_d0 *out
15685
)
15686
0
{
15687
0
  switch (eta)
15688
0
  {
15689
0
    case libcrux_ml_dsa_constants_Eta_Two:
15690
0
      {
15691
0
        break;
15692
0
      }
15693
0
    case libcrux_ml_dsa_constants_Eta_Four:
15694
0
      {
15695
0
        return
15696
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_eta_equals_4_37(randomness,
15697
0
            sampled,
15698
0
            out);
15699
0
      }
15700
0
    default:
15701
0
      {
15702
0
        KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, __LINE__);
15703
0
        KRML_HOST_EXIT(253U);
15704
0
      }
15705
0
  }
15706
0
  return
15707
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_eta_equals_2_37(randomness,
15708
0
      sampled,
15709
0
      out);
15710
0
}
15711
15712
typedef struct libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87KeyPair_s
15713
{
15714
  Eurydice_arr_e2 signing_key;
15715
  Eurydice_arr_43 verification_key;
15716
}
15717
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87KeyPair;
15718
15719
typedef struct libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65KeyPair_s
15720
{
15721
  Eurydice_arr_24 signing_key;
15722
  Eurydice_arr_29 verification_key;
15723
}
15724
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65KeyPair;
15725
15726
typedef struct libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44KeyPair_s
15727
{
15728
  Eurydice_arr_10 signing_key;
15729
  Eurydice_arr_02 verification_key;
15730
}
15731
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44KeyPair;
15732
15733
#if defined(__cplusplus)
15734
}
15735
#endif
15736
15737
#define libcrux_mldsa_core_H_DEFINED
15738
#endif /* libcrux_mldsa_core_H */
15739
15740
/* from libcrux/combined_extraction/generated/libcrux_ct_ops.h */
15741
/*
15742
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
15743
 *
15744
 * SPDX-License-Identifier: MIT or Apache-2.0
15745
 *
15746
 * This code was generated with the following revisions:
15747
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
15748
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
15749
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
15750
 * F*: unset
15751
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
15752
 */
15753
15754
15755
#ifndef libcrux_ct_ops_H
15756
#define libcrux_ct_ops_H
15757
15758
15759
15760
#if defined(__cplusplus)
15761
extern "C" {
15762
#endif
15763
15764
15765
/**
15766
 Return 1 if `value` is not zero and 0 otherwise.
15767
*/
15768
static KRML_NOINLINE uint8_t libcrux_ml_kem_constant_time_ops_inz(uint8_t value)
15769
0
{
15770
0
  uint16_t value0 = (uint16_t)(uint32_t)value;
15771
0
  uint8_t result = (uint8_t)((uint32_t)core_num__u16__wrapping_add(~value0, 1U) >> 8U & 0xFFFFU);
15772
0
  return (uint32_t)result & 1U;
15773
0
}
15774
15775
static KRML_NOINLINE uint8_t libcrux_ml_kem_constant_time_ops_is_non_zero(uint8_t value)
15776
0
{
15777
0
  return libcrux_ml_kem_constant_time_ops_inz(value);
15778
0
}
15779
15780
/**
15781
 Return 1 if the bytes of `lhs` and `rhs` do not exactly
15782
 match and 0 otherwise.
15783
*/
15784
static KRML_NOINLINE uint8_t
15785
libcrux_ml_kem_constant_time_ops_compare(
15786
  Eurydice_borrow_slice_u8 lhs,
15787
  Eurydice_borrow_slice_u8 rhs
15788
)
15789
0
{
15790
0
  uint8_t r = 0U;
15791
0
  for (size_t i = (size_t)0U; i < lhs.meta; i++)
15792
0
  {
15793
0
    size_t i0 = i;
15794
0
    uint8_t nr = (uint32_t)r | ((uint32_t)lhs.ptr[i0] ^ (uint32_t)rhs.ptr[i0]);
15795
0
    r = nr;
15796
0
  }
15797
0
  return libcrux_ml_kem_constant_time_ops_is_non_zero(r);
15798
0
}
15799
15800
static KRML_NOINLINE uint8_t
15801
libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(
15802
  Eurydice_borrow_slice_u8 lhs,
15803
  Eurydice_borrow_slice_u8 rhs
15804
)
15805
0
{
15806
0
  return libcrux_ml_kem_constant_time_ops_compare(lhs, rhs);
15807
0
}
15808
15809
/**
15810
 If `selector` is not zero, return the bytes in `rhs`; return the bytes in
15811
 `lhs` otherwise.
15812
*/
15813
static KRML_NOINLINE Eurydice_arr_ec
15814
libcrux_ml_kem_constant_time_ops_select_ct(
15815
  Eurydice_borrow_slice_u8 lhs,
15816
  Eurydice_borrow_slice_u8 rhs,
15817
  uint8_t selector
15818
)
15819
0
{
15820
0
  uint8_t
15821
0
  mask = core_num__u8__wrapping_sub(libcrux_ml_kem_constant_time_ops_is_non_zero(selector), 1U);
15822
0
  Eurydice_arr_ec out = { .data = { 0U } };
15823
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE; i++)
15824
0
  {
15825
0
    size_t i0 = i;
15826
0
    uint8_t
15827
0
    outi =
15828
0
      ((uint32_t)lhs.ptr[i0] & (uint32_t)mask) | ((uint32_t)rhs.ptr[i0] & (~(uint32_t)mask & 0xFFU));
15829
0
    out.data[i0] = outi;
15830
0
  }
15831
0
  return out;
15832
0
}
15833
15834
static KRML_NOINLINE Eurydice_arr_ec
15835
libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(
15836
  Eurydice_borrow_slice_u8 lhs,
15837
  Eurydice_borrow_slice_u8 rhs,
15838
  uint8_t selector
15839
)
15840
0
{
15841
0
  return libcrux_ml_kem_constant_time_ops_select_ct(lhs, rhs, selector);
15842
0
}
15843
15844
static KRML_NOINLINE Eurydice_arr_ec
15845
libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time(
15846
  Eurydice_borrow_slice_u8 lhs_c,
15847
  Eurydice_borrow_slice_u8 rhs_c,
15848
  Eurydice_borrow_slice_u8 lhs_s,
15849
  Eurydice_borrow_slice_u8 rhs_s
15850
)
15851
0
{
15852
0
  uint8_t
15853
0
  selector = libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(lhs_c, rhs_c);
15854
0
  return
15855
0
    libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(lhs_s,
15856
0
      rhs_s,
15857
0
      selector);
15858
0
}
15859
15860
#if defined(__cplusplus)
15861
}
15862
#endif
15863
15864
#define libcrux_ct_ops_H_DEFINED
15865
#endif /* libcrux_ct_ops_H */
15866
15867
/* from libcrux/combined_extraction/generated/libcrux_mldsa_portable.h */
15868
/*
15869
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
15870
 *
15871
 * SPDX-License-Identifier: MIT or Apache-2.0
15872
 *
15873
 * This code was generated with the following revisions:
15874
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
15875
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
15876
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
15877
 * F*: unset
15878
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
15879
 */
15880
15881
15882
#ifndef libcrux_mldsa_portable_H
15883
#define libcrux_mldsa_portable_H
15884
15885
15886
15887
#if defined(__cplusplus)
15888
extern "C" {
15889
#endif
15890
15891
15892
typedef struct libcrux_ml_dsa_hash_functions_portable_Shake128X4_s
15893
{
15894
  Eurydice_arr_7c state0;
15895
  Eurydice_arr_7c state1;
15896
  Eurydice_arr_7c state2;
15897
  Eurydice_arr_7c state3;
15898
}
15899
libcrux_ml_dsa_hash_functions_portable_Shake128X4;
15900
15901
typedef libcrux_sha3_portable_KeccakState libcrux_ml_dsa_hash_functions_portable_Shake256;
15902
15903
typedef struct libcrux_ml_dsa_hash_functions_portable_Shake256X4_s
15904
{
15905
  Eurydice_arr_7c state0;
15906
  Eurydice_arr_7c state1;
15907
  Eurydice_arr_7c state2;
15908
  Eurydice_arr_7c state3;
15909
}
15910
libcrux_ml_dsa_hash_functions_portable_Shake256X4;
15911
15912
typedef libcrux_sha3_portable_incremental_Shake256Xof
15913
libcrux_ml_dsa_hash_functions_portable_Shake256Xof;
15914
15915
static KRML_MUSTINLINE libcrux_ml_dsa_hash_functions_portable_Shake128X4
15916
libcrux_ml_dsa_hash_functions_portable_init_absorb(
15917
  Eurydice_borrow_slice_u8 input0,
15918
  Eurydice_borrow_slice_u8 input1,
15919
  Eurydice_borrow_slice_u8 input2,
15920
  Eurydice_borrow_slice_u8 input3
15921
)
15922
0
{
15923
0
  Eurydice_arr_7c state0 = libcrux_sha3_portable_incremental_shake128_init();
15924
0
  libcrux_sha3_portable_incremental_shake128_absorb_final(&state0, input0);
15925
0
  Eurydice_arr_7c state1 = libcrux_sha3_portable_incremental_shake128_init();
15926
0
  libcrux_sha3_portable_incremental_shake128_absorb_final(&state1, input1);
15927
0
  Eurydice_arr_7c state2 = libcrux_sha3_portable_incremental_shake128_init();
15928
0
  libcrux_sha3_portable_incremental_shake128_absorb_final(&state2, input2);
15929
0
  Eurydice_arr_7c state3 = libcrux_sha3_portable_incremental_shake128_init();
15930
0
  libcrux_sha3_portable_incremental_shake128_absorb_final(&state3, input3);
15931
0
  return
15932
0
    (
15933
0
      KRML_CLITERAL(libcrux_ml_dsa_hash_functions_portable_Shake128X4){
15934
0
        .state0 = state0,
15935
0
        .state1 = state1,
15936
0
        .state2 = state2,
15937
0
        .state3 = state3
15938
0
      }
15939
0
    );
15940
0
}
15941
15942
static KRML_MUSTINLINE Eurydice_arr_7c
15943
libcrux_ml_dsa_hash_functions_portable_init_absorb_final_shake256(
15944
  Eurydice_borrow_slice_u8 input
15945
)
15946
0
{
15947
0
  Eurydice_arr_7c state = libcrux_sha3_portable_incremental_shake256_init();
15948
0
  libcrux_sha3_portable_incremental_shake256_absorb_final(&state, input);
15949
0
  return state;
15950
0
}
15951
15952
static KRML_MUSTINLINE libcrux_ml_dsa_hash_functions_portable_Shake256X4
15953
libcrux_ml_dsa_hash_functions_portable_init_absorb_x4(
15954
  Eurydice_borrow_slice_u8 input0,
15955
  Eurydice_borrow_slice_u8 input1,
15956
  Eurydice_borrow_slice_u8 input2,
15957
  Eurydice_borrow_slice_u8 input3
15958
)
15959
0
{
15960
0
  Eurydice_arr_7c state0 = libcrux_sha3_portable_incremental_shake256_init();
15961
0
  libcrux_sha3_portable_incremental_shake256_absorb_final(&state0, input0);
15962
0
  Eurydice_arr_7c state1 = libcrux_sha3_portable_incremental_shake256_init();
15963
0
  libcrux_sha3_portable_incremental_shake256_absorb_final(&state1, input1);
15964
0
  Eurydice_arr_7c state2 = libcrux_sha3_portable_incremental_shake256_init();
15965
0
  libcrux_sha3_portable_incremental_shake256_absorb_final(&state2, input2);
15966
0
  Eurydice_arr_7c state3 = libcrux_sha3_portable_incremental_shake256_init();
15967
0
  libcrux_sha3_portable_incremental_shake256_absorb_final(&state3, input3);
15968
0
  return
15969
0
    (
15970
0
      KRML_CLITERAL(libcrux_ml_dsa_hash_functions_portable_Shake256X4){
15971
0
        .state0 = state0,
15972
0
        .state1 = state1,
15973
0
        .state2 = state2,
15974
0
        .state3 = state3
15975
0
      }
15976
0
    );
15977
0
}
15978
15979
static KRML_MUSTINLINE void
15980
libcrux_ml_dsa_hash_functions_portable_shake128(
15981
  Eurydice_borrow_slice_u8 input,
15982
  Eurydice_mut_borrow_slice_u8 out
15983
)
15984
0
{
15985
0
  libcrux_sha3_portable_shake128(out, input);
15986
0
}
15987
15988
static KRML_MUSTINLINE Eurydice_arr_ff
15989
libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_shake256(Eurydice_arr_7c *state)
15990
0
{
15991
0
  Eurydice_arr_ff out = { .data = { 0U } };
15992
0
  libcrux_sha3_portable_incremental_shake256_squeeze_first_block(state,
15993
0
    Eurydice_array_to_slice_mut_58(&out));
15994
0
  return out;
15995
0
}
15996
15997
static KRML_MUSTINLINE Eurydice_arr_ff_x4
15998
libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_x4(
15999
  libcrux_ml_dsa_hash_functions_portable_Shake256X4 *state
16000
)
16001
0
{
16002
0
  Eurydice_arr_ff out0 = { .data = { 0U } };
16003
0
  libcrux_sha3_portable_incremental_shake256_squeeze_first_block(&state->state0,
16004
0
    Eurydice_array_to_slice_mut_58(&out0));
16005
0
  Eurydice_arr_ff out1 = { .data = { 0U } };
16006
0
  libcrux_sha3_portable_incremental_shake256_squeeze_first_block(&state->state1,
16007
0
    Eurydice_array_to_slice_mut_58(&out1));
16008
0
  Eurydice_arr_ff out2 = { .data = { 0U } };
16009
0
  libcrux_sha3_portable_incremental_shake256_squeeze_first_block(&state->state2,
16010
0
    Eurydice_array_to_slice_mut_58(&out2));
16011
0
  Eurydice_arr_ff out3 = { .data = { 0U } };
16012
0
  libcrux_sha3_portable_incremental_shake256_squeeze_first_block(&state->state3,
16013
0
    Eurydice_array_to_slice_mut_58(&out3));
16014
0
  return
16015
0
    (KRML_CLITERAL(Eurydice_arr_ff_x4){ .fst = out0, .snd = out1, .thd = out2, .f3 = out3 });
16016
0
}
16017
16018
static KRML_MUSTINLINE void
16019
libcrux_ml_dsa_hash_functions_portable_squeeze_first_five_blocks(
16020
  libcrux_ml_dsa_hash_functions_portable_Shake128X4 *state,
16021
  Eurydice_arr_d10 *out0,
16022
  Eurydice_arr_d10 *out1,
16023
  Eurydice_arr_d10 *out2,
16024
  Eurydice_arr_d10 *out3
16025
)
16026
0
{
16027
0
  libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks(&state->state0,
16028
0
    Eurydice_array_to_slice_mut_4c(out0));
16029
0
  libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks(&state->state1,
16030
0
    Eurydice_array_to_slice_mut_4c(out1));
16031
0
  libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks(&state->state2,
16032
0
    Eurydice_array_to_slice_mut_4c(out2));
16033
0
  libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks(&state->state3,
16034
0
    Eurydice_array_to_slice_mut_4c(out3));
16035
0
}
16036
16037
static KRML_MUSTINLINE Eurydice_arr_c5_x4
16038
libcrux_ml_dsa_hash_functions_portable_squeeze_next_block(
16039
  libcrux_ml_dsa_hash_functions_portable_Shake128X4 *state
16040
)
16041
0
{
16042
0
  Eurydice_arr_c5 out0 = { .data = { 0U } };
16043
0
  libcrux_sha3_portable_incremental_shake128_squeeze_next_block(&state->state0,
16044
0
    Eurydice_array_to_slice_mut_2c(&out0));
16045
0
  Eurydice_arr_c5 out1 = { .data = { 0U } };
16046
0
  libcrux_sha3_portable_incremental_shake128_squeeze_next_block(&state->state1,
16047
0
    Eurydice_array_to_slice_mut_2c(&out1));
16048
0
  Eurydice_arr_c5 out2 = { .data = { 0U } };
16049
0
  libcrux_sha3_portable_incremental_shake128_squeeze_next_block(&state->state2,
16050
0
    Eurydice_array_to_slice_mut_2c(&out2));
16051
0
  Eurydice_arr_c5 out3 = { .data = { 0U } };
16052
0
  libcrux_sha3_portable_incremental_shake128_squeeze_next_block(&state->state3,
16053
0
    Eurydice_array_to_slice_mut_2c(&out3));
16054
0
  return
16055
0
    (KRML_CLITERAL(Eurydice_arr_c5_x4){ .fst = out0, .snd = out1, .thd = out2, .f3 = out3 });
16056
0
}
16057
16058
static KRML_MUSTINLINE Eurydice_arr_ff
16059
libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_shake256(Eurydice_arr_7c *state)
16060
0
{
16061
0
  Eurydice_arr_ff out = { .data = { 0U } };
16062
0
  libcrux_sha3_portable_incremental_shake256_squeeze_next_block(state,
16063
0
    Eurydice_array_to_slice_mut_58(&out));
16064
0
  return out;
16065
0
}
16066
16067
static KRML_MUSTINLINE Eurydice_arr_ff_x4
16068
libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4(
16069
  libcrux_ml_dsa_hash_functions_portable_Shake256X4 *state
16070
)
16071
0
{
16072
0
  Eurydice_arr_ff out0 = { .data = { 0U } };
16073
0
  libcrux_sha3_portable_incremental_shake256_squeeze_next_block(&state->state0,
16074
0
    Eurydice_array_to_slice_mut_58(&out0));
16075
0
  Eurydice_arr_ff out1 = { .data = { 0U } };
16076
0
  libcrux_sha3_portable_incremental_shake256_squeeze_next_block(&state->state1,
16077
0
    Eurydice_array_to_slice_mut_58(&out1));
16078
0
  Eurydice_arr_ff out2 = { .data = { 0U } };
16079
0
  libcrux_sha3_portable_incremental_shake256_squeeze_next_block(&state->state2,
16080
0
    Eurydice_array_to_slice_mut_58(&out2));
16081
0
  Eurydice_arr_ff out3 = { .data = { 0U } };
16082
0
  libcrux_sha3_portable_incremental_shake256_squeeze_next_block(&state->state3,
16083
0
    Eurydice_array_to_slice_mut_58(&out3));
16084
0
  return
16085
0
    (KRML_CLITERAL(Eurydice_arr_ff_x4){ .fst = out0, .snd = out1, .thd = out2, .f3 = out3 });
16086
0
}
16087
16088
/**
16089
This function found in impl {libcrux_ml_dsa::hash_functions::shake128::Xof for libcrux_ml_dsa::hash_functions::portable::Shake128}
16090
*/
16091
static KRML_MUSTINLINE void
16092
libcrux_ml_dsa_hash_functions_portable_shake128_7b(
16093
  Eurydice_borrow_slice_u8 input,
16094
  Eurydice_mut_borrow_slice_u8 out
16095
)
16096
0
{
16097
0
  libcrux_ml_dsa_hash_functions_portable_shake128(input, out);
16098
0
}
16099
16100
/**
16101
This function found in impl {libcrux_ml_dsa::hash_functions::shake128::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake128X4}
16102
*/
16103
static KRML_MUSTINLINE libcrux_ml_dsa_hash_functions_portable_Shake128X4
16104
libcrux_ml_dsa_hash_functions_portable_init_absorb_11(
16105
  Eurydice_borrow_slice_u8 input0,
16106
  Eurydice_borrow_slice_u8 input1,
16107
  Eurydice_borrow_slice_u8 input2,
16108
  Eurydice_borrow_slice_u8 input3
16109
)
16110
0
{
16111
0
  return libcrux_ml_dsa_hash_functions_portable_init_absorb(input0, input1, input2, input3);
16112
0
}
16113
16114
/**
16115
This function found in impl {libcrux_ml_dsa::hash_functions::shake128::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake128X4}
16116
*/
16117
static KRML_MUSTINLINE void
16118
libcrux_ml_dsa_hash_functions_portable_squeeze_first_five_blocks_11(
16119
  libcrux_ml_dsa_hash_functions_portable_Shake128X4 *self,
16120
  Eurydice_arr_d10 *out0,
16121
  Eurydice_arr_d10 *out1,
16122
  Eurydice_arr_d10 *out2,
16123
  Eurydice_arr_d10 *out3
16124
)
16125
0
{
16126
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_first_five_blocks(self, out0, out1, out2, out3);
16127
0
}
16128
16129
/**
16130
This function found in impl {libcrux_ml_dsa::hash_functions::shake128::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake128X4}
16131
*/
16132
static KRML_MUSTINLINE Eurydice_arr_c5_x4
16133
libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_11(
16134
  libcrux_ml_dsa_hash_functions_portable_Shake128X4 *self
16135
)
16136
0
{
16137
0
  return libcrux_ml_dsa_hash_functions_portable_squeeze_next_block(self);
16138
0
}
16139
16140
/**
16141
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::DsaXof for libcrux_ml_dsa::hash_functions::portable::Shake256}
16142
*/
16143
static KRML_MUSTINLINE Eurydice_arr_7c
16144
libcrux_ml_dsa_hash_functions_portable_init_absorb_final_61(Eurydice_borrow_slice_u8 input)
16145
0
{
16146
0
  return libcrux_ml_dsa_hash_functions_portable_init_absorb_final_shake256(input);
16147
0
}
16148
16149
/**
16150
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::DsaXof for libcrux_ml_dsa::hash_functions::portable::Shake256}
16151
*/
16152
static KRML_MUSTINLINE Eurydice_arr_ff
16153
libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_61(Eurydice_arr_7c *self)
16154
0
{
16155
0
  return libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_shake256(self);
16156
0
}
16157
16158
/**
16159
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::DsaXof for libcrux_ml_dsa::hash_functions::portable::Shake256}
16160
*/
16161
static KRML_MUSTINLINE Eurydice_arr_ff
16162
libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_61(Eurydice_arr_7c *self)
16163
0
{
16164
0
  return libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_shake256(self);
16165
0
}
16166
16167
/**
16168
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::Xof for libcrux_ml_dsa::hash_functions::portable::Shake256Xof}
16169
*/
16170
static inline void
16171
libcrux_ml_dsa_hash_functions_portable_absorb_26(
16172
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
16173
  Eurydice_borrow_slice_u8 input
16174
)
16175
0
{
16176
0
  libcrux_sha3_portable_incremental_absorb_42(self, input);
16177
0
}
16178
16179
/**
16180
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::Xof for libcrux_ml_dsa::hash_functions::portable::Shake256Xof}
16181
*/
16182
static inline void
16183
libcrux_ml_dsa_hash_functions_portable_absorb_final_26(
16184
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
16185
  Eurydice_borrow_slice_u8 input
16186
)
16187
0
{
16188
0
  libcrux_sha3_portable_incremental_absorb_final_42(self, input);
16189
0
}
16190
16191
/**
16192
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::Xof for libcrux_ml_dsa::hash_functions::portable::Shake256Xof}
16193
*/
16194
static inline libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
16195
libcrux_ml_dsa_hash_functions_portable_init_26(void)
16196
0
{
16197
0
  return libcrux_sha3_portable_incremental_new_42();
16198
0
}
16199
16200
/**
16201
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::Xof for libcrux_ml_dsa::hash_functions::portable::Shake256Xof}
16202
*/
16203
static inline void
16204
libcrux_ml_dsa_hash_functions_portable_squeeze_26(
16205
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *self,
16206
  Eurydice_mut_borrow_slice_u8 out
16207
)
16208
0
{
16209
0
  libcrux_sha3_portable_incremental_squeeze_42(self, out);
16210
0
}
16211
16212
/**
16213
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake256X4}
16214
*/
16215
static KRML_MUSTINLINE libcrux_ml_dsa_hash_functions_portable_Shake256X4
16216
libcrux_ml_dsa_hash_functions_portable_init_absorb_x4_9b(
16217
  Eurydice_borrow_slice_u8 input0,
16218
  Eurydice_borrow_slice_u8 input1,
16219
  Eurydice_borrow_slice_u8 input2,
16220
  Eurydice_borrow_slice_u8 input3
16221
)
16222
0
{
16223
0
  return libcrux_ml_dsa_hash_functions_portable_init_absorb_x4(input0, input1, input2, input3);
16224
0
}
16225
16226
/**
16227
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake256X4}
16228
*/
16229
static KRML_MUSTINLINE Eurydice_arr_ff_x4
16230
libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_x4_9b(
16231
  libcrux_ml_dsa_hash_functions_portable_Shake256X4 *self
16232
)
16233
0
{
16234
0
  return libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_x4(self);
16235
0
}
16236
16237
/**
16238
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake256X4}
16239
*/
16240
static KRML_MUSTINLINE Eurydice_arr_ff_x4
16241
libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4_9b(
16242
  libcrux_ml_dsa_hash_functions_portable_Shake256X4 *self
16243
)
16244
0
{
16245
0
  return libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4(self);
16246
0
}
16247
16248
/**
16249
A monomorphic instance of libcrux_ml_dsa.sample.sample_four_error_ring_elements
16250
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake256X4
16251
with const generics
16252
16253
*/
16254
static KRML_MUSTINLINE void
16255
libcrux_ml_dsa_sample_sample_four_error_ring_elements_29(
16256
  libcrux_ml_dsa_constants_Eta eta,
16257
  Eurydice_borrow_slice_u8 seed,
16258
  uint16_t start_index,
16259
  Eurydice_dst_ref_mut_44 re
16260
)
16261
0
{
16262
0
  Eurydice_arr_91 seed0 = libcrux_ml_dsa_sample_add_error_domain_separator(seed, start_index);
16263
0
  Eurydice_arr_91
16264
0
  seed1 = libcrux_ml_dsa_sample_add_error_domain_separator(seed, (uint32_t)start_index + 1U);
16265
0
  Eurydice_arr_91
16266
0
  seed2 = libcrux_ml_dsa_sample_add_error_domain_separator(seed, (uint32_t)start_index + 2U);
16267
0
  Eurydice_arr_91
16268
0
  seed3 = libcrux_ml_dsa_sample_add_error_domain_separator(seed, (uint32_t)start_index + 3U);
16269
0
  libcrux_ml_dsa_hash_functions_portable_Shake256X4
16270
0
  state =
16271
0
    libcrux_ml_dsa_hash_functions_portable_init_absorb_x4_9b(Eurydice_array_to_slice_shared_f1(&seed0),
16272
0
      Eurydice_array_to_slice_shared_f1(&seed1),
16273
0
      Eurydice_array_to_slice_shared_f1(&seed2),
16274
0
      Eurydice_array_to_slice_shared_f1(&seed3));
16275
0
  Eurydice_arr_ff_x4
16276
0
  randomnesses0 = libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_x4_9b(&state);
16277
0
  Eurydice_arr_930
16278
0
  out =
16279
0
    { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
16280
0
  size_t sampled0 = (size_t)0U;
16281
0
  size_t sampled1 = (size_t)0U;
16282
0
  size_t sampled2 = (size_t)0U;
16283
0
  size_t sampled3 = (size_t)0U;
16284
0
  libcrux_ml_dsa_constants_Eta uu____0 = eta;
16285
0
  bool
16286
0
  done0 =
16287
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____0,
16288
0
      Eurydice_array_to_slice_shared_58(&randomnesses0.fst),
16289
0
      &sampled0,
16290
0
      out.data);
16291
0
  libcrux_ml_dsa_constants_Eta uu____1 = eta;
16292
0
  bool
16293
0
  done1 =
16294
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____1,
16295
0
      Eurydice_array_to_slice_shared_58(&randomnesses0.snd),
16296
0
      &sampled1,
16297
0
      &out.data[1U]);
16298
0
  libcrux_ml_dsa_constants_Eta uu____2 = eta;
16299
0
  bool
16300
0
  done2 =
16301
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____2,
16302
0
      Eurydice_array_to_slice_shared_58(&randomnesses0.thd),
16303
0
      &sampled2,
16304
0
      &out.data[2U]);
16305
0
  libcrux_ml_dsa_constants_Eta uu____3 = eta;
16306
0
  bool
16307
0
  done3 =
16308
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____3,
16309
0
      Eurydice_array_to_slice_shared_58(&randomnesses0.f3),
16310
0
      &sampled3,
16311
0
      &out.data[3U]);
16312
0
  while (true)
16313
0
  {
16314
0
    if (done0)
16315
0
    {
16316
0
      if (done1)
16317
0
      {
16318
0
        if (done2)
16319
0
        {
16320
0
          if (done3)
16321
0
          {
16322
0
            break;
16323
0
          }
16324
0
          else
16325
0
          {
16326
0
            Eurydice_arr_ff_x4
16327
0
            randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4_9b(&state);
16328
0
            if (!done0)
16329
0
            {
16330
0
              libcrux_ml_dsa_constants_Eta uu____4 = eta;
16331
0
              done0 =
16332
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____4,
16333
0
                  Eurydice_array_to_slice_shared_58(&randomnesses.fst),
16334
0
                  &sampled0,
16335
0
                  out.data);
16336
0
            }
16337
0
            if (!done1)
16338
0
            {
16339
0
              libcrux_ml_dsa_constants_Eta uu____5 = eta;
16340
0
              done1 =
16341
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____5,
16342
0
                  Eurydice_array_to_slice_shared_58(&randomnesses.snd),
16343
0
                  &sampled1,
16344
0
                  &out.data[1U]);
16345
0
            }
16346
0
            if (!done2)
16347
0
            {
16348
0
              libcrux_ml_dsa_constants_Eta uu____6 = eta;
16349
0
              done2 =
16350
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____6,
16351
0
                  Eurydice_array_to_slice_shared_58(&randomnesses.thd),
16352
0
                  &sampled2,
16353
0
                  &out.data[2U]);
16354
0
            }
16355
0
            if (!done3)
16356
0
            {
16357
0
              libcrux_ml_dsa_constants_Eta uu____7 = eta;
16358
0
              done3 =
16359
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____7,
16360
0
                  Eurydice_array_to_slice_shared_58(&randomnesses.f3),
16361
0
                  &sampled3,
16362
0
                  &out.data[3U]);
16363
0
            }
16364
0
          }
16365
0
        }
16366
0
        else
16367
0
        {
16368
0
          Eurydice_arr_ff_x4
16369
0
          randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4_9b(&state);
16370
0
          if (!done0)
16371
0
          {
16372
0
            libcrux_ml_dsa_constants_Eta uu____8 = eta;
16373
0
            done0 =
16374
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____8,
16375
0
                Eurydice_array_to_slice_shared_58(&randomnesses.fst),
16376
0
                &sampled0,
16377
0
                out.data);
16378
0
          }
16379
0
          if (!done1)
16380
0
          {
16381
0
            libcrux_ml_dsa_constants_Eta uu____9 = eta;
16382
0
            done1 =
16383
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____9,
16384
0
                Eurydice_array_to_slice_shared_58(&randomnesses.snd),
16385
0
                &sampled1,
16386
0
                &out.data[1U]);
16387
0
          }
16388
0
          if (!done2)
16389
0
          {
16390
0
            libcrux_ml_dsa_constants_Eta uu____10 = eta;
16391
0
            done2 =
16392
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____10,
16393
0
                Eurydice_array_to_slice_shared_58(&randomnesses.thd),
16394
0
                &sampled2,
16395
0
                &out.data[2U]);
16396
0
          }
16397
0
          if (!done3)
16398
0
          {
16399
0
            libcrux_ml_dsa_constants_Eta uu____11 = eta;
16400
0
            done3 =
16401
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____11,
16402
0
                Eurydice_array_to_slice_shared_58(&randomnesses.f3),
16403
0
                &sampled3,
16404
0
                &out.data[3U]);
16405
0
          }
16406
0
        }
16407
0
      }
16408
0
      else
16409
0
      {
16410
0
        Eurydice_arr_ff_x4
16411
0
        randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4_9b(&state);
16412
0
        if (!done0)
16413
0
        {
16414
0
          libcrux_ml_dsa_constants_Eta uu____12 = eta;
16415
0
          done0 =
16416
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____12,
16417
0
              Eurydice_array_to_slice_shared_58(&randomnesses.fst),
16418
0
              &sampled0,
16419
0
              out.data);
16420
0
        }
16421
0
        if (!done1)
16422
0
        {
16423
0
          libcrux_ml_dsa_constants_Eta uu____13 = eta;
16424
0
          done1 =
16425
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____13,
16426
0
              Eurydice_array_to_slice_shared_58(&randomnesses.snd),
16427
0
              &sampled1,
16428
0
              &out.data[1U]);
16429
0
        }
16430
0
        if (!done2)
16431
0
        {
16432
0
          libcrux_ml_dsa_constants_Eta uu____14 = eta;
16433
0
          done2 =
16434
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____14,
16435
0
              Eurydice_array_to_slice_shared_58(&randomnesses.thd),
16436
0
              &sampled2,
16437
0
              &out.data[2U]);
16438
0
        }
16439
0
        if (!done3)
16440
0
        {
16441
0
          libcrux_ml_dsa_constants_Eta uu____15 = eta;
16442
0
          done3 =
16443
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____15,
16444
0
              Eurydice_array_to_slice_shared_58(&randomnesses.f3),
16445
0
              &sampled3,
16446
0
              &out.data[3U]);
16447
0
        }
16448
0
      }
16449
0
    }
16450
0
    else
16451
0
    {
16452
0
      Eurydice_arr_ff_x4
16453
0
      randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_x4_9b(&state);
16454
0
      if (!done0)
16455
0
      {
16456
0
        libcrux_ml_dsa_constants_Eta uu____16 = eta;
16457
0
        done0 =
16458
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____16,
16459
0
            Eurydice_array_to_slice_shared_58(&randomnesses.fst),
16460
0
            &sampled0,
16461
0
            out.data);
16462
0
      }
16463
0
      if (!done1)
16464
0
      {
16465
0
        libcrux_ml_dsa_constants_Eta uu____17 = eta;
16466
0
        done1 =
16467
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____17,
16468
0
            Eurydice_array_to_slice_shared_58(&randomnesses.snd),
16469
0
            &sampled1,
16470
0
            &out.data[1U]);
16471
0
      }
16472
0
      if (!done2)
16473
0
      {
16474
0
        libcrux_ml_dsa_constants_Eta uu____18 = eta;
16475
0
        done2 =
16476
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____18,
16477
0
            Eurydice_array_to_slice_shared_58(&randomnesses.thd),
16478
0
            &sampled2,
16479
0
            &out.data[2U]);
16480
0
      }
16481
0
      if (!done3)
16482
0
      {
16483
0
        libcrux_ml_dsa_constants_Eta uu____19 = eta;
16484
0
        done3 =
16485
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_eta_37(uu____19,
16486
0
            Eurydice_array_to_slice_shared_58(&randomnesses.f3),
16487
0
            &sampled3,
16488
0
            &out.data[3U]);
16489
0
      }
16490
0
    }
16491
0
  }
16492
0
  size_t max0 = (size_t)(uint32_t)start_index + (size_t)4U;
16493
0
  size_t max;
16494
0
  if (re.meta < max0)
16495
0
  {
16496
0
    max = re.meta;
16497
0
  }
16498
0
  else
16499
0
  {
16500
0
    max = max0;
16501
0
  }
16502
0
  for (size_t i = (size_t)(uint32_t)start_index; i < max; i++)
16503
0
  {
16504
0
    size_t i0 = i;
16505
0
    libcrux_ml_dsa_polynomial_from_i32_array_ff_37(Eurydice_array_to_slice_shared_2c0(&out.data[i0
16506
0
        % (size_t)4U]),
16507
0
      &re.ptr[i0]);
16508
0
  }
16509
0
}
16510
16511
/**
16512
A monomorphic instance of libcrux_ml_dsa.samplex4.sample_s1_and_s2
16513
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake256X4
16514
with const generics
16515
16516
*/
16517
static KRML_MUSTINLINE void
16518
libcrux_ml_dsa_samplex4_sample_s1_and_s2_29(
16519
  libcrux_ml_dsa_constants_Eta eta,
16520
  Eurydice_borrow_slice_u8 seed,
16521
  Eurydice_dst_ref_mut_44 s1_s2
16522
)
16523
0
{
16524
0
  size_t len = s1_s2.meta;
16525
0
  for (size_t i = (size_t)0U; i < len / (size_t)4U; i++)
16526
0
  {
16527
0
    size_t i0 = i;
16528
0
    libcrux_ml_dsa_sample_sample_four_error_ring_elements_29(eta,
16529
0
      seed,
16530
0
      4U * (uint32_t)(uint16_t)i0,
16531
0
      s1_s2);
16532
0
  }
16533
0
  size_t remainder = len % (size_t)4U;
16534
0
  if (remainder != (size_t)0U)
16535
0
  {
16536
0
    libcrux_ml_dsa_sample_sample_four_error_ring_elements_29(eta,
16537
0
      seed,
16538
0
      (uint16_t)(len - remainder),
16539
0
      s1_s2);
16540
0
  }
16541
0
}
16542
16543
/**
16544
 Sample and write out up to four ring elements.
16545
16546
 If i <= `elements_requested`, a field element with domain separated
16547
 seed according to the provided index is generated in
16548
 `tmp_stack[i]`. After successful rejection sampling in
16549
 `tmp_stack[i]`, the ring element is written to `matrix` at the
16550
 provided index in `indices[i]`.
16551
 `rand_stack` is a working buffer that holds initial Shake output.
16552
*/
16553
/**
16554
A monomorphic instance of libcrux_ml_dsa.sample.sample_up_to_four_ring_elements_flat
16555
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake128X4
16556
with const generics
16557
16558
*/
16559
static KRML_MUSTINLINE void
16560
libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_63(
16561
  size_t columns,
16562
  Eurydice_borrow_slice_u8 seed,
16563
  Eurydice_dst_ref_mut_44 matrix,
16564
  Eurydice_arr_d10 *rand_stack0,
16565
  Eurydice_arr_d10 *rand_stack1,
16566
  Eurydice_arr_d10 *rand_stack2,
16567
  Eurydice_arr_d10 *rand_stack3,
16568
  Eurydice_dst_ref_mut_33 tmp_stack,
16569
  size_t start_index,
16570
  size_t elements_requested
16571
)
16572
0
{
16573
0
  Eurydice_arr_31
16574
0
  seed0 =
16575
0
    libcrux_ml_dsa_sample_add_domain_separator(seed,
16576
0
      libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_xy(start_index, columns));
16577
0
  Eurydice_arr_31
16578
0
  seed1 =
16579
0
    libcrux_ml_dsa_sample_add_domain_separator(seed,
16580
0
      libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_xy(start_index + (size_t)1U,
16581
0
        columns));
16582
0
  Eurydice_arr_31
16583
0
  seed2 =
16584
0
    libcrux_ml_dsa_sample_add_domain_separator(seed,
16585
0
      libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_xy(start_index + (size_t)2U,
16586
0
        columns));
16587
0
  Eurydice_arr_31
16588
0
  seed3 =
16589
0
    libcrux_ml_dsa_sample_add_domain_separator(seed,
16590
0
      libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_xy(start_index + (size_t)3U,
16591
0
        columns));
16592
0
  libcrux_ml_dsa_hash_functions_portable_Shake128X4
16593
0
  state =
16594
0
    libcrux_ml_dsa_hash_functions_portable_init_absorb_11(Eurydice_array_to_slice_shared_e9(&seed0),
16595
0
      Eurydice_array_to_slice_shared_e9(&seed1),
16596
0
      Eurydice_array_to_slice_shared_e9(&seed2),
16597
0
      Eurydice_array_to_slice_shared_e9(&seed3));
16598
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_first_five_blocks_11(&state,
16599
0
    rand_stack0,
16600
0
    rand_stack1,
16601
0
    rand_stack2,
16602
0
    rand_stack3);
16603
0
  size_t sampled0 = (size_t)0U;
16604
0
  size_t sampled1 = (size_t)0U;
16605
0
  size_t sampled2 = (size_t)0U;
16606
0
  size_t sampled3 = (size_t)0U;
16607
0
  bool
16608
0
  done0 =
16609
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_4c(rand_stack0),
16610
0
      &sampled0,
16611
0
      tmp_stack.ptr);
16612
0
  bool
16613
0
  done1 =
16614
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_4c(rand_stack1),
16615
0
      &sampled1,
16616
0
      &tmp_stack.ptr[1U]);
16617
0
  bool
16618
0
  done2 =
16619
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_4c(rand_stack2),
16620
0
      &sampled2,
16621
0
      &tmp_stack.ptr[2U]);
16622
0
  bool
16623
0
  done3 =
16624
0
    libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_4c(rand_stack3),
16625
0
      &sampled3,
16626
0
      &tmp_stack.ptr[3U]);
16627
0
  while (true)
16628
0
  {
16629
0
    if (done0)
16630
0
    {
16631
0
      if (done1)
16632
0
      {
16633
0
        if (done2)
16634
0
        {
16635
0
          if (done3)
16636
0
          {
16637
0
            break;
16638
0
          }
16639
0
          else
16640
0
          {
16641
0
            Eurydice_arr_c5_x4
16642
0
            randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_11(&state);
16643
0
            if (!done0)
16644
0
            {
16645
0
              done0 =
16646
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.fst),
16647
0
                  &sampled0,
16648
0
                  tmp_stack.ptr);
16649
0
            }
16650
0
            if (!done1)
16651
0
            {
16652
0
              done1 =
16653
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.snd),
16654
0
                  &sampled1,
16655
0
                  &tmp_stack.ptr[1U]);
16656
0
            }
16657
0
            if (!done2)
16658
0
            {
16659
0
              done2 =
16660
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.thd),
16661
0
                  &sampled2,
16662
0
                  &tmp_stack.ptr[2U]);
16663
0
            }
16664
0
            if (!done3)
16665
0
            {
16666
0
              done3 =
16667
0
                libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.f3),
16668
0
                  &sampled3,
16669
0
                  &tmp_stack.ptr[3U]);
16670
0
            }
16671
0
          }
16672
0
        }
16673
0
        else
16674
0
        {
16675
0
          Eurydice_arr_c5_x4
16676
0
          randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_11(&state);
16677
0
          if (!done0)
16678
0
          {
16679
0
            done0 =
16680
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.fst),
16681
0
                &sampled0,
16682
0
                tmp_stack.ptr);
16683
0
          }
16684
0
          if (!done1)
16685
0
          {
16686
0
            done1 =
16687
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.snd),
16688
0
                &sampled1,
16689
0
                &tmp_stack.ptr[1U]);
16690
0
          }
16691
0
          if (!done2)
16692
0
          {
16693
0
            done2 =
16694
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.thd),
16695
0
                &sampled2,
16696
0
                &tmp_stack.ptr[2U]);
16697
0
          }
16698
0
          if (!done3)
16699
0
          {
16700
0
            done3 =
16701
0
              libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.f3),
16702
0
                &sampled3,
16703
0
                &tmp_stack.ptr[3U]);
16704
0
          }
16705
0
        }
16706
0
      }
16707
0
      else
16708
0
      {
16709
0
        Eurydice_arr_c5_x4
16710
0
        randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_11(&state);
16711
0
        if (!done0)
16712
0
        {
16713
0
          done0 =
16714
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.fst),
16715
0
              &sampled0,
16716
0
              tmp_stack.ptr);
16717
0
        }
16718
0
        if (!done1)
16719
0
        {
16720
0
          done1 =
16721
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.snd),
16722
0
              &sampled1,
16723
0
              &tmp_stack.ptr[1U]);
16724
0
        }
16725
0
        if (!done2)
16726
0
        {
16727
0
          done2 =
16728
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.thd),
16729
0
              &sampled2,
16730
0
              &tmp_stack.ptr[2U]);
16731
0
        }
16732
0
        if (!done3)
16733
0
        {
16734
0
          done3 =
16735
0
            libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.f3),
16736
0
              &sampled3,
16737
0
              &tmp_stack.ptr[3U]);
16738
0
        }
16739
0
      }
16740
0
    }
16741
0
    else
16742
0
    {
16743
0
      Eurydice_arr_c5_x4
16744
0
      randomnesses = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_11(&state);
16745
0
      if (!done0)
16746
0
      {
16747
0
        done0 =
16748
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.fst),
16749
0
            &sampled0,
16750
0
            tmp_stack.ptr);
16751
0
      }
16752
0
      if (!done1)
16753
0
      {
16754
0
        done1 =
16755
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.snd),
16756
0
            &sampled1,
16757
0
            &tmp_stack.ptr[1U]);
16758
0
      }
16759
0
      if (!done2)
16760
0
      {
16761
0
        done2 =
16762
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.thd),
16763
0
            &sampled2,
16764
0
            &tmp_stack.ptr[2U]);
16765
0
      }
16766
0
      if (!done3)
16767
0
      {
16768
0
        done3 =
16769
0
          libcrux_ml_dsa_sample_rejection_sample_less_than_field_modulus_37(Eurydice_array_to_slice_shared_2c(&randomnesses.f3),
16770
0
            &sampled3,
16771
0
            &tmp_stack.ptr[3U]);
16772
0
      }
16773
0
    }
16774
0
  }
16775
0
  for (size_t i = (size_t)0U; i < elements_requested; i++)
16776
0
  {
16777
0
    size_t k = i;
16778
0
    libcrux_ml_dsa_polynomial_from_i32_array_ff_37(Eurydice_array_to_slice_shared_2c0(&tmp_stack.ptr[k]),
16779
0
      &matrix.ptr[start_index + k]);
16780
0
  }
16781
0
}
16782
16783
/**
16784
A monomorphic instance of libcrux_ml_dsa.samplex4.matrix_flat
16785
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake128X4
16786
with const generics
16787
16788
*/
16789
static KRML_MUSTINLINE void
16790
libcrux_ml_dsa_samplex4_matrix_flat_63(
16791
  size_t columns,
16792
  Eurydice_borrow_slice_u8 seed,
16793
  Eurydice_dst_ref_mut_44 matrix
16794
)
16795
0
{
16796
0
  Eurydice_arr_d10 rand_stack0 = { .data = { 0U } };
16797
0
  Eurydice_arr_d10 rand_stack1 = { .data = { 0U } };
16798
0
  Eurydice_arr_d10 rand_stack2 = { .data = { 0U } };
16799
0
  Eurydice_arr_d10 rand_stack3 = { .data = { 0U } };
16800
0
  Eurydice_arr_930
16801
0
  tmp_stack =
16802
0
    { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
16803
0
  for (size_t i = (size_t)0U; i < matrix.meta / (size_t)4U + (size_t)1U; i++)
16804
0
  {
16805
0
    size_t start_index = i;
16806
0
    size_t start_index0 = start_index * (size_t)4U;
16807
0
    if (start_index0 >= matrix.meta)
16808
0
    {
16809
0
      break;
16810
0
    }
16811
0
    size_t elements_requested;
16812
0
    if (start_index0 + (size_t)4U <= matrix.meta)
16813
0
    {
16814
0
      elements_requested = (size_t)4U;
16815
0
    }
16816
0
    else
16817
0
    {
16818
0
      elements_requested = matrix.meta - start_index0;
16819
0
    }
16820
0
    libcrux_ml_dsa_sample_sample_up_to_four_ring_elements_flat_63(columns,
16821
0
      seed,
16822
0
      matrix,
16823
0
      &rand_stack0,
16824
0
      &rand_stack1,
16825
0
      &rand_stack2,
16826
0
      &rand_stack3,
16827
0
      Eurydice_array_to_slice_mut_7e(&tmp_stack),
16828
0
      start_index0,
16829
0
      elements_requested);
16830
0
  }
16831
0
}
16832
16833
/**
16834
This function found in impl {libcrux_ml_dsa::samplex4::X4Sampler for libcrux_ml_dsa::samplex4::portable::PortableSampler}
16835
*/
16836
/**
16837
A monomorphic instance of libcrux_ml_dsa.samplex4.portable.matrix_flat_a8
16838
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients
16839
with const generics
16840
16841
*/
16842
static inline void
16843
libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(
16844
  size_t columns,
16845
  Eurydice_borrow_slice_u8 seed,
16846
  Eurydice_dst_ref_mut_44 matrix
16847
)
16848
0
{
16849
0
  libcrux_ml_dsa_samplex4_matrix_flat_63(columns, seed, matrix);
16850
0
}
16851
16852
/**
16853
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256
16854
with const generics
16855
- OUTPUT_LENGTH= 64
16856
*/
16857
static KRML_MUSTINLINE void
16858
libcrux_ml_dsa_hash_functions_portable_shake256_c9(
16859
  Eurydice_borrow_slice_u8 input,
16860
  Eurydice_arr_c7 *out
16861
)
16862
0
{
16863
0
  libcrux_sha3_portable_shake256(Eurydice_array_to_slice_mut_17(out), input);
16864
0
}
16865
16866
/**
16867
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::DsaXof for libcrux_ml_dsa::hash_functions::portable::Shake256}
16868
*/
16869
/**
16870
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256_61
16871
with const generics
16872
- OUTPUT_LENGTH= 64
16873
*/
16874
static KRML_MUSTINLINE void
16875
libcrux_ml_dsa_hash_functions_portable_shake256_61_c9(
16876
  Eurydice_borrow_slice_u8 input,
16877
  Eurydice_arr_c7 *out
16878
)
16879
0
{
16880
0
  libcrux_ml_dsa_hash_functions_portable_shake256_c9(input, out);
16881
0
}
16882
16883
/**
16884
A monomorphic instance of libcrux_ml_dsa.encoding.signing_key.generate_serialized
16885
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake256
16886
with const generics
16887
16888
*/
16889
static KRML_MUSTINLINE void
16890
libcrux_ml_dsa_encoding_signing_key_generate_serialized_2e(
16891
  libcrux_ml_dsa_constants_Eta eta,
16892
  size_t error_ring_element_size,
16893
  Eurydice_borrow_slice_u8 seed_matrix,
16894
  Eurydice_borrow_slice_u8 seed_signing,
16895
  Eurydice_borrow_slice_u8 verification_key,
16896
  Eurydice_dst_ref_shared_44 s1_2,
16897
  Eurydice_dst_ref_shared_44 t0,
16898
  Eurydice_mut_borrow_slice_u8 signing_key_serialized
16899
)
16900
0
{
16901
0
  size_t offset = (size_t)0U;
16902
0
  Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(signing_key_serialized,
16903
0
      (
16904
0
        KRML_CLITERAL(core_ops_range_Range_87){
16905
0
          .start = offset,
16906
0
          .end = offset + LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE
16907
0
        }
16908
0
      )),
16909
0
    seed_matrix,
16910
0
    uint8_t);
16911
0
  offset += LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE;
16912
0
  Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(signing_key_serialized,
16913
0
      (
16914
0
        KRML_CLITERAL(core_ops_range_Range_87){
16915
0
          .start = offset,
16916
0
          .end = offset + LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE
16917
0
        }
16918
0
      )),
16919
0
    seed_signing,
16920
0
    uint8_t);
16921
0
  offset += LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE;
16922
0
  Eurydice_arr_c7 verification_key_hash = { .data = { 0U } };
16923
0
  libcrux_ml_dsa_hash_functions_portable_shake256_61_c9(verification_key,
16924
0
    &verification_key_hash);
16925
0
  Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(signing_key_serialized,
16926
0
      (
16927
0
        KRML_CLITERAL(core_ops_range_Range_87){
16928
0
          .start = offset,
16929
0
          .end = offset + LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH
16930
0
        }
16931
0
      )),
16932
0
    Eurydice_array_to_slice_shared_17(&verification_key_hash),
16933
0
    uint8_t);
16934
0
  offset += LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH;
16935
0
  for (size_t i = (size_t)0U; i < s1_2.meta; i++)
16936
0
  {
16937
0
    size_t i0 = i;
16938
0
    libcrux_ml_dsa_encoding_error_serialize_37(eta,
16939
0
      &s1_2.ptr[i0],
16940
0
      Eurydice_slice_subslice_mut_c8(signing_key_serialized,
16941
0
        (
16942
0
          KRML_CLITERAL(core_ops_range_Range_87){
16943
0
            .start = offset,
16944
0
            .end = offset + error_ring_element_size
16945
0
          }
16946
0
        )));
16947
0
    offset += error_ring_element_size;
16948
0
  }
16949
0
  for (size_t i = (size_t)0U; i < t0.meta; i++)
16950
0
  {
16951
0
    size_t _cloop_j = i;
16952
0
    const Eurydice_arr_a3 *ring_element = &t0.ptr[_cloop_j];
16953
0
    libcrux_ml_dsa_encoding_t0_serialize_37(ring_element,
16954
0
      Eurydice_slice_subslice_mut_c8(signing_key_serialized,
16955
0
        (
16956
0
          KRML_CLITERAL(core_ops_range_Range_87){
16957
0
            .start = offset,
16958
0
            .end = offset + LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE
16959
0
          }
16960
0
        )));
16961
0
    offset += LIBCRUX_ML_DSA_CONSTANTS_RING_ELEMENT_OF_T0S_SIZE;
16962
0
  }
16963
0
}
16964
16965
/**
16966
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.generate_key_pair
16967
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
16968
with const generics
16969
16970
*/
16971
static KRML_MUSTINLINE void
16972
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_generate_key_pair_5a(
16973
  Eurydice_arr_ec randomness,
16974
  Eurydice_mut_borrow_slice_u8 signing_key,
16975
  Eurydice_mut_borrow_slice_u8 verification_key
16976
)
16977
0
{
16978
0
  Eurydice_arr_89 seed_expanded0 = { .data = { 0U } };
16979
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
16980
0
  shake = libcrux_ml_dsa_hash_functions_portable_init_26();
16981
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
16982
0
    Eurydice_array_to_slice_shared_01(&randomness));
16983
  /* original Rust expression is not an lvalue in C */
16984
0
  Eurydice_array_u8x2
16985
0
  lvalue =
16986
0
    {
16987
0
      .data = {
16988
0
        (uint8_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
16989
0
        (uint8_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A
16990
0
      }
16991
0
    };
16992
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
16993
0
    Eurydice_array_to_slice_shared_82(&lvalue));
16994
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
16995
0
    Eurydice_array_to_slice_mut_78(&seed_expanded0));
16996
0
  Eurydice_borrow_slice_u8_x2
16997
0
  uu____0 =
16998
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_78(&seed_expanded0),
16999
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
17000
0
      uint8_t,
17001
0
      Eurydice_borrow_slice_u8_x2);
17002
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
17003
0
  Eurydice_borrow_slice_u8 seed_expanded = uu____0.snd;
17004
0
  Eurydice_borrow_slice_u8_x2
17005
0
  uu____1 =
17006
0
    Eurydice_slice_split_at(seed_expanded,
17007
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_ERROR_VECTORS_SIZE,
17008
0
      uint8_t,
17009
0
      Eurydice_borrow_slice_u8_x2);
17010
0
  Eurydice_borrow_slice_u8 seed_for_error_vectors = uu____1.fst;
17011
0
  Eurydice_borrow_slice_u8 seed_for_signing = uu____1.snd;
17012
0
  Eurydice_arr_8f s1_s2;
17013
0
  Eurydice_arr_a3 repeat_expression0[8U];
17014
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
17015
0
  {
17016
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17017
0
  }
17018
0
  memcpy(s1_s2.data, repeat_expression0, (size_t)8U * sizeof (Eurydice_arr_a3));
17019
0
  libcrux_ml_dsa_samplex4_sample_s1_and_s2_29(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ETA,
17020
0
    seed_for_error_vectors,
17021
0
    Eurydice_array_to_slice_mut_20(&s1_s2));
17022
0
  Eurydice_arr_9d t0;
17023
0
  Eurydice_arr_a3 repeat_expression1[4U];
17024
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17025
0
  {
17026
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17027
0
  }
17028
0
  memcpy(t0.data, repeat_expression1, (size_t)4U * sizeof (Eurydice_arr_a3));
17029
0
  Eurydice_arr_2f a_as_ntt;
17030
0
  Eurydice_arr_a3 repeat_expression2[16U];
17031
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
17032
0
  {
17033
0
    repeat_expression2[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17034
0
  }
17035
0
  memcpy(a_as_ntt.data, repeat_expression2, (size_t)16U * sizeof (Eurydice_arr_a3));
17036
0
  libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17037
0
    seed_for_a,
17038
0
    Eurydice_array_to_slice_mut_200(&a_as_ntt));
17039
0
  Eurydice_arr_9d s1_ntt;
17040
0
  Eurydice_arr_a3 repeat_expression3[4U];
17041
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17042
0
  {
17043
0
    repeat_expression3[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17044
0
  }
17045
0
  memcpy(s1_ntt.data, repeat_expression3, (size_t)4U * sizeof (Eurydice_arr_a3));
17046
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_201(&s1_ntt),
17047
0
    Eurydice_array_to_subslice_shared_25(&s1_s2,
17048
0
      (
17049
0
        KRML_CLITERAL(core_ops_range_Range_87){
17050
0
          .start = (size_t)0U,
17051
0
          .end = LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A
17052
0
        }
17053
0
      )),
17054
0
    Eurydice_arr_a3);
17055
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17056
0
  {
17057
0
    size_t i0 = i;
17058
0
    libcrux_ml_dsa_ntt_ntt_37(&s1_ntt.data[i0]);
17059
0
  }
17060
0
  libcrux_ml_dsa_matrix_compute_as1_plus_s2_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17061
0
    LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17062
0
    Eurydice_array_to_slice_mut_200(&a_as_ntt),
17063
0
    Eurydice_array_to_slice_shared_20(&s1_ntt),
17064
0
    Eurydice_array_to_slice_shared_200(&s1_s2),
17065
0
    Eurydice_array_to_slice_mut_201(&t0));
17066
0
  Eurydice_arr_9d t1;
17067
0
  Eurydice_arr_a3 repeat_expression[4U];
17068
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17069
0
  {
17070
0
    repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17071
0
  }
17072
0
  memcpy(t1.data, repeat_expression, (size_t)4U * sizeof (Eurydice_arr_a3));
17073
0
  libcrux_ml_dsa_arithmetic_power2round_vector_37(Eurydice_array_to_slice_mut_201(&t0),
17074
0
    Eurydice_array_to_slice_mut_201(&t1));
17075
0
  libcrux_ml_dsa_encoding_verification_key_generate_serialized_37(seed_for_a,
17076
0
    Eurydice_array_to_slice_shared_20(&t1),
17077
0
    verification_key);
17078
0
  libcrux_ml_dsa_encoding_signing_key_generate_serialized_2e(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ETA,
17079
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE,
17080
0
    seed_for_a,
17081
0
    seed_for_signing,
17082
0
    (
17083
0
      KRML_CLITERAL(Eurydice_borrow_slice_u8){
17084
0
        .ptr = verification_key.ptr,
17085
0
        .meta = verification_key.meta
17086
0
      }
17087
0
    ),
17088
0
    Eurydice_array_to_slice_shared_200(&s1_s2),
17089
0
    Eurydice_array_to_slice_shared_20(&t0),
17090
0
    signing_key);
17091
0
}
17092
17093
/**
17094
 Generate key pair.
17095
*/
17096
static inline void
17097
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_generate_key_pair(
17098
  Eurydice_arr_ec randomness,
17099
  Eurydice_arr_10 *signing_key,
17100
  Eurydice_arr_02 *verification_key
17101
)
17102
0
{
17103
0
  libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_generate_key_pair_5a(randomness,
17104
0
    Eurydice_array_to_slice_mut_34(signing_key),
17105
0
    Eurydice_array_to_slice_mut_9f0(verification_key));
17106
0
}
17107
17108
/**
17109
 This corresponds to line 6 in algorithm 7 in FIPS 204 (line 7 in algorithm
17110
 8, resp.).
17111
17112
 If `domain_separation_context` is supplied, applies domain
17113
 separation and length encoding to the context string,
17114
 before appending the message (in the regular variant) or the
17115
 pre-hash OID as well as the pre-hashed message digest. Otherwise,
17116
 it is assumed that `message` already contains domain separation
17117
 information.
17118
17119
 In FIPS 204 M' is the concatenation of the domain separated context, any
17120
 potential pre-hash OID and the message (or the message pre-hash). We do not
17121
 explicitely construct the concatenation in memory since it is of statically unknown
17122
 length, but feed its components directly into the incremental XOF.
17123
17124
 Refer to line 10 of Algorithm 2 (and line 5 of Algorithm 3, resp.) in [FIPS
17125
 204](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.204.pdf#section.5)
17126
 for details on the domain separation for regular ML-DSA. Line
17127
 23 of Algorithm 4 (and line 18 of Algorithm 5,resp.) describe domain separation for the HashMl-DSA
17128
 variant.
17129
*/
17130
/**
17131
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.derive_message_representative
17132
with types libcrux_ml_dsa_hash_functions_portable_Shake256Xof
17133
with const generics
17134
17135
*/
17136
static KRML_MUSTINLINE void
17137
libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(
17138
  Eurydice_borrow_slice_u8 verification_key_hash,
17139
  const core_option_Option_84 *domain_separation_context,
17140
  Eurydice_borrow_slice_u8 message,
17141
  Eurydice_arr_c7 *message_representative
17142
)
17143
0
{
17144
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
17145
0
  shake = libcrux_ml_dsa_hash_functions_portable_init_26();
17146
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake, verification_key_hash);
17147
0
  if (domain_separation_context->tag == core_option_Some)
17148
0
  {
17149
0
    const
17150
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext
17151
0
    *domain_separation_context0 = &domain_separation_context->f0;
17152
0
    libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *uu____0 = &shake;
17153
    /* original Rust expression is not an lvalue in C */
17154
0
    Eurydice_arr_82
17155
0
    lvalue0 =
17156
0
      {
17157
0
        .data = {
17158
0
          (uint8_t)core_option__core__option__Option_T__TraitClause_0___is_some(libcrux_ml_dsa_pre_hash_pre_hash_oid_88(domain_separation_context0),
17159
0
            Eurydice_arr_c9,
17160
0
            bool)
17161
0
        }
17162
0
      };
17163
0
    libcrux_ml_dsa_hash_functions_portable_absorb_26(uu____0,
17164
0
      Eurydice_array_to_slice_shared_79(&lvalue0));
17165
0
    libcrux_sha3_generic_keccak_xof_KeccakXofState_8d *uu____1 = &shake;
17166
    /* original Rust expression is not an lvalue in C */
17167
0
    Eurydice_arr_82
17168
0
    lvalue =
17169
0
      { .data = { (uint8_t)libcrux_ml_dsa_pre_hash_context_88(domain_separation_context0).meta } };
17170
0
    libcrux_ml_dsa_hash_functions_portable_absorb_26(uu____1,
17171
0
      Eurydice_array_to_slice_shared_79(&lvalue));
17172
0
    libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
17173
0
      libcrux_ml_dsa_pre_hash_context_88(domain_separation_context0));
17174
0
    const
17175
0
    core_option_Option_57
17176
0
    *uu____2 = libcrux_ml_dsa_pre_hash_pre_hash_oid_88(domain_separation_context0);
17177
0
    if (uu____2->tag == core_option_Some)
17178
0
    {
17179
0
      const Eurydice_arr_c9 *pre_hash_oid = &uu____2->f0;
17180
0
      libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
17181
0
        Eurydice_array_to_slice_shared_2f(pre_hash_oid));
17182
0
    }
17183
0
  }
17184
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake, message);
17185
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
17186
0
    Eurydice_array_to_slice_mut_17(message_representative));
17187
0
}
17188
17189
/**
17190
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256
17191
with const generics
17192
- OUTPUT_LENGTH= 576
17193
*/
17194
static KRML_MUSTINLINE void
17195
libcrux_ml_dsa_hash_functions_portable_shake256_5a(
17196
  Eurydice_borrow_slice_u8 input,
17197
  Eurydice_arr_220 *out
17198
)
17199
0
{
17200
0
  libcrux_sha3_portable_shake256(Eurydice_array_to_slice_mut_8a(out), input);
17201
0
}
17202
17203
/**
17204
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake256X4}
17205
*/
17206
/**
17207
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256_x4_9b
17208
with const generics
17209
- OUT_LEN= 576
17210
*/
17211
static KRML_MUSTINLINE void
17212
libcrux_ml_dsa_hash_functions_portable_shake256_x4_9b_5a(
17213
  Eurydice_borrow_slice_u8 input0,
17214
  Eurydice_borrow_slice_u8 input1,
17215
  Eurydice_borrow_slice_u8 input2,
17216
  Eurydice_borrow_slice_u8 input3,
17217
  Eurydice_arr_220 *out0,
17218
  Eurydice_arr_220 *out1,
17219
  Eurydice_arr_220 *out2,
17220
  Eurydice_arr_220 *out3
17221
)
17222
0
{
17223
0
  libcrux_ml_dsa_hash_functions_portable_shake256_5a(input0, out0);
17224
0
  libcrux_ml_dsa_hash_functions_portable_shake256_5a(input1, out1);
17225
0
  libcrux_ml_dsa_hash_functions_portable_shake256_5a(input2, out2);
17226
0
  libcrux_ml_dsa_hash_functions_portable_shake256_5a(input3, out3);
17227
0
}
17228
17229
/**
17230
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256
17231
with const generics
17232
- OUTPUT_LENGTH= 640
17233
*/
17234
static KRML_MUSTINLINE void
17235
libcrux_ml_dsa_hash_functions_portable_shake256_0e(
17236
  Eurydice_borrow_slice_u8 input,
17237
  Eurydice_arr_20 *out
17238
)
17239
0
{
17240
0
  libcrux_sha3_portable_shake256(Eurydice_array_to_slice_mut_4f(out), input);
17241
0
}
17242
17243
/**
17244
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::XofX4 for libcrux_ml_dsa::hash_functions::portable::Shake256X4}
17245
*/
17246
/**
17247
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256_x4_9b
17248
with const generics
17249
- OUT_LEN= 640
17250
*/
17251
static KRML_MUSTINLINE void
17252
libcrux_ml_dsa_hash_functions_portable_shake256_x4_9b_0e(
17253
  Eurydice_borrow_slice_u8 input0,
17254
  Eurydice_borrow_slice_u8 input1,
17255
  Eurydice_borrow_slice_u8 input2,
17256
  Eurydice_borrow_slice_u8 input3,
17257
  Eurydice_arr_20 *out0,
17258
  Eurydice_arr_20 *out1,
17259
  Eurydice_arr_20 *out2,
17260
  Eurydice_arr_20 *out3
17261
)
17262
0
{
17263
0
  libcrux_ml_dsa_hash_functions_portable_shake256_0e(input0, out0);
17264
0
  libcrux_ml_dsa_hash_functions_portable_shake256_0e(input1, out1);
17265
0
  libcrux_ml_dsa_hash_functions_portable_shake256_0e(input2, out2);
17266
0
  libcrux_ml_dsa_hash_functions_portable_shake256_0e(input3, out3);
17267
0
}
17268
17269
/**
17270
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::DsaXof for libcrux_ml_dsa::hash_functions::portable::Shake256}
17271
*/
17272
/**
17273
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256_61
17274
with const generics
17275
- OUTPUT_LENGTH= 640
17276
*/
17277
static KRML_MUSTINLINE void
17278
libcrux_ml_dsa_hash_functions_portable_shake256_61_0e(
17279
  Eurydice_borrow_slice_u8 input,
17280
  Eurydice_arr_20 *out
17281
)
17282
0
{
17283
0
  libcrux_ml_dsa_hash_functions_portable_shake256_0e(input, out);
17284
0
}
17285
17286
/**
17287
This function found in impl {libcrux_ml_dsa::hash_functions::shake256::DsaXof for libcrux_ml_dsa::hash_functions::portable::Shake256}
17288
*/
17289
/**
17290
A monomorphic instance of libcrux_ml_dsa.hash_functions.portable.shake256_61
17291
with const generics
17292
- OUTPUT_LENGTH= 576
17293
*/
17294
static KRML_MUSTINLINE void
17295
libcrux_ml_dsa_hash_functions_portable_shake256_61_5a(
17296
  Eurydice_borrow_slice_u8 input,
17297
  Eurydice_arr_220 *out
17298
)
17299
0
{
17300
0
  libcrux_ml_dsa_hash_functions_portable_shake256_5a(input, out);
17301
0
}
17302
17303
/**
17304
A monomorphic instance of libcrux_ml_dsa.sample.sample_mask_ring_element
17305
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake256
17306
with const generics
17307
17308
*/
17309
static KRML_MUSTINLINE void
17310
libcrux_ml_dsa_sample_sample_mask_ring_element_2e(
17311
  const Eurydice_arr_91 *seed,
17312
  Eurydice_arr_a3 *result,
17313
  size_t gamma1_exponent
17314
)
17315
0
{
17316
0
  switch (gamma1_exponent)
17317
0
  {
17318
0
    case 17U:
17319
0
      {
17320
0
        break;
17321
0
      }
17322
0
    case 19U:
17323
0
      {
17324
0
        Eurydice_arr_20 out = { .data = { 0U } };
17325
0
        libcrux_ml_dsa_hash_functions_portable_shake256_61_0e(Eurydice_array_to_slice_shared_f1(seed),
17326
0
          &out);
17327
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17328
0
          Eurydice_array_to_slice_shared_4f(&out),
17329
0
          result);
17330
0
        return;
17331
0
      }
17332
0
    default:
17333
0
      {
17334
0
        KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
17335
0
        KRML_HOST_EXIT(255U);
17336
0
      }
17337
0
  }
17338
0
  Eurydice_arr_220 out = { .data = { 0U } };
17339
0
  libcrux_ml_dsa_hash_functions_portable_shake256_61_5a(Eurydice_array_to_slice_shared_f1(seed),
17340
0
    &out);
17341
0
  libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17342
0
    Eurydice_array_to_slice_shared_8a(&out),
17343
0
    result);
17344
0
}
17345
17346
/**
17347
A monomorphic instance of libcrux_ml_dsa.sample.sample_mask_vector
17348
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256X4
17349
with const generics
17350
17351
*/
17352
static KRML_MUSTINLINE void
17353
libcrux_ml_dsa_sample_sample_mask_vector_67(
17354
  size_t dimension,
17355
  size_t gamma1_exponent,
17356
  const Eurydice_arr_c7 *seed,
17357
  uint16_t *domain_separator,
17358
  Eurydice_dst_ref_mut_44 mask
17359
)
17360
0
{
17361
0
  Eurydice_arr_91
17362
0
  seed0 =
17363
0
    libcrux_ml_dsa_sample_add_error_domain_separator(Eurydice_array_to_slice_shared_17(seed),
17364
0
      domain_separator[0U]);
17365
0
  Eurydice_arr_91
17366
0
  seed1 =
17367
0
    libcrux_ml_dsa_sample_add_error_domain_separator(Eurydice_array_to_slice_shared_17(seed),
17368
0
      (uint32_t)domain_separator[0U] + 1U);
17369
0
  Eurydice_arr_91
17370
0
  seed2 =
17371
0
    libcrux_ml_dsa_sample_add_error_domain_separator(Eurydice_array_to_slice_shared_17(seed),
17372
0
      (uint32_t)domain_separator[0U] + 2U);
17373
0
  Eurydice_arr_91
17374
0
  seed3 =
17375
0
    libcrux_ml_dsa_sample_add_error_domain_separator(Eurydice_array_to_slice_shared_17(seed),
17376
0
      (uint32_t)domain_separator[0U] + 3U);
17377
0
  domain_separator[0U] = (uint32_t)domain_separator[0U] + 4U;
17378
0
  switch (gamma1_exponent)
17379
0
  {
17380
0
    case 17U:
17381
0
      {
17382
0
        Eurydice_arr_220 out0 = { .data = { 0U } };
17383
0
        Eurydice_arr_220 out1 = { .data = { 0U } };
17384
0
        Eurydice_arr_220 out2 = { .data = { 0U } };
17385
0
        Eurydice_arr_220 out3 = { .data = { 0U } };
17386
0
        libcrux_ml_dsa_hash_functions_portable_shake256_x4_9b_5a(Eurydice_array_to_slice_shared_f1(&seed0),
17387
0
          Eurydice_array_to_slice_shared_f1(&seed1),
17388
0
          Eurydice_array_to_slice_shared_f1(&seed2),
17389
0
          Eurydice_array_to_slice_shared_f1(&seed3),
17390
0
          &out0,
17391
0
          &out1,
17392
0
          &out2,
17393
0
          &out3);
17394
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17395
0
          Eurydice_array_to_slice_shared_8a(&out0),
17396
0
          mask.ptr);
17397
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17398
0
          Eurydice_array_to_slice_shared_8a(&out1),
17399
0
          &mask.ptr[1U]);
17400
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17401
0
          Eurydice_array_to_slice_shared_8a(&out2),
17402
0
          &mask.ptr[2U]);
17403
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17404
0
          Eurydice_array_to_slice_shared_8a(&out3),
17405
0
          &mask.ptr[3U]);
17406
0
        break;
17407
0
      }
17408
0
    case 19U:
17409
0
      {
17410
0
        Eurydice_arr_20 out0 = { .data = { 0U } };
17411
0
        Eurydice_arr_20 out1 = { .data = { 0U } };
17412
0
        Eurydice_arr_20 out2 = { .data = { 0U } };
17413
0
        Eurydice_arr_20 out3 = { .data = { 0U } };
17414
0
        libcrux_ml_dsa_hash_functions_portable_shake256_x4_9b_0e(Eurydice_array_to_slice_shared_f1(&seed0),
17415
0
          Eurydice_array_to_slice_shared_f1(&seed1),
17416
0
          Eurydice_array_to_slice_shared_f1(&seed2),
17417
0
          Eurydice_array_to_slice_shared_f1(&seed3),
17418
0
          &out0,
17419
0
          &out1,
17420
0
          &out2,
17421
0
          &out3);
17422
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17423
0
          Eurydice_array_to_slice_shared_4f(&out0),
17424
0
          mask.ptr);
17425
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17426
0
          Eurydice_array_to_slice_shared_4f(&out1),
17427
0
          &mask.ptr[1U]);
17428
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17429
0
          Eurydice_array_to_slice_shared_4f(&out2),
17430
0
          &mask.ptr[2U]);
17431
0
        libcrux_ml_dsa_encoding_gamma1_deserialize_37(gamma1_exponent,
17432
0
          Eurydice_array_to_slice_shared_4f(&out3),
17433
0
          &mask.ptr[3U]);
17434
0
        break;
17435
0
      }
17436
0
    default:
17437
0
      {
17438
0
        KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, "panic!");
17439
0
        KRML_HOST_EXIT(255U);
17440
0
      }
17441
0
  }
17442
0
  for (size_t i = (size_t)4U; i < dimension; i++)
17443
0
  {
17444
0
    size_t i0 = i;
17445
0
    Eurydice_arr_91
17446
0
    seed4 =
17447
0
      libcrux_ml_dsa_sample_add_error_domain_separator(Eurydice_array_to_slice_shared_17(seed),
17448
0
        domain_separator[0U]);
17449
0
    domain_separator[0U] = (uint32_t)domain_separator[0U] + 1U;
17450
0
    libcrux_ml_dsa_sample_sample_mask_ring_element_2e(&seed4, &mask.ptr[i0], gamma1_exponent);
17451
0
  }
17452
0
}
17453
17454
/**
17455
A monomorphic instance of libcrux_ml_dsa.sample.sample_challenge_ring_element
17456
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_hash_functions_portable_Shake256
17457
with const generics
17458
17459
*/
17460
static KRML_MUSTINLINE void
17461
libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(
17462
  Eurydice_borrow_slice_u8 seed,
17463
  size_t number_of_ones,
17464
  Eurydice_arr_a3 *re
17465
)
17466
0
{
17467
0
  Eurydice_arr_7c state = libcrux_ml_dsa_hash_functions_portable_init_absorb_final_61(seed);
17468
0
  Eurydice_arr_ff
17469
0
  randomness0 = libcrux_ml_dsa_hash_functions_portable_squeeze_first_block_61(&state);
17470
0
  Eurydice_array_u8x8 arr;
17471
0
  memcpy(arr.data,
17472
0
    Eurydice_array_to_subslice_shared_d40(&randomness0,
17473
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)8U })).ptr,
17474
0
    (size_t)8U * sizeof (uint8_t));
17475
0
  uint64_t
17476
0
  signs =
17477
0
    core_num__u64__from_le_bytes(core_result_unwrap_26_e0((
17478
0
          KRML_CLITERAL(core_result_Result_8e){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
17479
0
        )));
17480
0
  Eurydice_arr_6c result = { .data = { 0U } };
17481
0
  size_t out_index = (size_t)256U - number_of_ones;
17482
0
  bool
17483
0
  done =
17484
0
    libcrux_ml_dsa_sample_inside_out_shuffle(Eurydice_array_to_subslice_from_shared_5f(&randomness0,
17485
0
        (size_t)8U),
17486
0
      &out_index,
17487
0
      &signs,
17488
0
      &result);
17489
0
  while (true)
17490
0
  {
17491
0
    if (done)
17492
0
    {
17493
0
      break;
17494
0
    }
17495
0
    else
17496
0
    {
17497
0
      Eurydice_arr_ff
17498
0
      randomness = libcrux_ml_dsa_hash_functions_portable_squeeze_next_block_61(&state);
17499
0
      done =
17500
0
        libcrux_ml_dsa_sample_inside_out_shuffle(Eurydice_array_to_slice_shared_58(&randomness),
17501
0
          &out_index,
17502
0
          &signs,
17503
0
          &result);
17504
0
    }
17505
0
  }
17506
0
  libcrux_ml_dsa_polynomial_from_i32_array_ff_37(Eurydice_array_to_slice_shared_af(&result), re);
17507
0
}
17508
17509
/**
17510
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.sign_internal
17511
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
17512
with const generics
17513
17514
*/
17515
static KRML_MUSTINLINE core_result_Result_53
17516
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_internal_5a(
17517
  Eurydice_borrow_slice_u8 signing_key,
17518
  Eurydice_borrow_slice_u8 message,
17519
  core_option_Option_84 domain_separation_context,
17520
  Eurydice_arr_ec randomness,
17521
  Eurydice_arr_85 *signature
17522
)
17523
0
{
17524
0
  Eurydice_borrow_slice_u8_x2
17525
0
  uu____0 =
17526
0
    Eurydice_slice_split_at(signing_key,
17527
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
17528
0
      uint8_t,
17529
0
      Eurydice_borrow_slice_u8_x2);
17530
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
17531
0
  Eurydice_borrow_slice_u8 remaining_serialized0 = uu____0.snd;
17532
0
  Eurydice_borrow_slice_u8_x2
17533
0
  uu____1 =
17534
0
    Eurydice_slice_split_at(remaining_serialized0,
17535
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE,
17536
0
      uint8_t,
17537
0
      Eurydice_borrow_slice_u8_x2);
17538
0
  Eurydice_borrow_slice_u8 seed_for_signing = uu____1.fst;
17539
0
  Eurydice_borrow_slice_u8 remaining_serialized1 = uu____1.snd;
17540
0
  Eurydice_borrow_slice_u8_x2
17541
0
  uu____2 =
17542
0
    Eurydice_slice_split_at(remaining_serialized1,
17543
0
      LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH,
17544
0
      uint8_t,
17545
0
      Eurydice_borrow_slice_u8_x2);
17546
0
  Eurydice_borrow_slice_u8 verification_key_hash = uu____2.fst;
17547
0
  Eurydice_borrow_slice_u8 remaining_serialized2 = uu____2.snd;
17548
0
  Eurydice_borrow_slice_u8_x2
17549
0
  uu____3 =
17550
0
    Eurydice_slice_split_at(remaining_serialized2,
17551
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE *
17552
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17553
0
      uint8_t,
17554
0
      Eurydice_borrow_slice_u8_x2);
17555
0
  Eurydice_borrow_slice_u8 s1_serialized = uu____3.fst;
17556
0
  Eurydice_borrow_slice_u8 remaining_serialized = uu____3.snd;
17557
0
  Eurydice_borrow_slice_u8_x2
17558
0
  uu____4 =
17559
0
    Eurydice_slice_split_at(remaining_serialized,
17560
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE *
17561
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17562
0
      uint8_t,
17563
0
      Eurydice_borrow_slice_u8_x2);
17564
0
  Eurydice_borrow_slice_u8 s2_serialized = uu____4.fst;
17565
0
  Eurydice_borrow_slice_u8 t0_serialized = uu____4.snd;
17566
0
  Eurydice_arr_9d s1_as_ntt;
17567
0
  Eurydice_arr_a3 repeat_expression0[4U];
17568
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17569
0
  {
17570
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17571
0
  }
17572
0
  memcpy(s1_as_ntt.data, repeat_expression0, (size_t)4U * sizeof (Eurydice_arr_a3));
17573
0
  Eurydice_arr_9d s2_as_ntt;
17574
0
  Eurydice_arr_a3 repeat_expression1[4U];
17575
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17576
0
  {
17577
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17578
0
  }
17579
0
  memcpy(s2_as_ntt.data, repeat_expression1, (size_t)4U * sizeof (Eurydice_arr_a3));
17580
0
  Eurydice_arr_9d t0_as_ntt;
17581
0
  Eurydice_arr_a3 repeat_expression2[4U];
17582
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17583
0
  {
17584
0
    repeat_expression2[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17585
0
  }
17586
0
  memcpy(t0_as_ntt.data, repeat_expression2, (size_t)4U * sizeof (Eurydice_arr_a3));
17587
0
  libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ETA,
17588
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE,
17589
0
    s1_serialized,
17590
0
    Eurydice_array_to_slice_mut_201(&s1_as_ntt));
17591
0
  libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ETA,
17592
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_ERROR_RING_ELEMENT_SIZE,
17593
0
    s2_serialized,
17594
0
    Eurydice_array_to_slice_mut_201(&s2_as_ntt));
17595
0
  libcrux_ml_dsa_encoding_t0_deserialize_to_vector_then_ntt_37(t0_serialized,
17596
0
    Eurydice_array_to_slice_mut_201(&t0_as_ntt));
17597
0
  Eurydice_arr_2f matrix;
17598
0
  Eurydice_arr_a3 repeat_expression3[16U];
17599
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
17600
0
  {
17601
0
    repeat_expression3[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17602
0
  }
17603
0
  memcpy(matrix.data, repeat_expression3, (size_t)16U * sizeof (Eurydice_arr_a3));
17604
0
  libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17605
0
    seed_for_a,
17606
0
    Eurydice_array_to_slice_mut_200(&matrix));
17607
0
  Eurydice_arr_c7 message_representative = { .data = { 0U } };
17608
0
  libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(verification_key_hash,
17609
0
    &domain_separation_context,
17610
0
    message,
17611
0
    &message_representative);
17612
0
  Eurydice_arr_c7 mask_seed = { .data = { 0U } };
17613
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
17614
0
  shake0 = libcrux_ml_dsa_hash_functions_portable_init_26();
17615
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake0, seed_for_signing);
17616
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake0,
17617
0
    Eurydice_array_to_slice_shared_01(&randomness));
17618
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake0,
17619
0
    Eurydice_array_to_slice_shared_17(&message_representative));
17620
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake0,
17621
0
    Eurydice_array_to_slice_mut_17(&mask_seed));
17622
0
  uint16_t domain_separator_for_mask = 0U;
17623
0
  size_t attempt = (size_t)0U;
17624
0
  core_option_Option_14 commitment_hash0 = { .tag = core_option_None };
17625
0
  core_option_Option_d9 signer_response0 = { .tag = core_option_None };
17626
0
  core_option_Option_51 hint0 = { .tag = core_option_None };
17627
0
  while (attempt < LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN)
17628
0
  {
17629
0
    attempt++;
17630
0
    Eurydice_arr_9d mask;
17631
0
    Eurydice_arr_a3 repeat_expression4[4U];
17632
0
    for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17633
0
    {
17634
0
      repeat_expression4[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17635
0
    }
17636
0
    memcpy(mask.data, repeat_expression4, (size_t)4U * sizeof (Eurydice_arr_a3));
17637
0
    Eurydice_arr_9d w0;
17638
0
    Eurydice_arr_a3 repeat_expression5[4U];
17639
0
    for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17640
0
    {
17641
0
      repeat_expression5[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17642
0
    }
17643
0
    memcpy(w0.data, repeat_expression5, (size_t)4U * sizeof (Eurydice_arr_a3));
17644
0
    Eurydice_arr_9d commitment;
17645
0
    Eurydice_arr_a3 repeat_expression6[4U];
17646
0
    for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17647
0
    {
17648
0
      repeat_expression6[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17649
0
    }
17650
0
    memcpy(commitment.data, repeat_expression6, (size_t)4U * sizeof (Eurydice_arr_a3));
17651
0
    libcrux_ml_dsa_sample_sample_mask_vector_67(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17652
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA1_EXPONENT,
17653
0
      &mask_seed,
17654
0
      &domain_separator_for_mask,
17655
0
      Eurydice_array_to_slice_mut_201(&mask));
17656
0
    Eurydice_arr_9d a_x_mask;
17657
0
    Eurydice_arr_a3 repeat_expression[4U];
17658
0
    for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17659
0
    {
17660
0
      repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
17661
0
    }
17662
0
    memcpy(a_x_mask.data, repeat_expression, (size_t)4U * sizeof (Eurydice_arr_a3));
17663
0
    Eurydice_arr_9d
17664
0
    mask_ntt =
17665
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)4U,
17666
0
        &mask,
17667
0
        Eurydice_arr_a3,
17668
0
        Eurydice_arr_9d);
17669
0
    for (size_t i = (size_t)0U; i < (size_t)4U; i++)
17670
0
    {
17671
0
      size_t i0 = i;
17672
0
      libcrux_ml_dsa_ntt_ntt_37(&mask_ntt.data[i0]);
17673
0
    }
17674
0
    libcrux_ml_dsa_matrix_compute_matrix_x_mask_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17675
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17676
0
      Eurydice_array_to_slice_shared_201(&matrix),
17677
0
      Eurydice_array_to_slice_shared_20(&mask_ntt),
17678
0
      Eurydice_array_to_slice_mut_201(&a_x_mask));
17679
0
    libcrux_ml_dsa_arithmetic_decompose_vector_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17680
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA2,
17681
0
      Eurydice_array_to_slice_shared_20(&a_x_mask),
17682
0
      Eurydice_array_to_slice_mut_201(&w0),
17683
0
      Eurydice_array_to_slice_mut_201(&commitment));
17684
0
    Eurydice_arr_ec commitment_hash_candidate = { .data = { 0U } };
17685
0
    Eurydice_arr_d2 commitment_serialized = { .data = { 0U } };
17686
0
    libcrux_ml_dsa_encoding_commitment_serialize_vector_37(LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_COMMITMENT_RING_ELEMENT_SIZE,
17687
0
      Eurydice_array_to_slice_shared_20(&commitment),
17688
0
      Eurydice_array_to_slice_mut_27(&commitment_serialized));
17689
0
    libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
17690
0
    shake = libcrux_ml_dsa_hash_functions_portable_init_26();
17691
0
    libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
17692
0
      Eurydice_array_to_slice_shared_17(&message_representative));
17693
0
    libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
17694
0
      Eurydice_array_to_slice_shared_27(&commitment_serialized));
17695
0
    libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
17696
0
      Eurydice_array_to_slice_mut_01(&commitment_hash_candidate));
17697
0
    Eurydice_arr_a3 verifier_challenge = libcrux_ml_dsa_polynomial_zero_ff_37();
17698
0
    libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(Eurydice_array_to_slice_shared_01(&commitment_hash_candidate),
17699
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ONES_IN_VERIFIER_CHALLENGE,
17700
0
      &verifier_challenge);
17701
0
    libcrux_ml_dsa_ntt_ntt_37(&verifier_challenge);
17702
0
    Eurydice_arr_9d
17703
0
    challenge_times_s1 =
17704
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)4U,
17705
0
        &s1_as_ntt,
17706
0
        Eurydice_arr_a3,
17707
0
        Eurydice_arr_9d);
17708
0
    Eurydice_arr_9d
17709
0
    challenge_times_s2 =
17710
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)4U,
17711
0
        &s2_as_ntt,
17712
0
        Eurydice_arr_a3,
17713
0
        Eurydice_arr_9d);
17714
0
    libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_201(&challenge_times_s1),
17715
0
      &verifier_challenge);
17716
0
    libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_201(&challenge_times_s2),
17717
0
      &verifier_challenge);
17718
0
    libcrux_ml_dsa_matrix_add_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17719
0
      Eurydice_array_to_slice_mut_201(&mask),
17720
0
      Eurydice_array_to_slice_shared_20(&challenge_times_s1));
17721
0
    libcrux_ml_dsa_matrix_subtract_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17722
0
      Eurydice_array_to_slice_mut_201(&w0),
17723
0
      Eurydice_array_to_slice_shared_20(&challenge_times_s2));
17724
0
    if
17725
0
    (
17726
0
      !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_20(&mask),
17727
0
        (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA1_EXPONENT) -
17728
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_BETA)
17729
0
    )
17730
0
    {
17731
0
      if
17732
0
      (
17733
0
        !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_20(&w0),
17734
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA2 - LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_BETA)
17735
0
      )
17736
0
      {
17737
0
        Eurydice_arr_9d
17738
0
        challenge_times_t0 =
17739
0
          core_array__core__clone__Clone_for__T__N___clone((size_t)4U,
17740
0
            &t0_as_ntt,
17741
0
            Eurydice_arr_a3,
17742
0
            Eurydice_arr_9d);
17743
0
        libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_201(&challenge_times_t0),
17744
0
          &verifier_challenge);
17745
0
        if
17746
0
        (
17747
0
          !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_20(&challenge_times_t0),
17748
0
            LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA2)
17749
0
        )
17750
0
        {
17751
0
          libcrux_ml_dsa_matrix_add_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17752
0
            Eurydice_array_to_slice_mut_201(&w0),
17753
0
            Eurydice_array_to_slice_shared_20(&challenge_times_t0));
17754
0
          Eurydice_arr_b7
17755
0
          hint_candidate =
17756
0
            {
17757
0
              .data = {
17758
0
                { .data = { 0U } },
17759
0
                { .data = { 0U } },
17760
0
                { .data = { 0U } },
17761
0
                { .data = { 0U } }
17762
0
              }
17763
0
            };
17764
0
          size_t
17765
0
          ones_in_hint =
17766
0
            libcrux_ml_dsa_arithmetic_make_hint_37(Eurydice_array_to_slice_shared_20(&w0),
17767
0
              Eurydice_array_to_slice_shared_20(&commitment),
17768
0
              LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA2,
17769
0
              Eurydice_array_to_slice_mut_86(&hint_candidate));
17770
0
          if (!(ones_in_hint > LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_MAX_ONES_IN_HINT))
17771
0
          {
17772
0
            attempt = LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN;
17773
0
            commitment_hash0 =
17774
0
              (
17775
0
                KRML_CLITERAL(core_option_Option_14){
17776
0
                  .tag = core_option_Some,
17777
0
                  .f0 = commitment_hash_candidate
17778
0
                }
17779
0
              );
17780
0
            signer_response0 =
17781
0
              (KRML_CLITERAL(core_option_Option_d9){ .tag = core_option_Some, .f0 = mask });
17782
0
            hint0 =
17783
0
              (
17784
0
                KRML_CLITERAL(core_option_Option_51){
17785
0
                  .tag = core_option_Some,
17786
0
                  .f0 = hint_candidate
17787
0
                }
17788
0
              );
17789
0
          }
17790
0
        }
17791
0
      }
17792
0
    }
17793
0
  }
17794
0
  core_result_Result_53 uu____5;
17795
0
  if (commitment_hash0.tag == core_option_None)
17796
0
  {
17797
0
    uu____5 =
17798
0
      (
17799
0
        KRML_CLITERAL(core_result_Result_53){
17800
0
          .tag = core_result_Err,
17801
0
          .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
17802
0
        }
17803
0
      );
17804
0
  }
17805
0
  else
17806
0
  {
17807
0
    Eurydice_arr_ec commitment_hash = commitment_hash0.f0;
17808
0
    Eurydice_arr_ec commitment_hash1 = commitment_hash;
17809
0
    if (signer_response0.tag == core_option_None)
17810
0
    {
17811
0
      uu____5 =
17812
0
        (
17813
0
          KRML_CLITERAL(core_result_Result_53){
17814
0
            .tag = core_result_Err,
17815
0
            .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
17816
0
          }
17817
0
        );
17818
0
    }
17819
0
    else
17820
0
    {
17821
0
      Eurydice_arr_9d signer_response = signer_response0.f0;
17822
0
      Eurydice_arr_9d signer_response1 = signer_response;
17823
0
      if (!(hint0.tag == core_option_None))
17824
0
      {
17825
0
        Eurydice_arr_b7 hint = hint0.f0;
17826
0
        Eurydice_arr_b7 hint1 = hint;
17827
0
        libcrux_ml_dsa_encoding_signature_serialize_37(Eurydice_array_to_slice_shared_01(&commitment_hash1),
17828
0
          Eurydice_array_to_slice_shared_20(&signer_response1),
17829
0
          Eurydice_array_to_slice_shared_86(&hint1),
17830
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COMMITMENT_HASH_SIZE,
17831
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
17832
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
17833
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA1_EXPONENT,
17834
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_GAMMA1_RING_ELEMENT_SIZE,
17835
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_MAX_ONES_IN_HINT,
17836
0
          Eurydice_array_to_slice_mut_0d(signature));
17837
0
        return (KRML_CLITERAL(core_result_Result_53){ .tag = core_result_Ok });
17838
0
      }
17839
0
      uu____5 =
17840
0
        (
17841
0
          KRML_CLITERAL(core_result_Result_53){
17842
0
            .tag = core_result_Err,
17843
0
            .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
17844
0
          }
17845
0
        );
17846
0
    }
17847
0
  }
17848
0
  return uu____5;
17849
0
}
17850
17851
/**
17852
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.sign_mut
17853
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
17854
with const generics
17855
17856
*/
17857
static KRML_MUSTINLINE core_result_Result_53
17858
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_mut_5a(
17859
  Eurydice_borrow_slice_u8 signing_key,
17860
  Eurydice_borrow_slice_u8 message,
17861
  Eurydice_borrow_slice_u8 context,
17862
  Eurydice_arr_ec randomness,
17863
  Eurydice_arr_85 *signature
17864
)
17865
0
{
17866
0
  core_result_Result_a8
17867
0
  uu____0 =
17868
0
    libcrux_ml_dsa_pre_hash_new_88(context,
17869
0
      (KRML_CLITERAL(core_option_Option_57){ .tag = core_option_None }));
17870
0
  if (!(uu____0.tag == core_result_Ok))
17871
0
  {
17872
0
    return
17873
0
      (
17874
0
        KRML_CLITERAL(core_result_Result_53){
17875
0
          .tag = core_result_Err,
17876
0
          .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
17877
0
        }
17878
0
      );
17879
0
  }
17880
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
17881
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
17882
0
  return
17883
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_internal_5a(signing_key,
17884
0
      message,
17885
0
      (
17886
0
        KRML_CLITERAL(core_option_Option_84){
17887
0
          .tag = core_option_Some,
17888
0
          .f0 = domain_separation_context
17889
0
        }
17890
0
      ),
17891
0
      randomness,
17892
0
      signature);
17893
0
}
17894
17895
/**
17896
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.sign
17897
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
17898
with const generics
17899
17900
*/
17901
static KRML_MUSTINLINE core_result_Result_48
17902
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_5a(
17903
  Eurydice_borrow_slice_u8 signing_key,
17904
  Eurydice_borrow_slice_u8 message,
17905
  Eurydice_borrow_slice_u8 context,
17906
  Eurydice_arr_ec randomness
17907
)
17908
0
{
17909
0
  Eurydice_arr_85 signature = libcrux_ml_dsa_types_zero_c5_37();
17910
0
  core_result_Result_53
17911
0
  uu____0 =
17912
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_mut_5a(signing_key,
17913
0
      message,
17914
0
      context,
17915
0
      randomness,
17916
0
      &signature);
17917
0
  core_result_Result_48 uu____1;
17918
0
  if (uu____0.tag == core_result_Ok)
17919
0
  {
17920
0
    uu____1 =
17921
0
      (
17922
0
        KRML_CLITERAL(core_result_Result_48){
17923
0
          .tag = core_result_Ok,
17924
0
          .val = { .case_Ok = signature }
17925
0
        }
17926
0
      );
17927
0
  }
17928
0
  else
17929
0
  {
17930
0
    libcrux_ml_dsa_types_SigningError e = uu____0.f0;
17931
0
    uu____1 =
17932
0
      (KRML_CLITERAL(core_result_Result_48){ .tag = core_result_Err, .val = { .case_Err = e } });
17933
0
  }
17934
0
  return uu____1;
17935
0
}
17936
17937
/**
17938
 Sign.
17939
*/
17940
static inline core_result_Result_48
17941
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_sign(
17942
  const Eurydice_arr_10 *signing_key,
17943
  Eurydice_borrow_slice_u8 message,
17944
  Eurydice_borrow_slice_u8 context,
17945
  Eurydice_arr_ec randomness
17946
)
17947
0
{
17948
0
  return
17949
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_5a(Eurydice_array_to_slice_shared_34(signing_key),
17950
0
      message,
17951
0
      context,
17952
0
      randomness);
17953
0
}
17954
17955
/**
17956
 Sign.
17957
*/
17958
static inline core_result_Result_53
17959
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_sign_mut(
17960
  const Eurydice_arr_10 *signing_key,
17961
  Eurydice_borrow_slice_u8 message,
17962
  Eurydice_borrow_slice_u8 context,
17963
  Eurydice_arr_ec randomness,
17964
  Eurydice_arr_85 *signature
17965
)
17966
0
{
17967
0
  return
17968
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_mut_5a(Eurydice_array_to_slice_shared_34(signing_key),
17969
0
      message,
17970
0
      context,
17971
0
      randomness,
17972
0
      signature);
17973
0
}
17974
17975
/**
17976
This function found in impl {libcrux_ml_dsa::pre_hash::PreHash for libcrux_ml_dsa::pre_hash::SHAKE128_PH}
17977
*/
17978
/**
17979
A monomorphic instance of libcrux_ml_dsa.pre_hash.hash_30
17980
with types libcrux_ml_dsa_hash_functions_portable_Shake128
17981
with const generics
17982
17983
*/
17984
static KRML_MUSTINLINE void
17985
libcrux_ml_dsa_pre_hash_hash_30_83(
17986
  Eurydice_borrow_slice_u8 message,
17987
  Eurydice_mut_borrow_slice_u8 output
17988
)
17989
0
{
17990
0
  libcrux_ml_dsa_hash_functions_portable_shake128_7b(message, output);
17991
0
}
17992
17993
/**
17994
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.sign_pre_hashed_mut
17995
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4, libcrux_ml_dsa_pre_hash_SHAKE128_PH
17996
with const generics
17997
17998
*/
17999
static KRML_MUSTINLINE core_result_Result_53
18000
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_pre_hashed_mut_3f(
18001
  Eurydice_borrow_slice_u8 signing_key,
18002
  Eurydice_borrow_slice_u8 message,
18003
  Eurydice_borrow_slice_u8 context,
18004
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
18005
  Eurydice_arr_ec randomness,
18006
  Eurydice_arr_85 *signature
18007
)
18008
0
{
18009
0
  if (!(context.meta > LIBCRUX_ML_DSA_CONSTANTS_CONTEXT_MAX_LEN))
18010
0
  {
18011
0
    libcrux_ml_dsa_pre_hash_hash_30_83(message, pre_hash_buffer);
18012
0
    core_result_Result_a8
18013
0
    uu____0 =
18014
0
      libcrux_ml_dsa_pre_hash_new_88(context,
18015
0
        (
18016
0
          KRML_CLITERAL(core_option_Option_57){
18017
0
            .tag = core_option_Some,
18018
0
            .f0 = libcrux_ml_dsa_pre_hash_oid_30()
18019
0
          }
18020
0
        ));
18021
0
    if (!(uu____0.tag == core_result_Ok))
18022
0
    {
18023
0
      return
18024
0
        (
18025
0
          KRML_CLITERAL(core_result_Result_53){
18026
0
            .tag = core_result_Err,
18027
0
            .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
18028
0
          }
18029
0
        );
18030
0
    }
18031
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
18032
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
18033
0
    return
18034
0
      libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_internal_5a(signing_key,
18035
0
        (
18036
0
          KRML_CLITERAL(Eurydice_borrow_slice_u8){
18037
0
            .ptr = pre_hash_buffer.ptr,
18038
0
            .meta = pre_hash_buffer.meta
18039
0
          }
18040
0
        ),
18041
0
        (
18042
0
          KRML_CLITERAL(core_option_Option_84){
18043
0
            .tag = core_option_Some,
18044
0
            .f0 = domain_separation_context
18045
0
          }
18046
0
        ),
18047
0
        randomness,
18048
0
        signature);
18049
0
  }
18050
0
  return
18051
0
    (
18052
0
      KRML_CLITERAL(core_result_Result_53){
18053
0
        .tag = core_result_Err,
18054
0
        .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
18055
0
      }
18056
0
    );
18057
0
}
18058
18059
/**
18060
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.sign_pre_hashed
18061
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4, libcrux_ml_dsa_pre_hash_SHAKE128_PH
18062
with const generics
18063
18064
*/
18065
static KRML_MUSTINLINE core_result_Result_48
18066
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_pre_hashed_3f(
18067
  Eurydice_borrow_slice_u8 signing_key,
18068
  Eurydice_borrow_slice_u8 message,
18069
  Eurydice_borrow_slice_u8 context,
18070
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
18071
  Eurydice_arr_ec randomness
18072
)
18073
0
{
18074
0
  Eurydice_arr_85 signature = libcrux_ml_dsa_types_zero_c5_37();
18075
0
  core_result_Result_53
18076
0
  uu____0 =
18077
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_pre_hashed_mut_3f(signing_key,
18078
0
      message,
18079
0
      context,
18080
0
      pre_hash_buffer,
18081
0
      randomness,
18082
0
      &signature);
18083
0
  core_result_Result_48 uu____1;
18084
0
  if (uu____0.tag == core_result_Ok)
18085
0
  {
18086
0
    uu____1 =
18087
0
      (
18088
0
        KRML_CLITERAL(core_result_Result_48){
18089
0
          .tag = core_result_Ok,
18090
0
          .val = { .case_Ok = signature }
18091
0
        }
18092
0
      );
18093
0
  }
18094
0
  else
18095
0
  {
18096
0
    libcrux_ml_dsa_types_SigningError e = uu____0.f0;
18097
0
    uu____1 =
18098
0
      (KRML_CLITERAL(core_result_Result_48){ .tag = core_result_Err, .val = { .case_Err = e } });
18099
0
  }
18100
0
  return uu____1;
18101
0
}
18102
18103
/**
18104
 Sign (pre-hashed).
18105
*/
18106
static inline core_result_Result_48
18107
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_sign_pre_hashed_shake128(
18108
  const Eurydice_arr_10 *signing_key,
18109
  Eurydice_borrow_slice_u8 message,
18110
  Eurydice_borrow_slice_u8 context,
18111
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
18112
  Eurydice_arr_ec randomness
18113
)
18114
0
{
18115
0
  return
18116
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_sign_pre_hashed_3f(Eurydice_array_to_slice_shared_34(signing_key),
18117
0
      message,
18118
0
      context,
18119
0
      pre_hash_buffer,
18120
0
      randomness);
18121
0
}
18122
18123
/**
18124
 The internal verification API.
18125
18126
 If no `domain_separation_context` is supplied, it is assumed that
18127
 `message` already contains the domain separation.
18128
*/
18129
/**
18130
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.verify_internal
18131
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof
18132
with const generics
18133
18134
*/
18135
static KRML_MUSTINLINE core_result_Result_41
18136
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_internal_5a(
18137
  const Eurydice_arr_02 *verification_key,
18138
  Eurydice_borrow_slice_u8 message,
18139
  core_option_Option_84 domain_separation_context,
18140
  const Eurydice_arr_85 *signature_serialized
18141
)
18142
0
{
18143
0
  Eurydice_borrow_slice_u8_x2
18144
0
  uu____0 =
18145
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_9f(verification_key),
18146
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
18147
0
      uint8_t,
18148
0
      Eurydice_borrow_slice_u8_x2);
18149
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
18150
0
  Eurydice_borrow_slice_u8 t1_serialized = uu____0.snd;
18151
0
  Eurydice_arr_9d t1;
18152
0
  Eurydice_arr_a3 repeat_expression0[4U];
18153
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
18154
0
  {
18155
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18156
0
  }
18157
0
  memcpy(t1.data, repeat_expression0, (size_t)4U * sizeof (Eurydice_arr_a3));
18158
0
  libcrux_ml_dsa_encoding_verification_key_deserialize_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
18159
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_VERIFICATION_KEY_SIZE,
18160
0
    t1_serialized,
18161
0
    Eurydice_array_to_slice_mut_201(&t1));
18162
0
  Eurydice_arr_ec deserialized_commitment_hash = { .data = { 0U } };
18163
0
  Eurydice_arr_9d deserialized_signer_response;
18164
0
  Eurydice_arr_a3 repeat_expression1[4U];
18165
0
  for (size_t i = (size_t)0U; i < (size_t)4U; i++)
18166
0
  {
18167
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18168
0
  }
18169
0
  memcpy(deserialized_signer_response.data,
18170
0
    repeat_expression1,
18171
0
    (size_t)4U * sizeof (Eurydice_arr_a3));
18172
0
  Eurydice_arr_b7
18173
0
  deserialized_hint =
18174
0
    { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
18175
0
  core_result_Result_41
18176
0
  uu____1 =
18177
0
    libcrux_ml_dsa_encoding_signature_deserialize_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
18178
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
18179
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COMMITMENT_HASH_SIZE,
18180
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA1_EXPONENT,
18181
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_GAMMA1_RING_ELEMENT_SIZE,
18182
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_MAX_ONES_IN_HINT,
18183
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_SIGNATURE_SIZE,
18184
0
      Eurydice_array_to_slice_shared_0d(signature_serialized),
18185
0
      Eurydice_array_to_slice_mut_01(&deserialized_commitment_hash),
18186
0
      Eurydice_array_to_slice_mut_201(&deserialized_signer_response),
18187
0
      Eurydice_array_to_slice_mut_86(&deserialized_hint));
18188
0
  core_result_Result_41 uu____2;
18189
0
  if (uu____1.tag == core_result_Ok)
18190
0
  {
18191
0
    if
18192
0
    (
18193
0
      libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_20(&deserialized_signer_response),
18194
0
        (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA1_EXPONENT) -
18195
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_BETA)
18196
0
    )
18197
0
    {
18198
0
      uu____2 =
18199
0
        (
18200
0
          KRML_CLITERAL(core_result_Result_41){
18201
0
            .tag = core_result_Err,
18202
0
            .f0 = libcrux_ml_dsa_types_VerificationError_SignerResponseExceedsBoundError
18203
0
          }
18204
0
        );
18205
0
    }
18206
0
    else
18207
0
    {
18208
0
      Eurydice_arr_2f matrix;
18209
0
      Eurydice_arr_a3 repeat_expression[16U];
18210
0
      for (size_t i = (size_t)0U; i < (size_t)16U; i++)
18211
0
      {
18212
0
        repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18213
0
      }
18214
0
      memcpy(matrix.data, repeat_expression, (size_t)16U * sizeof (Eurydice_arr_a3));
18215
0
      libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
18216
0
        seed_for_a,
18217
0
        Eurydice_array_to_slice_mut_200(&matrix));
18218
0
      Eurydice_arr_c7 verification_key_hash = { .data = { 0U } };
18219
0
      libcrux_ml_dsa_hash_functions_portable_shake256_61_c9(Eurydice_array_to_slice_shared_9f(verification_key),
18220
0
        &verification_key_hash);
18221
0
      Eurydice_arr_c7 message_representative = { .data = { 0U } };
18222
0
      libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(Eurydice_array_to_slice_shared_17(&verification_key_hash),
18223
0
        &domain_separation_context,
18224
0
        message,
18225
0
        &message_representative);
18226
0
      Eurydice_arr_a3 verifier_challenge = libcrux_ml_dsa_polynomial_zero_ff_37();
18227
0
      libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(Eurydice_array_to_slice_shared_01(&deserialized_commitment_hash),
18228
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ONES_IN_VERIFIER_CHALLENGE,
18229
0
        &verifier_challenge);
18230
0
      libcrux_ml_dsa_ntt_ntt_37(&verifier_challenge);
18231
0
      for (size_t i = (size_t)0U; i < (size_t)4U; i++)
18232
0
      {
18233
0
        size_t i0 = i;
18234
0
        libcrux_ml_dsa_ntt_ntt_37(&deserialized_signer_response.data[i0]);
18235
0
      }
18236
0
      libcrux_ml_dsa_matrix_compute_w_approx_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_ROWS_IN_A,
18237
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_COLUMNS_IN_A,
18238
0
        Eurydice_array_to_slice_shared_201(&matrix),
18239
0
        Eurydice_array_to_slice_shared_20(&deserialized_signer_response),
18240
0
        &verifier_challenge,
18241
0
        Eurydice_array_to_slice_mut_201(&t1));
18242
0
      Eurydice_arr_ec recomputed_commitment_hash = { .data = { 0U } };
18243
0
      libcrux_ml_dsa_arithmetic_use_hint_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_44_GAMMA2,
18244
0
        Eurydice_array_to_slice_shared_86(&deserialized_hint),
18245
0
        Eurydice_array_to_slice_mut_201(&t1));
18246
0
      Eurydice_arr_d2 commitment_serialized = { .data = { 0U } };
18247
0
      libcrux_ml_dsa_encoding_commitment_serialize_vector_37(LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_44_COMMITMENT_RING_ELEMENT_SIZE,
18248
0
        Eurydice_array_to_slice_shared_20(&t1),
18249
0
        Eurydice_array_to_slice_mut_27(&commitment_serialized));
18250
0
      libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
18251
0
      shake = libcrux_ml_dsa_hash_functions_portable_init_26();
18252
0
      libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
18253
0
        Eurydice_array_to_slice_shared_17(&message_representative));
18254
0
      libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
18255
0
        Eurydice_array_to_slice_shared_27(&commitment_serialized));
18256
0
      libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
18257
0
        Eurydice_array_to_slice_mut_01(&recomputed_commitment_hash));
18258
0
      if
18259
0
      (
18260
0
        Eurydice_array_eq((size_t)32U,
18261
0
          &deserialized_commitment_hash,
18262
0
          &recomputed_commitment_hash,
18263
0
          uint8_t)
18264
0
      )
18265
0
      {
18266
0
        uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Ok });
18267
0
      }
18268
0
      else
18269
0
      {
18270
0
        uu____2 =
18271
0
          (
18272
0
            KRML_CLITERAL(core_result_Result_41){
18273
0
              .tag = core_result_Err,
18274
0
              .f0 = libcrux_ml_dsa_types_VerificationError_CommitmentHashesDontMatchError
18275
0
            }
18276
0
          );
18277
0
      }
18278
0
    }
18279
0
  }
18280
0
  else
18281
0
  {
18282
0
    libcrux_ml_dsa_types_VerificationError e = uu____1.f0;
18283
0
    uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Err, .f0 = e });
18284
0
  }
18285
0
  return uu____2;
18286
0
}
18287
18288
/**
18289
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.verify
18290
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof
18291
with const generics
18292
18293
*/
18294
static KRML_MUSTINLINE core_result_Result_41
18295
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_5a(
18296
  const Eurydice_arr_02 *verification_key_serialized,
18297
  Eurydice_borrow_slice_u8 message,
18298
  Eurydice_borrow_slice_u8 context,
18299
  const Eurydice_arr_85 *signature_serialized
18300
)
18301
0
{
18302
0
  core_result_Result_a8
18303
0
  uu____0 =
18304
0
    libcrux_ml_dsa_pre_hash_new_88(context,
18305
0
      (KRML_CLITERAL(core_option_Option_57){ .tag = core_option_None }));
18306
0
  if (!(uu____0.tag == core_result_Ok))
18307
0
  {
18308
0
    return
18309
0
      (
18310
0
        KRML_CLITERAL(core_result_Result_41){
18311
0
          .tag = core_result_Err,
18312
0
          .f0 = libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError
18313
0
        }
18314
0
      );
18315
0
  }
18316
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
18317
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
18318
0
  return
18319
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_internal_5a(verification_key_serialized,
18320
0
      message,
18321
0
      (
18322
0
        KRML_CLITERAL(core_option_Option_84){
18323
0
          .tag = core_option_Some,
18324
0
          .f0 = domain_separation_context
18325
0
        }
18326
0
      ),
18327
0
      signature_serialized);
18328
0
}
18329
18330
/**
18331
 Verify.
18332
*/
18333
static inline core_result_Result_41
18334
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_verify(
18335
  const Eurydice_arr_02 *verification_key,
18336
  Eurydice_borrow_slice_u8 message,
18337
  Eurydice_borrow_slice_u8 context,
18338
  const Eurydice_arr_85 *signature
18339
)
18340
0
{
18341
0
  return
18342
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_5a(verification_key,
18343
0
      message,
18344
0
      context,
18345
0
      signature);
18346
0
}
18347
18348
/**
18349
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_44.verify_pre_hashed
18350
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_pre_hash_SHAKE128_PH
18351
with const generics
18352
18353
*/
18354
static KRML_MUSTINLINE core_result_Result_41
18355
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_pre_hashed_3f(
18356
  const Eurydice_arr_02 *verification_key_serialized,
18357
  Eurydice_borrow_slice_u8 message,
18358
  Eurydice_borrow_slice_u8 context,
18359
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
18360
  const Eurydice_arr_85 *signature_serialized
18361
)
18362
0
{
18363
0
  libcrux_ml_dsa_pre_hash_hash_30_83(message, pre_hash_buffer);
18364
0
  core_result_Result_a8
18365
0
  uu____0 =
18366
0
    libcrux_ml_dsa_pre_hash_new_88(context,
18367
0
      (
18368
0
        KRML_CLITERAL(core_option_Option_57){
18369
0
          .tag = core_option_Some,
18370
0
          .f0 = libcrux_ml_dsa_pre_hash_oid_30()
18371
0
        }
18372
0
      ));
18373
0
  if (!(uu____0.tag == core_result_Ok))
18374
0
  {
18375
0
    return
18376
0
      (
18377
0
        KRML_CLITERAL(core_result_Result_41){
18378
0
          .tag = core_result_Err,
18379
0
          .f0 = libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError
18380
0
        }
18381
0
      );
18382
0
  }
18383
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
18384
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
18385
0
  return
18386
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_internal_5a(verification_key_serialized,
18387
0
      (
18388
0
        KRML_CLITERAL(Eurydice_borrow_slice_u8){
18389
0
          .ptr = pre_hash_buffer.ptr,
18390
0
          .meta = pre_hash_buffer.meta
18391
0
        }
18392
0
      ),
18393
0
      (
18394
0
        KRML_CLITERAL(core_option_Option_84){
18395
0
          .tag = core_option_Some,
18396
0
          .f0 = domain_separation_context
18397
0
        }
18398
0
      ),
18399
0
      signature_serialized);
18400
0
}
18401
18402
/**
18403
 Verify (pre-hashed with SHAKE-128).
18404
*/
18405
static inline core_result_Result_41
18406
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_verify_pre_hashed_shake128(
18407
  const Eurydice_arr_02 *verification_key,
18408
  Eurydice_borrow_slice_u8 message,
18409
  Eurydice_borrow_slice_u8 context,
18410
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
18411
  const Eurydice_arr_85 *signature
18412
)
18413
0
{
18414
0
  return
18415
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_verify_pre_hashed_3f(verification_key,
18416
0
      message,
18417
0
      context,
18418
0
      pre_hash_buffer,
18419
0
      signature);
18420
0
}
18421
18422
/**
18423
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.generate_key_pair
18424
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
18425
with const generics
18426
18427
*/
18428
static KRML_MUSTINLINE void
18429
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_generate_key_pair_5a(
18430
  Eurydice_arr_ec randomness,
18431
  Eurydice_mut_borrow_slice_u8 signing_key,
18432
  Eurydice_mut_borrow_slice_u8 verification_key
18433
)
18434
0
{
18435
0
  Eurydice_arr_89 seed_expanded0 = { .data = { 0U } };
18436
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
18437
0
  shake = libcrux_ml_dsa_hash_functions_portable_init_26();
18438
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
18439
0
    Eurydice_array_to_slice_shared_01(&randomness));
18440
0
  /* original Rust expression is not an lvalue in C */
18441
0
  Eurydice_array_u8x2
18442
0
  lvalue =
18443
0
    {
18444
0
      .data = {
18445
0
        (uint8_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18446
0
        (uint8_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A
18447
0
      }
18448
0
    };
18449
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
18450
0
    Eurydice_array_to_slice_shared_82(&lvalue));
18451
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
18452
0
    Eurydice_array_to_slice_mut_78(&seed_expanded0));
18453
0
  Eurydice_borrow_slice_u8_x2
18454
0
  uu____0 =
18455
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_78(&seed_expanded0),
18456
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
18457
0
      uint8_t,
18458
0
      Eurydice_borrow_slice_u8_x2);
18459
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
18460
0
  Eurydice_borrow_slice_u8 seed_expanded = uu____0.snd;
18461
0
  Eurydice_borrow_slice_u8_x2
18462
0
  uu____1 =
18463
0
    Eurydice_slice_split_at(seed_expanded,
18464
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_ERROR_VECTORS_SIZE,
18465
0
      uint8_t,
18466
0
      Eurydice_borrow_slice_u8_x2);
18467
0
  Eurydice_borrow_slice_u8 seed_for_error_vectors = uu____1.fst;
18468
0
  Eurydice_borrow_slice_u8 seed_for_signing = uu____1.snd;
18469
0
  Eurydice_arr_47 s1_s2;
18470
0
  Eurydice_arr_a3 repeat_expression0[11U];
18471
0
  for (size_t i = (size_t)0U; i < (size_t)11U; i++)
18472
0
  {
18473
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18474
0
  }
18475
0
  memcpy(s1_s2.data, repeat_expression0, (size_t)11U * sizeof (Eurydice_arr_a3));
18476
0
  libcrux_ml_dsa_samplex4_sample_s1_and_s2_29(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ETA,
18477
0
    seed_for_error_vectors,
18478
0
    Eurydice_array_to_slice_mut_202(&s1_s2));
18479
0
  Eurydice_arr_dc1 t0;
18480
0
  Eurydice_arr_a3 repeat_expression1[6U];
18481
0
  for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18482
0
  {
18483
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18484
0
  }
18485
0
  memcpy(t0.data, repeat_expression1, (size_t)6U * sizeof (Eurydice_arr_a3));
18486
0
  Eurydice_arr_5a a_as_ntt;
18487
0
  Eurydice_arr_a3 repeat_expression2[30U];
18488
0
  for (size_t i = (size_t)0U; i < (size_t)30U; i++)
18489
0
  {
18490
0
    repeat_expression2[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18491
0
  }
18492
0
  memcpy(a_as_ntt.data, repeat_expression2, (size_t)30U * sizeof (Eurydice_arr_a3));
18493
0
  libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18494
0
    seed_for_a,
18495
0
    Eurydice_array_to_slice_mut_203(&a_as_ntt));
18496
0
  Eurydice_arr_5d s1_ntt;
18497
0
  Eurydice_arr_a3 repeat_expression3[5U];
18498
0
  for (size_t i = (size_t)0U; i < (size_t)5U; i++)
18499
0
  {
18500
0
    repeat_expression3[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18501
0
  }
18502
0
  memcpy(s1_ntt.data, repeat_expression3, (size_t)5U * sizeof (Eurydice_arr_a3));
18503
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_204(&s1_ntt),
18504
0
    Eurydice_array_to_subslice_shared_250(&s1_s2,
18505
0
      (
18506
0
        KRML_CLITERAL(core_ops_range_Range_87){
18507
0
          .start = (size_t)0U,
18508
0
          .end = LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A
18509
0
        }
18510
0
      )),
18511
0
    Eurydice_arr_a3);
18512
0
  for (size_t i = (size_t)0U; i < (size_t)5U; i++)
18513
0
  {
18514
0
    size_t i0 = i;
18515
0
    libcrux_ml_dsa_ntt_ntt_37(&s1_ntt.data[i0]);
18516
0
  }
18517
0
  libcrux_ml_dsa_matrix_compute_as1_plus_s2_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18518
0
    LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18519
0
    Eurydice_array_to_slice_mut_203(&a_as_ntt),
18520
0
    Eurydice_array_to_slice_shared_202(&s1_ntt),
18521
0
    Eurydice_array_to_slice_shared_203(&s1_s2),
18522
0
    Eurydice_array_to_slice_mut_205(&t0));
18523
0
  Eurydice_arr_dc1 t1;
18524
0
  Eurydice_arr_a3 repeat_expression[6U];
18525
0
  for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18526
0
  {
18527
0
    repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18528
0
  }
18529
0
  memcpy(t1.data, repeat_expression, (size_t)6U * sizeof (Eurydice_arr_a3));
18530
0
  libcrux_ml_dsa_arithmetic_power2round_vector_37(Eurydice_array_to_slice_mut_205(&t0),
18531
0
    Eurydice_array_to_slice_mut_205(&t1));
18532
0
  libcrux_ml_dsa_encoding_verification_key_generate_serialized_37(seed_for_a,
18533
0
    Eurydice_array_to_slice_shared_204(&t1),
18534
0
    verification_key);
18535
0
  libcrux_ml_dsa_encoding_signing_key_generate_serialized_2e(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ETA,
18536
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE,
18537
0
    seed_for_a,
18538
0
    seed_for_signing,
18539
0
    (
18540
0
      KRML_CLITERAL(Eurydice_borrow_slice_u8){
18541
0
        .ptr = verification_key.ptr,
18542
0
        .meta = verification_key.meta
18543
0
      }
18544
0
    ),
18545
0
    Eurydice_array_to_slice_shared_203(&s1_s2),
18546
0
    Eurydice_array_to_slice_shared_204(&t0),
18547
0
    signing_key);
18548
0
}
18549
18550
/**
18551
 Generate key pair.
18552
*/
18553
static inline void
18554
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_generate_key_pair(
18555
  Eurydice_arr_ec randomness,
18556
  Eurydice_arr_24 *signing_key,
18557
  Eurydice_arr_29 *verification_key
18558
)
18559
0
{
18560
0
  libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_generate_key_pair_5a(randomness,
18561
0
    Eurydice_array_to_slice_mut_98(signing_key),
18562
0
    Eurydice_array_to_slice_mut_37(verification_key));
18563
0
}
18564
18565
/**
18566
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.sign_internal
18567
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
18568
with const generics
18569
18570
*/
18571
static KRML_MUSTINLINE core_result_Result_53
18572
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_internal_5a(
18573
  Eurydice_borrow_slice_u8 signing_key,
18574
  Eurydice_borrow_slice_u8 message,
18575
  core_option_Option_84 domain_separation_context,
18576
  Eurydice_arr_ec randomness,
18577
  Eurydice_arr_0c *signature
18578
)
18579
0
{
18580
0
  Eurydice_borrow_slice_u8_x2
18581
0
  uu____0 =
18582
0
    Eurydice_slice_split_at(signing_key,
18583
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
18584
0
      uint8_t,
18585
0
      Eurydice_borrow_slice_u8_x2);
18586
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
18587
0
  Eurydice_borrow_slice_u8 remaining_serialized0 = uu____0.snd;
18588
0
  Eurydice_borrow_slice_u8_x2
18589
0
  uu____1 =
18590
0
    Eurydice_slice_split_at(remaining_serialized0,
18591
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE,
18592
0
      uint8_t,
18593
0
      Eurydice_borrow_slice_u8_x2);
18594
0
  Eurydice_borrow_slice_u8 seed_for_signing = uu____1.fst;
18595
0
  Eurydice_borrow_slice_u8 remaining_serialized1 = uu____1.snd;
18596
0
  Eurydice_borrow_slice_u8_x2
18597
0
  uu____2 =
18598
0
    Eurydice_slice_split_at(remaining_serialized1,
18599
0
      LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH,
18600
0
      uint8_t,
18601
0
      Eurydice_borrow_slice_u8_x2);
18602
0
  Eurydice_borrow_slice_u8 verification_key_hash = uu____2.fst;
18603
0
  Eurydice_borrow_slice_u8 remaining_serialized2 = uu____2.snd;
18604
0
  Eurydice_borrow_slice_u8_x2
18605
0
  uu____3 =
18606
0
    Eurydice_slice_split_at(remaining_serialized2,
18607
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE *
18608
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18609
0
      uint8_t,
18610
0
      Eurydice_borrow_slice_u8_x2);
18611
0
  Eurydice_borrow_slice_u8 s1_serialized = uu____3.fst;
18612
0
  Eurydice_borrow_slice_u8 remaining_serialized = uu____3.snd;
18613
0
  Eurydice_borrow_slice_u8_x2
18614
0
  uu____4 =
18615
0
    Eurydice_slice_split_at(remaining_serialized,
18616
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE *
18617
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18618
0
      uint8_t,
18619
0
      Eurydice_borrow_slice_u8_x2);
18620
0
  Eurydice_borrow_slice_u8 s2_serialized = uu____4.fst;
18621
0
  Eurydice_borrow_slice_u8 t0_serialized = uu____4.snd;
18622
0
  Eurydice_arr_5d s1_as_ntt;
18623
0
  Eurydice_arr_a3 repeat_expression0[5U];
18624
0
  for (size_t i = (size_t)0U; i < (size_t)5U; i++)
18625
0
  {
18626
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18627
0
  }
18628
0
  memcpy(s1_as_ntt.data, repeat_expression0, (size_t)5U * sizeof (Eurydice_arr_a3));
18629
0
  Eurydice_arr_dc1 s2_as_ntt;
18630
0
  Eurydice_arr_a3 repeat_expression1[6U];
18631
0
  for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18632
0
  {
18633
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18634
0
  }
18635
0
  memcpy(s2_as_ntt.data, repeat_expression1, (size_t)6U * sizeof (Eurydice_arr_a3));
18636
0
  Eurydice_arr_dc1 t0_as_ntt;
18637
0
  Eurydice_arr_a3 repeat_expression2[6U];
18638
0
  for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18639
0
  {
18640
0
    repeat_expression2[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18641
0
  }
18642
0
  memcpy(t0_as_ntt.data, repeat_expression2, (size_t)6U * sizeof (Eurydice_arr_a3));
18643
0
  libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ETA,
18644
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE,
18645
0
    s1_serialized,
18646
0
    Eurydice_array_to_slice_mut_204(&s1_as_ntt));
18647
0
  libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ETA,
18648
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_ERROR_RING_ELEMENT_SIZE,
18649
0
    s2_serialized,
18650
0
    Eurydice_array_to_slice_mut_205(&s2_as_ntt));
18651
0
  libcrux_ml_dsa_encoding_t0_deserialize_to_vector_then_ntt_37(t0_serialized,
18652
0
    Eurydice_array_to_slice_mut_205(&t0_as_ntt));
18653
0
  Eurydice_arr_5a matrix;
18654
0
  Eurydice_arr_a3 repeat_expression3[30U];
18655
0
  for (size_t i = (size_t)0U; i < (size_t)30U; i++)
18656
0
  {
18657
0
    repeat_expression3[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18658
0
  }
18659
0
  memcpy(matrix.data, repeat_expression3, (size_t)30U * sizeof (Eurydice_arr_a3));
18660
0
  libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18661
0
    seed_for_a,
18662
0
    Eurydice_array_to_slice_mut_203(&matrix));
18663
0
  Eurydice_arr_c7 message_representative = { .data = { 0U } };
18664
0
  libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(verification_key_hash,
18665
0
    &domain_separation_context,
18666
0
    message,
18667
0
    &message_representative);
18668
0
  Eurydice_arr_c7 mask_seed = { .data = { 0U } };
18669
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
18670
0
  shake0 = libcrux_ml_dsa_hash_functions_portable_init_26();
18671
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake0, seed_for_signing);
18672
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake0,
18673
0
    Eurydice_array_to_slice_shared_01(&randomness));
18674
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake0,
18675
0
    Eurydice_array_to_slice_shared_17(&message_representative));
18676
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake0,
18677
0
    Eurydice_array_to_slice_mut_17(&mask_seed));
18678
0
  uint16_t domain_separator_for_mask = 0U;
18679
0
  size_t attempt = (size_t)0U;
18680
0
  core_option_Option_81 commitment_hash0 = { .tag = core_option_None };
18681
0
  core_option_Option_1e signer_response0 = { .tag = core_option_None };
18682
0
  core_option_Option_05 hint0 = { .tag = core_option_None };
18683
0
  while (attempt < LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN)
18684
0
  {
18685
0
    attempt++;
18686
0
    Eurydice_arr_5d mask;
18687
0
    Eurydice_arr_a3 repeat_expression4[5U];
18688
0
    for (size_t i = (size_t)0U; i < (size_t)5U; i++)
18689
0
    {
18690
0
      repeat_expression4[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18691
0
    }
18692
0
    memcpy(mask.data, repeat_expression4, (size_t)5U * sizeof (Eurydice_arr_a3));
18693
0
    Eurydice_arr_dc1 w0;
18694
0
    Eurydice_arr_a3 repeat_expression5[6U];
18695
0
    for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18696
0
    {
18697
0
      repeat_expression5[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18698
0
    }
18699
0
    memcpy(w0.data, repeat_expression5, (size_t)6U * sizeof (Eurydice_arr_a3));
18700
0
    Eurydice_arr_dc1 commitment;
18701
0
    Eurydice_arr_a3 repeat_expression6[6U];
18702
0
    for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18703
0
    {
18704
0
      repeat_expression6[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18705
0
    }
18706
0
    memcpy(commitment.data, repeat_expression6, (size_t)6U * sizeof (Eurydice_arr_a3));
18707
0
    libcrux_ml_dsa_sample_sample_mask_vector_67(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18708
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA1_EXPONENT,
18709
0
      &mask_seed,
18710
0
      &domain_separator_for_mask,
18711
0
      Eurydice_array_to_slice_mut_204(&mask));
18712
0
    Eurydice_arr_dc1 a_x_mask;
18713
0
    Eurydice_arr_a3 repeat_expression[6U];
18714
0
    for (size_t i = (size_t)0U; i < (size_t)6U; i++)
18715
0
    {
18716
0
      repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
18717
0
    }
18718
0
    memcpy(a_x_mask.data, repeat_expression, (size_t)6U * sizeof (Eurydice_arr_a3));
18719
0
    Eurydice_arr_5d
18720
0
    mask_ntt =
18721
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)5U,
18722
0
        &mask,
18723
0
        Eurydice_arr_a3,
18724
0
        Eurydice_arr_5d);
18725
0
    for (size_t i = (size_t)0U; i < (size_t)5U; i++)
18726
0
    {
18727
0
      size_t i0 = i;
18728
0
      libcrux_ml_dsa_ntt_ntt_37(&mask_ntt.data[i0]);
18729
0
    }
18730
0
    libcrux_ml_dsa_matrix_compute_matrix_x_mask_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18731
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18732
0
      Eurydice_array_to_slice_shared_205(&matrix),
18733
0
      Eurydice_array_to_slice_shared_202(&mask_ntt),
18734
0
      Eurydice_array_to_slice_mut_205(&a_x_mask));
18735
0
    libcrux_ml_dsa_arithmetic_decompose_vector_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18736
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA2,
18737
0
      Eurydice_array_to_slice_shared_204(&a_x_mask),
18738
0
      Eurydice_array_to_slice_mut_205(&w0),
18739
0
      Eurydice_array_to_slice_mut_205(&commitment));
18740
0
    Eurydice_arr_65 commitment_hash_candidate = { .data = { 0U } };
18741
0
    Eurydice_arr_d2 commitment_serialized = { .data = { 0U } };
18742
0
    libcrux_ml_dsa_encoding_commitment_serialize_vector_37(LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_COMMITMENT_RING_ELEMENT_SIZE,
18743
0
      Eurydice_array_to_slice_shared_204(&commitment),
18744
0
      Eurydice_array_to_slice_mut_27(&commitment_serialized));
18745
0
    libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
18746
0
    shake = libcrux_ml_dsa_hash_functions_portable_init_26();
18747
0
    libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
18748
0
      Eurydice_array_to_slice_shared_17(&message_representative));
18749
0
    libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
18750
0
      Eurydice_array_to_slice_shared_27(&commitment_serialized));
18751
0
    libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
18752
0
      Eurydice_array_to_slice_mut_9f(&commitment_hash_candidate));
18753
0
    Eurydice_arr_a3 verifier_challenge = libcrux_ml_dsa_polynomial_zero_ff_37();
18754
0
    libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(Eurydice_array_to_slice_shared_9f0(&commitment_hash_candidate),
18755
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ONES_IN_VERIFIER_CHALLENGE,
18756
0
      &verifier_challenge);
18757
0
    libcrux_ml_dsa_ntt_ntt_37(&verifier_challenge);
18758
0
    Eurydice_arr_5d
18759
0
    challenge_times_s1 =
18760
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)5U,
18761
0
        &s1_as_ntt,
18762
0
        Eurydice_arr_a3,
18763
0
        Eurydice_arr_5d);
18764
0
    Eurydice_arr_dc1
18765
0
    challenge_times_s2 =
18766
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)6U,
18767
0
        &s2_as_ntt,
18768
0
        Eurydice_arr_a3,
18769
0
        Eurydice_arr_dc1);
18770
0
    libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_204(&challenge_times_s1),
18771
0
      &verifier_challenge);
18772
0
    libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_205(&challenge_times_s2),
18773
0
      &verifier_challenge);
18774
0
    libcrux_ml_dsa_matrix_add_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18775
0
      Eurydice_array_to_slice_mut_204(&mask),
18776
0
      Eurydice_array_to_slice_shared_202(&challenge_times_s1));
18777
0
    libcrux_ml_dsa_matrix_subtract_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18778
0
      Eurydice_array_to_slice_mut_205(&w0),
18779
0
      Eurydice_array_to_slice_shared_204(&challenge_times_s2));
18780
0
    if
18781
0
    (
18782
0
      !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_202(&mask),
18783
0
        (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA1_EXPONENT) -
18784
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_BETA)
18785
0
    )
18786
0
    {
18787
0
      if
18788
0
      (
18789
0
        !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_204(&w0),
18790
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA2 - LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_BETA)
18791
0
      )
18792
0
      {
18793
0
        Eurydice_arr_dc1
18794
0
        challenge_times_t0 =
18795
0
          core_array__core__clone__Clone_for__T__N___clone((size_t)6U,
18796
0
            &t0_as_ntt,
18797
0
            Eurydice_arr_a3,
18798
0
            Eurydice_arr_dc1);
18799
0
        libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_205(&challenge_times_t0),
18800
0
          &verifier_challenge);
18801
0
        if
18802
0
        (
18803
0
          !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_204(&challenge_times_t0),
18804
0
            LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA2)
18805
0
        )
18806
0
        {
18807
0
          libcrux_ml_dsa_matrix_add_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18808
0
            Eurydice_array_to_slice_mut_205(&w0),
18809
0
            Eurydice_array_to_slice_shared_204(&challenge_times_t0));
18810
0
          Eurydice_arr_5d0
18811
0
          hint_candidate =
18812
0
            {
18813
0
              .data = {
18814
0
                { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } },
18815
0
                { .data = { 0U } }, { .data = { 0U } }
18816
0
              }
18817
0
            };
18818
0
          size_t
18819
0
          ones_in_hint =
18820
0
            libcrux_ml_dsa_arithmetic_make_hint_37(Eurydice_array_to_slice_shared_204(&w0),
18821
0
              Eurydice_array_to_slice_shared_204(&commitment),
18822
0
              LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA2,
18823
0
              Eurydice_array_to_slice_mut_860(&hint_candidate));
18824
0
          if (!(ones_in_hint > LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_MAX_ONES_IN_HINT))
18825
0
          {
18826
0
            attempt = LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN;
18827
0
            commitment_hash0 =
18828
0
              (
18829
0
                KRML_CLITERAL(core_option_Option_81){
18830
0
                  .tag = core_option_Some,
18831
0
                  .f0 = commitment_hash_candidate
18832
0
                }
18833
0
              );
18834
0
            signer_response0 =
18835
0
              (KRML_CLITERAL(core_option_Option_1e){ .tag = core_option_Some, .f0 = mask });
18836
0
            hint0 =
18837
0
              (
18838
0
                KRML_CLITERAL(core_option_Option_05){
18839
0
                  .tag = core_option_Some,
18840
0
                  .f0 = hint_candidate
18841
0
                }
18842
0
              );
18843
0
          }
18844
0
        }
18845
0
      }
18846
0
    }
18847
0
  }
18848
0
  core_result_Result_53 uu____5;
18849
0
  if (commitment_hash0.tag == core_option_None)
18850
0
  {
18851
0
    uu____5 =
18852
0
      (
18853
0
        KRML_CLITERAL(core_result_Result_53){
18854
0
          .tag = core_result_Err,
18855
0
          .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
18856
0
        }
18857
0
      );
18858
0
  }
18859
0
  else
18860
0
  {
18861
0
    Eurydice_arr_65 commitment_hash = commitment_hash0.f0;
18862
0
    Eurydice_arr_65 commitment_hash1 = commitment_hash;
18863
0
    if (signer_response0.tag == core_option_None)
18864
0
    {
18865
0
      uu____5 =
18866
0
        (
18867
0
          KRML_CLITERAL(core_result_Result_53){
18868
0
            .tag = core_result_Err,
18869
0
            .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
18870
0
          }
18871
0
        );
18872
0
    }
18873
0
    else
18874
0
    {
18875
0
      Eurydice_arr_5d signer_response = signer_response0.f0;
18876
0
      Eurydice_arr_5d signer_response1 = signer_response;
18877
0
      if (!(hint0.tag == core_option_None))
18878
0
      {
18879
0
        Eurydice_arr_5d0 hint = hint0.f0;
18880
0
        Eurydice_arr_5d0 hint1 = hint;
18881
0
        libcrux_ml_dsa_encoding_signature_serialize_37(Eurydice_array_to_slice_shared_9f0(&commitment_hash1),
18882
0
          Eurydice_array_to_slice_shared_202(&signer_response1),
18883
0
          Eurydice_array_to_slice_shared_860(&hint1),
18884
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COMMITMENT_HASH_SIZE,
18885
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
18886
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
18887
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA1_EXPONENT,
18888
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_GAMMA1_RING_ELEMENT_SIZE,
18889
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_MAX_ONES_IN_HINT,
18890
0
          Eurydice_array_to_slice_mut_6b(signature));
18891
0
        return (KRML_CLITERAL(core_result_Result_53){ .tag = core_result_Ok });
18892
0
      }
18893
0
      uu____5 =
18894
0
        (
18895
0
          KRML_CLITERAL(core_result_Result_53){
18896
0
            .tag = core_result_Err,
18897
0
            .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
18898
0
          }
18899
0
        );
18900
0
    }
18901
0
  }
18902
0
  return uu____5;
18903
0
}
18904
18905
/**
18906
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.sign_mut
18907
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
18908
with const generics
18909
18910
*/
18911
static KRML_MUSTINLINE core_result_Result_53
18912
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_mut_5a(
18913
  Eurydice_borrow_slice_u8 signing_key,
18914
  Eurydice_borrow_slice_u8 message,
18915
  Eurydice_borrow_slice_u8 context,
18916
  Eurydice_arr_ec randomness,
18917
  Eurydice_arr_0c *signature
18918
)
18919
0
{
18920
0
  core_result_Result_a8
18921
0
  uu____0 =
18922
0
    libcrux_ml_dsa_pre_hash_new_88(context,
18923
0
      (KRML_CLITERAL(core_option_Option_57){ .tag = core_option_None }));
18924
0
  if (!(uu____0.tag == core_result_Ok))
18925
0
  {
18926
0
    return
18927
0
      (
18928
0
        KRML_CLITERAL(core_result_Result_53){
18929
0
          .tag = core_result_Err,
18930
0
          .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
18931
0
        }
18932
0
      );
18933
0
  }
18934
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
18935
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
18936
0
  return
18937
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_internal_5a(signing_key,
18938
0
      message,
18939
0
      (
18940
0
        KRML_CLITERAL(core_option_Option_84){
18941
0
          .tag = core_option_Some,
18942
0
          .f0 = domain_separation_context
18943
0
        }
18944
0
      ),
18945
0
      randomness,
18946
0
      signature);
18947
0
}
18948
18949
/**
18950
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.sign
18951
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
18952
with const generics
18953
18954
*/
18955
static KRML_MUSTINLINE core_result_Result_8c
18956
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_5a(
18957
  Eurydice_borrow_slice_u8 signing_key,
18958
  Eurydice_borrow_slice_u8 message,
18959
  Eurydice_borrow_slice_u8 context,
18960
  Eurydice_arr_ec randomness
18961
)
18962
0
{
18963
0
  Eurydice_arr_0c signature = libcrux_ml_dsa_types_zero_c5_5c();
18964
0
  core_result_Result_53
18965
0
  uu____0 =
18966
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_mut_5a(signing_key,
18967
0
      message,
18968
0
      context,
18969
0
      randomness,
18970
0
      &signature);
18971
0
  core_result_Result_8c uu____1;
18972
0
  if (uu____0.tag == core_result_Ok)
18973
0
  {
18974
0
    uu____1 =
18975
0
      (
18976
0
        KRML_CLITERAL(core_result_Result_8c){
18977
0
          .tag = core_result_Ok,
18978
0
          .val = { .case_Ok = signature }
18979
0
        }
18980
0
      );
18981
0
  }
18982
0
  else
18983
0
  {
18984
0
    libcrux_ml_dsa_types_SigningError e = uu____0.f0;
18985
0
    uu____1 =
18986
0
      (KRML_CLITERAL(core_result_Result_8c){ .tag = core_result_Err, .val = { .case_Err = e } });
18987
0
  }
18988
0
  return uu____1;
18989
0
}
18990
18991
/**
18992
 Sign.
18993
*/
18994
static inline core_result_Result_8c
18995
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_sign(
18996
  const Eurydice_arr_24 *signing_key,
18997
  Eurydice_borrow_slice_u8 message,
18998
  Eurydice_borrow_slice_u8 context,
18999
  Eurydice_arr_ec randomness
19000
)
19001
0
{
19002
0
  return
19003
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_5a(Eurydice_array_to_slice_shared_98(signing_key),
19004
0
      message,
19005
0
      context,
19006
0
      randomness);
19007
0
}
19008
19009
/**
19010
 Sign.
19011
*/
19012
static inline core_result_Result_53
19013
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_sign_mut(
19014
  const Eurydice_arr_24 *signing_key,
19015
  Eurydice_borrow_slice_u8 message,
19016
  Eurydice_borrow_slice_u8 context,
19017
  Eurydice_arr_ec randomness,
19018
  Eurydice_arr_0c *signature
19019
)
19020
0
{
19021
0
  return
19022
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_mut_5a(Eurydice_array_to_slice_shared_98(signing_key),
19023
0
      message,
19024
0
      context,
19025
0
      randomness,
19026
0
      signature);
19027
0
}
19028
19029
/**
19030
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.sign_pre_hashed_mut
19031
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4, libcrux_ml_dsa_pre_hash_SHAKE128_PH
19032
with const generics
19033
19034
*/
19035
static KRML_MUSTINLINE core_result_Result_53
19036
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_pre_hashed_mut_3f(
19037
  Eurydice_borrow_slice_u8 signing_key,
19038
  Eurydice_borrow_slice_u8 message,
19039
  Eurydice_borrow_slice_u8 context,
19040
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
19041
  Eurydice_arr_ec randomness,
19042
  Eurydice_arr_0c *signature
19043
)
19044
0
{
19045
0
  if (!(context.meta > LIBCRUX_ML_DSA_CONSTANTS_CONTEXT_MAX_LEN))
19046
0
  {
19047
0
    libcrux_ml_dsa_pre_hash_hash_30_83(message, pre_hash_buffer);
19048
0
    core_result_Result_a8
19049
0
    uu____0 =
19050
0
      libcrux_ml_dsa_pre_hash_new_88(context,
19051
0
        (
19052
0
          KRML_CLITERAL(core_option_Option_57){
19053
0
            .tag = core_option_Some,
19054
0
            .f0 = libcrux_ml_dsa_pre_hash_oid_30()
19055
0
          }
19056
0
        ));
19057
0
    if (!(uu____0.tag == core_result_Ok))
19058
0
    {
19059
0
      return
19060
0
        (
19061
0
          KRML_CLITERAL(core_result_Result_53){
19062
0
            .tag = core_result_Err,
19063
0
            .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
19064
0
          }
19065
0
        );
19066
0
    }
19067
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
19068
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
19069
0
    return
19070
0
      libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_internal_5a(signing_key,
19071
0
        (
19072
0
          KRML_CLITERAL(Eurydice_borrow_slice_u8){
19073
0
            .ptr = pre_hash_buffer.ptr,
19074
0
            .meta = pre_hash_buffer.meta
19075
0
          }
19076
0
        ),
19077
0
        (
19078
0
          KRML_CLITERAL(core_option_Option_84){
19079
0
            .tag = core_option_Some,
19080
0
            .f0 = domain_separation_context
19081
0
          }
19082
0
        ),
19083
0
        randomness,
19084
0
        signature);
19085
0
  }
19086
0
  return
19087
0
    (
19088
0
      KRML_CLITERAL(core_result_Result_53){
19089
0
        .tag = core_result_Err,
19090
0
        .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
19091
0
      }
19092
0
    );
19093
0
}
19094
19095
/**
19096
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.sign_pre_hashed
19097
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4, libcrux_ml_dsa_pre_hash_SHAKE128_PH
19098
with const generics
19099
19100
*/
19101
static KRML_MUSTINLINE core_result_Result_8c
19102
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_pre_hashed_3f(
19103
  Eurydice_borrow_slice_u8 signing_key,
19104
  Eurydice_borrow_slice_u8 message,
19105
  Eurydice_borrow_slice_u8 context,
19106
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
19107
  Eurydice_arr_ec randomness
19108
)
19109
0
{
19110
0
  Eurydice_arr_0c signature = libcrux_ml_dsa_types_zero_c5_5c();
19111
0
  core_result_Result_53
19112
0
  uu____0 =
19113
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_pre_hashed_mut_3f(signing_key,
19114
0
      message,
19115
0
      context,
19116
0
      pre_hash_buffer,
19117
0
      randomness,
19118
0
      &signature);
19119
0
  core_result_Result_8c uu____1;
19120
0
  if (uu____0.tag == core_result_Ok)
19121
0
  {
19122
0
    uu____1 =
19123
0
      (
19124
0
        KRML_CLITERAL(core_result_Result_8c){
19125
0
          .tag = core_result_Ok,
19126
0
          .val = { .case_Ok = signature }
19127
0
        }
19128
0
      );
19129
0
  }
19130
0
  else
19131
0
  {
19132
0
    libcrux_ml_dsa_types_SigningError e = uu____0.f0;
19133
0
    uu____1 =
19134
0
      (KRML_CLITERAL(core_result_Result_8c){ .tag = core_result_Err, .val = { .case_Err = e } });
19135
0
  }
19136
0
  return uu____1;
19137
0
}
19138
19139
/**
19140
 Sign (pre-hashed).
19141
*/
19142
static inline core_result_Result_8c
19143
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_sign_pre_hashed_shake128(
19144
  const Eurydice_arr_24 *signing_key,
19145
  Eurydice_borrow_slice_u8 message,
19146
  Eurydice_borrow_slice_u8 context,
19147
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
19148
  Eurydice_arr_ec randomness
19149
)
19150
0
{
19151
0
  return
19152
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_sign_pre_hashed_3f(Eurydice_array_to_slice_shared_98(signing_key),
19153
0
      message,
19154
0
      context,
19155
0
      pre_hash_buffer,
19156
0
      randomness);
19157
0
}
19158
19159
/**
19160
 The internal verification API.
19161
19162
 If no `domain_separation_context` is supplied, it is assumed that
19163
 `message` already contains the domain separation.
19164
*/
19165
/**
19166
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.verify_internal
19167
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof
19168
with const generics
19169
19170
*/
19171
static KRML_MUSTINLINE core_result_Result_41
19172
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_internal_5a(
19173
  const Eurydice_arr_29 *verification_key,
19174
  Eurydice_borrow_slice_u8 message,
19175
  core_option_Option_84 domain_separation_context,
19176
  const Eurydice_arr_0c *signature_serialized
19177
)
19178
0
{
19179
0
  Eurydice_borrow_slice_u8_x2
19180
0
  uu____0 =
19181
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_37(verification_key),
19182
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
19183
0
      uint8_t,
19184
0
      Eurydice_borrow_slice_u8_x2);
19185
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
19186
0
  Eurydice_borrow_slice_u8 t1_serialized = uu____0.snd;
19187
0
  Eurydice_arr_dc1 t1;
19188
0
  Eurydice_arr_a3 repeat_expression0[6U];
19189
0
  for (size_t i = (size_t)0U; i < (size_t)6U; i++)
19190
0
  {
19191
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19192
0
  }
19193
0
  memcpy(t1.data, repeat_expression0, (size_t)6U * sizeof (Eurydice_arr_a3));
19194
0
  libcrux_ml_dsa_encoding_verification_key_deserialize_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
19195
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_VERIFICATION_KEY_SIZE,
19196
0
    t1_serialized,
19197
0
    Eurydice_array_to_slice_mut_205(&t1));
19198
0
  Eurydice_arr_65 deserialized_commitment_hash = { .data = { 0U } };
19199
0
  Eurydice_arr_5d deserialized_signer_response;
19200
0
  Eurydice_arr_a3 repeat_expression1[5U];
19201
0
  for (size_t i = (size_t)0U; i < (size_t)5U; i++)
19202
0
  {
19203
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19204
0
  }
19205
0
  memcpy(deserialized_signer_response.data,
19206
0
    repeat_expression1,
19207
0
    (size_t)5U * sizeof (Eurydice_arr_a3));
19208
0
  Eurydice_arr_5d0
19209
0
  deserialized_hint =
19210
0
    {
19211
0
      .data = {
19212
0
        { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } },
19213
0
        { .data = { 0U } }, { .data = { 0U } }
19214
0
      }
19215
0
    };
19216
0
  core_result_Result_41
19217
0
  uu____1 =
19218
0
    libcrux_ml_dsa_encoding_signature_deserialize_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
19219
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
19220
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COMMITMENT_HASH_SIZE,
19221
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA1_EXPONENT,
19222
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_GAMMA1_RING_ELEMENT_SIZE,
19223
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_MAX_ONES_IN_HINT,
19224
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_SIGNATURE_SIZE,
19225
0
      Eurydice_array_to_slice_shared_6b(signature_serialized),
19226
0
      Eurydice_array_to_slice_mut_9f(&deserialized_commitment_hash),
19227
0
      Eurydice_array_to_slice_mut_204(&deserialized_signer_response),
19228
0
      Eurydice_array_to_slice_mut_860(&deserialized_hint));
19229
0
  core_result_Result_41 uu____2;
19230
0
  if (uu____1.tag == core_result_Ok)
19231
0
  {
19232
0
    if
19233
0
    (
19234
0
      libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_202(&deserialized_signer_response),
19235
0
        (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA1_EXPONENT) -
19236
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_BETA)
19237
0
    )
19238
0
    {
19239
0
      uu____2 =
19240
0
        (
19241
0
          KRML_CLITERAL(core_result_Result_41){
19242
0
            .tag = core_result_Err,
19243
0
            .f0 = libcrux_ml_dsa_types_VerificationError_SignerResponseExceedsBoundError
19244
0
          }
19245
0
        );
19246
0
    }
19247
0
    else
19248
0
    {
19249
0
      Eurydice_arr_5a matrix;
19250
0
      Eurydice_arr_a3 repeat_expression[30U];
19251
0
      for (size_t i = (size_t)0U; i < (size_t)30U; i++)
19252
0
      {
19253
0
        repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19254
0
      }
19255
0
      memcpy(matrix.data, repeat_expression, (size_t)30U * sizeof (Eurydice_arr_a3));
19256
0
      libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
19257
0
        seed_for_a,
19258
0
        Eurydice_array_to_slice_mut_203(&matrix));
19259
0
      Eurydice_arr_c7 verification_key_hash = { .data = { 0U } };
19260
0
      libcrux_ml_dsa_hash_functions_portable_shake256_61_c9(Eurydice_array_to_slice_shared_37(verification_key),
19261
0
        &verification_key_hash);
19262
0
      Eurydice_arr_c7 message_representative = { .data = { 0U } };
19263
0
      libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(Eurydice_array_to_slice_shared_17(&verification_key_hash),
19264
0
        &domain_separation_context,
19265
0
        message,
19266
0
        &message_representative);
19267
0
      Eurydice_arr_a3 verifier_challenge = libcrux_ml_dsa_polynomial_zero_ff_37();
19268
0
      libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(Eurydice_array_to_slice_shared_9f0(&deserialized_commitment_hash),
19269
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ONES_IN_VERIFIER_CHALLENGE,
19270
0
        &verifier_challenge);
19271
0
      libcrux_ml_dsa_ntt_ntt_37(&verifier_challenge);
19272
0
      for (size_t i = (size_t)0U; i < (size_t)5U; i++)
19273
0
      {
19274
0
        size_t i0 = i;
19275
0
        libcrux_ml_dsa_ntt_ntt_37(&deserialized_signer_response.data[i0]);
19276
0
      }
19277
0
      libcrux_ml_dsa_matrix_compute_w_approx_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_ROWS_IN_A,
19278
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_COLUMNS_IN_A,
19279
0
        Eurydice_array_to_slice_shared_205(&matrix),
19280
0
        Eurydice_array_to_slice_shared_202(&deserialized_signer_response),
19281
0
        &verifier_challenge,
19282
0
        Eurydice_array_to_slice_mut_205(&t1));
19283
0
      Eurydice_arr_65 recomputed_commitment_hash = { .data = { 0U } };
19284
0
      libcrux_ml_dsa_arithmetic_use_hint_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_65_GAMMA2,
19285
0
        Eurydice_array_to_slice_shared_860(&deserialized_hint),
19286
0
        Eurydice_array_to_slice_mut_205(&t1));
19287
0
      Eurydice_arr_d2 commitment_serialized = { .data = { 0U } };
19288
0
      libcrux_ml_dsa_encoding_commitment_serialize_vector_37(LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_65_COMMITMENT_RING_ELEMENT_SIZE,
19289
0
        Eurydice_array_to_slice_shared_204(&t1),
19290
0
        Eurydice_array_to_slice_mut_27(&commitment_serialized));
19291
0
      libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
19292
0
      shake = libcrux_ml_dsa_hash_functions_portable_init_26();
19293
0
      libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
19294
0
        Eurydice_array_to_slice_shared_17(&message_representative));
19295
0
      libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
19296
0
        Eurydice_array_to_slice_shared_27(&commitment_serialized));
19297
0
      libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
19298
0
        Eurydice_array_to_slice_mut_9f(&recomputed_commitment_hash));
19299
0
      if
19300
0
      (
19301
0
        Eurydice_array_eq((size_t)48U,
19302
0
          &deserialized_commitment_hash,
19303
0
          &recomputed_commitment_hash,
19304
0
          uint8_t)
19305
0
      )
19306
0
      {
19307
0
        uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Ok });
19308
0
      }
19309
0
      else
19310
0
      {
19311
0
        uu____2 =
19312
0
          (
19313
0
            KRML_CLITERAL(core_result_Result_41){
19314
0
              .tag = core_result_Err,
19315
0
              .f0 = libcrux_ml_dsa_types_VerificationError_CommitmentHashesDontMatchError
19316
0
            }
19317
0
          );
19318
0
      }
19319
0
    }
19320
0
  }
19321
0
  else
19322
0
  {
19323
0
    libcrux_ml_dsa_types_VerificationError e = uu____1.f0;
19324
0
    uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Err, .f0 = e });
19325
0
  }
19326
0
  return uu____2;
19327
0
}
19328
19329
/**
19330
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.verify
19331
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof
19332
with const generics
19333
19334
*/
19335
static KRML_MUSTINLINE core_result_Result_41
19336
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_5a(
19337
  const Eurydice_arr_29 *verification_key_serialized,
19338
  Eurydice_borrow_slice_u8 message,
19339
  Eurydice_borrow_slice_u8 context,
19340
  const Eurydice_arr_0c *signature_serialized
19341
)
19342
0
{
19343
0
  core_result_Result_a8
19344
0
  uu____0 =
19345
0
    libcrux_ml_dsa_pre_hash_new_88(context,
19346
0
      (KRML_CLITERAL(core_option_Option_57){ .tag = core_option_None }));
19347
0
  if (!(uu____0.tag == core_result_Ok))
19348
0
  {
19349
0
    return
19350
0
      (
19351
0
        KRML_CLITERAL(core_result_Result_41){
19352
0
          .tag = core_result_Err,
19353
0
          .f0 = libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError
19354
0
        }
19355
0
      );
19356
0
  }
19357
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
19358
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
19359
0
  return
19360
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_internal_5a(verification_key_serialized,
19361
0
      message,
19362
0
      (
19363
0
        KRML_CLITERAL(core_option_Option_84){
19364
0
          .tag = core_option_Some,
19365
0
          .f0 = domain_separation_context
19366
0
        }
19367
0
      ),
19368
0
      signature_serialized);
19369
0
}
19370
19371
/**
19372
 Verify.
19373
*/
19374
static inline core_result_Result_41
19375
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_verify(
19376
  const Eurydice_arr_29 *verification_key,
19377
  Eurydice_borrow_slice_u8 message,
19378
  Eurydice_borrow_slice_u8 context,
19379
  const Eurydice_arr_0c *signature
19380
)
19381
0
{
19382
0
  return
19383
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_5a(verification_key,
19384
0
      message,
19385
0
      context,
19386
0
      signature);
19387
0
}
19388
19389
/**
19390
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_65.verify_pre_hashed
19391
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_pre_hash_SHAKE128_PH
19392
with const generics
19393
19394
*/
19395
static KRML_MUSTINLINE core_result_Result_41
19396
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_pre_hashed_3f(
19397
  const Eurydice_arr_29 *verification_key_serialized,
19398
  Eurydice_borrow_slice_u8 message,
19399
  Eurydice_borrow_slice_u8 context,
19400
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
19401
  const Eurydice_arr_0c *signature_serialized
19402
)
19403
0
{
19404
0
  libcrux_ml_dsa_pre_hash_hash_30_83(message, pre_hash_buffer);
19405
0
  core_result_Result_a8
19406
0
  uu____0 =
19407
0
    libcrux_ml_dsa_pre_hash_new_88(context,
19408
0
      (
19409
0
        KRML_CLITERAL(core_option_Option_57){
19410
0
          .tag = core_option_Some,
19411
0
          .f0 = libcrux_ml_dsa_pre_hash_oid_30()
19412
0
        }
19413
0
      ));
19414
0
  if (!(uu____0.tag == core_result_Ok))
19415
0
  {
19416
0
    return
19417
0
      (
19418
0
        KRML_CLITERAL(core_result_Result_41){
19419
0
          .tag = core_result_Err,
19420
0
          .f0 = libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError
19421
0
        }
19422
0
      );
19423
0
  }
19424
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
19425
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
19426
0
  return
19427
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_internal_5a(verification_key_serialized,
19428
0
      (
19429
0
        KRML_CLITERAL(Eurydice_borrow_slice_u8){
19430
0
          .ptr = pre_hash_buffer.ptr,
19431
0
          .meta = pre_hash_buffer.meta
19432
0
        }
19433
0
      ),
19434
0
      (
19435
0
        KRML_CLITERAL(core_option_Option_84){
19436
0
          .tag = core_option_Some,
19437
0
          .f0 = domain_separation_context
19438
0
        }
19439
0
      ),
19440
0
      signature_serialized);
19441
0
}
19442
19443
/**
19444
 Verify (pre-hashed with SHAKE-128).
19445
*/
19446
static inline core_result_Result_41
19447
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_verify_pre_hashed_shake128(
19448
  const Eurydice_arr_29 *verification_key,
19449
  Eurydice_borrow_slice_u8 message,
19450
  Eurydice_borrow_slice_u8 context,
19451
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
19452
  const Eurydice_arr_0c *signature
19453
)
19454
0
{
19455
0
  return
19456
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_verify_pre_hashed_3f(verification_key,
19457
0
      message,
19458
0
      context,
19459
0
      pre_hash_buffer,
19460
0
      signature);
19461
0
}
19462
19463
/**
19464
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.generate_key_pair
19465
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
19466
with const generics
19467
19468
*/
19469
static KRML_MUSTINLINE void
19470
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_generate_key_pair_5a(
19471
  Eurydice_arr_ec randomness,
19472
  Eurydice_mut_borrow_slice_u8 signing_key,
19473
  Eurydice_mut_borrow_slice_u8 verification_key
19474
)
19475
0
{
19476
0
  Eurydice_arr_89 seed_expanded0 = { .data = { 0U } };
19477
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
19478
0
  shake = libcrux_ml_dsa_hash_functions_portable_init_26();
19479
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
19480
0
    Eurydice_array_to_slice_shared_01(&randomness));
19481
0
  /* original Rust expression is not an lvalue in C */
19482
0
  Eurydice_array_u8x2
19483
0
  lvalue =
19484
0
    {
19485
0
      .data = {
19486
0
        (uint8_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19487
0
        (uint8_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A
19488
0
      }
19489
0
    };
19490
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
19491
0
    Eurydice_array_to_slice_shared_82(&lvalue));
19492
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
19493
0
    Eurydice_array_to_slice_mut_78(&seed_expanded0));
19494
0
  Eurydice_borrow_slice_u8_x2
19495
0
  uu____0 =
19496
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_78(&seed_expanded0),
19497
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
19498
0
      uint8_t,
19499
0
      Eurydice_borrow_slice_u8_x2);
19500
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
19501
0
  Eurydice_borrow_slice_u8 seed_expanded = uu____0.snd;
19502
0
  Eurydice_borrow_slice_u8_x2
19503
0
  uu____1 =
19504
0
    Eurydice_slice_split_at(seed_expanded,
19505
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_ERROR_VECTORS_SIZE,
19506
0
      uint8_t,
19507
0
      Eurydice_borrow_slice_u8_x2);
19508
0
  Eurydice_borrow_slice_u8 seed_for_error_vectors = uu____1.fst;
19509
0
  Eurydice_borrow_slice_u8 seed_for_signing = uu____1.snd;
19510
0
  Eurydice_arr_92 s1_s2;
19511
0
  Eurydice_arr_a3 repeat_expression0[15U];
19512
0
  for (size_t i = (size_t)0U; i < (size_t)15U; i++)
19513
0
  {
19514
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19515
0
  }
19516
0
  memcpy(s1_s2.data, repeat_expression0, (size_t)15U * sizeof (Eurydice_arr_a3));
19517
0
  libcrux_ml_dsa_samplex4_sample_s1_and_s2_29(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ETA,
19518
0
    seed_for_error_vectors,
19519
0
    Eurydice_array_to_slice_mut_206(&s1_s2));
19520
0
  Eurydice_arr_8f t0;
19521
0
  Eurydice_arr_a3 repeat_expression1[8U];
19522
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19523
0
  {
19524
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19525
0
  }
19526
0
  memcpy(t0.data, repeat_expression1, (size_t)8U * sizeof (Eurydice_arr_a3));
19527
0
  Eurydice_arr_0f a_as_ntt;
19528
0
  Eurydice_arr_a3 repeat_expression2[56U];
19529
0
  for (size_t i = (size_t)0U; i < (size_t)56U; i++)
19530
0
  {
19531
0
    repeat_expression2[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19532
0
  }
19533
0
  memcpy(a_as_ntt.data, repeat_expression2, (size_t)56U * sizeof (Eurydice_arr_a3));
19534
0
  libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19535
0
    seed_for_a,
19536
0
    Eurydice_array_to_slice_mut_207(&a_as_ntt));
19537
0
  Eurydice_arr_bb s1_ntt;
19538
0
  Eurydice_arr_a3 repeat_expression3[7U];
19539
0
  for (size_t i = (size_t)0U; i < (size_t)7U; i++)
19540
0
  {
19541
0
    repeat_expression3[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19542
0
  }
19543
0
  memcpy(s1_ntt.data, repeat_expression3, (size_t)7U * sizeof (Eurydice_arr_a3));
19544
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_208(&s1_ntt),
19545
0
    Eurydice_array_to_subslice_shared_251(&s1_s2,
19546
0
      (
19547
0
        KRML_CLITERAL(core_ops_range_Range_87){
19548
0
          .start = (size_t)0U,
19549
0
          .end = LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A
19550
0
        }
19551
0
      )),
19552
0
    Eurydice_arr_a3);
19553
0
  for (size_t i = (size_t)0U; i < (size_t)7U; i++)
19554
0
  {
19555
0
    size_t i0 = i;
19556
0
    libcrux_ml_dsa_ntt_ntt_37(&s1_ntt.data[i0]);
19557
0
  }
19558
0
  libcrux_ml_dsa_matrix_compute_as1_plus_s2_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19559
0
    LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19560
0
    Eurydice_array_to_slice_mut_207(&a_as_ntt),
19561
0
    Eurydice_array_to_slice_shared_206(&s1_ntt),
19562
0
    Eurydice_array_to_slice_shared_207(&s1_s2),
19563
0
    Eurydice_array_to_slice_mut_20(&t0));
19564
0
  Eurydice_arr_8f t1;
19565
0
  Eurydice_arr_a3 repeat_expression[8U];
19566
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19567
0
  {
19568
0
    repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19569
0
  }
19570
0
  memcpy(t1.data, repeat_expression, (size_t)8U * sizeof (Eurydice_arr_a3));
19571
0
  libcrux_ml_dsa_arithmetic_power2round_vector_37(Eurydice_array_to_slice_mut_20(&t0),
19572
0
    Eurydice_array_to_slice_mut_20(&t1));
19573
0
  libcrux_ml_dsa_encoding_verification_key_generate_serialized_37(seed_for_a,
19574
0
    Eurydice_array_to_slice_shared_200(&t1),
19575
0
    verification_key);
19576
0
  libcrux_ml_dsa_encoding_signing_key_generate_serialized_2e(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ETA,
19577
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE,
19578
0
    seed_for_a,
19579
0
    seed_for_signing,
19580
0
    (
19581
0
      KRML_CLITERAL(Eurydice_borrow_slice_u8){
19582
0
        .ptr = verification_key.ptr,
19583
0
        .meta = verification_key.meta
19584
0
      }
19585
0
    ),
19586
0
    Eurydice_array_to_slice_shared_207(&s1_s2),
19587
0
    Eurydice_array_to_slice_shared_200(&t0),
19588
0
    signing_key);
19589
0
}
19590
19591
/**
19592
 Generate key pair.
19593
*/
19594
static inline void
19595
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_generate_key_pair(
19596
  Eurydice_arr_ec randomness,
19597
  Eurydice_arr_e2 *signing_key,
19598
  Eurydice_arr_43 *verification_key
19599
)
19600
0
{
19601
0
  libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_generate_key_pair_5a(randomness,
19602
0
    Eurydice_array_to_slice_mut_f7(signing_key),
19603
0
    Eurydice_array_to_slice_mut_fc(verification_key));
19604
0
}
19605
19606
/**
19607
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.sign_internal
19608
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
19609
with const generics
19610
19611
*/
19612
static KRML_MUSTINLINE core_result_Result_53
19613
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_internal_5a(
19614
  Eurydice_borrow_slice_u8 signing_key,
19615
  Eurydice_borrow_slice_u8 message,
19616
  core_option_Option_84 domain_separation_context,
19617
  Eurydice_arr_ec randomness,
19618
  Eurydice_arr_93 *signature
19619
)
19620
0
{
19621
0
  Eurydice_borrow_slice_u8_x2
19622
0
  uu____0 =
19623
0
    Eurydice_slice_split_at(signing_key,
19624
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
19625
0
      uint8_t,
19626
0
      Eurydice_borrow_slice_u8_x2);
19627
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
19628
0
  Eurydice_borrow_slice_u8 remaining_serialized0 = uu____0.snd;
19629
0
  Eurydice_borrow_slice_u8_x2
19630
0
  uu____1 =
19631
0
    Eurydice_slice_split_at(remaining_serialized0,
19632
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_SIGNING_SIZE,
19633
0
      uint8_t,
19634
0
      Eurydice_borrow_slice_u8_x2);
19635
0
  Eurydice_borrow_slice_u8 seed_for_signing = uu____1.fst;
19636
0
  Eurydice_borrow_slice_u8 remaining_serialized1 = uu____1.snd;
19637
0
  Eurydice_borrow_slice_u8_x2
19638
0
  uu____2 =
19639
0
    Eurydice_slice_split_at(remaining_serialized1,
19640
0
      LIBCRUX_ML_DSA_CONSTANTS_BYTES_FOR_VERIFICATION_KEY_HASH,
19641
0
      uint8_t,
19642
0
      Eurydice_borrow_slice_u8_x2);
19643
0
  Eurydice_borrow_slice_u8 verification_key_hash = uu____2.fst;
19644
0
  Eurydice_borrow_slice_u8 remaining_serialized2 = uu____2.snd;
19645
0
  Eurydice_borrow_slice_u8_x2
19646
0
  uu____3 =
19647
0
    Eurydice_slice_split_at(remaining_serialized2,
19648
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE *
19649
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19650
0
      uint8_t,
19651
0
      Eurydice_borrow_slice_u8_x2);
19652
0
  Eurydice_borrow_slice_u8 s1_serialized = uu____3.fst;
19653
0
  Eurydice_borrow_slice_u8 remaining_serialized = uu____3.snd;
19654
0
  Eurydice_borrow_slice_u8_x2
19655
0
  uu____4 =
19656
0
    Eurydice_slice_split_at(remaining_serialized,
19657
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE *
19658
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19659
0
      uint8_t,
19660
0
      Eurydice_borrow_slice_u8_x2);
19661
0
  Eurydice_borrow_slice_u8 s2_serialized = uu____4.fst;
19662
0
  Eurydice_borrow_slice_u8 t0_serialized = uu____4.snd;
19663
0
  Eurydice_arr_bb s1_as_ntt;
19664
0
  Eurydice_arr_a3 repeat_expression0[7U];
19665
0
  for (size_t i = (size_t)0U; i < (size_t)7U; i++)
19666
0
  {
19667
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19668
0
  }
19669
0
  memcpy(s1_as_ntt.data, repeat_expression0, (size_t)7U * sizeof (Eurydice_arr_a3));
19670
0
  Eurydice_arr_8f s2_as_ntt;
19671
0
  Eurydice_arr_a3 repeat_expression1[8U];
19672
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19673
0
  {
19674
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19675
0
  }
19676
0
  memcpy(s2_as_ntt.data, repeat_expression1, (size_t)8U * sizeof (Eurydice_arr_a3));
19677
0
  Eurydice_arr_8f t0_as_ntt;
19678
0
  Eurydice_arr_a3 repeat_expression2[8U];
19679
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19680
0
  {
19681
0
    repeat_expression2[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19682
0
  }
19683
0
  memcpy(t0_as_ntt.data, repeat_expression2, (size_t)8U * sizeof (Eurydice_arr_a3));
19684
0
  libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ETA,
19685
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE,
19686
0
    s1_serialized,
19687
0
    Eurydice_array_to_slice_mut_208(&s1_as_ntt));
19688
0
  libcrux_ml_dsa_encoding_error_deserialize_to_vector_then_ntt_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ETA,
19689
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_ERROR_RING_ELEMENT_SIZE,
19690
0
    s2_serialized,
19691
0
    Eurydice_array_to_slice_mut_20(&s2_as_ntt));
19692
0
  libcrux_ml_dsa_encoding_t0_deserialize_to_vector_then_ntt_37(t0_serialized,
19693
0
    Eurydice_array_to_slice_mut_20(&t0_as_ntt));
19694
0
  Eurydice_arr_0f matrix;
19695
0
  Eurydice_arr_a3 repeat_expression3[56U];
19696
0
  for (size_t i = (size_t)0U; i < (size_t)56U; i++)
19697
0
  {
19698
0
    repeat_expression3[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19699
0
  }
19700
0
  memcpy(matrix.data, repeat_expression3, (size_t)56U * sizeof (Eurydice_arr_a3));
19701
0
  libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19702
0
    seed_for_a,
19703
0
    Eurydice_array_to_slice_mut_207(&matrix));
19704
0
  Eurydice_arr_c7 message_representative = { .data = { 0U } };
19705
0
  libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(verification_key_hash,
19706
0
    &domain_separation_context,
19707
0
    message,
19708
0
    &message_representative);
19709
0
  Eurydice_arr_c7 mask_seed = { .data = { 0U } };
19710
0
  libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
19711
0
  shake0 = libcrux_ml_dsa_hash_functions_portable_init_26();
19712
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake0, seed_for_signing);
19713
0
  libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake0,
19714
0
    Eurydice_array_to_slice_shared_01(&randomness));
19715
0
  libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake0,
19716
0
    Eurydice_array_to_slice_shared_17(&message_representative));
19717
0
  libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake0,
19718
0
    Eurydice_array_to_slice_mut_17(&mask_seed));
19719
0
  uint16_t domain_separator_for_mask = 0U;
19720
0
  size_t attempt = (size_t)0U;
19721
0
  core_option_Option_b2 commitment_hash0 = { .tag = core_option_None };
19722
0
  core_option_Option_2d signer_response0 = { .tag = core_option_None };
19723
0
  core_option_Option_45 hint0 = { .tag = core_option_None };
19724
0
  while (attempt < LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN)
19725
0
  {
19726
0
    attempt++;
19727
0
    Eurydice_arr_bb mask;
19728
0
    Eurydice_arr_a3 repeat_expression4[7U];
19729
0
    for (size_t i = (size_t)0U; i < (size_t)7U; i++)
19730
0
    {
19731
0
      repeat_expression4[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19732
0
    }
19733
0
    memcpy(mask.data, repeat_expression4, (size_t)7U * sizeof (Eurydice_arr_a3));
19734
0
    Eurydice_arr_8f w0;
19735
0
    Eurydice_arr_a3 repeat_expression5[8U];
19736
0
    for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19737
0
    {
19738
0
      repeat_expression5[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19739
0
    }
19740
0
    memcpy(w0.data, repeat_expression5, (size_t)8U * sizeof (Eurydice_arr_a3));
19741
0
    Eurydice_arr_8f commitment;
19742
0
    Eurydice_arr_a3 repeat_expression6[8U];
19743
0
    for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19744
0
    {
19745
0
      repeat_expression6[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19746
0
    }
19747
0
    memcpy(commitment.data, repeat_expression6, (size_t)8U * sizeof (Eurydice_arr_a3));
19748
0
    libcrux_ml_dsa_sample_sample_mask_vector_67(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19749
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA1_EXPONENT,
19750
0
      &mask_seed,
19751
0
      &domain_separator_for_mask,
19752
0
      Eurydice_array_to_slice_mut_208(&mask));
19753
0
    Eurydice_arr_8f a_x_mask;
19754
0
    Eurydice_arr_a3 repeat_expression[8U];
19755
0
    for (size_t i = (size_t)0U; i < (size_t)8U; i++)
19756
0
    {
19757
0
      repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
19758
0
    }
19759
0
    memcpy(a_x_mask.data, repeat_expression, (size_t)8U * sizeof (Eurydice_arr_a3));
19760
0
    Eurydice_arr_bb
19761
0
    mask_ntt =
19762
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)7U,
19763
0
        &mask,
19764
0
        Eurydice_arr_a3,
19765
0
        Eurydice_arr_bb);
19766
0
    for (size_t i = (size_t)0U; i < (size_t)7U; i++)
19767
0
    {
19768
0
      size_t i0 = i;
19769
0
      libcrux_ml_dsa_ntt_ntt_37(&mask_ntt.data[i0]);
19770
0
    }
19771
0
    libcrux_ml_dsa_matrix_compute_matrix_x_mask_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19772
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19773
0
      Eurydice_array_to_slice_shared_208(&matrix),
19774
0
      Eurydice_array_to_slice_shared_206(&mask_ntt),
19775
0
      Eurydice_array_to_slice_mut_20(&a_x_mask));
19776
0
    libcrux_ml_dsa_arithmetic_decompose_vector_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19777
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA2,
19778
0
      Eurydice_array_to_slice_shared_200(&a_x_mask),
19779
0
      Eurydice_array_to_slice_mut_20(&w0),
19780
0
      Eurydice_array_to_slice_mut_20(&commitment));
19781
0
    Eurydice_arr_c7 commitment_hash_candidate = { .data = { 0U } };
19782
0
    Eurydice_arr_1b commitment_serialized = { .data = { 0U } };
19783
0
    libcrux_ml_dsa_encoding_commitment_serialize_vector_37(LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_COMMITMENT_RING_ELEMENT_SIZE,
19784
0
      Eurydice_array_to_slice_shared_200(&commitment),
19785
0
      Eurydice_array_to_slice_mut_68(&commitment_serialized));
19786
0
    libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
19787
0
    shake = libcrux_ml_dsa_hash_functions_portable_init_26();
19788
0
    libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
19789
0
      Eurydice_array_to_slice_shared_17(&message_representative));
19790
0
    libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
19791
0
      Eurydice_array_to_slice_shared_68(&commitment_serialized));
19792
0
    libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
19793
0
      Eurydice_array_to_slice_mut_17(&commitment_hash_candidate));
19794
0
    Eurydice_arr_a3 verifier_challenge = libcrux_ml_dsa_polynomial_zero_ff_37();
19795
0
    libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(Eurydice_array_to_slice_shared_17(&commitment_hash_candidate),
19796
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ONES_IN_VERIFIER_CHALLENGE,
19797
0
      &verifier_challenge);
19798
0
    libcrux_ml_dsa_ntt_ntt_37(&verifier_challenge);
19799
0
    Eurydice_arr_bb
19800
0
    challenge_times_s1 =
19801
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)7U,
19802
0
        &s1_as_ntt,
19803
0
        Eurydice_arr_a3,
19804
0
        Eurydice_arr_bb);
19805
0
    Eurydice_arr_8f
19806
0
    challenge_times_s2 =
19807
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)8U,
19808
0
        &s2_as_ntt,
19809
0
        Eurydice_arr_a3,
19810
0
        Eurydice_arr_8f);
19811
0
    libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_208(&challenge_times_s1),
19812
0
      &verifier_challenge);
19813
0
    libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_20(&challenge_times_s2),
19814
0
      &verifier_challenge);
19815
0
    libcrux_ml_dsa_matrix_add_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19816
0
      Eurydice_array_to_slice_mut_208(&mask),
19817
0
      Eurydice_array_to_slice_shared_206(&challenge_times_s1));
19818
0
    libcrux_ml_dsa_matrix_subtract_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19819
0
      Eurydice_array_to_slice_mut_20(&w0),
19820
0
      Eurydice_array_to_slice_shared_200(&challenge_times_s2));
19821
0
    if
19822
0
    (
19823
0
      !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_206(&mask),
19824
0
        (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA1_EXPONENT) -
19825
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_BETA)
19826
0
    )
19827
0
    {
19828
0
      if
19829
0
      (
19830
0
        !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_200(&w0),
19831
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA2 - LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_BETA)
19832
0
      )
19833
0
      {
19834
0
        Eurydice_arr_8f
19835
0
        challenge_times_t0 =
19836
0
          core_array__core__clone__Clone_for__T__N___clone((size_t)8U,
19837
0
            &t0_as_ntt,
19838
0
            Eurydice_arr_a3,
19839
0
            Eurydice_arr_8f);
19840
0
        libcrux_ml_dsa_matrix_vector_times_ring_element_37(Eurydice_array_to_slice_mut_20(&challenge_times_t0),
19841
0
          &verifier_challenge);
19842
0
        if
19843
0
        (
19844
0
          !libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_200(&challenge_times_t0),
19845
0
            LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA2)
19846
0
        )
19847
0
        {
19848
0
          libcrux_ml_dsa_matrix_add_vectors_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19849
0
            Eurydice_array_to_slice_mut_20(&w0),
19850
0
            Eurydice_array_to_slice_shared_200(&challenge_times_t0));
19851
0
          Eurydice_arr_81
19852
0
          hint_candidate =
19853
0
            {
19854
0
              .data = {
19855
0
                { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } },
19856
0
                { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }
19857
0
              }
19858
0
            };
19859
0
          size_t
19860
0
          ones_in_hint =
19861
0
            libcrux_ml_dsa_arithmetic_make_hint_37(Eurydice_array_to_slice_shared_200(&w0),
19862
0
              Eurydice_array_to_slice_shared_200(&commitment),
19863
0
              LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA2,
19864
0
              Eurydice_array_to_slice_mut_861(&hint_candidate));
19865
0
          if (!(ones_in_hint > LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_MAX_ONES_IN_HINT))
19866
0
          {
19867
0
            attempt = LIBCRUX_ML_DSA_CONSTANTS_REJECTION_SAMPLE_BOUND_SIGN;
19868
0
            commitment_hash0 =
19869
0
              (
19870
0
                KRML_CLITERAL(core_option_Option_b2){
19871
0
                  .tag = core_option_Some,
19872
0
                  .f0 = commitment_hash_candidate
19873
0
                }
19874
0
              );
19875
0
            signer_response0 =
19876
0
              (KRML_CLITERAL(core_option_Option_2d){ .tag = core_option_Some, .f0 = mask });
19877
0
            hint0 =
19878
0
              (
19879
0
                KRML_CLITERAL(core_option_Option_45){
19880
0
                  .tag = core_option_Some,
19881
0
                  .f0 = hint_candidate
19882
0
                }
19883
0
              );
19884
0
          }
19885
0
        }
19886
0
      }
19887
0
    }
19888
0
  }
19889
0
  core_result_Result_53 uu____5;
19890
0
  if (commitment_hash0.tag == core_option_None)
19891
0
  {
19892
0
    uu____5 =
19893
0
      (
19894
0
        KRML_CLITERAL(core_result_Result_53){
19895
0
          .tag = core_result_Err,
19896
0
          .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
19897
0
        }
19898
0
      );
19899
0
  }
19900
0
  else
19901
0
  {
19902
0
    Eurydice_arr_c7 commitment_hash = commitment_hash0.f0;
19903
0
    Eurydice_arr_c7 commitment_hash1 = commitment_hash;
19904
0
    if (signer_response0.tag == core_option_None)
19905
0
    {
19906
0
      uu____5 =
19907
0
        (
19908
0
          KRML_CLITERAL(core_result_Result_53){
19909
0
            .tag = core_result_Err,
19910
0
            .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
19911
0
          }
19912
0
        );
19913
0
    }
19914
0
    else
19915
0
    {
19916
0
      Eurydice_arr_bb signer_response = signer_response0.f0;
19917
0
      Eurydice_arr_bb signer_response1 = signer_response;
19918
0
      if (!(hint0.tag == core_option_None))
19919
0
      {
19920
0
        Eurydice_arr_81 hint = hint0.f0;
19921
0
        Eurydice_arr_81 hint1 = hint;
19922
0
        libcrux_ml_dsa_encoding_signature_serialize_37(Eurydice_array_to_slice_shared_17(&commitment_hash1),
19923
0
          Eurydice_array_to_slice_shared_206(&signer_response1),
19924
0
          Eurydice_array_to_slice_shared_861(&hint1),
19925
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COMMITMENT_HASH_SIZE,
19926
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
19927
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
19928
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA1_EXPONENT,
19929
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_GAMMA1_RING_ELEMENT_SIZE,
19930
0
          LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_MAX_ONES_IN_HINT,
19931
0
          Eurydice_array_to_slice_mut_11(signature));
19932
0
        return (KRML_CLITERAL(core_result_Result_53){ .tag = core_result_Ok });
19933
0
      }
19934
0
      uu____5 =
19935
0
        (
19936
0
          KRML_CLITERAL(core_result_Result_53){
19937
0
            .tag = core_result_Err,
19938
0
            .f0 = libcrux_ml_dsa_types_SigningError_RejectionSamplingError
19939
0
          }
19940
0
        );
19941
0
    }
19942
0
  }
19943
0
  return uu____5;
19944
0
}
19945
19946
/**
19947
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.sign_mut
19948
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
19949
with const generics
19950
19951
*/
19952
static KRML_MUSTINLINE core_result_Result_53
19953
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_mut_5a(
19954
  Eurydice_borrow_slice_u8 signing_key,
19955
  Eurydice_borrow_slice_u8 message,
19956
  Eurydice_borrow_slice_u8 context,
19957
  Eurydice_arr_ec randomness,
19958
  Eurydice_arr_93 *signature
19959
)
19960
0
{
19961
0
  core_result_Result_a8
19962
0
  uu____0 =
19963
0
    libcrux_ml_dsa_pre_hash_new_88(context,
19964
0
      (KRML_CLITERAL(core_option_Option_57){ .tag = core_option_None }));
19965
0
  if (!(uu____0.tag == core_result_Ok))
19966
0
  {
19967
0
    return
19968
0
      (
19969
0
        KRML_CLITERAL(core_result_Result_53){
19970
0
          .tag = core_result_Err,
19971
0
          .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
19972
0
        }
19973
0
      );
19974
0
  }
19975
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
19976
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
19977
0
  return
19978
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_internal_5a(signing_key,
19979
0
      message,
19980
0
      (
19981
0
        KRML_CLITERAL(core_option_Option_84){
19982
0
          .tag = core_option_Some,
19983
0
          .f0 = domain_separation_context
19984
0
        }
19985
0
      ),
19986
0
      randomness,
19987
0
      signature);
19988
0
}
19989
19990
/**
19991
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.sign
19992
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4
19993
with const generics
19994
19995
*/
19996
static KRML_MUSTINLINE core_result_Result_8b
19997
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_5a(
19998
  Eurydice_borrow_slice_u8 signing_key,
19999
  Eurydice_borrow_slice_u8 message,
20000
  Eurydice_borrow_slice_u8 context,
20001
  Eurydice_arr_ec randomness
20002
)
20003
0
{
20004
0
  Eurydice_arr_93 signature = libcrux_ml_dsa_types_zero_c5_f1();
20005
0
  core_result_Result_53
20006
0
  uu____0 =
20007
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_mut_5a(signing_key,
20008
0
      message,
20009
0
      context,
20010
0
      randomness,
20011
0
      &signature);
20012
0
  core_result_Result_8b uu____1;
20013
0
  if (uu____0.tag == core_result_Ok)
20014
0
  {
20015
0
    uu____1 =
20016
0
      (
20017
0
        KRML_CLITERAL(core_result_Result_8b){
20018
0
          .tag = core_result_Ok,
20019
0
          .val = { .case_Ok = signature }
20020
0
        }
20021
0
      );
20022
0
  }
20023
0
  else
20024
0
  {
20025
0
    libcrux_ml_dsa_types_SigningError e = uu____0.f0;
20026
0
    uu____1 =
20027
0
      (KRML_CLITERAL(core_result_Result_8b){ .tag = core_result_Err, .val = { .case_Err = e } });
20028
0
  }
20029
0
  return uu____1;
20030
0
}
20031
20032
/**
20033
 Sign.
20034
*/
20035
static inline core_result_Result_8b
20036
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_sign(
20037
  const Eurydice_arr_e2 *signing_key,
20038
  Eurydice_borrow_slice_u8 message,
20039
  Eurydice_borrow_slice_u8 context,
20040
  Eurydice_arr_ec randomness
20041
)
20042
0
{
20043
0
  return
20044
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_5a(Eurydice_array_to_slice_shared_f7(signing_key),
20045
0
      message,
20046
0
      context,
20047
0
      randomness);
20048
0
}
20049
20050
/**
20051
 Sign.
20052
*/
20053
static inline core_result_Result_53
20054
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_sign_mut(
20055
  const Eurydice_arr_e2 *signing_key,
20056
  Eurydice_borrow_slice_u8 message,
20057
  Eurydice_borrow_slice_u8 context,
20058
  Eurydice_arr_ec randomness,
20059
  Eurydice_arr_93 *signature
20060
)
20061
0
{
20062
0
  return
20063
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_mut_5a(Eurydice_array_to_slice_shared_f7(signing_key),
20064
0
      message,
20065
0
      context,
20066
0
      randomness,
20067
0
      signature);
20068
0
}
20069
20070
/**
20071
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.sign_pre_hashed_mut
20072
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4, libcrux_ml_dsa_pre_hash_SHAKE128_PH
20073
with const generics
20074
20075
*/
20076
static KRML_MUSTINLINE core_result_Result_53
20077
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_pre_hashed_mut_3f(
20078
  Eurydice_borrow_slice_u8 signing_key,
20079
  Eurydice_borrow_slice_u8 message,
20080
  Eurydice_borrow_slice_u8 context,
20081
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
20082
  Eurydice_arr_ec randomness,
20083
  Eurydice_arr_93 *signature
20084
)
20085
0
{
20086
0
  if (!(context.meta > LIBCRUX_ML_DSA_CONSTANTS_CONTEXT_MAX_LEN))
20087
0
  {
20088
0
    libcrux_ml_dsa_pre_hash_hash_30_83(message, pre_hash_buffer);
20089
0
    core_result_Result_a8
20090
0
    uu____0 =
20091
0
      libcrux_ml_dsa_pre_hash_new_88(context,
20092
0
        (
20093
0
          KRML_CLITERAL(core_option_Option_57){
20094
0
            .tag = core_option_Some,
20095
0
            .f0 = libcrux_ml_dsa_pre_hash_oid_30()
20096
0
          }
20097
0
        ));
20098
0
    if (!(uu____0.tag == core_result_Ok))
20099
0
    {
20100
0
      return
20101
0
        (
20102
0
          KRML_CLITERAL(core_result_Result_53){
20103
0
            .tag = core_result_Err,
20104
0
            .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
20105
0
          }
20106
0
        );
20107
0
    }
20108
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
20109
0
    libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
20110
0
    return
20111
0
      libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_internal_5a(signing_key,
20112
0
        (
20113
0
          KRML_CLITERAL(Eurydice_borrow_slice_u8){
20114
0
            .ptr = pre_hash_buffer.ptr,
20115
0
            .meta = pre_hash_buffer.meta
20116
0
          }
20117
0
        ),
20118
0
        (
20119
0
          KRML_CLITERAL(core_option_Option_84){
20120
0
            .tag = core_option_Some,
20121
0
            .f0 = domain_separation_context
20122
0
          }
20123
0
        ),
20124
0
        randomness,
20125
0
        signature);
20126
0
  }
20127
0
  return
20128
0
    (
20129
0
      KRML_CLITERAL(core_result_Result_53){
20130
0
        .tag = core_result_Err,
20131
0
        .f0 = libcrux_ml_dsa_types_SigningError_ContextTooLongError
20132
0
      }
20133
0
    );
20134
0
}
20135
20136
/**
20137
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.sign_pre_hashed
20138
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_hash_functions_portable_Shake256X4, libcrux_ml_dsa_pre_hash_SHAKE128_PH
20139
with const generics
20140
20141
*/
20142
static KRML_MUSTINLINE core_result_Result_8b
20143
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_pre_hashed_3f(
20144
  Eurydice_borrow_slice_u8 signing_key,
20145
  Eurydice_borrow_slice_u8 message,
20146
  Eurydice_borrow_slice_u8 context,
20147
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
20148
  Eurydice_arr_ec randomness
20149
)
20150
0
{
20151
0
  Eurydice_arr_93 signature = libcrux_ml_dsa_types_zero_c5_f1();
20152
0
  core_result_Result_53
20153
0
  uu____0 =
20154
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_pre_hashed_mut_3f(signing_key,
20155
0
      message,
20156
0
      context,
20157
0
      pre_hash_buffer,
20158
0
      randomness,
20159
0
      &signature);
20160
0
  core_result_Result_8b uu____1;
20161
0
  if (uu____0.tag == core_result_Ok)
20162
0
  {
20163
0
    uu____1 =
20164
0
      (
20165
0
        KRML_CLITERAL(core_result_Result_8b){
20166
0
          .tag = core_result_Ok,
20167
0
          .val = { .case_Ok = signature }
20168
0
        }
20169
0
      );
20170
0
  }
20171
0
  else
20172
0
  {
20173
0
    libcrux_ml_dsa_types_SigningError e = uu____0.f0;
20174
0
    uu____1 =
20175
0
      (KRML_CLITERAL(core_result_Result_8b){ .tag = core_result_Err, .val = { .case_Err = e } });
20176
0
  }
20177
0
  return uu____1;
20178
0
}
20179
20180
/**
20181
 Sign (pre-hashed).
20182
*/
20183
static inline core_result_Result_8b
20184
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_sign_pre_hashed_shake128(
20185
  const Eurydice_arr_e2 *signing_key,
20186
  Eurydice_borrow_slice_u8 message,
20187
  Eurydice_borrow_slice_u8 context,
20188
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
20189
  Eurydice_arr_ec randomness
20190
)
20191
0
{
20192
0
  return
20193
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_sign_pre_hashed_3f(Eurydice_array_to_slice_shared_f7(signing_key),
20194
0
      message,
20195
0
      context,
20196
0
      pre_hash_buffer,
20197
0
      randomness);
20198
0
}
20199
20200
/**
20201
 The internal verification API.
20202
20203
 If no `domain_separation_context` is supplied, it is assumed that
20204
 `message` already contains the domain separation.
20205
*/
20206
/**
20207
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.verify_internal
20208
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof
20209
with const generics
20210
20211
*/
20212
static KRML_MUSTINLINE core_result_Result_41
20213
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_internal_5a(
20214
  const Eurydice_arr_43 *verification_key,
20215
  Eurydice_borrow_slice_u8 message,
20216
  core_option_Option_84 domain_separation_context,
20217
  const Eurydice_arr_93 *signature_serialized
20218
)
20219
0
{
20220
0
  Eurydice_borrow_slice_u8_x2
20221
0
  uu____0 =
20222
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_fc(verification_key),
20223
0
      LIBCRUX_ML_DSA_CONSTANTS_SEED_FOR_A_SIZE,
20224
0
      uint8_t,
20225
0
      Eurydice_borrow_slice_u8_x2);
20226
0
  Eurydice_borrow_slice_u8 seed_for_a = uu____0.fst;
20227
0
  Eurydice_borrow_slice_u8 t1_serialized = uu____0.snd;
20228
0
  Eurydice_arr_8f t1;
20229
0
  Eurydice_arr_a3 repeat_expression0[8U];
20230
0
  for (size_t i = (size_t)0U; i < (size_t)8U; i++)
20231
0
  {
20232
0
    repeat_expression0[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
20233
0
  }
20234
0
  memcpy(t1.data, repeat_expression0, (size_t)8U * sizeof (Eurydice_arr_a3));
20235
0
  libcrux_ml_dsa_encoding_verification_key_deserialize_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
20236
0
    LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_VERIFICATION_KEY_SIZE,
20237
0
    t1_serialized,
20238
0
    Eurydice_array_to_slice_mut_20(&t1));
20239
0
  Eurydice_arr_c7 deserialized_commitment_hash = { .data = { 0U } };
20240
0
  Eurydice_arr_bb deserialized_signer_response;
20241
0
  Eurydice_arr_a3 repeat_expression1[7U];
20242
0
  for (size_t i = (size_t)0U; i < (size_t)7U; i++)
20243
0
  {
20244
0
    repeat_expression1[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
20245
0
  }
20246
0
  memcpy(deserialized_signer_response.data,
20247
0
    repeat_expression1,
20248
0
    (size_t)7U * sizeof (Eurydice_arr_a3));
20249
0
  Eurydice_arr_81
20250
0
  deserialized_hint =
20251
0
    {
20252
0
      .data = {
20253
0
        { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } },
20254
0
        { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } }
20255
0
      }
20256
0
    };
20257
0
  core_result_Result_41
20258
0
  uu____1 =
20259
0
    libcrux_ml_dsa_encoding_signature_deserialize_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
20260
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
20261
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COMMITMENT_HASH_SIZE,
20262
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA1_EXPONENT,
20263
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_GAMMA1_RING_ELEMENT_SIZE,
20264
0
      LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_MAX_ONES_IN_HINT,
20265
0
      LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_SIGNATURE_SIZE,
20266
0
      Eurydice_array_to_slice_shared_11(signature_serialized),
20267
0
      Eurydice_array_to_slice_mut_17(&deserialized_commitment_hash),
20268
0
      Eurydice_array_to_slice_mut_208(&deserialized_signer_response),
20269
0
      Eurydice_array_to_slice_mut_861(&deserialized_hint));
20270
0
  core_result_Result_41 uu____2;
20271
0
  if (uu____1.tag == core_result_Ok)
20272
0
  {
20273
0
    if
20274
0
    (
20275
0
      libcrux_ml_dsa_arithmetic_vector_infinity_norm_exceeds_37(Eurydice_array_to_slice_shared_206(&deserialized_signer_response),
20276
0
        (int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA1_EXPONENT) -
20277
0
          LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_BETA)
20278
0
    )
20279
0
    {
20280
0
      uu____2 =
20281
0
        (
20282
0
          KRML_CLITERAL(core_result_Result_41){
20283
0
            .tag = core_result_Err,
20284
0
            .f0 = libcrux_ml_dsa_types_VerificationError_SignerResponseExceedsBoundError
20285
0
          }
20286
0
        );
20287
0
    }
20288
0
    else
20289
0
    {
20290
0
      Eurydice_arr_0f matrix;
20291
0
      Eurydice_arr_a3 repeat_expression[56U];
20292
0
      for (size_t i = (size_t)0U; i < (size_t)56U; i++)
20293
0
      {
20294
0
        repeat_expression[i] = libcrux_ml_dsa_polynomial_zero_ff_37();
20295
0
      }
20296
0
      memcpy(matrix.data, repeat_expression, (size_t)56U * sizeof (Eurydice_arr_a3));
20297
0
      libcrux_ml_dsa_samplex4_portable_matrix_flat_a8_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
20298
0
        seed_for_a,
20299
0
        Eurydice_array_to_slice_mut_207(&matrix));
20300
0
      Eurydice_arr_c7 verification_key_hash = { .data = { 0U } };
20301
0
      libcrux_ml_dsa_hash_functions_portable_shake256_61_c9(Eurydice_array_to_slice_shared_fc(verification_key),
20302
0
        &verification_key_hash);
20303
0
      Eurydice_arr_c7 message_representative = { .data = { 0U } };
20304
0
      libcrux_ml_dsa_ml_dsa_generic_derive_message_representative_43(Eurydice_array_to_slice_shared_17(&verification_key_hash),
20305
0
        &domain_separation_context,
20306
0
        message,
20307
0
        &message_representative);
20308
0
      Eurydice_arr_a3 verifier_challenge = libcrux_ml_dsa_polynomial_zero_ff_37();
20309
0
      libcrux_ml_dsa_sample_sample_challenge_ring_element_2e(Eurydice_array_to_slice_shared_17(&deserialized_commitment_hash),
20310
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ONES_IN_VERIFIER_CHALLENGE,
20311
0
        &verifier_challenge);
20312
0
      libcrux_ml_dsa_ntt_ntt_37(&verifier_challenge);
20313
0
      for (size_t i = (size_t)0U; i < (size_t)7U; i++)
20314
0
      {
20315
0
        size_t i0 = i;
20316
0
        libcrux_ml_dsa_ntt_ntt_37(&deserialized_signer_response.data[i0]);
20317
0
      }
20318
0
      libcrux_ml_dsa_matrix_compute_w_approx_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_ROWS_IN_A,
20319
0
        LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_COLUMNS_IN_A,
20320
0
        Eurydice_array_to_slice_shared_208(&matrix),
20321
0
        Eurydice_array_to_slice_shared_206(&deserialized_signer_response),
20322
0
        &verifier_challenge,
20323
0
        Eurydice_array_to_slice_mut_20(&t1));
20324
0
      Eurydice_arr_c7 recomputed_commitment_hash = { .data = { 0U } };
20325
0
      libcrux_ml_dsa_arithmetic_use_hint_37(LIBCRUX_ML_DSA_CONSTANTS_ML_DSA_87_GAMMA2,
20326
0
        Eurydice_array_to_slice_shared_861(&deserialized_hint),
20327
0
        Eurydice_array_to_slice_mut_20(&t1));
20328
0
      Eurydice_arr_1b commitment_serialized = { .data = { 0U } };
20329
0
      libcrux_ml_dsa_encoding_commitment_serialize_vector_37(LIBCRUX_ML_DSA_ML_DSA_GENERIC_ML_DSA_87_COMMITMENT_RING_ELEMENT_SIZE,
20330
0
        Eurydice_array_to_slice_shared_200(&t1),
20331
0
        Eurydice_array_to_slice_mut_68(&commitment_serialized));
20332
0
      libcrux_sha3_generic_keccak_xof_KeccakXofState_8d
20333
0
      shake = libcrux_ml_dsa_hash_functions_portable_init_26();
20334
0
      libcrux_ml_dsa_hash_functions_portable_absorb_26(&shake,
20335
0
        Eurydice_array_to_slice_shared_17(&message_representative));
20336
0
      libcrux_ml_dsa_hash_functions_portable_absorb_final_26(&shake,
20337
0
        Eurydice_array_to_slice_shared_68(&commitment_serialized));
20338
0
      libcrux_ml_dsa_hash_functions_portable_squeeze_26(&shake,
20339
0
        Eurydice_array_to_slice_mut_17(&recomputed_commitment_hash));
20340
0
      if
20341
0
      (
20342
0
        Eurydice_array_eq((size_t)64U,
20343
0
          &deserialized_commitment_hash,
20344
0
          &recomputed_commitment_hash,
20345
0
          uint8_t)
20346
0
      )
20347
0
      {
20348
0
        uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Ok });
20349
0
      }
20350
0
      else
20351
0
      {
20352
0
        uu____2 =
20353
0
          (
20354
0
            KRML_CLITERAL(core_result_Result_41){
20355
0
              .tag = core_result_Err,
20356
0
              .f0 = libcrux_ml_dsa_types_VerificationError_CommitmentHashesDontMatchError
20357
0
            }
20358
0
          );
20359
0
      }
20360
0
    }
20361
0
  }
20362
0
  else
20363
0
  {
20364
0
    libcrux_ml_dsa_types_VerificationError e = uu____1.f0;
20365
0
    uu____2 = (KRML_CLITERAL(core_result_Result_41){ .tag = core_result_Err, .f0 = e });
20366
0
  }
20367
0
  return uu____2;
20368
0
}
20369
20370
/**
20371
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.verify
20372
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof
20373
with const generics
20374
20375
*/
20376
static KRML_MUSTINLINE core_result_Result_41
20377
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_5a(
20378
  const Eurydice_arr_43 *verification_key_serialized,
20379
  Eurydice_borrow_slice_u8 message,
20380
  Eurydice_borrow_slice_u8 context,
20381
  const Eurydice_arr_93 *signature_serialized
20382
)
20383
0
{
20384
0
  core_result_Result_a8
20385
0
  uu____0 =
20386
0
    libcrux_ml_dsa_pre_hash_new_88(context,
20387
0
      (KRML_CLITERAL(core_option_Option_57){ .tag = core_option_None }));
20388
0
  if (!(uu____0.tag == core_result_Ok))
20389
0
  {
20390
0
    return
20391
0
      (
20392
0
        KRML_CLITERAL(core_result_Result_41){
20393
0
          .tag = core_result_Err,
20394
0
          .f0 = libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError
20395
0
        }
20396
0
      );
20397
0
  }
20398
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
20399
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
20400
0
  return
20401
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_internal_5a(verification_key_serialized,
20402
0
      message,
20403
0
      (
20404
0
        KRML_CLITERAL(core_option_Option_84){
20405
0
          .tag = core_option_Some,
20406
0
          .f0 = domain_separation_context
20407
0
        }
20408
0
      ),
20409
0
      signature_serialized);
20410
0
}
20411
20412
/**
20413
 Verify.
20414
*/
20415
static inline core_result_Result_41
20416
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_verify(
20417
  const Eurydice_arr_43 *verification_key,
20418
  Eurydice_borrow_slice_u8 message,
20419
  Eurydice_borrow_slice_u8 context,
20420
  const Eurydice_arr_93 *signature
20421
)
20422
0
{
20423
0
  return
20424
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_5a(verification_key,
20425
0
      message,
20426
0
      context,
20427
0
      signature);
20428
0
}
20429
20430
/**
20431
A monomorphic instance of libcrux_ml_dsa.ml_dsa_generic.ml_dsa_87.verify_pre_hashed
20432
with types libcrux_ml_dsa_simd_portable_vector_type_Coefficients, libcrux_ml_dsa_samplex4_portable_PortableSampler, libcrux_ml_dsa_hash_functions_portable_Shake128, libcrux_ml_dsa_hash_functions_portable_Shake128X4, libcrux_ml_dsa_hash_functions_portable_Shake256, libcrux_ml_dsa_hash_functions_portable_Shake256Xof, libcrux_ml_dsa_pre_hash_SHAKE128_PH
20433
with const generics
20434
20435
*/
20436
static KRML_MUSTINLINE core_result_Result_41
20437
libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_pre_hashed_3f(
20438
  const Eurydice_arr_43 *verification_key_serialized,
20439
  Eurydice_borrow_slice_u8 message,
20440
  Eurydice_borrow_slice_u8 context,
20441
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
20442
  const Eurydice_arr_93 *signature_serialized
20443
)
20444
0
{
20445
0
  libcrux_ml_dsa_pre_hash_hash_30_83(message, pre_hash_buffer);
20446
0
  core_result_Result_a8
20447
0
  uu____0 =
20448
0
    libcrux_ml_dsa_pre_hash_new_88(context,
20449
0
      (
20450
0
        KRML_CLITERAL(core_option_Option_57){
20451
0
          .tag = core_option_Some,
20452
0
          .f0 = libcrux_ml_dsa_pre_hash_oid_30()
20453
0
        }
20454
0
      ));
20455
0
  if (!(uu____0.tag == core_result_Ok))
20456
0
  {
20457
0
    return
20458
0
      (
20459
0
        KRML_CLITERAL(core_result_Result_41){
20460
0
          .tag = core_result_Err,
20461
0
          .f0 = libcrux_ml_dsa_types_VerificationError_VerificationContextTooLongError
20462
0
        }
20463
0
      );
20464
0
  }
20465
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext dsc = uu____0.val.case_Ok;
20466
0
  libcrux_ml_dsa_pre_hash_DomainSeparationContext domain_separation_context = dsc;
20467
0
  return
20468
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_internal_5a(verification_key_serialized,
20469
0
      (
20470
0
        KRML_CLITERAL(Eurydice_borrow_slice_u8){
20471
0
          .ptr = pre_hash_buffer.ptr,
20472
0
          .meta = pre_hash_buffer.meta
20473
0
        }
20474
0
      ),
20475
0
      (
20476
0
        KRML_CLITERAL(core_option_Option_84){
20477
0
          .tag = core_option_Some,
20478
0
          .f0 = domain_separation_context
20479
0
        }
20480
0
      ),
20481
0
      signature_serialized);
20482
0
}
20483
20484
/**
20485
 Verify (pre-hashed with SHAKE-128).
20486
*/
20487
static inline core_result_Result_41
20488
libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_verify_pre_hashed_shake128(
20489
  const Eurydice_arr_43 *verification_key,
20490
  Eurydice_borrow_slice_u8 message,
20491
  Eurydice_borrow_slice_u8 context,
20492
  Eurydice_mut_borrow_slice_u8 pre_hash_buffer,
20493
  const Eurydice_arr_93 *signature
20494
)
20495
0
{
20496
0
  return
20497
0
    libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_verify_pre_hashed_3f(verification_key,
20498
0
      message,
20499
0
      context,
20500
0
      pre_hash_buffer,
20501
0
      signature);
20502
0
}
20503
20504
#if defined(__cplusplus)
20505
}
20506
#endif
20507
20508
#define libcrux_mldsa_portable_H_DEFINED
20509
#endif /* libcrux_mldsa_portable_H */
20510
20511
/* from libcrux/combined_extraction/generated/libcrux_mldsa44_portable.h */
20512
/*
20513
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
20514
 *
20515
 * SPDX-License-Identifier: MIT or Apache-2.0
20516
 *
20517
 * This code was generated with the following revisions:
20518
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
20519
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
20520
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
20521
 * F*: unset
20522
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
20523
 */
20524
20525
20526
#ifndef libcrux_mldsa44_portable_H
20527
#define libcrux_mldsa44_portable_H
20528
20529
20530
20531
#if defined(__cplusplus)
20532
extern "C" {
20533
#endif
20534
20535
20536
/**
20537
 Generate an ML-DSA-44 Key Pair
20538
*/
20539
static inline libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44KeyPair
20540
libcrux_ml_dsa_ml_dsa_44_portable_generate_key_pair(Eurydice_arr_ec randomness)
20541
0
{
20542
0
  Eurydice_arr_10 signing_key = { .data = { 0U } };
20543
0
  Eurydice_arr_02 verification_key = { .data = { 0U } };
20544
0
  libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_generate_key_pair(randomness,
20545
0
    &signing_key,
20546
0
    &verification_key);
20547
0
  return
20548
0
    (
20549
0
      KRML_CLITERAL(libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44KeyPair){
20550
0
        .signing_key = libcrux_ml_dsa_types_new_9b_ab(signing_key),
20551
0
        .verification_key = libcrux_ml_dsa_types_new_7f_7d(verification_key)
20552
0
      }
20553
0
    );
20554
0
}
20555
20556
/**
20557
 Generate an ML-DSA-44 Signature
20558
20559
 The parameter `context` is used for domain separation
20560
 and is a byte string of length at most 255 bytes. It
20561
 may also be empty.
20562
*/
20563
static inline core_result_Result_48
20564
libcrux_ml_dsa_ml_dsa_44_portable_sign(
20565
  const Eurydice_arr_10 *signing_key,
20566
  Eurydice_borrow_slice_u8 message,
20567
  Eurydice_borrow_slice_u8 context,
20568
  Eurydice_arr_ec randomness
20569
)
20570
0
{
20571
0
  return
20572
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_sign(libcrux_ml_dsa_types_as_ref_9b_ab(signing_key),
20573
0
      message,
20574
0
      context,
20575
0
      randomness);
20576
0
}
20577
20578
/**
20579
 Generate an ML-DSA-44 Signature
20580
20581
 The parameter `context` is used for domain separation
20582
 and is a byte string of length at most 255 bytes. It
20583
 may also be empty.
20584
*/
20585
static inline core_result_Result_53
20586
libcrux_ml_dsa_ml_dsa_44_portable_sign_mut(
20587
  const Eurydice_arr_10 *signing_key,
20588
  Eurydice_borrow_slice_u8 message,
20589
  Eurydice_borrow_slice_u8 context,
20590
  Eurydice_arr_ec randomness,
20591
  Eurydice_arr_85 *signature
20592
)
20593
0
{
20594
0
  return
20595
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_sign_mut(libcrux_ml_dsa_types_as_ref_9b_ab(signing_key),
20596
0
      message,
20597
0
      context,
20598
0
      randomness,
20599
0
      signature);
20600
0
}
20601
20602
/**
20603
 Generate a HashML-DSA-44 Signature, with a SHAKE128 pre-hashing
20604
20605
 The parameter `context` is used for domain separation
20606
 and is a byte string of length at most 255 bytes. It
20607
 may also be empty.
20608
*/
20609
static inline core_result_Result_48
20610
libcrux_ml_dsa_ml_dsa_44_portable_sign_pre_hashed_shake128(
20611
  const Eurydice_arr_10 *signing_key,
20612
  Eurydice_borrow_slice_u8 message,
20613
  Eurydice_borrow_slice_u8 context,
20614
  Eurydice_arr_ec randomness
20615
)
20616
0
{
20617
0
  Eurydice_arr_ec pre_hash_buffer = { .data = { 0U } };
20618
0
  const Eurydice_arr_10 *uu____0 = libcrux_ml_dsa_types_as_ref_9b_ab(signing_key);
20619
0
  return
20620
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_sign_pre_hashed_shake128(uu____0,
20621
0
      message,
20622
0
      context,
20623
0
      Eurydice_array_to_slice_mut_01(&pre_hash_buffer),
20624
0
      randomness);
20625
0
}
20626
20627
/**
20628
 Verify an ML-DSA-44 Signature
20629
20630
 The parameter `context` is used for domain separation
20631
 and is a byte string of length at most 255 bytes. It
20632
 may also be empty.
20633
*/
20634
static inline core_result_Result_41
20635
libcrux_ml_dsa_ml_dsa_44_portable_verify(
20636
  const Eurydice_arr_02 *verification_key,
20637
  Eurydice_borrow_slice_u8 message,
20638
  Eurydice_borrow_slice_u8 context,
20639
  const Eurydice_arr_85 *signature
20640
)
20641
0
{
20642
0
  return
20643
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_verify(libcrux_ml_dsa_types_as_ref_7f_7d(verification_key),
20644
0
      message,
20645
0
      context,
20646
0
      libcrux_ml_dsa_types_as_ref_c5_37(signature));
20647
0
}
20648
20649
/**
20650
 Verify a HashML-DSA-44 Signature, with a SHAKE128 pre-hashing
20651
20652
 The parameter `context` is used for domain separation
20653
 and is a byte string of length at most 255 bytes. It
20654
 may also be empty.
20655
*/
20656
static inline core_result_Result_41
20657
libcrux_ml_dsa_ml_dsa_44_portable_verify_pre_hashed_shake128(
20658
  const Eurydice_arr_02 *verification_key,
20659
  Eurydice_borrow_slice_u8 message,
20660
  Eurydice_borrow_slice_u8 context,
20661
  const Eurydice_arr_85 *signature
20662
)
20663
0
{
20664
0
  Eurydice_arr_ec pre_hash_buffer = { .data = { 0U } };
20665
0
  const Eurydice_arr_02 *uu____0 = libcrux_ml_dsa_types_as_ref_7f_7d(verification_key);
20666
0
  Eurydice_borrow_slice_u8 uu____1 = message;
20667
0
  Eurydice_borrow_slice_u8 uu____2 = context;
20668
0
  Eurydice_mut_borrow_slice_u8 uu____3 = Eurydice_array_to_slice_mut_01(&pre_hash_buffer);
20669
0
  return
20670
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_44_verify_pre_hashed_shake128(uu____0,
20671
0
      uu____1,
20672
0
      uu____2,
20673
0
      uu____3,
20674
0
      libcrux_ml_dsa_types_as_ref_c5_37(signature));
20675
0
}
20676
20677
#if defined(__cplusplus)
20678
}
20679
#endif
20680
20681
#define libcrux_mldsa44_portable_H_DEFINED
20682
#endif /* libcrux_mldsa44_portable_H */
20683
20684
/* from libcrux/combined_extraction/generated/libcrux_mldsa65_portable.h */
20685
/*
20686
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
20687
 *
20688
 * SPDX-License-Identifier: MIT or Apache-2.0
20689
 *
20690
 * This code was generated with the following revisions:
20691
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
20692
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
20693
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
20694
 * F*: unset
20695
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
20696
 */
20697
20698
20699
#ifndef libcrux_mldsa65_portable_H
20700
#define libcrux_mldsa65_portable_H
20701
20702
20703
20704
#if defined(__cplusplus)
20705
extern "C" {
20706
#endif
20707
20708
20709
/**
20710
 Generate an ML-DSA-65 Key Pair
20711
*/
20712
static inline libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65KeyPair
20713
libcrux_ml_dsa_ml_dsa_65_portable_generate_key_pair(Eurydice_arr_ec randomness)
20714
0
{
20715
0
  Eurydice_arr_24 signing_key = { .data = { 0U } };
20716
0
  Eurydice_arr_29 verification_key = { .data = { 0U } };
20717
0
  libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_generate_key_pair(randomness,
20718
0
    &signing_key,
20719
0
    &verification_key);
20720
0
  return
20721
0
    (
20722
0
      KRML_CLITERAL(libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65KeyPair){
20723
0
        .signing_key = libcrux_ml_dsa_types_new_9b_e5(signing_key),
20724
0
        .verification_key = libcrux_ml_dsa_types_new_7f_a2(verification_key)
20725
0
      }
20726
0
    );
20727
0
}
20728
20729
/**
20730
 Generate an ML-DSA-65 Key Pair
20731
*/
20732
static inline void
20733
libcrux_ml_dsa_ml_dsa_65_portable_generate_key_pair_mut(
20734
  Eurydice_arr_ec randomness,
20735
  Eurydice_arr_24 *signing_key,
20736
  Eurydice_arr_29 *verification_key
20737
)
20738
0
{
20739
0
  libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_generate_key_pair(randomness,
20740
0
    signing_key,
20741
0
    verification_key);
20742
0
}
20743
20744
/**
20745
 Generate an ML-DSA-65 Signature
20746
20747
 The parameter `context` is used for domain separation
20748
 and is a byte string of length at most 255 bytes. It
20749
 may also be empty.
20750
*/
20751
static inline core_result_Result_8c
20752
libcrux_ml_dsa_ml_dsa_65_portable_sign(
20753
  const Eurydice_arr_24 *signing_key,
20754
  Eurydice_borrow_slice_u8 message,
20755
  Eurydice_borrow_slice_u8 context,
20756
  Eurydice_arr_ec randomness
20757
)
20758
0
{
20759
0
  return
20760
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_sign(libcrux_ml_dsa_types_as_ref_9b_e5(signing_key),
20761
0
      message,
20762
0
      context,
20763
0
      randomness);
20764
0
}
20765
20766
/**
20767
 Generate an ML-DSA-65 Signature
20768
20769
 The parameter `context` is used for domain separation
20770
 and is a byte string of length at most 255 bytes. It
20771
 may also be empty.
20772
*/
20773
static inline core_result_Result_53
20774
libcrux_ml_dsa_ml_dsa_65_portable_sign_mut(
20775
  const Eurydice_arr_24 *signing_key,
20776
  Eurydice_borrow_slice_u8 message,
20777
  Eurydice_borrow_slice_u8 context,
20778
  Eurydice_arr_ec randomness,
20779
  Eurydice_arr_0c *signature
20780
)
20781
0
{
20782
0
  return
20783
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_sign_mut(signing_key,
20784
0
      message,
20785
0
      context,
20786
0
      randomness,
20787
0
      signature);
20788
0
}
20789
20790
/**
20791
 Generate a HashML-DSA-65 Signature, with a SHAKE128 pre-hashing
20792
20793
 The parameter `context` is used for domain separation
20794
 and is a byte string of length at most 255 bytes. It
20795
 may also be empty.
20796
*/
20797
static inline core_result_Result_8c
20798
libcrux_ml_dsa_ml_dsa_65_portable_sign_pre_hashed_shake128(
20799
  const Eurydice_arr_24 *signing_key,
20800
  Eurydice_borrow_slice_u8 message,
20801
  Eurydice_borrow_slice_u8 context,
20802
  Eurydice_arr_ec randomness
20803
)
20804
0
{
20805
0
  Eurydice_arr_ec pre_hash_buffer = { .data = { 0U } };
20806
0
  const Eurydice_arr_24 *uu____0 = libcrux_ml_dsa_types_as_ref_9b_e5(signing_key);
20807
0
  return
20808
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_sign_pre_hashed_shake128(uu____0,
20809
0
      message,
20810
0
      context,
20811
0
      Eurydice_array_to_slice_mut_01(&pre_hash_buffer),
20812
0
      randomness);
20813
0
}
20814
20815
/**
20816
 Verify an ML-DSA-65 Signature
20817
20818
 The parameter `context` is used for domain separation
20819
 and is a byte string of length at most 255 bytes. It
20820
 may also be empty.
20821
*/
20822
static inline core_result_Result_41
20823
libcrux_ml_dsa_ml_dsa_65_portable_verify(
20824
  const Eurydice_arr_29 *verification_key,
20825
  Eurydice_borrow_slice_u8 message,
20826
  Eurydice_borrow_slice_u8 context,
20827
  const Eurydice_arr_0c *signature
20828
)
20829
0
{
20830
0
  return
20831
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_verify(libcrux_ml_dsa_types_as_ref_7f_a2(verification_key),
20832
0
      message,
20833
0
      context,
20834
0
      libcrux_ml_dsa_types_as_ref_c5_5c(signature));
20835
0
}
20836
20837
/**
20838
 Verify a HashML-DSA-65 Signature, with a SHAKE128 pre-hashing
20839
20840
 The parameter `context` is used for domain separation
20841
 and is a byte string of length at most 255 bytes. It
20842
 may also be empty.
20843
*/
20844
static inline core_result_Result_41
20845
libcrux_ml_dsa_ml_dsa_65_portable_verify_pre_hashed_shake128(
20846
  const Eurydice_arr_29 *verification_key,
20847
  Eurydice_borrow_slice_u8 message,
20848
  Eurydice_borrow_slice_u8 context,
20849
  const Eurydice_arr_0c *signature
20850
)
20851
0
{
20852
0
  Eurydice_arr_ec pre_hash_buffer = { .data = { 0U } };
20853
0
  const Eurydice_arr_29 *uu____0 = libcrux_ml_dsa_types_as_ref_7f_a2(verification_key);
20854
0
  Eurydice_borrow_slice_u8 uu____1 = message;
20855
0
  Eurydice_borrow_slice_u8 uu____2 = context;
20856
0
  Eurydice_mut_borrow_slice_u8 uu____3 = Eurydice_array_to_slice_mut_01(&pre_hash_buffer);
20857
0
  return
20858
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_65_verify_pre_hashed_shake128(uu____0,
20859
0
      uu____1,
20860
0
      uu____2,
20861
0
      uu____3,
20862
0
      libcrux_ml_dsa_types_as_ref_c5_5c(signature));
20863
0
}
20864
20865
#if defined(__cplusplus)
20866
}
20867
#endif
20868
20869
#define libcrux_mldsa65_portable_H_DEFINED
20870
#endif /* libcrux_mldsa65_portable_H */
20871
20872
/* from libcrux/combined_extraction/generated/libcrux_mldsa87_portable.h */
20873
/*
20874
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
20875
 *
20876
 * SPDX-License-Identifier: MIT or Apache-2.0
20877
 *
20878
 * This code was generated with the following revisions:
20879
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
20880
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
20881
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
20882
 * F*: unset
20883
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
20884
 */
20885
20886
20887
#ifndef libcrux_mldsa87_portable_H
20888
#define libcrux_mldsa87_portable_H
20889
20890
20891
20892
#if defined(__cplusplus)
20893
extern "C" {
20894
#endif
20895
20896
20897
/**
20898
 Generate an ML-DSA-87 Key Pair
20899
*/
20900
static inline libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87KeyPair
20901
libcrux_ml_dsa_ml_dsa_87_portable_generate_key_pair(Eurydice_arr_ec randomness)
20902
0
{
20903
0
  Eurydice_arr_e2 signing_key = { .data = { 0U } };
20904
0
  Eurydice_arr_43 verification_key = { .data = { 0U } };
20905
0
  libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_generate_key_pair(randomness,
20906
0
    &signing_key,
20907
0
    &verification_key);
20908
0
  return
20909
0
    (
20910
0
      KRML_CLITERAL(libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87KeyPair){
20911
0
        .signing_key = libcrux_ml_dsa_types_new_9b_72(signing_key),
20912
0
        .verification_key = libcrux_ml_dsa_types_new_7f_c6(verification_key)
20913
0
      }
20914
0
    );
20915
0
}
20916
20917
/**
20918
 Generate an ML-DSA-87 Signature
20919
20920
 The parameter `context` is used for domain separation
20921
 and is a byte string of length at most 255 bytes. It
20922
 may also be empty.
20923
*/
20924
static inline core_result_Result_8b
20925
libcrux_ml_dsa_ml_dsa_87_portable_sign(
20926
  const Eurydice_arr_e2 *signing_key,
20927
  Eurydice_borrow_slice_u8 message,
20928
  Eurydice_borrow_slice_u8 context,
20929
  Eurydice_arr_ec randomness
20930
)
20931
0
{
20932
0
  return
20933
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_sign(libcrux_ml_dsa_types_as_ref_9b_72(signing_key),
20934
0
      message,
20935
0
      context,
20936
0
      randomness);
20937
0
}
20938
20939
/**
20940
 Generate an ML-DSA-87 Signature
20941
20942
 The parameter `context` is used for domain separation
20943
 and is a byte string of length at most 255 bytes. It
20944
 may also be empty.
20945
*/
20946
static inline core_result_Result_53
20947
libcrux_ml_dsa_ml_dsa_87_portable_sign_mut(
20948
  const Eurydice_arr_e2 *signing_key,
20949
  Eurydice_borrow_slice_u8 message,
20950
  Eurydice_borrow_slice_u8 context,
20951
  Eurydice_arr_ec randomness,
20952
  Eurydice_arr_93 *signature
20953
)
20954
0
{
20955
0
  return
20956
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_sign_mut(libcrux_ml_dsa_types_as_ref_9b_72(signing_key),
20957
0
      message,
20958
0
      context,
20959
0
      randomness,
20960
0
      signature);
20961
0
}
20962
20963
/**
20964
 Generate a HashML-DSA-87 Signature, with a SHAKE128 pre-hashing
20965
20966
 The parameter `context` is used for domain separation
20967
 and is a byte string of length at most 255 bytes. It
20968
 may also be empty.
20969
*/
20970
static inline core_result_Result_8b
20971
libcrux_ml_dsa_ml_dsa_87_portable_sign_pre_hashed_shake128(
20972
  const Eurydice_arr_e2 *signing_key,
20973
  Eurydice_borrow_slice_u8 message,
20974
  Eurydice_borrow_slice_u8 context,
20975
  Eurydice_arr_ec randomness
20976
)
20977
0
{
20978
0
  Eurydice_arr_ec pre_hash_buffer = { .data = { 0U } };
20979
0
  const Eurydice_arr_e2 *uu____0 = libcrux_ml_dsa_types_as_ref_9b_72(signing_key);
20980
0
  return
20981
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_sign_pre_hashed_shake128(uu____0,
20982
0
      message,
20983
0
      context,
20984
0
      Eurydice_array_to_slice_mut_01(&pre_hash_buffer),
20985
0
      randomness);
20986
0
}
20987
20988
/**
20989
 Verify an ML-DSA-87 Signature
20990
20991
 The parameter `context` is used for domain separation
20992
 and is a byte string of length at most 255 bytes. It
20993
 may also be empty.
20994
*/
20995
static inline core_result_Result_41
20996
libcrux_ml_dsa_ml_dsa_87_portable_verify(
20997
  const Eurydice_arr_43 *verification_key,
20998
  Eurydice_borrow_slice_u8 message,
20999
  Eurydice_borrow_slice_u8 context,
21000
  const Eurydice_arr_93 *signature
21001
)
21002
0
{
21003
0
  return
21004
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_verify(libcrux_ml_dsa_types_as_ref_7f_c6(verification_key),
21005
0
      message,
21006
0
      context,
21007
0
      libcrux_ml_dsa_types_as_ref_c5_f1(signature));
21008
0
}
21009
21010
/**
21011
 Verify a HashML-DSA-87 Signature, with a SHAKE128 pre-hashing
21012
21013
 The parameter `context` is used for domain separation
21014
 and is a byte string of length at most 255 bytes. It
21015
 may also be empty.
21016
*/
21017
static inline core_result_Result_41
21018
libcrux_ml_dsa_ml_dsa_87_portable_verify_pre_hashed_shake128(
21019
  const Eurydice_arr_43 *verification_key,
21020
  Eurydice_borrow_slice_u8 message,
21021
  Eurydice_borrow_slice_u8 context,
21022
  const Eurydice_arr_93 *signature
21023
)
21024
0
{
21025
0
  Eurydice_arr_ec pre_hash_buffer = { .data = { 0U } };
21026
0
  const Eurydice_arr_43 *uu____0 = libcrux_ml_dsa_types_as_ref_7f_c6(verification_key);
21027
0
  Eurydice_borrow_slice_u8 uu____1 = message;
21028
0
  Eurydice_borrow_slice_u8 uu____2 = context;
21029
0
  Eurydice_mut_borrow_slice_u8 uu____3 = Eurydice_array_to_slice_mut_01(&pre_hash_buffer);
21030
0
  return
21031
0
    libcrux_ml_dsa_ml_dsa_generic_instantiations_portable_ml_dsa_87_verify_pre_hashed_shake128(uu____0,
21032
0
      uu____1,
21033
0
      uu____2,
21034
0
      uu____3,
21035
0
      libcrux_ml_dsa_types_as_ref_c5_f1(signature));
21036
0
}
21037
21038
#if defined(__cplusplus)
21039
}
21040
#endif
21041
21042
#define libcrux_mldsa87_portable_H_DEFINED
21043
#endif /* libcrux_mldsa87_portable_H */
21044
21045
/* from libcrux/combined_extraction/generated/libcrux_mlkem768_portable.h */
21046
/*
21047
 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
21048
 *
21049
 * SPDX-License-Identifier: MIT or Apache-2.0
21050
 *
21051
 * This code was generated with the following revisions:
21052
 * Charon: e656e17bff6ca5efac8ab6919b9b74cb9a8dd8ad
21053
 * Eurydice: aaa9fa657fb6f09802edb890252040d94cd93982
21054
 * Karamel: 8c19d41458ce5cbfea029ebc03334ba96d149039
21055
 * F*: unset
21056
 * Libcrux: c4e5e5e511bbc4c53f826163f57bfd10e9228911
21057
 */
21058
21059
21060
#ifndef libcrux_mlkem768_portable_H
21061
#define libcrux_mlkem768_portable_H
21062
21063
21064
21065
#if defined(__cplusplus)
21066
extern "C" {
21067
#endif
21068
21069
21070
static inline Eurydice_arr_c7
21071
libcrux_ml_kem_hash_functions_portable_G(Eurydice_borrow_slice_u8 input)
21072
0
{
21073
0
  Eurydice_arr_c7 digest = { .data = { 0U } };
21074
0
  libcrux_sha3_portable_sha512(Eurydice_array_to_slice_mut_17(&digest), input);
21075
0
  return digest;
21076
0
}
21077
21078
static inline Eurydice_arr_ec
21079
libcrux_ml_kem_hash_functions_portable_H(Eurydice_borrow_slice_u8 input)
21080
0
{
21081
0
  Eurydice_arr_ec digest = { .data = { 0U } };
21082
0
  libcrux_sha3_portable_sha256(Eurydice_array_to_slice_mut_01(&digest), input);
21083
0
  return digest;
21084
0
}
21085
21086
0
#define LIBCRUX_ML_KEM_POLYNOMIAL_ZETAS_TIMES_MONTGOMERY_R ((KRML_CLITERAL(Eurydice_arr_34){ .data = { -1044, -758, -359, -1517, 1493, 1422, 287, 202, -171, 622, 1577, 182, 962, -1202, -1474, 1468, 573, -1325, 264, 383, -829, 1458, -1602, -130, -681, 1017, 732, 608, -1542, 411, -205, -1571, 1223, 652, -552, 1015, -1293, 1491, -282, -1544, 516, -8, -320, -666, -1618, -1162, 126, 1469, -853, -90, -271, 830, 107, -1421, -247, -951, -398, 961, -1508, -725, 448, -1065, 677, -1275, -1103, 430, 555, 843, -1251, 871, 1550, 105, 422, 587, 177, -235, -291, -460, 1574, 1653, -246, 778, 1159, -147, -777, 1483, -602, 1119, -1590, 644, -872, 349, 418, 329, -156, -75, 817, 1097, 603, 610, 1322, -1285, -1465, 384, -1215, -136, 1218, -1335, -874, 220, -1187, -1659, -1185, -1530, -1278, 794, -1510, -854, -870, 478, -108, -308, 996, 991, 958, -1460, 1522, 1628 } }))
21087
21088
static KRML_MUSTINLINE int16_t libcrux_ml_kem_polynomial_zeta(size_t i)
21089
0
{
21090
0
  return LIBCRUX_ML_KEM_POLYNOMIAL_ZETAS_TIMES_MONTGOMERY_R.data[i];
21091
0
}
21092
21093
0
#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
21094
21095
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
21096
21097
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS (1353)
21098
21099
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS (3329)
21100
21101
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R (62209U)
21102
21103
static KRML_MUSTINLINE Eurydice_arr_d6
21104
libcrux_ml_kem_vector_portable_vector_type_from_i16_array(Eurydice_borrow_slice_i16 array)
21105
0
{
21106
0
  Eurydice_arr_d6 arr;
21107
0
  memcpy(arr.data,
21108
0
    Eurydice_slice_subslice_shared_a6(array,
21109
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)16U })).ptr,
21110
0
    (size_t)16U * sizeof (int16_t));
21111
0
  return
21112
0
    core_result_unwrap_26_d3((
21113
0
        KRML_CLITERAL(core_result_Result_ec){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
21114
0
      ));
21115
0
}
21116
21117
/**
21118
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21119
*/
21120
static inline Eurydice_arr_d6
21121
libcrux_ml_kem_vector_portable_from_i16_array_b8(Eurydice_borrow_slice_i16 array)
21122
0
{
21123
0
  return
21124
0
    libcrux_ml_kem_vector_portable_vector_type_from_i16_array(libcrux_secrets_int_classify_public_classify_ref_6d_39(array));
21125
0
}
21126
21127
static KRML_MUSTINLINE Eurydice_arr_d6 libcrux_ml_kem_vector_portable_vector_type_zero(void)
21128
0
{
21129
0
  return
21130
0
    libcrux_secrets_int_public_integers_classify_27_4b((
21131
0
        KRML_CLITERAL(Eurydice_arr_d6){ .data = { 0U } }
21132
0
      ));
21133
0
}
21134
21135
/**
21136
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21137
*/
21138
static inline Eurydice_arr_d6 libcrux_ml_kem_vector_portable_ZERO_b8(void)
21139
0
{
21140
0
  return libcrux_ml_kem_vector_portable_vector_type_zero();
21141
0
}
21142
21143
static KRML_MUSTINLINE Eurydice_arr_d6
21144
libcrux_ml_kem_vector_portable_arithmetic_add(Eurydice_arr_d6 lhs, const Eurydice_arr_d6 *rhs)
21145
0
{
21146
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21147
0
  {
21148
0
    size_t i0 = i;
21149
0
    size_t uu____0 = i0;
21150
0
    lhs.data[uu____0] += rhs->data[i0];
21151
0
  }
21152
0
  return lhs;
21153
0
}
21154
21155
/**
21156
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21157
*/
21158
static inline Eurydice_arr_d6
21159
libcrux_ml_kem_vector_portable_add_b8(Eurydice_arr_d6 lhs, const Eurydice_arr_d6 *rhs)
21160
0
{
21161
0
  return libcrux_ml_kem_vector_portable_arithmetic_add(lhs, rhs);
21162
0
}
21163
21164
static KRML_MUSTINLINE Eurydice_arr_d6
21165
libcrux_ml_kem_vector_portable_arithmetic_sub(Eurydice_arr_d6 lhs, const Eurydice_arr_d6 *rhs)
21166
0
{
21167
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21168
0
  {
21169
0
    size_t i0 = i;
21170
0
    size_t uu____0 = i0;
21171
0
    lhs.data[uu____0] -= rhs->data[i0];
21172
0
  }
21173
0
  return lhs;
21174
0
}
21175
21176
/**
21177
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21178
*/
21179
static inline Eurydice_arr_d6
21180
libcrux_ml_kem_vector_portable_sub_b8(Eurydice_arr_d6 lhs, const Eurydice_arr_d6 *rhs)
21181
0
{
21182
0
  return libcrux_ml_kem_vector_portable_arithmetic_sub(lhs, rhs);
21183
0
}
21184
21185
static KRML_MUSTINLINE Eurydice_arr_d6
21186
libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(Eurydice_arr_d6 vec, int16_t c)
21187
0
{
21188
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21189
0
  {
21190
0
    size_t i0 = i;
21191
0
    size_t uu____0 = i0;
21192
0
    vec.data[uu____0] *= c;
21193
0
  }
21194
0
  return vec;
21195
0
}
21196
21197
/**
21198
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21199
*/
21200
static inline Eurydice_arr_d6
21201
libcrux_ml_kem_vector_portable_multiply_by_constant_b8(Eurydice_arr_d6 vec, int16_t c)
21202
0
{
21203
0
  return libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(vec, c);
21204
0
}
21205
21206
/**
21207
 Note: This function is not secret independent
21208
 Only use with public values.
21209
*/
21210
static KRML_MUSTINLINE Eurydice_arr_d6
21211
libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329(Eurydice_arr_d6 vec)
21212
0
{
21213
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21214
0
  {
21215
0
    size_t i0 = i;
21216
0
    if (libcrux_secrets_int_public_integers_declassify_d8_39(vec.data[i0]) >= 3329)
21217
0
    {
21218
0
      size_t uu____0 = i0;
21219
0
      vec.data[uu____0] -= 3329;
21220
0
    }
21221
0
  }
21222
0
  return vec;
21223
0
}
21224
21225
/**
21226
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21227
*/
21228
static inline Eurydice_arr_d6
21229
libcrux_ml_kem_vector_portable_cond_subtract_3329_b8(Eurydice_arr_d6 v)
21230
0
{
21231
0
  return libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329(v);
21232
0
}
21233
21234
0
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER (20159)
21235
21236
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT (26)
21237
21238
0
#define LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_R ((int32_t)((uint32_t)1 << (uint32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT))
21239
21240
/**
21241
 Signed Barrett Reduction
21242
21243
 Given an input `value`, `barrett_reduce` outputs a representative `result`
21244
 such that:
21245
21246
 - result ≡ value (mod FIELD_MODULUS)
21247
 - the absolute value of `result` is bound as follows:
21248
21249
 `|result| ≤ FIELD_MODULUS / 2 · (|value|/BARRETT_R + 1)
21250
21251
 Note: The input bound is 28296 to prevent overflow in the multiplication of quotient by FIELD_MODULUS
21252
21253
*/
21254
static inline int16_t
21255
libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(int16_t value)
21256
0
{
21257
0
  int32_t
21258
0
  t =
21259
0
    libcrux_secrets_int_as_i32_f5(value) *
21260
0
      LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER
21261
0
    + (LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_R >> 1U);
21262
0
  int16_t
21263
0
  quotient =
21264
0
    libcrux_secrets_int_as_i16_36(t >> (uint32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT);
21265
0
  return value - quotient * LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
21266
0
}
21267
21268
static KRML_MUSTINLINE Eurydice_arr_d6
21269
libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(Eurydice_arr_d6 vec)
21270
0
{
21271
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21272
0
  {
21273
0
    size_t i0 = i;
21274
0
    int16_t vi = libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(vec.data[i0]);
21275
0
    vec.data[i0] = vi;
21276
0
  }
21277
0
  return vec;
21278
0
}
21279
21280
/**
21281
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21282
*/
21283
static inline Eurydice_arr_d6
21284
libcrux_ml_kem_vector_portable_barrett_reduce_b8(Eurydice_arr_d6 vector)
21285
0
{
21286
0
  return libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(vector);
21287
0
}
21288
21289
0
#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
21290
21291
/**
21292
 Signed Montgomery Reduction
21293
21294
 Given an input `value`, `montgomery_reduce` outputs a representative `o`
21295
 such that:
21296
21297
 - o ≡ value · MONTGOMERY_R^(-1) (mod FIELD_MODULUS)
21298
 - the absolute value of `o` is bound as follows:
21299
21300
 `|result| ≤ ceil(|value| / MONTGOMERY_R) + 1665
21301
21302
 In particular, if `|value| ≤ FIELD_MODULUS-1 * FIELD_MODULUS-1`, then `|o| <= FIELD_MODULUS-1`.
21303
 And, if `|value| ≤ pow2 16 * FIELD_MODULUS-1`, then `|o| <= FIELD_MODULUS + 1664
21304
21305
*/
21306
static inline int16_t
21307
libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(int32_t value)
21308
0
{
21309
0
  int32_t
21310
0
  k =
21311
0
    libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_as_i16_36(value)) *
21312
0
      libcrux_secrets_int_as_i32_b8(libcrux_secrets_int_public_integers_classify_27_df(LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R));
21313
0
  int32_t
21314
0
  k_times_modulus =
21315
0
    libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_as_i16_36(k)) *
21316
0
      libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_public_integers_classify_27_39(LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
21317
0
  int16_t
21318
0
  c =
21319
0
    libcrux_secrets_int_as_i16_36(k_times_modulus >>
21320
0
        (uint32_t)LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
21321
0
  int16_t
21322
0
  value_high =
21323
0
    libcrux_secrets_int_as_i16_36(value >>
21324
0
        (uint32_t)LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
21325
0
  return value_high - c;
21326
0
}
21327
21328
/**
21329
 If `fe` is some field element 'x' of the Kyber field and `fer` is congruent to
21330
 `y · MONTGOMERY_R`, this procedure outputs a value that is congruent to
21331
 `x · y`, as follows:
21332
21333
    `fe · fer ≡ x · y · MONTGOMERY_R (mod FIELD_MODULUS)`
21334
21335
 `montgomery_reduce` takes the value `x · y · MONTGOMERY_R` and outputs a representative
21336
 `x · y · MONTGOMERY_R * MONTGOMERY_R^{-1} ≡ x · y (mod FIELD_MODULUS)`.
21337
*/
21338
static KRML_MUSTINLINE int16_t
21339
libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
21340
  int16_t fe,
21341
  int16_t fer
21342
)
21343
0
{
21344
0
  int32_t product = libcrux_secrets_int_as_i32_f5(fe) * libcrux_secrets_int_as_i32_f5(fer);
21345
0
  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(product);
21346
0
}
21347
21348
static KRML_MUSTINLINE Eurydice_arr_d6
21349
libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(
21350
  Eurydice_arr_d6 vec,
21351
  int16_t c
21352
)
21353
0
{
21354
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21355
0
  {
21356
0
    size_t i0 = i;
21357
0
    vec.data[i0] =
21358
0
      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(vec.data[i0],
21359
0
        c);
21360
0
  }
21361
0
  return vec;
21362
0
}
21363
21364
/**
21365
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21366
*/
21367
static inline Eurydice_arr_d6
21368
libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
21369
  Eurydice_arr_d6 vector,
21370
  int16_t constant
21371
)
21372
0
{
21373
0
  return
21374
0
    libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(vector,
21375
0
      libcrux_secrets_int_public_integers_classify_27_39(constant));
21376
0
}
21377
21378
static KRML_MUSTINLINE Eurydice_arr_d6
21379
libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(
21380
  Eurydice_arr_d6 vec,
21381
  int16_t c
21382
)
21383
0
{
21384
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21385
0
  {
21386
0
    size_t i0 = i;
21387
0
    size_t uu____0 = i0;
21388
0
    vec.data[uu____0] &= c;
21389
0
  }
21390
0
  return vec;
21391
0
}
21392
21393
/**
21394
A monomorphic instance of libcrux_ml_kem.vector.portable.arithmetic.shift_right
21395
with const generics
21396
- SHIFT_BY= 15
21397
*/
21398
static KRML_MUSTINLINE Eurydice_arr_d6
21399
libcrux_ml_kem_vector_portable_arithmetic_shift_right_ef(Eurydice_arr_d6 vec)
21400
0
{
21401
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21402
0
  {
21403
0
    size_t i0 = i;
21404
0
    vec.data[i0] >>= (uint32_t)15;
21405
0
  }
21406
0
  return vec;
21407
0
}
21408
21409
static KRML_MUSTINLINE Eurydice_arr_d6
21410
libcrux_ml_kem_vector_portable_arithmetic_to_unsigned_representative(Eurydice_arr_d6 a)
21411
0
{
21412
0
  Eurydice_arr_d6 t = libcrux_ml_kem_vector_portable_arithmetic_shift_right_ef(a);
21413
0
  Eurydice_arr_d6
21414
0
  fm =
21415
0
    libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(t,
21416
0
      LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS);
21417
0
  return libcrux_ml_kem_vector_portable_arithmetic_add(a, &fm);
21418
0
}
21419
21420
/**
21421
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21422
*/
21423
static inline Eurydice_arr_d6
21424
libcrux_ml_kem_vector_portable_to_unsigned_representative_b8(Eurydice_arr_d6 a)
21425
0
{
21426
0
  return libcrux_ml_kem_vector_portable_arithmetic_to_unsigned_representative(a);
21427
0
}
21428
21429
/**
21430
 The `compress_*` functions implement the `Compress` function specified in the NIST FIPS
21431
 203 standard (Page 18, Expression 4.5), which is defined as:
21432
21433
 ```plaintext
21434
 Compress_d: ℤq -> ℤ_{2ᵈ}
21435
 Compress_d(x) = ⌈(2ᵈ/q)·x⌋
21436
 ```
21437
21438
 Since `⌈x⌋ = ⌊x + 1/2⌋` we have:
21439
21440
 ```plaintext
21441
 Compress_d(x) = ⌊(2ᵈ/q)·x + 1/2⌋
21442
               = ⌊(2^{d+1}·x + q) / 2q⌋
21443
 ```
21444
21445
 For further information about the function implementations, consult the
21446
 `implementation_notes.pdf` document in this directory.
21447
21448
 The NIST FIPS 203 standard can be found at
21449
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
21450
*/
21451
static inline uint8_t
21452
libcrux_ml_kem_vector_portable_compress_compress_message_coefficient(uint16_t fe)
21453
0
{
21454
0
  int16_t
21455
0
  shifted =
21456
0
    libcrux_secrets_int_public_integers_classify_27_39(1664) - libcrux_secrets_int_as_i16_ca(fe);
21457
0
  int16_t mask = shifted >> 15U;
21458
0
  int16_t shifted_to_positive = mask ^ shifted;
21459
0
  int16_t shifted_positive_in_range = shifted_to_positive - 832;
21460
0
  int16_t r0 = shifted_positive_in_range >> 15U;
21461
0
  int16_t r1 = r0 & 1;
21462
0
  return libcrux_secrets_int_as_u8_f5(r1);
21463
0
}
21464
21465
static KRML_MUSTINLINE Eurydice_arr_d6
21466
libcrux_ml_kem_vector_portable_compress_compress_1(Eurydice_arr_d6 a)
21467
0
{
21468
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
21469
0
  {
21470
0
    size_t i0 = i;
21471
0
    a.data[i0] =
21472
0
      libcrux_secrets_int_as_i16_59(libcrux_ml_kem_vector_portable_compress_compress_message_coefficient(libcrux_secrets_int_as_u16_f5(a.data[i0])));
21473
0
  }
21474
0
  return a;
21475
0
}
21476
21477
/**
21478
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21479
*/
21480
static inline Eurydice_arr_d6 libcrux_ml_kem_vector_portable_compress_1_b8(Eurydice_arr_d6 a)
21481
0
{
21482
0
  return libcrux_ml_kem_vector_portable_compress_compress_1(a);
21483
0
}
21484
21485
static KRML_MUSTINLINE uint32_t
21486
libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits(
21487
  uint8_t n,
21488
  uint32_t value
21489
)
21490
0
{
21491
0
  return value & ((1U << (uint32_t)n) - 1U);
21492
0
}
21493
21494
static inline int16_t
21495
libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
21496
  uint8_t coefficient_bits,
21497
  uint16_t fe
21498
)
21499
0
{
21500
0
  uint64_t compressed = libcrux_secrets_int_as_u64_ca(fe) << (uint32_t)coefficient_bits;
21501
0
  compressed += 1664ULL;
21502
0
  compressed *= 10321340ULL;
21503
0
  compressed >>= 35U;
21504
0
  return
21505
0
    libcrux_secrets_int_as_i16_b8(libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits(coefficient_bits,
21506
0
        libcrux_secrets_int_as_u32_a3(compressed)));
21507
0
}
21508
21509
static KRML_MUSTINLINE Eurydice_arr_d6
21510
libcrux_ml_kem_vector_portable_compress_decompress_1(Eurydice_arr_d6 a)
21511
0
{
21512
0
  Eurydice_arr_d6 z = libcrux_ml_kem_vector_portable_vector_type_zero();
21513
0
  Eurydice_arr_d6 s = libcrux_ml_kem_vector_portable_arithmetic_sub(z, &a);
21514
0
  Eurydice_arr_d6
21515
0
  res = libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(s, 1665);
21516
0
  return res;
21517
0
}
21518
21519
/**
21520
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21521
*/
21522
static inline Eurydice_arr_d6 libcrux_ml_kem_vector_portable_decompress_1_b8(Eurydice_arr_d6 a)
21523
0
{
21524
0
  return libcrux_ml_kem_vector_portable_compress_decompress_1(a);
21525
0
}
21526
21527
static KRML_MUSTINLINE void
21528
libcrux_ml_kem_vector_portable_ntt_ntt_step(
21529
  Eurydice_arr_d6 *vec,
21530
  int16_t zeta,
21531
  size_t i,
21532
  size_t j
21533
)
21534
0
{
21535
0
  int16_t
21536
0
  t =
21537
0
    libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(vec->data[j],
21538
0
      libcrux_secrets_int_public_integers_classify_27_39(zeta));
21539
0
  int16_t a_minus_t = vec->data[i] - t;
21540
0
  int16_t a_plus_t = vec->data[i] + t;
21541
0
  vec->data[j] = a_minus_t;
21542
0
  vec->data[i] = a_plus_t;
21543
0
}
21544
21545
static KRML_MUSTINLINE Eurydice_arr_d6
21546
libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(
21547
  Eurydice_arr_d6 vec,
21548
  int16_t zeta0,
21549
  int16_t zeta1,
21550
  int16_t zeta2,
21551
  int16_t zeta3
21552
)
21553
0
{
21554
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)0U, (size_t)2U);
21555
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)1U, (size_t)3U);
21556
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)4U, (size_t)6U);
21557
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)5U, (size_t)7U);
21558
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta2, (size_t)8U, (size_t)10U);
21559
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta2, (size_t)9U, (size_t)11U);
21560
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta3, (size_t)12U, (size_t)14U);
21561
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta3, (size_t)13U, (size_t)15U);
21562
0
  return vec;
21563
0
}
21564
21565
/**
21566
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21567
*/
21568
static inline Eurydice_arr_d6
21569
libcrux_ml_kem_vector_portable_ntt_layer_1_step_b8(
21570
  Eurydice_arr_d6 a,
21571
  int16_t zeta0,
21572
  int16_t zeta1,
21573
  int16_t zeta2,
21574
  int16_t zeta3
21575
)
21576
0
{
21577
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(a, zeta0, zeta1, zeta2, zeta3);
21578
0
}
21579
21580
static KRML_MUSTINLINE Eurydice_arr_d6
21581
libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(
21582
  Eurydice_arr_d6 vec,
21583
  int16_t zeta0,
21584
  int16_t zeta1
21585
)
21586
0
{
21587
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)0U, (size_t)4U);
21588
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)1U, (size_t)5U);
21589
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)2U, (size_t)6U);
21590
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)3U, (size_t)7U);
21591
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)8U, (size_t)12U);
21592
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)9U, (size_t)13U);
21593
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)10U, (size_t)14U);
21594
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)11U, (size_t)15U);
21595
0
  return vec;
21596
0
}
21597
21598
/**
21599
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21600
*/
21601
static inline Eurydice_arr_d6
21602
libcrux_ml_kem_vector_portable_ntt_layer_2_step_b8(
21603
  Eurydice_arr_d6 a,
21604
  int16_t zeta0,
21605
  int16_t zeta1
21606
)
21607
0
{
21608
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(a, zeta0, zeta1);
21609
0
}
21610
21611
static KRML_MUSTINLINE Eurydice_arr_d6
21612
libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(Eurydice_arr_d6 vec, int16_t zeta)
21613
0
{
21614
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)0U, (size_t)8U);
21615
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)1U, (size_t)9U);
21616
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)2U, (size_t)10U);
21617
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)3U, (size_t)11U);
21618
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)4U, (size_t)12U);
21619
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)5U, (size_t)13U);
21620
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)6U, (size_t)14U);
21621
0
  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)7U, (size_t)15U);
21622
0
  return vec;
21623
0
}
21624
21625
/**
21626
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21627
*/
21628
static inline Eurydice_arr_d6
21629
libcrux_ml_kem_vector_portable_ntt_layer_3_step_b8(Eurydice_arr_d6 a, int16_t zeta)
21630
0
{
21631
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(a, zeta);
21632
0
}
21633
21634
static KRML_MUSTINLINE void
21635
libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(
21636
  Eurydice_arr_d6 *vec,
21637
  int16_t zeta,
21638
  size_t i,
21639
  size_t j
21640
)
21641
0
{
21642
0
  int16_t a_minus_b = vec->data[j] - vec->data[i];
21643
0
  int16_t a_plus_b = vec->data[j] + vec->data[i];
21644
0
  int16_t o0 = libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(a_plus_b);
21645
0
  int16_t
21646
0
  o1 =
21647
0
    libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(a_minus_b,
21648
0
      libcrux_secrets_int_public_integers_classify_27_39(zeta));
21649
0
  vec->data[i] = o0;
21650
0
  vec->data[j] = o1;
21651
0
}
21652
21653
static KRML_MUSTINLINE Eurydice_arr_d6
21654
libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step(
21655
  Eurydice_arr_d6 vec,
21656
  int16_t zeta0,
21657
  int16_t zeta1,
21658
  int16_t zeta2,
21659
  int16_t zeta3
21660
)
21661
0
{
21662
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)0U, (size_t)2U);
21663
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)1U, (size_t)3U);
21664
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)4U, (size_t)6U);
21665
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)5U, (size_t)7U);
21666
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta2, (size_t)8U, (size_t)10U);
21667
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta2, (size_t)9U, (size_t)11U);
21668
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta3, (size_t)12U, (size_t)14U);
21669
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta3, (size_t)13U, (size_t)15U);
21670
0
  return vec;
21671
0
}
21672
21673
/**
21674
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21675
*/
21676
static inline Eurydice_arr_d6
21677
libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_b8(
21678
  Eurydice_arr_d6 a,
21679
  int16_t zeta0,
21680
  int16_t zeta1,
21681
  int16_t zeta2,
21682
  int16_t zeta3
21683
)
21684
0
{
21685
0
  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step(a, zeta0, zeta1, zeta2, zeta3);
21686
0
}
21687
21688
static KRML_MUSTINLINE Eurydice_arr_d6
21689
libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step(
21690
  Eurydice_arr_d6 vec,
21691
  int16_t zeta0,
21692
  int16_t zeta1
21693
)
21694
0
{
21695
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)0U, (size_t)4U);
21696
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)1U, (size_t)5U);
21697
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)2U, (size_t)6U);
21698
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)3U, (size_t)7U);
21699
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)8U, (size_t)12U);
21700
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)9U, (size_t)13U);
21701
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)10U, (size_t)14U);
21702
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)11U, (size_t)15U);
21703
0
  return vec;
21704
0
}
21705
21706
/**
21707
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21708
*/
21709
static inline Eurydice_arr_d6
21710
libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_b8(
21711
  Eurydice_arr_d6 a,
21712
  int16_t zeta0,
21713
  int16_t zeta1
21714
)
21715
0
{
21716
0
  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step(a, zeta0, zeta1);
21717
0
}
21718
21719
static KRML_MUSTINLINE Eurydice_arr_d6
21720
libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step(Eurydice_arr_d6 vec, int16_t zeta)
21721
0
{
21722
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)0U, (size_t)8U);
21723
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)1U, (size_t)9U);
21724
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)2U, (size_t)10U);
21725
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)3U, (size_t)11U);
21726
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)4U, (size_t)12U);
21727
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)5U, (size_t)13U);
21728
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)6U, (size_t)14U);
21729
0
  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)7U, (size_t)15U);
21730
0
  return vec;
21731
0
}
21732
21733
/**
21734
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21735
*/
21736
static inline Eurydice_arr_d6
21737
libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_b8(Eurydice_arr_d6 a, int16_t zeta)
21738
0
{
21739
0
  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step(a, zeta);
21740
0
}
21741
21742
/**
21743
 Compute the product of two Kyber binomials with respect to the
21744
 modulus `X² - zeta`.
21745
21746
 This function almost implements <strong>Algorithm 11</strong> of the
21747
 NIST FIPS 203 standard, which is reproduced below:
21748
21749
 ```plaintext
21750
 Input:  a₀, a₁, b₀, b₁ ∈ ℤq.
21751
 Input: γ ∈ ℤq.
21752
 Output: c₀, c₁ ∈ ℤq.
21753
21754
 c₀ ← a₀·b₀ + a₁·b₁·γ
21755
 c₁ ← a₀·b₁ + a₁·b₀
21756
 return c₀, c₁
21757
 ```
21758
 We say "almost" because the coefficients output by this function are in
21759
 the Montgomery domain (unlike in the specification).
21760
21761
 The NIST FIPS 203 standard can be found at
21762
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
21763
*/
21764
static KRML_MUSTINLINE void
21765
libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
21766
  const Eurydice_arr_d6 *a,
21767
  const Eurydice_arr_d6 *b,
21768
  int16_t zeta,
21769
  size_t i,
21770
  Eurydice_arr_d6 *out
21771
)
21772
0
{
21773
0
  int16_t ai = a->data[(size_t)2U * i];
21774
0
  int16_t bi = b->data[(size_t)2U * i];
21775
0
  int16_t aj = a->data[(size_t)2U * i + (size_t)1U];
21776
0
  int16_t bj = b->data[(size_t)2U * i + (size_t)1U];
21777
0
  int32_t ai_bi = libcrux_secrets_int_as_i32_f5(ai) * libcrux_secrets_int_as_i32_f5(bi);
21778
0
  int32_t aj_bj_ = libcrux_secrets_int_as_i32_f5(aj) * libcrux_secrets_int_as_i32_f5(bj);
21779
0
  int16_t aj_bj = libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(aj_bj_);
21780
0
  int32_t
21781
0
  aj_bj_zeta = libcrux_secrets_int_as_i32_f5(aj_bj) * libcrux_secrets_int_as_i32_f5(zeta);
21782
0
  int32_t ai_bi_aj_bj = ai_bi + aj_bj_zeta;
21783
0
  int16_t o0 = libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(ai_bi_aj_bj);
21784
0
  int32_t ai_bj = libcrux_secrets_int_as_i32_f5(ai) * libcrux_secrets_int_as_i32_f5(bj);
21785
0
  int32_t aj_bi = libcrux_secrets_int_as_i32_f5(aj) * libcrux_secrets_int_as_i32_f5(bi);
21786
0
  int32_t ai_bj_aj_bi = ai_bj + aj_bi;
21787
0
  int16_t o1 = libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(ai_bj_aj_bi);
21788
0
  out->data[(size_t)2U * i] = o0;
21789
0
  out->data[(size_t)2U * i + (size_t)1U] = o1;
21790
0
}
21791
21792
static KRML_MUSTINLINE Eurydice_arr_d6
21793
libcrux_ml_kem_vector_portable_ntt_ntt_multiply(
21794
  const Eurydice_arr_d6 *lhs,
21795
  const Eurydice_arr_d6 *rhs,
21796
  int16_t zeta0,
21797
  int16_t zeta1,
21798
  int16_t zeta2,
21799
  int16_t zeta3
21800
)
21801
0
{
21802
0
  int16_t nzeta0 = -zeta0;
21803
0
  int16_t nzeta1 = -zeta1;
21804
0
  int16_t nzeta2 = -zeta2;
21805
0
  int16_t nzeta3 = -zeta3;
21806
0
  Eurydice_arr_d6 out = libcrux_ml_kem_vector_portable_vector_type_zero();
21807
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21808
0
    rhs,
21809
0
    libcrux_secrets_int_public_integers_classify_27_39(zeta0),
21810
0
    (size_t)0U,
21811
0
    &out);
21812
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21813
0
    rhs,
21814
0
    libcrux_secrets_int_public_integers_classify_27_39(nzeta0),
21815
0
    (size_t)1U,
21816
0
    &out);
21817
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21818
0
    rhs,
21819
0
    libcrux_secrets_int_public_integers_classify_27_39(zeta1),
21820
0
    (size_t)2U,
21821
0
    &out);
21822
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21823
0
    rhs,
21824
0
    libcrux_secrets_int_public_integers_classify_27_39(nzeta1),
21825
0
    (size_t)3U,
21826
0
    &out);
21827
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21828
0
    rhs,
21829
0
    libcrux_secrets_int_public_integers_classify_27_39(zeta2),
21830
0
    (size_t)4U,
21831
0
    &out);
21832
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21833
0
    rhs,
21834
0
    libcrux_secrets_int_public_integers_classify_27_39(nzeta2),
21835
0
    (size_t)5U,
21836
0
    &out);
21837
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21838
0
    rhs,
21839
0
    libcrux_secrets_int_public_integers_classify_27_39(zeta3),
21840
0
    (size_t)6U,
21841
0
    &out);
21842
0
  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(lhs,
21843
0
    rhs,
21844
0
    libcrux_secrets_int_public_integers_classify_27_39(nzeta3),
21845
0
    (size_t)7U,
21846
0
    &out);
21847
0
  return out;
21848
0
}
21849
21850
/**
21851
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21852
*/
21853
static inline Eurydice_arr_d6
21854
libcrux_ml_kem_vector_portable_ntt_multiply_b8(
21855
  const Eurydice_arr_d6 *lhs,
21856
  const Eurydice_arr_d6 *rhs,
21857
  int16_t zeta0,
21858
  int16_t zeta1,
21859
  int16_t zeta2,
21860
  int16_t zeta3
21861
)
21862
0
{
21863
0
  return libcrux_ml_kem_vector_portable_ntt_ntt_multiply(lhs, rhs, zeta0, zeta1, zeta2, zeta3);
21864
0
}
21865
21866
static KRML_MUSTINLINE Eurydice_array_u8x2
21867
libcrux_ml_kem_vector_portable_serialize_serialize_1(Eurydice_arr_d6 v)
21868
0
{
21869
0
  uint8_t
21870
0
  result0 =
21871
0
    (((((((uint32_t)libcrux_secrets_int_as_u8_f5(v.data[0U]) |
21872
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[1U]) << 1U)
21873
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[2U]) << 2U)
21874
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[3U]) << 3U)
21875
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[4U]) << 4U)
21876
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[5U]) << 5U)
21877
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[6U]) << 6U)
21878
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[7U]) << 7U;
21879
0
  uint8_t
21880
0
  result1 =
21881
0
    (((((((uint32_t)libcrux_secrets_int_as_u8_f5(v.data[8U]) |
21882
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[9U]) << 1U)
21883
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[10U]) << 2U)
21884
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[11U]) << 3U)
21885
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[12U]) << 4U)
21886
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[13U]) << 5U)
21887
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[14U]) << 6U)
21888
0
    | (uint32_t)libcrux_secrets_int_as_u8_f5(v.data[15U]) << 7U;
21889
0
  return (KRML_CLITERAL(Eurydice_array_u8x2){ .data = { result0, result1 } });
21890
0
}
21891
21892
static inline Eurydice_array_u8x2 libcrux_ml_kem_vector_portable_serialize_1(Eurydice_arr_d6 a)
21893
0
{
21894
0
  return
21895
0
    libcrux_secrets_int_public_integers_declassify_d8_75(libcrux_ml_kem_vector_portable_serialize_serialize_1(a));
21896
0
}
21897
21898
/**
21899
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21900
*/
21901
static inline Eurydice_array_u8x2
21902
libcrux_ml_kem_vector_portable_serialize_1_b8(Eurydice_arr_d6 a)
21903
0
{
21904
0
  return libcrux_ml_kem_vector_portable_serialize_1(a);
21905
0
}
21906
21907
static KRML_MUSTINLINE Eurydice_arr_d6
21908
libcrux_ml_kem_vector_portable_serialize_deserialize_1(Eurydice_borrow_slice_u8 v)
21909
0
{
21910
0
  int16_t result0 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] & 1U);
21911
0
  int16_t result1 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 1U & 1U);
21912
0
  int16_t result2 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 2U & 1U);
21913
0
  int16_t result3 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 3U & 1U);
21914
0
  int16_t result4 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 4U & 1U);
21915
0
  int16_t result5 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 5U & 1U);
21916
0
  int16_t result6 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 6U & 1U);
21917
0
  int16_t result7 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[0U] >> 7U & 1U);
21918
0
  int16_t result8 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] & 1U);
21919
0
  int16_t result9 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 1U & 1U);
21920
0
  int16_t result10 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 2U & 1U);
21921
0
  int16_t result11 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 3U & 1U);
21922
0
  int16_t result12 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 4U & 1U);
21923
0
  int16_t result13 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 5U & 1U);
21924
0
  int16_t result14 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 6U & 1U);
21925
0
  int16_t result15 = libcrux_secrets_int_as_i16_59((uint32_t)v.ptr[1U] >> 7U & 1U);
21926
0
  return
21927
0
    (
21928
0
      KRML_CLITERAL(Eurydice_arr_d6){
21929
0
        .data = {
21930
0
          result0, result1, result2, result3, result4, result5, result6, result7, result8, result9,
21931
0
          result10, result11, result12, result13, result14, result15
21932
0
        }
21933
0
      }
21934
0
    );
21935
0
}
21936
21937
static inline Eurydice_arr_d6
21938
libcrux_ml_kem_vector_portable_deserialize_1(Eurydice_borrow_slice_u8 a)
21939
0
{
21940
0
  return
21941
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_1(libcrux_secrets_int_classify_public_classify_ref_6d_90(a));
21942
0
}
21943
21944
/**
21945
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
21946
*/
21947
static inline Eurydice_arr_d6
21948
libcrux_ml_kem_vector_portable_deserialize_1_b8(Eurydice_borrow_slice_u8 a)
21949
0
{
21950
0
  return libcrux_ml_kem_vector_portable_deserialize_1(a);
21951
0
}
21952
21953
static KRML_MUSTINLINE uint8_t_x4
21954
libcrux_ml_kem_vector_portable_serialize_serialize_4_int(Eurydice_borrow_slice_i16 v)
21955
0
{
21956
0
  uint8_t
21957
0
  result0 =
21958
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[1U]) << 4U |
21959
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[0U]);
21960
0
  uint8_t
21961
0
  result1 =
21962
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[3U]) << 4U |
21963
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[2U]);
21964
0
  uint8_t
21965
0
  result2 =
21966
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[5U]) << 4U |
21967
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[4U]);
21968
0
  uint8_t
21969
0
  result3 =
21970
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[7U]) << 4U |
21971
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[6U]);
21972
0
  return
21973
0
    (KRML_CLITERAL(uint8_t_x4){ .fst = result0, .snd = result1, .thd = result2, .f3 = result3 });
21974
0
}
21975
21976
static KRML_MUSTINLINE Eurydice_array_u8x8
21977
libcrux_ml_kem_vector_portable_serialize_serialize_4(Eurydice_arr_d6 v)
21978
0
{
21979
0
  uint8_t_x4
21980
0
  result0_3 =
21981
0
    libcrux_ml_kem_vector_portable_serialize_serialize_4_int(Eurydice_array_to_subslice_shared_e7(&v,
21982
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)8U })));
21983
0
  uint8_t_x4
21984
0
  result4_7 =
21985
0
    libcrux_ml_kem_vector_portable_serialize_serialize_4_int(Eurydice_array_to_subslice_shared_e7(&v,
21986
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)8U, .end = (size_t)16U })));
21987
0
  return
21988
0
    (
21989
0
      KRML_CLITERAL(Eurydice_array_u8x8){
21990
0
        .data = {
21991
0
          result0_3.fst, result0_3.snd, result0_3.thd, result0_3.f3, result4_7.fst, result4_7.snd,
21992
0
          result4_7.thd, result4_7.f3
21993
0
        }
21994
0
      }
21995
0
    );
21996
0
}
21997
21998
static inline Eurydice_array_u8x8 libcrux_ml_kem_vector_portable_serialize_4(Eurydice_arr_d6 a)
21999
0
{
22000
0
  return
22001
0
    libcrux_secrets_int_public_integers_declassify_d8_52(libcrux_ml_kem_vector_portable_serialize_serialize_4(a));
22002
0
}
22003
22004
/**
22005
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22006
*/
22007
static inline Eurydice_array_u8x8
22008
libcrux_ml_kem_vector_portable_serialize_4_b8(Eurydice_arr_d6 a)
22009
0
{
22010
0
  return libcrux_ml_kem_vector_portable_serialize_4(a);
22011
0
}
22012
22013
static KRML_MUSTINLINE int16_t_x8
22014
libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(Eurydice_borrow_slice_u8 bytes)
22015
0
{
22016
0
  int16_t v0 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[0U] & 15U);
22017
0
  int16_t v1 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[0U] >> 4U & 15U);
22018
0
  int16_t v2 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[1U] & 15U);
22019
0
  int16_t v3 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[1U] >> 4U & 15U);
22020
0
  int16_t v4 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[2U] & 15U);
22021
0
  int16_t v5 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[2U] >> 4U & 15U);
22022
0
  int16_t v6 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[3U] & 15U);
22023
0
  int16_t v7 = libcrux_secrets_int_as_i16_59((uint32_t)bytes.ptr[3U] >> 4U & 15U);
22024
0
  return
22025
0
    (
22026
0
      KRML_CLITERAL(int16_t_x8){
22027
0
        .fst = v0,
22028
0
        .snd = v1,
22029
0
        .thd = v2,
22030
0
        .f3 = v3,
22031
0
        .f4 = v4,
22032
0
        .f5 = v5,
22033
0
        .f6 = v6,
22034
0
        .f7 = v7
22035
0
      }
22036
0
    );
22037
0
}
22038
22039
static KRML_MUSTINLINE Eurydice_arr_d6
22040
libcrux_ml_kem_vector_portable_serialize_deserialize_4(Eurydice_borrow_slice_u8 bytes)
22041
0
{
22042
0
  int16_t_x8
22043
0
  v0_7 =
22044
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(Eurydice_slice_subslice_shared_c8(bytes,
22045
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)4U })));
22046
0
  int16_t_x8
22047
0
  v8_15 =
22048
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(Eurydice_slice_subslice_shared_c8(bytes,
22049
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)4U, .end = (size_t)8U })));
22050
0
  return
22051
0
    (
22052
0
      KRML_CLITERAL(Eurydice_arr_d6){
22053
0
        .data = {
22054
0
          v0_7.fst, v0_7.snd, v0_7.thd, v0_7.f3, v0_7.f4, v0_7.f5, v0_7.f6, v0_7.f7, v8_15.fst,
22055
0
          v8_15.snd, v8_15.thd, v8_15.f3, v8_15.f4, v8_15.f5, v8_15.f6, v8_15.f7
22056
0
        }
22057
0
      }
22058
0
    );
22059
0
}
22060
22061
static inline Eurydice_arr_d6
22062
libcrux_ml_kem_vector_portable_deserialize_4(Eurydice_borrow_slice_u8 a)
22063
0
{
22064
0
  return
22065
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_4(libcrux_secrets_int_classify_public_classify_ref_6d_90(a));
22066
0
}
22067
22068
/**
22069
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22070
*/
22071
static inline Eurydice_arr_d6
22072
libcrux_ml_kem_vector_portable_deserialize_4_b8(Eurydice_borrow_slice_u8 a)
22073
0
{
22074
0
  return libcrux_ml_kem_vector_portable_deserialize_4(a);
22075
0
}
22076
22077
static KRML_MUSTINLINE uint8_t_x5
22078
libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_borrow_slice_i16 v)
22079
0
{
22080
0
  uint8_t r0 = libcrux_secrets_int_as_u8_f5(v.ptr[0U] & 255);
22081
0
  uint8_t
22082
0
  r1 =
22083
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[1U] & 63) << 2U |
22084
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[0U] >> 8U & 3);
22085
0
  uint8_t
22086
0
  r2 =
22087
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[2U] & 15) << 4U |
22088
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[1U] >> 6U & 15);
22089
0
  uint8_t
22090
0
  r3 =
22091
0
    (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[3U] & 3) << 6U |
22092
0
      (uint32_t)libcrux_secrets_int_as_u8_f5(v.ptr[2U] >> 4U & 63);
22093
0
  uint8_t r4 = libcrux_secrets_int_as_u8_f5(v.ptr[3U] >> 2U & 255);
22094
0
  return (KRML_CLITERAL(uint8_t_x5){ .fst = r0, .snd = r1, .thd = r2, .f3 = r3, .f4 = r4 });
22095
0
}
22096
22097
static KRML_MUSTINLINE Eurydice_arr_fc
22098
libcrux_ml_kem_vector_portable_serialize_serialize_10(Eurydice_arr_d6 v)
22099
0
{
22100
0
  uint8_t_x5
22101
0
  r0_4 =
22102
0
    libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_array_to_subslice_shared_e7(&v,
22103
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)4U })));
22104
0
  uint8_t_x5
22105
0
  r5_9 =
22106
0
    libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_array_to_subslice_shared_e7(&v,
22107
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)4U, .end = (size_t)8U })));
22108
0
  uint8_t_x5
22109
0
  r10_14 =
22110
0
    libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_array_to_subslice_shared_e7(&v,
22111
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)8U, .end = (size_t)12U })));
22112
0
  uint8_t_x5
22113
0
  r15_19 =
22114
0
    libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_array_to_subslice_shared_e7(&v,
22115
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)12U, .end = (size_t)16U })));
22116
0
  return
22117
0
    (
22118
0
      KRML_CLITERAL(Eurydice_arr_fc){
22119
0
        .data = {
22120
0
          r0_4.fst, r0_4.snd, r0_4.thd, r0_4.f3, r0_4.f4, r5_9.fst, r5_9.snd, r5_9.thd, r5_9.f3,
22121
0
          r5_9.f4, r10_14.fst, r10_14.snd, r10_14.thd, r10_14.f3, r10_14.f4, r15_19.fst, r15_19.snd,
22122
0
          r15_19.thd, r15_19.f3, r15_19.f4
22123
0
        }
22124
0
      }
22125
0
    );
22126
0
}
22127
22128
static inline Eurydice_arr_fc libcrux_ml_kem_vector_portable_serialize_10(Eurydice_arr_d6 a)
22129
0
{
22130
0
  return
22131
0
    libcrux_secrets_int_public_integers_declassify_d8_2b(libcrux_ml_kem_vector_portable_serialize_serialize_10(a));
22132
0
}
22133
22134
/**
22135
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22136
*/
22137
static inline Eurydice_arr_fc libcrux_ml_kem_vector_portable_serialize_10_b8(Eurydice_arr_d6 a)
22138
0
{
22139
0
  return libcrux_ml_kem_vector_portable_serialize_10(a);
22140
0
}
22141
22142
static KRML_MUSTINLINE int16_t_x8
22143
libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(Eurydice_borrow_slice_u8 bytes)
22144
0
{
22145
0
  int16_t
22146
0
  r0 =
22147
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)(libcrux_secrets_int_as_i16_59(bytes.ptr[1U])
22148
0
      & 3)
22149
0
      << 8U)
22150
0
      | (libcrux_secrets_int_as_i16_59(bytes.ptr[0U]) & 255));
22151
0
  int16_t
22152
0
  r1 =
22153
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)(libcrux_secrets_int_as_i16_59(bytes.ptr[2U])
22154
0
      & 15)
22155
0
      << 6U)
22156
0
      | libcrux_secrets_int_as_i16_59(bytes.ptr[1U]) >> 2U);
22157
0
  int16_t
22158
0
  r2 =
22159
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)(libcrux_secrets_int_as_i16_59(bytes.ptr[3U])
22160
0
      & 63)
22161
0
      << 4U)
22162
0
      | libcrux_secrets_int_as_i16_59(bytes.ptr[2U]) >> 4U);
22163
0
  int16_t
22164
0
  r3 =
22165
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)libcrux_secrets_int_as_i16_59(bytes.ptr[4U])
22166
0
      << 2U)
22167
0
      | libcrux_secrets_int_as_i16_59(bytes.ptr[3U]) >> 6U);
22168
0
  int16_t
22169
0
  r4 =
22170
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)(libcrux_secrets_int_as_i16_59(bytes.ptr[6U])
22171
0
      & 3)
22172
0
      << 8U)
22173
0
      | (libcrux_secrets_int_as_i16_59(bytes.ptr[5U]) & 255));
22174
0
  int16_t
22175
0
  r5 =
22176
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)(libcrux_secrets_int_as_i16_59(bytes.ptr[7U])
22177
0
      & 15)
22178
0
      << 6U)
22179
0
      | libcrux_secrets_int_as_i16_59(bytes.ptr[6U]) >> 2U);
22180
0
  int16_t
22181
0
  r6 =
22182
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)(libcrux_secrets_int_as_i16_59(bytes.ptr[8U])
22183
0
      & 63)
22184
0
      << 4U)
22185
0
      | libcrux_secrets_int_as_i16_59(bytes.ptr[7U]) >> 4U);
22186
0
  int16_t
22187
0
  r7 =
22188
0
    libcrux_secrets_int_as_i16_f5((int16_t)((uint32_t)libcrux_secrets_int_as_i16_59(bytes.ptr[9U])
22189
0
      << 2U)
22190
0
      | libcrux_secrets_int_as_i16_59(bytes.ptr[8U]) >> 6U);
22191
0
  return
22192
0
    (
22193
0
      KRML_CLITERAL(int16_t_x8){
22194
0
        .fst = r0,
22195
0
        .snd = r1,
22196
0
        .thd = r2,
22197
0
        .f3 = r3,
22198
0
        .f4 = r4,
22199
0
        .f5 = r5,
22200
0
        .f6 = r6,
22201
0
        .f7 = r7
22202
0
      }
22203
0
    );
22204
0
}
22205
22206
static KRML_MUSTINLINE Eurydice_arr_d6
22207
libcrux_ml_kem_vector_portable_serialize_deserialize_10(Eurydice_borrow_slice_u8 bytes)
22208
0
{
22209
0
  int16_t_x8
22210
0
  v0_7 =
22211
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(Eurydice_slice_subslice_shared_c8(bytes,
22212
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)10U })));
22213
0
  int16_t_x8
22214
0
  v8_15 =
22215
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(Eurydice_slice_subslice_shared_c8(bytes,
22216
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)10U, .end = (size_t)20U })));
22217
0
  return
22218
0
    (
22219
0
      KRML_CLITERAL(Eurydice_arr_d6){
22220
0
        .data = {
22221
0
          v0_7.fst, v0_7.snd, v0_7.thd, v0_7.f3, v0_7.f4, v0_7.f5, v0_7.f6, v0_7.f7, v8_15.fst,
22222
0
          v8_15.snd, v8_15.thd, v8_15.f3, v8_15.f4, v8_15.f5, v8_15.f6, v8_15.f7
22223
0
        }
22224
0
      }
22225
0
    );
22226
0
}
22227
22228
static inline Eurydice_arr_d6
22229
libcrux_ml_kem_vector_portable_deserialize_10(Eurydice_borrow_slice_u8 a)
22230
0
{
22231
0
  return
22232
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_10(libcrux_secrets_int_classify_public_classify_ref_6d_90(a));
22233
0
}
22234
22235
/**
22236
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22237
*/
22238
static inline Eurydice_arr_d6
22239
libcrux_ml_kem_vector_portable_deserialize_10_b8(Eurydice_borrow_slice_u8 a)
22240
0
{
22241
0
  return libcrux_ml_kem_vector_portable_deserialize_10(a);
22242
0
}
22243
22244
static KRML_MUSTINLINE uint8_t_x3
22245
libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_borrow_slice_i16 v)
22246
0
{
22247
0
  uint8_t r0 = libcrux_secrets_int_as_u8_f5(v.ptr[0U] & 255);
22248
0
  uint8_t
22249
0
  r1 =
22250
0
    libcrux_secrets_int_as_u8_f5(v.ptr[0U] >> 8U | (int16_t)((uint32_t)(v.ptr[1U] & 15) << 4U));
22251
0
  uint8_t r2 = libcrux_secrets_int_as_u8_f5(v.ptr[1U] >> 4U & 255);
22252
0
  return (KRML_CLITERAL(uint8_t_x3){ .fst = r0, .snd = r1, .thd = r2 });
22253
0
}
22254
22255
static KRML_MUSTINLINE Eurydice_arr_94
22256
libcrux_ml_kem_vector_portable_serialize_serialize_12(Eurydice_arr_d6 v)
22257
0
{
22258
0
  uint8_t_x3
22259
0
  r0_2 =
22260
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22261
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)2U })));
22262
0
  uint8_t_x3
22263
0
  r3_5 =
22264
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22265
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)2U, .end = (size_t)4U })));
22266
0
  uint8_t_x3
22267
0
  r6_8 =
22268
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22269
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)4U, .end = (size_t)6U })));
22270
0
  uint8_t_x3
22271
0
  r9_11 =
22272
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22273
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)6U, .end = (size_t)8U })));
22274
0
  uint8_t_x3
22275
0
  r12_14 =
22276
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22277
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)8U, .end = (size_t)10U })));
22278
0
  uint8_t_x3
22279
0
  r15_17 =
22280
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22281
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)10U, .end = (size_t)12U })));
22282
0
  uint8_t_x3
22283
0
  r18_20 =
22284
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22285
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)12U, .end = (size_t)14U })));
22286
0
  uint8_t_x3
22287
0
  r21_23 =
22288
0
    libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_array_to_subslice_shared_e7(&v,
22289
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)14U, .end = (size_t)16U })));
22290
0
  return
22291
0
    (
22292
0
      KRML_CLITERAL(Eurydice_arr_94){
22293
0
        .data = {
22294
0
          r0_2.fst, r0_2.snd, r0_2.thd, r3_5.fst, r3_5.snd, r3_5.thd, r6_8.fst, r6_8.snd, r6_8.thd,
22295
0
          r9_11.fst, r9_11.snd, r9_11.thd, r12_14.fst, r12_14.snd, r12_14.thd, r15_17.fst,
22296
0
          r15_17.snd, r15_17.thd, r18_20.fst, r18_20.snd, r18_20.thd, r21_23.fst, r21_23.snd,
22297
0
          r21_23.thd
22298
0
        }
22299
0
      }
22300
0
    );
22301
0
}
22302
22303
static inline Eurydice_arr_94 libcrux_ml_kem_vector_portable_serialize_12(Eurydice_arr_d6 a)
22304
0
{
22305
0
  return
22306
0
    libcrux_secrets_int_public_integers_declassify_d8_40(libcrux_ml_kem_vector_portable_serialize_serialize_12(a));
22307
0
}
22308
22309
/**
22310
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22311
*/
22312
static inline Eurydice_arr_94 libcrux_ml_kem_vector_portable_serialize_12_b8(Eurydice_arr_d6 a)
22313
0
{
22314
0
  return libcrux_ml_kem_vector_portable_serialize_12(a);
22315
0
}
22316
22317
static KRML_MUSTINLINE int16_t_x2
22318
libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_borrow_slice_u8 bytes)
22319
0
{
22320
0
  int16_t byte0 = libcrux_secrets_int_as_i16_59(bytes.ptr[0U]);
22321
0
  int16_t byte1 = libcrux_secrets_int_as_i16_59(bytes.ptr[1U]);
22322
0
  int16_t byte2 = libcrux_secrets_int_as_i16_59(bytes.ptr[2U]);
22323
0
  int16_t r0 = (int16_t)((uint32_t)(byte1 & 15) << 8U) | (byte0 & 255);
22324
0
  int16_t r1 = (int16_t)((uint32_t)byte2 << 4U) | (byte1 >> 4U & 15);
22325
0
  return (KRML_CLITERAL(int16_t_x2){ .fst = r0, .snd = r1 });
22326
0
}
22327
22328
static KRML_MUSTINLINE Eurydice_arr_d6
22329
libcrux_ml_kem_vector_portable_serialize_deserialize_12(Eurydice_borrow_slice_u8 bytes)
22330
0
{
22331
0
  int16_t_x2
22332
0
  v0_1 =
22333
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22334
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)3U })));
22335
0
  int16_t_x2
22336
0
  v2_3 =
22337
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22338
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)3U, .end = (size_t)6U })));
22339
0
  int16_t_x2
22340
0
  v4_5 =
22341
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22342
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)6U, .end = (size_t)9U })));
22343
0
  int16_t_x2
22344
0
  v6_7 =
22345
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22346
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)9U, .end = (size_t)12U })));
22347
0
  int16_t_x2
22348
0
  v8_9 =
22349
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22350
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)12U, .end = (size_t)15U })));
22351
0
  int16_t_x2
22352
0
  v10_11 =
22353
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22354
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)15U, .end = (size_t)18U })));
22355
0
  int16_t_x2
22356
0
  v12_13 =
22357
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22358
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)18U, .end = (size_t)21U })));
22359
0
  int16_t_x2
22360
0
  v14_15 =
22361
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(Eurydice_slice_subslice_shared_c8(bytes,
22362
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)21U, .end = (size_t)24U })));
22363
0
  return
22364
0
    (
22365
0
      KRML_CLITERAL(Eurydice_arr_d6){
22366
0
        .data = {
22367
0
          v0_1.fst, v0_1.snd, v2_3.fst, v2_3.snd, v4_5.fst, v4_5.snd, v6_7.fst, v6_7.snd, v8_9.fst,
22368
0
          v8_9.snd, v10_11.fst, v10_11.snd, v12_13.fst, v12_13.snd, v14_15.fst, v14_15.snd
22369
0
        }
22370
0
      }
22371
0
    );
22372
0
}
22373
22374
static inline Eurydice_arr_d6
22375
libcrux_ml_kem_vector_portable_deserialize_12(Eurydice_borrow_slice_u8 a)
22376
0
{
22377
0
  return
22378
0
    libcrux_ml_kem_vector_portable_serialize_deserialize_12(libcrux_secrets_int_classify_public_classify_ref_6d_90(a));
22379
0
}
22380
22381
/**
22382
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22383
*/
22384
static inline Eurydice_arr_d6
22385
libcrux_ml_kem_vector_portable_deserialize_12_b8(Eurydice_borrow_slice_u8 a)
22386
0
{
22387
0
  return libcrux_ml_kem_vector_portable_deserialize_12(a);
22388
0
}
22389
22390
static KRML_MUSTINLINE size_t
22391
libcrux_ml_kem_vector_portable_sampling_rej_sample(
22392
  Eurydice_borrow_slice_u8 a,
22393
  Eurydice_mut_borrow_slice_i16 result
22394
)
22395
0
{
22396
0
  size_t sampled = (size_t)0U;
22397
0
  for (size_t i = (size_t)0U; i < a.meta / (size_t)3U; i++)
22398
0
  {
22399
0
    size_t i0 = i;
22400
0
    int16_t b1 = (int16_t)(uint32_t)a.ptr[i0 * (size_t)3U + (size_t)0U];
22401
0
    int16_t b2 = (int16_t)(uint32_t)a.ptr[i0 * (size_t)3U + (size_t)1U];
22402
0
    int16_t b3 = (int16_t)(uint32_t)a.ptr[i0 * (size_t)3U + (size_t)2U];
22403
0
    int16_t d1 = (int16_t)((uint32_t)(b2 & 15) << 8U) | b1;
22404
0
    int16_t d2 = (int16_t)((uint32_t)b3 << 4U) | b2 >> 4U;
22405
0
    if (d1 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS)
22406
0
    {
22407
0
      if (sampled < (size_t)16U)
22408
0
      {
22409
0
        result.ptr[sampled] = d1;
22410
0
        sampled++;
22411
0
      }
22412
0
    }
22413
0
    if (d2 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS)
22414
0
    {
22415
0
      if (sampled < (size_t)16U)
22416
0
      {
22417
0
        result.ptr[sampled] = d2;
22418
0
        sampled++;
22419
0
      }
22420
0
    }
22421
0
  }
22422
0
  return sampled;
22423
0
}
22424
22425
/**
22426
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22427
*/
22428
static inline size_t
22429
libcrux_ml_kem_vector_portable_rej_sample_b8(
22430
  Eurydice_borrow_slice_u8 a,
22431
  Eurydice_mut_borrow_slice_i16 out
22432
)
22433
0
{
22434
0
  return libcrux_ml_kem_vector_portable_sampling_rej_sample(a, out);
22435
0
}
22436
22437
#define LIBCRUX_ML_KEM_MLKEM768_VECTOR_U_COMPRESSION_FACTOR ((size_t)10U)
22438
22439
#define LIBCRUX_ML_KEM_MLKEM768_C1_BLOCK_SIZE (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * LIBCRUX_ML_KEM_MLKEM768_VECTOR_U_COMPRESSION_FACTOR / (size_t)8U)
22440
22441
#define LIBCRUX_ML_KEM_MLKEM768_RANK ((size_t)3U)
22442
22443
#define LIBCRUX_ML_KEM_MLKEM768_C1_SIZE (LIBCRUX_ML_KEM_MLKEM768_C1_BLOCK_SIZE * LIBCRUX_ML_KEM_MLKEM768_RANK)
22444
22445
#define LIBCRUX_ML_KEM_MLKEM768_VECTOR_V_COMPRESSION_FACTOR ((size_t)4U)
22446
22447
#define LIBCRUX_ML_KEM_MLKEM768_C2_SIZE (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * LIBCRUX_ML_KEM_MLKEM768_VECTOR_V_COMPRESSION_FACTOR / (size_t)8U)
22448
22449
#define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_CIPHERTEXT_SIZE (LIBCRUX_ML_KEM_MLKEM768_C1_SIZE + LIBCRUX_ML_KEM_MLKEM768_C2_SIZE)
22450
22451
#define LIBCRUX_ML_KEM_MLKEM768_T_AS_NTT_ENCODED_SIZE (LIBCRUX_ML_KEM_MLKEM768_RANK * LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT / (size_t)8U)
22452
22453
#define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_PUBLIC_KEY_SIZE (LIBCRUX_ML_KEM_MLKEM768_T_AS_NTT_ENCODED_SIZE + (size_t)32U)
22454
22455
#define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_SECRET_KEY_SIZE (LIBCRUX_ML_KEM_MLKEM768_RANK * LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT / (size_t)8U)
22456
22457
#define LIBCRUX_ML_KEM_MLKEM768_ETA1 ((size_t)2U)
22458
22459
#define LIBCRUX_ML_KEM_MLKEM768_ETA1_RANDOMNESS_SIZE (LIBCRUX_ML_KEM_MLKEM768_ETA1 * (size_t)64U)
22460
22461
#define LIBCRUX_ML_KEM_MLKEM768_ETA2 ((size_t)2U)
22462
22463
#define LIBCRUX_ML_KEM_MLKEM768_ETA2_RANDOMNESS_SIZE (LIBCRUX_ML_KEM_MLKEM768_ETA2 * (size_t)64U)
22464
22465
#define LIBCRUX_ML_KEM_MLKEM768_IMPLICIT_REJECTION_HASH_INPUT_SIZE (LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE + LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_CIPHERTEXT_SIZE)
22466
22467
typedef Eurydice_arr_7d libcrux_ml_kem_mlkem768_MlKem768PrivateKey;
22468
22469
typedef Eurydice_arr_5f libcrux_ml_kem_mlkem768_MlKem768PublicKey;
22470
22471
#define LIBCRUX_ML_KEM_MLKEM768_RANKED_BYTES_PER_RING_ELEMENT (LIBCRUX_ML_KEM_MLKEM768_RANK * LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U)
22472
22473
#define LIBCRUX_ML_KEM_MLKEM768_SECRET_KEY_SIZE (LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_SECRET_KEY_SIZE + LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_PUBLIC_KEY_SIZE + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE + LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE)
22474
22475
/**
22476
A monomorphic instance of Eurydice.arr
22477
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22478
with const generics
22479
- $16size_t
22480
*/
22481
typedef struct Eurydice_arr_9e_s { Eurydice_arr_d6 data[16U]; } Eurydice_arr_9e;
22482
22483
/**
22484
A monomorphic instance of Eurydice.arr
22485
with types libcrux_ml_kem_polynomial_PolynomialRingElement_1d
22486
with const generics
22487
- $3size_t
22488
*/
22489
typedef struct Eurydice_arr_bb0_s { Eurydice_arr_9e data[3U]; } Eurydice_arr_bb0;
22490
22491
/**
22492
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
22493
*/
22494
/**
22495
A monomorphic instance of libcrux_ml_kem.polynomial.ZERO_d6
22496
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22497
with const generics
22498
22499
*/
22500
static inline Eurydice_arr_9e libcrux_ml_kem_polynomial_ZERO_d6_ea(void)
22501
0
{
22502
0
  Eurydice_arr_9e lit;
22503
0
  Eurydice_arr_d6 repeat_expression[16U];
22504
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
22505
0
  {
22506
0
    repeat_expression[i] = libcrux_ml_kem_vector_portable_ZERO_b8();
22507
0
  }
22508
0
  memcpy(lit.data, repeat_expression, (size_t)16U * sizeof (Eurydice_arr_d6));
22509
0
  return lit;
22510
0
}
22511
22512
/**
22513
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]> for libcrux_ml_kem::ind_cpa::decrypt::closure<Vector, K, CIPHERTEXT_SIZE, VECTOR_U_ENCODED_SIZE, U_COMPRESSION_FACTOR, V_COMPRESSION_FACTOR>[TraitClause@0, TraitClause@1]}
22514
*/
22515
/**
22516
A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt.call_mut_0b
22517
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22518
with const generics
22519
- K= 3
22520
- CIPHERTEXT_SIZE= 1088
22521
- VECTOR_U_ENCODED_SIZE= 960
22522
- U_COMPRESSION_FACTOR= 10
22523
- V_COMPRESSION_FACTOR= 4
22524
*/
22525
static inline Eurydice_arr_9e
22526
libcrux_ml_kem_ind_cpa_decrypt_call_mut_0b_01(void **_, size_t tupled_args)
22527
0
{
22528
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
22529
0
}
22530
22531
/**
22532
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_to_uncompressed_ring_element
22533
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22534
with const generics
22535
22536
*/
22537
static KRML_MUSTINLINE Eurydice_arr_9e
22538
libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_ea(
22539
  Eurydice_borrow_slice_u8 serialized
22540
)
22541
0
{
22542
0
  Eurydice_arr_9e re = libcrux_ml_kem_polynomial_ZERO_d6_ea();
22543
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)24U; i++)
22544
0
  {
22545
0
    size_t i0 = i;
22546
0
    Eurydice_borrow_slice_u8
22547
0
    bytes =
22548
0
      Eurydice_slice_subslice_shared_c8(serialized,
22549
0
        (
22550
0
          KRML_CLITERAL(core_ops_range_Range_87){
22551
0
            .start = i0 * (size_t)24U,
22552
0
            .end = i0 * (size_t)24U + (size_t)24U
22553
0
          }
22554
0
        ));
22555
0
    Eurydice_arr_d6 uu____0 = libcrux_ml_kem_vector_portable_deserialize_12_b8(bytes);
22556
0
    re.data[i0] = uu____0;
22557
0
  }
22558
0
  return re;
22559
0
}
22560
22561
/**
22562
 Call [`deserialize_to_uncompressed_ring_element`] for each ring element.
22563
*/
22564
/**
22565
A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_vector
22566
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22567
with const generics
22568
- K= 3
22569
*/
22570
static KRML_MUSTINLINE void
22571
libcrux_ml_kem_ind_cpa_deserialize_vector_68(
22572
  Eurydice_borrow_slice_u8 secret_key,
22573
  Eurydice_arr_bb0 *secret_as_ntt
22574
)
22575
0
{
22576
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
22577
0
  {
22578
0
    size_t i0 = i;
22579
0
    Eurydice_arr_9e
22580
0
    uu____0 =
22581
0
      libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_ea(Eurydice_slice_subslice_shared_c8(secret_key,
22582
0
          (
22583
0
            KRML_CLITERAL(core_ops_range_Range_87){
22584
0
              .start = i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
22585
0
              .end = (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT
22586
0
            }
22587
0
          )));
22588
0
    secret_as_ntt->data[i0] = uu____0;
22589
0
  }
22590
0
}
22591
22592
/**
22593
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]> for libcrux_ml_kem::ind_cpa::deserialize_then_decompress_u::closure<Vector, K, CIPHERTEXT_SIZE, U_COMPRESSION_FACTOR>[TraitClause@0, TraitClause@1]}
22594
*/
22595
/**
22596
A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_then_decompress_u.call_mut_35
22597
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22598
with const generics
22599
- K= 3
22600
- CIPHERTEXT_SIZE= 1088
22601
- U_COMPRESSION_FACTOR= 10
22602
*/
22603
static inline Eurydice_arr_9e
22604
libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_call_mut_35_30(
22605
  void **_,
22606
  size_t tupled_args
22607
)
22608
0
{
22609
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
22610
0
}
22611
22612
/**
22613
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient
22614
with const generics
22615
- COEFFICIENT_BITS= 10
22616
*/
22617
static KRML_MUSTINLINE Eurydice_arr_d6
22618
libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_ef(Eurydice_arr_d6 a)
22619
0
{
22620
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
22621
0
  {
22622
0
    size_t i0 = i;
22623
0
    int32_t
22624
0
    decompressed =
22625
0
      libcrux_secrets_int_as_i32_f5(a.data[i0]) *
22626
0
        libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_public_integers_classify_27_39(LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
22627
0
    decompressed = (int32_t)((uint32_t)decompressed << 1U) + (int32_t)((uint32_t)1 << (uint32_t)10);
22628
0
    decompressed >>= (uint32_t)(10 + 1);
22629
0
    a.data[i0] = libcrux_secrets_int_as_i16_36(decompressed);
22630
0
  }
22631
0
  return a;
22632
0
}
22633
22634
/**
22635
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22636
*/
22637
/**
22638
A monomorphic instance of libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_b8
22639
with const generics
22640
- COEFFICIENT_BITS= 10
22641
*/
22642
static inline Eurydice_arr_d6
22643
libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_ef(Eurydice_arr_d6 a)
22644
0
{
22645
0
  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_ef(a);
22646
0
}
22647
22648
/**
22649
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_10
22650
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22651
with const generics
22652
22653
*/
22654
static KRML_MUSTINLINE Eurydice_arr_9e
22655
libcrux_ml_kem_serialize_deserialize_then_decompress_10_ea(Eurydice_borrow_slice_u8 serialized)
22656
0
{
22657
0
  Eurydice_arr_9e re = libcrux_ml_kem_polynomial_ZERO_d6_ea();
22658
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)20U; i++)
22659
0
  {
22660
0
    size_t i0 = i;
22661
0
    Eurydice_borrow_slice_u8
22662
0
    bytes =
22663
0
      Eurydice_slice_subslice_shared_c8(serialized,
22664
0
        (
22665
0
          KRML_CLITERAL(core_ops_range_Range_87){
22666
0
            .start = i0 * (size_t)20U,
22667
0
            .end = i0 * (size_t)20U + (size_t)20U
22668
0
          }
22669
0
        ));
22670
0
    Eurydice_arr_d6 coefficient = libcrux_ml_kem_vector_portable_deserialize_10_b8(bytes);
22671
0
    Eurydice_arr_d6
22672
0
    uu____0 = libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_ef(coefficient);
22673
0
    re.data[i0] = uu____0;
22674
0
  }
22675
0
  return re;
22676
0
}
22677
22678
/**
22679
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_ring_element_u
22680
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22681
with const generics
22682
- COMPRESSION_FACTOR= 10
22683
*/
22684
static KRML_MUSTINLINE Eurydice_arr_9e
22685
libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_f7(
22686
  Eurydice_borrow_slice_u8 serialized
22687
)
22688
0
{
22689
0
  return libcrux_ml_kem_serialize_deserialize_then_decompress_10_ea(serialized);
22690
0
}
22691
22692
typedef struct libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2_s
22693
{
22694
  Eurydice_arr_d6 fst;
22695
  Eurydice_arr_d6 snd;
22696
}
22697
libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2;
22698
22699
/**
22700
A monomorphic instance of libcrux_ml_kem.ntt.ntt_layer_int_vec_step
22701
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22702
with const generics
22703
22704
*/
22705
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2
22706
libcrux_ml_kem_ntt_ntt_layer_int_vec_step_ea(
22707
  Eurydice_arr_d6 a,
22708
  Eurydice_arr_d6 b,
22709
  int16_t zeta_r
22710
)
22711
0
{
22712
0
  Eurydice_arr_d6
22713
0
  t = libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(b, zeta_r);
22714
0
  b = libcrux_ml_kem_vector_portable_sub_b8(a, &t);
22715
0
  a = libcrux_ml_kem_vector_portable_add_b8(a, &t);
22716
0
  return
22717
0
    (
22718
0
      KRML_CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){
22719
0
        .fst = a,
22720
0
        .snd = b
22721
0
      }
22722
0
    );
22723
0
}
22724
22725
/**
22726
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_4_plus
22727
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22728
with const generics
22729
22730
*/
22731
static KRML_MUSTINLINE void
22732
libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(
22733
  size_t *zeta_i,
22734
  Eurydice_arr_9e *re,
22735
  size_t layer,
22736
  size_t _initial_coefficient_bound
22737
)
22738
0
{
22739
0
  size_t step = (size_t)1U << (uint32_t)layer;
22740
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++)
22741
0
  {
22742
0
    size_t round = i0;
22743
0
    zeta_i[0U]++;
22744
0
    size_t offset = round * step * (size_t)2U;
22745
0
    size_t offset_vec = offset / (size_t)16U;
22746
0
    size_t step_vec = step / (size_t)16U;
22747
0
    for (size_t i = offset_vec; i < offset_vec + step_vec; i++)
22748
0
    {
22749
0
      size_t j = i;
22750
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2
22751
0
      uu____0 =
22752
0
        libcrux_ml_kem_ntt_ntt_layer_int_vec_step_ea(re->data[j],
22753
0
          re->data[j + step_vec],
22754
0
          libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
22755
0
      Eurydice_arr_d6 x = uu____0.fst;
22756
0
      Eurydice_arr_d6 y = uu____0.snd;
22757
0
      re->data[j] = x;
22758
0
      re->data[j + step_vec] = y;
22759
0
    }
22760
0
  }
22761
0
}
22762
22763
/**
22764
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_3
22765
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22766
with const generics
22767
22768
*/
22769
static KRML_MUSTINLINE void
22770
libcrux_ml_kem_ntt_ntt_at_layer_3_ea(
22771
  size_t *zeta_i,
22772
  Eurydice_arr_9e *re,
22773
  size_t _initial_coefficient_bound
22774
)
22775
0
{
22776
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
22777
0
  {
22778
0
    size_t round = i;
22779
0
    zeta_i[0U]++;
22780
0
    Eurydice_arr_d6
22781
0
    uu____0 =
22782
0
      libcrux_ml_kem_vector_portable_ntt_layer_3_step_b8(re->data[round],
22783
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
22784
0
    re->data[round] = uu____0;
22785
0
  }
22786
0
}
22787
22788
/**
22789
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_2
22790
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22791
with const generics
22792
22793
*/
22794
static KRML_MUSTINLINE void
22795
libcrux_ml_kem_ntt_ntt_at_layer_2_ea(
22796
  size_t *zeta_i,
22797
  Eurydice_arr_9e *re,
22798
  size_t _initial_coefficient_bound
22799
)
22800
0
{
22801
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
22802
0
  {
22803
0
    size_t round = i;
22804
0
    zeta_i[0U]++;
22805
0
    re->data[round] =
22806
0
      libcrux_ml_kem_vector_portable_ntt_layer_2_step_b8(re->data[round],
22807
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
22808
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)1U));
22809
0
    zeta_i[0U]++;
22810
0
  }
22811
0
}
22812
22813
/**
22814
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_1
22815
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22816
with const generics
22817
22818
*/
22819
static KRML_MUSTINLINE void
22820
libcrux_ml_kem_ntt_ntt_at_layer_1_ea(
22821
  size_t *zeta_i,
22822
  Eurydice_arr_9e *re,
22823
  size_t _initial_coefficient_bound
22824
)
22825
0
{
22826
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
22827
0
  {
22828
0
    size_t round = i;
22829
0
    zeta_i[0U]++;
22830
0
    re->data[round] =
22831
0
      libcrux_ml_kem_vector_portable_ntt_layer_1_step_b8(re->data[round],
22832
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
22833
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)1U),
22834
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)2U),
22835
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)3U));
22836
0
    zeta_i[0U] += (size_t)3U;
22837
0
  }
22838
0
}
22839
22840
/**
22841
A monomorphic instance of libcrux_ml_kem.polynomial.poly_barrett_reduce
22842
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22843
with const generics
22844
22845
*/
22846
static KRML_MUSTINLINE void
22847
libcrux_ml_kem_polynomial_poly_barrett_reduce_ea(Eurydice_arr_9e *myself)
22848
0
{
22849
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
22850
0
  {
22851
0
    size_t i0 = i;
22852
0
    Eurydice_arr_d6 uu____0 = libcrux_ml_kem_vector_portable_barrett_reduce_b8(myself->data[i0]);
22853
0
    myself->data[i0] = uu____0;
22854
0
  }
22855
0
}
22856
22857
/**
22858
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
22859
*/
22860
/**
22861
A monomorphic instance of libcrux_ml_kem.polynomial.poly_barrett_reduce_d6
22862
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22863
with const generics
22864
22865
*/
22866
static KRML_MUSTINLINE void
22867
libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(Eurydice_arr_9e *self)
22868
0
{
22869
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_ea(self);
22870
0
}
22871
22872
/**
22873
A monomorphic instance of libcrux_ml_kem.ntt.ntt_vector_u
22874
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22875
with const generics
22876
- VECTOR_U_COMPRESSION_FACTOR= 10
22877
*/
22878
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_vector_u_f7(Eurydice_arr_9e *re)
22879
0
{
22880
0
  size_t zeta_i = (size_t)0U;
22881
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)7U, (size_t)3328U);
22882
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)6U, (size_t)2U * (size_t)3328U);
22883
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)5U, (size_t)3U * (size_t)3328U);
22884
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)4U, (size_t)4U * (size_t)3328U);
22885
0
  libcrux_ml_kem_ntt_ntt_at_layer_3_ea(&zeta_i, re, (size_t)5U * (size_t)3328U);
22886
0
  libcrux_ml_kem_ntt_ntt_at_layer_2_ea(&zeta_i, re, (size_t)6U * (size_t)3328U);
22887
0
  libcrux_ml_kem_ntt_ntt_at_layer_1_ea(&zeta_i, re, (size_t)7U * (size_t)3328U);
22888
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
22889
0
}
22890
22891
/**
22892
 Call [`deserialize_then_decompress_ring_element_u`] on each ring element
22893
 in the `ciphertext`.
22894
*/
22895
/**
22896
A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_then_decompress_u
22897
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22898
with const generics
22899
- K= 3
22900
- CIPHERTEXT_SIZE= 1088
22901
- U_COMPRESSION_FACTOR= 10
22902
*/
22903
static KRML_MUSTINLINE Eurydice_arr_bb0
22904
libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_30(const Eurydice_arr_2b *ciphertext)
22905
0
{
22906
0
  Eurydice_arr_bb0 arr_struct;
22907
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
22908
0
  {
22909
    /* original Rust expression is not an lvalue in C */
22910
0
    void *lvalue = (void *)0U;
22911
0
    arr_struct.data[i] =
22912
0
      libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_call_mut_35_30(&lvalue,
22913
0
        i);
22914
0
  }
22915
0
  Eurydice_arr_bb0 u_as_ntt = arr_struct;
22916
0
  for
22917
0
  (size_t
22918
0
    i = (size_t)0U;
22919
0
    i <
22920
0
      (size_t)1088U /
22921
0
        (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)10U / (size_t)8U);
22922
0
    i++)
22923
0
  {
22924
0
    size_t i0 = i;
22925
0
    Eurydice_borrow_slice_u8
22926
0
    u_bytes =
22927
0
      Eurydice_array_to_subslice_shared_d44(ciphertext,
22928
0
        (
22929
0
          KRML_CLITERAL(core_ops_range_Range_87){
22930
0
            .start = i0 *
22931
0
              (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)10U / (size_t)8U),
22932
0
            .end = i0 *
22933
0
              (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)10U / (size_t)8U)
22934
0
            + LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)10U / (size_t)8U
22935
0
          }
22936
0
        ));
22937
0
    u_as_ntt.data[i0] =
22938
0
      libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_f7(u_bytes);
22939
0
    libcrux_ml_kem_ntt_ntt_vector_u_f7(&u_as_ntt.data[i0]);
22940
0
  }
22941
0
  return u_as_ntt;
22942
0
}
22943
22944
/**
22945
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient
22946
with const generics
22947
- COEFFICIENT_BITS= 4
22948
*/
22949
static KRML_MUSTINLINE Eurydice_arr_d6
22950
libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_d1(Eurydice_arr_d6 a)
22951
0
{
22952
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
22953
0
  {
22954
0
    size_t i0 = i;
22955
0
    int32_t
22956
0
    decompressed =
22957
0
      libcrux_secrets_int_as_i32_f5(a.data[i0]) *
22958
0
        libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_public_integers_classify_27_39(LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
22959
0
    decompressed = (int32_t)((uint32_t)decompressed << 1U) + (int32_t)((uint32_t)1 << (uint32_t)4);
22960
0
    decompressed >>= (uint32_t)(4 + 1);
22961
0
    a.data[i0] = libcrux_secrets_int_as_i16_36(decompressed);
22962
0
  }
22963
0
  return a;
22964
0
}
22965
22966
/**
22967
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
22968
*/
22969
/**
22970
A monomorphic instance of libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_b8
22971
with const generics
22972
- COEFFICIENT_BITS= 4
22973
*/
22974
static inline Eurydice_arr_d6
22975
libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_d1(Eurydice_arr_d6 a)
22976
0
{
22977
0
  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_d1(a);
22978
0
}
22979
22980
/**
22981
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_4
22982
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
22983
with const generics
22984
22985
*/
22986
static KRML_MUSTINLINE Eurydice_arr_9e
22987
libcrux_ml_kem_serialize_deserialize_then_decompress_4_ea(Eurydice_borrow_slice_u8 serialized)
22988
0
{
22989
0
  Eurydice_arr_9e re = libcrux_ml_kem_polynomial_ZERO_d6_ea();
22990
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)8U; i++)
22991
0
  {
22992
0
    size_t i0 = i;
22993
0
    Eurydice_borrow_slice_u8
22994
0
    bytes =
22995
0
      Eurydice_slice_subslice_shared_c8(serialized,
22996
0
        (
22997
0
          KRML_CLITERAL(core_ops_range_Range_87){
22998
0
            .start = i0 * (size_t)8U,
22999
0
            .end = i0 * (size_t)8U + (size_t)8U
23000
0
          }
23001
0
        ));
23002
0
    Eurydice_arr_d6 coefficient = libcrux_ml_kem_vector_portable_deserialize_4_b8(bytes);
23003
0
    Eurydice_arr_d6
23004
0
    uu____0 = libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_d1(coefficient);
23005
0
    re.data[i0] = uu____0;
23006
0
  }
23007
0
  return re;
23008
0
}
23009
23010
/**
23011
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_ring_element_v
23012
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23013
with const generics
23014
- K= 3
23015
- COMPRESSION_FACTOR= 4
23016
*/
23017
static KRML_MUSTINLINE Eurydice_arr_9e
23018
libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_b6(
23019
  Eurydice_borrow_slice_u8 serialized
23020
)
23021
0
{
23022
0
  return libcrux_ml_kem_serialize_deserialize_then_decompress_4_ea(serialized);
23023
0
}
23024
23025
/**
23026
A monomorphic instance of libcrux_ml_kem.polynomial.ZERO
23027
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23028
with const generics
23029
23030
*/
23031
static inline Eurydice_arr_9e libcrux_ml_kem_polynomial_ZERO_ea(void)
23032
0
{
23033
0
  Eurydice_arr_9e lit;
23034
0
  Eurydice_arr_d6 repeat_expression[16U];
23035
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
23036
0
  {
23037
0
    repeat_expression[i] = libcrux_ml_kem_vector_portable_ZERO_b8();
23038
0
  }
23039
0
  memcpy(lit.data, repeat_expression, (size_t)16U * sizeof (Eurydice_arr_d6));
23040
0
  return lit;
23041
0
}
23042
23043
/**
23044
 Given two `KyberPolynomialRingElement`s in their NTT representations,
23045
 compute their product. Given two polynomials in the NTT domain `f^` and `ĵ`,
23046
 the `iᵗʰ` coefficient of the product `k̂` is determined by the calculation:
23047
23048
 ```plaintext
23049
 ĥ[2·i] + ĥ[2·i + 1]X = (f^[2·i] + f^[2·i + 1]X)·(ĝ[2·i] + ĝ[2·i + 1]X) mod (X² - ζ^(2·BitRev₇(i) + 1))
23050
 ```
23051
23052
 This function almost implements <strong>Algorithm 10</strong> of the
23053
 NIST FIPS 203 standard, which is reproduced below:
23054
23055
 ```plaintext
23056
 Input: Two arrays fˆ ∈ ℤ₂₅₆ and ĝ ∈ ℤ₂₅₆.
23057
 Output: An array ĥ ∈ ℤq.
23058
23059
 for(i ← 0; i < 128; i++)
23060
     (ĥ[2i], ĥ[2i+1]) ← BaseCaseMultiply(fˆ[2i], fˆ[2i+1], ĝ[2i], ĝ[2i+1], ζ^(2·BitRev₇(i) + 1))
23061
 end for
23062
 return ĥ
23063
 ```
23064
 We say "almost" because the coefficients of the ring element output by
23065
 this function are in the Montgomery domain.
23066
23067
 The NIST FIPS 203 standard can be found at
23068
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
23069
*/
23070
/**
23071
A monomorphic instance of libcrux_ml_kem.polynomial.ntt_multiply
23072
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23073
with const generics
23074
23075
*/
23076
static KRML_MUSTINLINE Eurydice_arr_9e
23077
libcrux_ml_kem_polynomial_ntt_multiply_ea(
23078
  const Eurydice_arr_9e *myself,
23079
  const Eurydice_arr_9e *rhs
23080
)
23081
0
{
23082
0
  Eurydice_arr_9e out = libcrux_ml_kem_polynomial_ZERO_ea();
23083
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
23084
0
  {
23085
0
    size_t i0 = i;
23086
0
    Eurydice_arr_d6
23087
0
    uu____0 =
23088
0
      libcrux_ml_kem_vector_portable_ntt_multiply_b8(&myself->data[i0],
23089
0
        &rhs->data[i0],
23090
0
        libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0),
23091
0
        libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 + (size_t)1U),
23092
0
        libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 + (size_t)2U),
23093
0
        libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 + (size_t)3U));
23094
0
    out.data[i0] = uu____0;
23095
0
  }
23096
0
  return out;
23097
0
}
23098
23099
/**
23100
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
23101
*/
23102
/**
23103
A monomorphic instance of libcrux_ml_kem.polynomial.ntt_multiply_d6
23104
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23105
with const generics
23106
23107
*/
23108
static KRML_MUSTINLINE Eurydice_arr_9e
23109
libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(
23110
  const Eurydice_arr_9e *self,
23111
  const Eurydice_arr_9e *rhs
23112
)
23113
0
{
23114
0
  return libcrux_ml_kem_polynomial_ntt_multiply_ea(self, rhs);
23115
0
}
23116
23117
/**
23118
 Given two polynomial ring elements `lhs` and `rhs`, compute the pointwise
23119
 sum of their constituent coefficients.
23120
*/
23121
/**
23122
A monomorphic instance of libcrux_ml_kem.polynomial.add_to_ring_element
23123
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23124
with const generics
23125
- K= 3
23126
*/
23127
static KRML_MUSTINLINE void
23128
libcrux_ml_kem_polynomial_add_to_ring_element_68(
23129
  Eurydice_arr_9e *myself,
23130
  const Eurydice_arr_9e *rhs
23131
)
23132
0
{
23133
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
23134
0
  {
23135
0
    size_t i0 = i;
23136
0
    Eurydice_arr_d6
23137
0
    uu____0 = libcrux_ml_kem_vector_portable_add_b8(myself->data[i0], &rhs->data[i0]);
23138
0
    myself->data[i0] = uu____0;
23139
0
  }
23140
0
}
23141
23142
/**
23143
 Given two polynomial ring elements `lhs` and `rhs`, compute the pointwise
23144
 sum of their constituent coefficients.
23145
*/
23146
/**
23147
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
23148
*/
23149
/**
23150
A monomorphic instance of libcrux_ml_kem.polynomial.add_to_ring_element_d6
23151
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23152
with const generics
23153
- K= 3
23154
*/
23155
static KRML_MUSTINLINE void
23156
libcrux_ml_kem_polynomial_add_to_ring_element_d6_68(
23157
  Eurydice_arr_9e *self,
23158
  const Eurydice_arr_9e *rhs
23159
)
23160
0
{
23161
0
  libcrux_ml_kem_polynomial_add_to_ring_element_68(self, rhs);
23162
0
}
23163
23164
/**
23165
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_1
23166
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23167
with const generics
23168
23169
*/
23170
static KRML_MUSTINLINE void
23171
libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_ea(size_t *zeta_i, Eurydice_arr_9e *re)
23172
0
{
23173
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
23174
0
  {
23175
0
    size_t round = i;
23176
0
    zeta_i[0U]--;
23177
0
    re->data[round] =
23178
0
      libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_b8(re->data[round],
23179
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
23180
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)1U),
23181
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)2U),
23182
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)3U));
23183
0
    zeta_i[0U] -= (size_t)3U;
23184
0
  }
23185
0
}
23186
23187
/**
23188
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_2
23189
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23190
with const generics
23191
23192
*/
23193
static KRML_MUSTINLINE void
23194
libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_ea(size_t *zeta_i, Eurydice_arr_9e *re)
23195
0
{
23196
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
23197
0
  {
23198
0
    size_t round = i;
23199
0
    zeta_i[0U]--;
23200
0
    re->data[round] =
23201
0
      libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_b8(re->data[round],
23202
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
23203
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)1U));
23204
0
    zeta_i[0U]--;
23205
0
  }
23206
0
}
23207
23208
/**
23209
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_3
23210
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23211
with const generics
23212
23213
*/
23214
static KRML_MUSTINLINE void
23215
libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_ea(size_t *zeta_i, Eurydice_arr_9e *re)
23216
0
{
23217
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
23218
0
  {
23219
0
    size_t round = i;
23220
0
    zeta_i[0U]--;
23221
0
    Eurydice_arr_d6
23222
0
    uu____0 =
23223
0
      libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_b8(re->data[round],
23224
0
        libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
23225
0
    re->data[round] = uu____0;
23226
0
  }
23227
0
}
23228
23229
/**
23230
A monomorphic instance of libcrux_ml_kem.invert_ntt.inv_ntt_layer_int_vec_step_reduce
23231
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23232
with const generics
23233
23234
*/
23235
static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2
23236
libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_ea(
23237
  Eurydice_arr_d6 a,
23238
  Eurydice_arr_d6 b,
23239
  int16_t zeta_r
23240
)
23241
0
{
23242
0
  Eurydice_arr_d6 a_minus_b = libcrux_ml_kem_vector_portable_sub_b8(b, &a);
23243
0
  a =
23244
0
    libcrux_ml_kem_vector_portable_barrett_reduce_b8(libcrux_ml_kem_vector_portable_add_b8(a, &b));
23245
0
  b = libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(a_minus_b, zeta_r);
23246
0
  return
23247
0
    (
23248
0
      KRML_CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){
23249
0
        .fst = a,
23250
0
        .snd = b
23251
0
      }
23252
0
    );
23253
0
}
23254
23255
/**
23256
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_4_plus
23257
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23258
with const generics
23259
23260
*/
23261
static KRML_MUSTINLINE void
23262
libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(
23263
  size_t *zeta_i,
23264
  Eurydice_arr_9e *re,
23265
  size_t layer
23266
)
23267
0
{
23268
0
  size_t step = (size_t)1U << (uint32_t)layer;
23269
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++)
23270
0
  {
23271
0
    size_t round = i0;
23272
0
    zeta_i[0U]--;
23273
0
    size_t offset = round * step * (size_t)2U;
23274
0
    size_t offset_vec = offset / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR;
23275
0
    size_t step_vec = step / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR;
23276
0
    for (size_t i = offset_vec; i < offset_vec + step_vec; i++)
23277
0
    {
23278
0
      size_t j = i;
23279
0
      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2
23280
0
      uu____0 =
23281
0
        libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_ea(re->data[j],
23282
0
          re->data[j + step_vec],
23283
0
          libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
23284
0
      Eurydice_arr_d6 x = uu____0.fst;
23285
0
      Eurydice_arr_d6 y = uu____0.snd;
23286
0
      re->data[j] = x;
23287
0
      re->data[j + step_vec] = y;
23288
0
    }
23289
0
  }
23290
0
}
23291
23292
/**
23293
A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_montgomery
23294
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23295
with const generics
23296
- K= 3
23297
*/
23298
static KRML_MUSTINLINE void
23299
libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_68(Eurydice_arr_9e *re)
23300
0
{
23301
0
  size_t zeta_i = LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)2U;
23302
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_ea(&zeta_i, re);
23303
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_ea(&zeta_i, re);
23304
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_ea(&zeta_i, re);
23305
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)4U);
23306
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)5U);
23307
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)6U);
23308
0
  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)7U);
23309
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
23310
0
}
23311
23312
/**
23313
A monomorphic instance of libcrux_ml_kem.polynomial.subtract_reduce
23314
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23315
with const generics
23316
23317
*/
23318
static KRML_MUSTINLINE Eurydice_arr_9e
23319
libcrux_ml_kem_polynomial_subtract_reduce_ea(const Eurydice_arr_9e *myself, Eurydice_arr_9e b)
23320
0
{
23321
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
23322
0
  {
23323
0
    size_t i0 = i;
23324
0
    Eurydice_arr_d6
23325
0
    coefficient_normal_form =
23326
0
      libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(b.data[i0],
23327
0
        1441);
23328
0
    Eurydice_arr_d6
23329
0
    diff = libcrux_ml_kem_vector_portable_sub_b8(myself->data[i0], &coefficient_normal_form);
23330
0
    Eurydice_arr_d6 red = libcrux_ml_kem_vector_portable_barrett_reduce_b8(diff);
23331
0
    b.data[i0] = red;
23332
0
  }
23333
0
  return b;
23334
0
}
23335
23336
/**
23337
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
23338
*/
23339
/**
23340
A monomorphic instance of libcrux_ml_kem.polynomial.subtract_reduce_d6
23341
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23342
with const generics
23343
23344
*/
23345
static KRML_MUSTINLINE Eurydice_arr_9e
23346
libcrux_ml_kem_polynomial_subtract_reduce_d6_ea(const Eurydice_arr_9e *self, Eurydice_arr_9e b)
23347
0
{
23348
0
  return libcrux_ml_kem_polynomial_subtract_reduce_ea(self, b);
23349
0
}
23350
23351
/**
23352
 The following functions compute various expressions involving
23353
 vectors and matrices. The computation of these expressions has been
23354
 abstracted away into these functions in order to save on loop iterations.
23355
 Compute v − InverseNTT(sᵀ ◦ NTT(u))
23356
*/
23357
/**
23358
A monomorphic instance of libcrux_ml_kem.matrix.compute_message
23359
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23360
with const generics
23361
- K= 3
23362
*/
23363
static KRML_MUSTINLINE Eurydice_arr_9e
23364
libcrux_ml_kem_matrix_compute_message_68(
23365
  const Eurydice_arr_9e *v,
23366
  const Eurydice_arr_bb0 *secret_as_ntt,
23367
  const Eurydice_arr_bb0 *u_as_ntt
23368
)
23369
0
{
23370
0
  Eurydice_arr_9e result = libcrux_ml_kem_polynomial_ZERO_d6_ea();
23371
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23372
0
  {
23373
0
    size_t i0 = i;
23374
0
    Eurydice_arr_9e
23375
0
    product =
23376
0
      libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(&secret_as_ntt->data[i0],
23377
0
        &u_as_ntt->data[i0]);
23378
0
    libcrux_ml_kem_polynomial_add_to_ring_element_d6_68(&result, &product);
23379
0
  }
23380
0
  libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_68(&result);
23381
0
  return libcrux_ml_kem_polynomial_subtract_reduce_d6_ea(v, result);
23382
0
}
23383
23384
/**
23385
A monomorphic instance of libcrux_ml_kem.serialize.to_unsigned_field_modulus
23386
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23387
with const generics
23388
23389
*/
23390
static KRML_MUSTINLINE Eurydice_arr_d6
23391
libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(Eurydice_arr_d6 a)
23392
0
{
23393
0
  return libcrux_ml_kem_vector_portable_to_unsigned_representative_b8(a);
23394
0
}
23395
23396
/**
23397
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_message
23398
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23399
with const generics
23400
23401
*/
23402
static KRML_MUSTINLINE Eurydice_arr_ec
23403
libcrux_ml_kem_serialize_compress_then_serialize_message_ea(Eurydice_arr_9e re)
23404
0
{
23405
0
  Eurydice_arr_ec serialized = { .data = { 0U } };
23406
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
23407
0
  {
23408
0
    size_t i0 = i;
23409
0
    Eurydice_arr_d6
23410
0
    coefficient = libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(re.data[i0]);
23411
0
    Eurydice_arr_d6
23412
0
    coefficient_compressed = libcrux_ml_kem_vector_portable_compress_1_b8(coefficient);
23413
0
    Eurydice_array_u8x2
23414
0
    bytes = libcrux_ml_kem_vector_portable_serialize_1_b8(coefficient_compressed);
23415
0
    Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d46(&serialized,
23416
0
        (
23417
0
          KRML_CLITERAL(core_ops_range_Range_87){
23418
0
            .start = (size_t)2U * i0,
23419
0
            .end = (size_t)2U * i0 + (size_t)2U
23420
0
          }
23421
0
        )),
23422
0
      Eurydice_array_to_slice_shared_82(&bytes),
23423
0
      uint8_t);
23424
0
  }
23425
0
  return serialized;
23426
0
}
23427
23428
/**
23429
 This function implements <strong>Algorithm 14</strong> of the
23430
 NIST FIPS 203 specification; this is the Kyber CPA-PKE decryption algorithm.
23431
23432
 Algorithm 14 is reproduced below:
23433
23434
 ```plaintext
23435
 Input: decryption key dkₚₖₑ ∈ 𝔹^{384k}.
23436
 Input: ciphertext c ∈ 𝔹^{32(dᵤk + dᵥ)}.
23437
 Output: message m ∈ 𝔹^{32}.
23438
23439
 c₁ ← c[0 : 32dᵤk]
23440
 c₂ ← c[32dᵤk : 32(dᵤk + dᵥ)]
23441
 u ← Decompress_{dᵤ}(ByteDecode_{dᵤ}(c₁))
23442
 v ← Decompress_{dᵥ}(ByteDecode_{dᵥ}(c₂))
23443
 ŝ ← ByteDecode₁₂(dkₚₖₑ)
23444
 w ← v - NTT-¹(ŝᵀ ◦ NTT(u))
23445
 m ← ByteEncode₁(Compress₁(w))
23446
 return m
23447
 ```
23448
23449
 The NIST FIPS 203 standard can be found at
23450
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
23451
*/
23452
/**
23453
A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt_unpacked
23454
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23455
with const generics
23456
- K= 3
23457
- CIPHERTEXT_SIZE= 1088
23458
- VECTOR_U_ENCODED_SIZE= 960
23459
- U_COMPRESSION_FACTOR= 10
23460
- V_COMPRESSION_FACTOR= 4
23461
*/
23462
static KRML_MUSTINLINE Eurydice_arr_ec
23463
libcrux_ml_kem_ind_cpa_decrypt_unpacked_01(
23464
  const Eurydice_arr_bb0 *secret_key,
23465
  const Eurydice_arr_2b *ciphertext
23466
)
23467
0
{
23468
0
  Eurydice_arr_bb0
23469
0
  u_as_ntt = libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_30(ciphertext);
23470
0
  Eurydice_arr_9e
23471
0
  v =
23472
0
    libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_b6(Eurydice_array_to_subslice_from_shared_5f0(ciphertext,
23473
0
        (size_t)960U));
23474
0
  Eurydice_arr_9e message = libcrux_ml_kem_matrix_compute_message_68(&v, secret_key, &u_as_ntt);
23475
0
  return libcrux_ml_kem_serialize_compress_then_serialize_message_ea(message);
23476
0
}
23477
23478
/**
23479
A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt
23480
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23481
with const generics
23482
- K= 3
23483
- CIPHERTEXT_SIZE= 1088
23484
- VECTOR_U_ENCODED_SIZE= 960
23485
- U_COMPRESSION_FACTOR= 10
23486
- V_COMPRESSION_FACTOR= 4
23487
*/
23488
static KRML_MUSTINLINE Eurydice_arr_ec
23489
libcrux_ml_kem_ind_cpa_decrypt_01(
23490
  Eurydice_borrow_slice_u8 secret_key,
23491
  const Eurydice_arr_2b *ciphertext
23492
)
23493
0
{
23494
0
  Eurydice_arr_bb0 arr_struct;
23495
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23496
0
  {
23497
    /* original Rust expression is not an lvalue in C */
23498
0
    void *lvalue = (void *)0U;
23499
0
    arr_struct.data[i] = libcrux_ml_kem_ind_cpa_decrypt_call_mut_0b_01(&lvalue, i);
23500
0
  }
23501
0
  Eurydice_arr_bb0 secret_key_unpacked = arr_struct;
23502
0
  libcrux_ml_kem_ind_cpa_deserialize_vector_68(secret_key, &secret_key_unpacked);
23503
0
  return libcrux_ml_kem_ind_cpa_decrypt_unpacked_01(&secret_key_unpacked, ciphertext);
23504
0
}
23505
23506
/**
23507
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
23508
*/
23509
/**
23510
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.G_4a
23511
with const generics
23512
- K= 3
23513
*/
23514
static inline Eurydice_arr_c7
23515
libcrux_ml_kem_hash_functions_portable_G_4a_78(Eurydice_borrow_slice_u8 input)
23516
0
{
23517
0
  return libcrux_ml_kem_hash_functions_portable_G(input);
23518
0
}
23519
23520
/**
23521
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF
23522
with const generics
23523
- LEN= 32
23524
*/
23525
static inline Eurydice_arr_ec
23526
libcrux_ml_kem_hash_functions_portable_PRF_ce(Eurydice_borrow_slice_u8 input)
23527
0
{
23528
0
  Eurydice_arr_ec digest = { .data = { 0U } };
23529
0
  libcrux_sha3_portable_shake256(Eurydice_array_to_slice_mut_01(&digest), input);
23530
0
  return digest;
23531
0
}
23532
23533
/**
23534
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
23535
*/
23536
/**
23537
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF_4a
23538
with const generics
23539
- K= 3
23540
- LEN= 32
23541
*/
23542
static inline Eurydice_arr_ec
23543
libcrux_ml_kem_hash_functions_portable_PRF_4a_3b(Eurydice_borrow_slice_u8 input)
23544
0
{
23545
0
  return libcrux_ml_kem_hash_functions_portable_PRF_ce(input);
23546
0
}
23547
23548
/**
23549
A monomorphic instance of Eurydice.arr
23550
with types Eurydice_arr_bb0
23551
with const generics
23552
- $3size_t
23553
*/
23554
typedef struct Eurydice_arr_c10_s { Eurydice_arr_bb0 data[3U]; } Eurydice_arr_c10;
23555
23556
/**
23557
A monomorphic instance of libcrux_ml_kem.ind_cpa.unpacked.IndCpaPublicKeyUnpacked
23558
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23559
with const generics
23560
- $3size_t
23561
*/
23562
typedef struct libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51_s
23563
{
23564
  Eurydice_arr_bb0 t_as_ntt;
23565
  Eurydice_arr_ec seed_for_A;
23566
  Eurydice_arr_c10 A;
23567
}
23568
libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51;
23569
23570
/**
23571
This function found in impl {core::default::Default for libcrux_ml_kem::ind_cpa::unpacked::IndCpaPublicKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
23572
*/
23573
/**
23574
A monomorphic instance of libcrux_ml_kem.ind_cpa.unpacked.default_8b
23575
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23576
with const generics
23577
- K= 3
23578
*/
23579
static inline libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
23580
libcrux_ml_kem_ind_cpa_unpacked_default_8b_68(void)
23581
0
{
23582
0
  Eurydice_arr_bb0 uu____0;
23583
0
  Eurydice_arr_9e repeat_expression0[3U];
23584
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23585
0
  {
23586
0
    repeat_expression0[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
23587
0
  }
23588
0
  memcpy(uu____0.data, repeat_expression0, (size_t)3U * sizeof (Eurydice_arr_9e));
23589
0
  Eurydice_arr_ec uu____1 = { .data = { 0U } };
23590
0
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 lit0;
23591
0
  lit0.t_as_ntt = uu____0;
23592
0
  lit0.seed_for_A = uu____1;
23593
0
  Eurydice_arr_bb0 repeat_expression1[3U];
23594
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++)
23595
0
  {
23596
0
    Eurydice_arr_bb0 lit;
23597
0
    Eurydice_arr_9e repeat_expression[3U];
23598
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23599
0
    {
23600
0
      repeat_expression[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
23601
0
    }
23602
0
    memcpy(lit.data, repeat_expression, (size_t)3U * sizeof (Eurydice_arr_9e));
23603
0
    repeat_expression1[i0] = lit;
23604
0
  }
23605
0
  memcpy(lit0.A.data, repeat_expression1, (size_t)3U * sizeof (Eurydice_arr_bb0));
23606
0
  return lit0;
23607
0
}
23608
23609
/**
23610
 Only use with public values.
23611
23612
 This MUST NOT be used with secret inputs, like its caller `deserialize_ring_elements_reduced`.
23613
*/
23614
/**
23615
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_to_reduced_ring_element
23616
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23617
with const generics
23618
23619
*/
23620
static KRML_MUSTINLINE Eurydice_arr_9e
23621
libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_ea(
23622
  Eurydice_borrow_slice_u8 serialized
23623
)
23624
0
{
23625
0
  Eurydice_arr_9e re = libcrux_ml_kem_polynomial_ZERO_d6_ea();
23626
0
  for (size_t i = (size_t)0U; i < serialized.meta / (size_t)24U; i++)
23627
0
  {
23628
0
    size_t i0 = i;
23629
0
    Eurydice_borrow_slice_u8
23630
0
    bytes =
23631
0
      Eurydice_slice_subslice_shared_c8(serialized,
23632
0
        (
23633
0
          KRML_CLITERAL(core_ops_range_Range_87){
23634
0
            .start = i0 * (size_t)24U,
23635
0
            .end = i0 * (size_t)24U + (size_t)24U
23636
0
          }
23637
0
        ));
23638
0
    Eurydice_arr_d6 coefficient = libcrux_ml_kem_vector_portable_deserialize_12_b8(bytes);
23639
0
    Eurydice_arr_d6 uu____0 = libcrux_ml_kem_vector_portable_cond_subtract_3329_b8(coefficient);
23640
0
    re.data[i0] = uu____0;
23641
0
  }
23642
0
  return re;
23643
0
}
23644
23645
/**
23646
 See [deserialize_ring_elements_reduced_out].
23647
*/
23648
/**
23649
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_ring_elements_reduced
23650
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23651
with const generics
23652
- K= 3
23653
*/
23654
static KRML_MUSTINLINE void
23655
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_68(
23656
  Eurydice_borrow_slice_u8 public_key,
23657
  Eurydice_arr_bb0 *deserialized_pk
23658
)
23659
0
{
23660
0
  for
23661
0
  (size_t
23662
0
    i = (size_t)0U;
23663
0
    i < public_key.meta / LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT;
23664
0
    i++)
23665
0
  {
23666
0
    size_t i0 = i;
23667
0
    Eurydice_borrow_slice_u8
23668
0
    ring_element =
23669
0
      Eurydice_slice_subslice_shared_c8(public_key,
23670
0
        (
23671
0
          KRML_CLITERAL(core_ops_range_Range_87){
23672
0
            .start = i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
23673
0
            .end = i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT +
23674
0
              LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT
23675
0
          }
23676
0
        ));
23677
0
    Eurydice_arr_9e
23678
0
    uu____0 = libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_ea(ring_element);
23679
0
    deserialized_pk->data[i0] = uu____0;
23680
0
  }
23681
0
}
23682
23683
/**
23684
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.shake128_init_absorb_final
23685
with const generics
23686
- K= 3
23687
*/
23688
static inline Eurydice_arr_1b0
23689
libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_78(
23690
  const Eurydice_arr_810 *input
23691
)
23692
0
{
23693
0
  Eurydice_arr_1b0 shake128_state;
23694
0
  Eurydice_arr_7c repeat_expression[3U];
23695
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23696
0
  {
23697
0
    repeat_expression[i] = libcrux_sha3_portable_incremental_shake128_init();
23698
0
  }
23699
0
  memcpy(shake128_state.data, repeat_expression, (size_t)3U * sizeof (Eurydice_arr_7c));
23700
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23701
0
  {
23702
0
    size_t i0 = i;
23703
0
    libcrux_sha3_portable_incremental_shake128_absorb_final(&shake128_state.data[i0],
23704
0
      Eurydice_array_to_slice_shared_e9(&input->data[i0]));
23705
0
  }
23706
0
  return shake128_state;
23707
0
}
23708
23709
/**
23710
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
23711
*/
23712
/**
23713
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.shake128_init_absorb_final_4a
23714
with const generics
23715
- K= 3
23716
*/
23717
static inline Eurydice_arr_1b0
23718
libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_4a_78(
23719
  const Eurydice_arr_810 *input
23720
)
23721
0
{
23722
0
  return libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_78(input);
23723
0
}
23724
23725
/**
23726
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.shake128_squeeze_first_three_blocks
23727
with const generics
23728
- K= 3
23729
*/
23730
static inline Eurydice_arr_7e
23731
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_78(
23732
  Eurydice_arr_1b0 *st
23733
)
23734
0
{
23735
0
  Eurydice_arr_7e
23736
0
  out = { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
23737
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23738
0
  {
23739
0
    size_t i0 = i;
23740
0
    libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(&st->data[i0],
23741
0
      Eurydice_array_to_slice_mut_48(&out.data[i0]));
23742
0
  }
23743
0
  return out;
23744
0
}
23745
23746
/**
23747
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
23748
*/
23749
/**
23750
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.shake128_squeeze_first_three_blocks_4a
23751
with const generics
23752
- K= 3
23753
*/
23754
static inline Eurydice_arr_7e
23755
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_4a_78(
23756
  Eurydice_arr_1b0 *self
23757
)
23758
0
{
23759
0
  return libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_78(self);
23760
0
}
23761
23762
/**
23763
 If `bytes` contains a set of uniformly random bytes, this function
23764
 uniformly samples a ring element `â` that is treated as being the NTT representation
23765
 of the corresponding polynomial `a`.
23766
23767
 Since rejection sampling is used, it is possible the supplied bytes are
23768
 not enough to sample the element, in which case an `Err` is returned and the
23769
 caller must try again with a fresh set of bytes.
23770
23771
 This function <strong>partially</strong> implements <strong>Algorithm 6</strong> of the NIST FIPS 203 standard,
23772
 We say "partially" because this implementation only accepts a finite set of
23773
 bytes as input and returns an error if the set is not enough; Algorithm 6 of
23774
 the FIPS 203 standard on the other hand samples from an infinite stream of bytes
23775
 until the ring element is filled. Algorithm 6 is reproduced below:
23776
23777
 ```plaintext
23778
 Input: byte stream B ∈ 𝔹*.
23779
 Output: array â ∈ ℤ₂₅₆.
23780
23781
 i ← 0
23782
 j ← 0
23783
 while j < 256 do
23784
     d₁ ← B[i] + 256·(B[i+1] mod 16)
23785
     d₂ ← ⌊B[i+1]/16⌋ + 16·B[i+2]
23786
     if d₁ < q then
23787
         â[j] ← d₁
23788
         j ← j + 1
23789
     end if
23790
     if d₂ < q and j < 256 then
23791
         â[j] ← d₂
23792
         j ← j + 1
23793
     end if
23794
     i ← i + 3
23795
 end while
23796
 return â
23797
 ```
23798
23799
 The NIST FIPS 203 standard can be found at
23800
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
23801
*/
23802
/**
23803
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_uniform_distribution_next
23804
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23805
with const generics
23806
- K= 3
23807
- N= 504
23808
*/
23809
static KRML_MUSTINLINE bool
23810
libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_b6(
23811
  const Eurydice_arr_7e *randomness,
23812
  Eurydice_arr_eb *sampled_coefficients,
23813
  Eurydice_arr_b1 *out
23814
)
23815
0
{
23816
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++)
23817
0
  {
23818
0
    size_t i1 = i0;
23819
0
    for (size_t i = (size_t)0U; i < (size_t)504U / (size_t)24U; i++)
23820
0
    {
23821
0
      size_t r = i;
23822
0
      if (sampled_coefficients->data[i1] < LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
23823
0
      {
23824
0
        size_t
23825
0
        sampled =
23826
0
          libcrux_ml_kem_vector_portable_rej_sample_b8(Eurydice_array_to_subslice_shared_d45(&randomness->data[i1],
23827
0
              (
23828
0
                KRML_CLITERAL(core_ops_range_Range_87){
23829
0
                  .start = r * (size_t)24U,
23830
0
                  .end = r * (size_t)24U + (size_t)24U
23831
0
                }
23832
0
              )),
23833
0
            Eurydice_array_to_subslice_mut_e7(&out->data[i1],
23834
0
              (
23835
0
                KRML_CLITERAL(core_ops_range_Range_87){
23836
0
                  .start = sampled_coefficients->data[i1],
23837
0
                  .end = sampled_coefficients->data[i1] + (size_t)16U
23838
0
                }
23839
0
              )));
23840
0
        size_t uu____0 = i1;
23841
0
        sampled_coefficients->data[uu____0] += sampled;
23842
0
      }
23843
0
    }
23844
0
  }
23845
0
  bool done = true;
23846
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23847
0
  {
23848
0
    size_t i0 = i;
23849
0
    if (sampled_coefficients->data[i0] >= LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
23850
0
    {
23851
0
      sampled_coefficients->data[i0] = LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
23852
0
    }
23853
0
    else
23854
0
    {
23855
0
      done = false;
23856
0
    }
23857
0
  }
23858
0
  return done;
23859
0
}
23860
23861
/**
23862
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.shake128_squeeze_next_block
23863
with const generics
23864
- K= 3
23865
*/
23866
static inline Eurydice_arr_2c
23867
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_78(Eurydice_arr_1b0 *st)
23868
0
{
23869
0
  Eurydice_arr_2c
23870
0
  out = { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
23871
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23872
0
  {
23873
0
    size_t i0 = i;
23874
0
    libcrux_sha3_portable_incremental_shake128_squeeze_next_block(&st->data[i0],
23875
0
      Eurydice_array_to_slice_mut_2c(&out.data[i0]));
23876
0
  }
23877
0
  return out;
23878
0
}
23879
23880
/**
23881
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
23882
*/
23883
/**
23884
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.shake128_squeeze_next_block_4a
23885
with const generics
23886
- K= 3
23887
*/
23888
static inline Eurydice_arr_2c
23889
libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_4a_78(
23890
  Eurydice_arr_1b0 *self
23891
)
23892
0
{
23893
0
  return libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_78(self);
23894
0
}
23895
23896
/**
23897
 If `bytes` contains a set of uniformly random bytes, this function
23898
 uniformly samples a ring element `â` that is treated as being the NTT representation
23899
 of the corresponding polynomial `a`.
23900
23901
 Since rejection sampling is used, it is possible the supplied bytes are
23902
 not enough to sample the element, in which case an `Err` is returned and the
23903
 caller must try again with a fresh set of bytes.
23904
23905
 This function <strong>partially</strong> implements <strong>Algorithm 6</strong> of the NIST FIPS 203 standard,
23906
 We say "partially" because this implementation only accepts a finite set of
23907
 bytes as input and returns an error if the set is not enough; Algorithm 6 of
23908
 the FIPS 203 standard on the other hand samples from an infinite stream of bytes
23909
 until the ring element is filled. Algorithm 6 is reproduced below:
23910
23911
 ```plaintext
23912
 Input: byte stream B ∈ 𝔹*.
23913
 Output: array â ∈ ℤ₂₅₆.
23914
23915
 i ← 0
23916
 j ← 0
23917
 while j < 256 do
23918
     d₁ ← B[i] + 256·(B[i+1] mod 16)
23919
     d₂ ← ⌊B[i+1]/16⌋ + 16·B[i+2]
23920
     if d₁ < q then
23921
         â[j] ← d₁
23922
         j ← j + 1
23923
     end if
23924
     if d₂ < q and j < 256 then
23925
         â[j] ← d₂
23926
         j ← j + 1
23927
     end if
23928
     i ← i + 3
23929
 end while
23930
 return â
23931
 ```
23932
23933
 The NIST FIPS 203 standard can be found at
23934
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
23935
*/
23936
/**
23937
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_uniform_distribution_next
23938
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23939
with const generics
23940
- K= 3
23941
- N= 168
23942
*/
23943
static KRML_MUSTINLINE bool
23944
libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_b60(
23945
  const Eurydice_arr_2c *randomness,
23946
  Eurydice_arr_eb *sampled_coefficients,
23947
  Eurydice_arr_b1 *out
23948
)
23949
0
{
23950
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++)
23951
0
  {
23952
0
    size_t i1 = i0;
23953
0
    for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)24U; i++)
23954
0
    {
23955
0
      size_t r = i;
23956
0
      if (sampled_coefficients->data[i1] < LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
23957
0
      {
23958
0
        size_t
23959
0
        sampled =
23960
0
          libcrux_ml_kem_vector_portable_rej_sample_b8(Eurydice_array_to_subslice_shared_d46(&randomness->data[i1],
23961
0
              (
23962
0
                KRML_CLITERAL(core_ops_range_Range_87){
23963
0
                  .start = r * (size_t)24U,
23964
0
                  .end = r * (size_t)24U + (size_t)24U
23965
0
                }
23966
0
              )),
23967
0
            Eurydice_array_to_subslice_mut_e7(&out->data[i1],
23968
0
              (
23969
0
                KRML_CLITERAL(core_ops_range_Range_87){
23970
0
                  .start = sampled_coefficients->data[i1],
23971
0
                  .end = sampled_coefficients->data[i1] + (size_t)16U
23972
0
                }
23973
0
              )));
23974
0
        size_t uu____0 = i1;
23975
0
        sampled_coefficients->data[uu____0] += sampled;
23976
0
      }
23977
0
    }
23978
0
  }
23979
0
  bool done = true;
23980
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
23981
0
  {
23982
0
    size_t i0 = i;
23983
0
    if (sampled_coefficients->data[i0] >= LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT)
23984
0
    {
23985
0
      sampled_coefficients->data[i0] = LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
23986
0
    }
23987
0
    else
23988
0
    {
23989
0
      done = false;
23990
0
    }
23991
0
  }
23992
0
  return done;
23993
0
}
23994
23995
/**
23996
A monomorphic instance of libcrux_ml_kem.polynomial.from_i16_array
23997
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
23998
with const generics
23999
24000
*/
24001
static KRML_MUSTINLINE Eurydice_arr_9e
24002
libcrux_ml_kem_polynomial_from_i16_array_ea(Eurydice_borrow_slice_i16 a)
24003
0
{
24004
0
  Eurydice_arr_9e result = libcrux_ml_kem_polynomial_ZERO_ea();
24005
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
24006
0
  {
24007
0
    size_t i0 = i;
24008
0
    Eurydice_arr_d6
24009
0
    uu____0 =
24010
0
      libcrux_ml_kem_vector_portable_from_i16_array_b8(Eurydice_slice_subslice_shared_a6(a,
24011
0
          (
24012
0
            KRML_CLITERAL(core_ops_range_Range_87){
24013
0
              .start = i0 * (size_t)16U,
24014
0
              .end = (i0 + (size_t)1U) * (size_t)16U
24015
0
            }
24016
0
          )));
24017
0
    result.data[i0] = uu____0;
24018
0
  }
24019
0
  return result;
24020
0
}
24021
24022
/**
24023
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
24024
*/
24025
/**
24026
A monomorphic instance of libcrux_ml_kem.polynomial.from_i16_array_d6
24027
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24028
with const generics
24029
24030
*/
24031
static KRML_MUSTINLINE Eurydice_arr_9e
24032
libcrux_ml_kem_polynomial_from_i16_array_d6_ea(Eurydice_borrow_slice_i16 a)
24033
0
{
24034
0
  return libcrux_ml_kem_polynomial_from_i16_array_ea(a);
24035
0
}
24036
24037
/**
24038
This function found in impl {core::ops::function::FnMut<([i16; 272usize]), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@2]> for libcrux_ml_kem::sampling::sample_from_xof::closure<Vector, Hasher, K>[TraitClause@0, TraitClause@1, TraitClause@2, TraitClause@3]}
24039
*/
24040
/**
24041
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_xof.call_mut_0a
24042
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24043
with const generics
24044
- K= 3
24045
*/
24046
static inline Eurydice_arr_9e
24047
libcrux_ml_kem_sampling_sample_from_xof_call_mut_0a_91(void **_, Eurydice_arr_5b tupled_args)
24048
0
{
24049
0
  Eurydice_arr_5b s = tupled_args;
24050
0
  return
24051
0
    libcrux_ml_kem_polynomial_from_i16_array_d6_ea(Eurydice_array_to_subslice_shared_e70(&s,
24052
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)256U })));
24053
0
}
24054
24055
/**
24056
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_xof
24057
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24058
with const generics
24059
- K= 3
24060
*/
24061
static KRML_MUSTINLINE Eurydice_arr_bb0
24062
libcrux_ml_kem_sampling_sample_from_xof_91(const Eurydice_arr_810 *seeds)
24063
0
{
24064
0
  Eurydice_arr_eb sampled_coefficients = { .data = { 0U } };
24065
0
  Eurydice_arr_b1
24066
0
  out = { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
24067
0
  Eurydice_arr_1b0
24068
0
  xof_state = libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_4a_78(seeds);
24069
0
  Eurydice_arr_7e
24070
0
  randomness0 =
24071
0
    libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_4a_78(&xof_state);
24072
0
  bool
24073
0
  done =
24074
0
    libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_b6(&randomness0,
24075
0
      &sampled_coefficients,
24076
0
      &out);
24077
0
  while (true)
24078
0
  {
24079
0
    if (done)
24080
0
    {
24081
0
      break;
24082
0
    }
24083
0
    else
24084
0
    {
24085
0
      Eurydice_arr_2c
24086
0
      randomness =
24087
0
        libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_4a_78(&xof_state);
24088
0
      done =
24089
0
        libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_b60(&randomness,
24090
0
          &sampled_coefficients,
24091
0
          &out);
24092
0
    }
24093
0
  }
24094
0
  Eurydice_arr_bb0 arr_mapped_str;
24095
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24096
0
  {
24097
    /* original Rust expression is not an lvalue in C */
24098
0
    void *lvalue = (void *)0U;
24099
0
    arr_mapped_str.data[i] =
24100
0
      libcrux_ml_kem_sampling_sample_from_xof_call_mut_0a_91(&lvalue,
24101
0
        out.data[i]);
24102
0
  }
24103
0
  return arr_mapped_str;
24104
0
}
24105
24106
/**
24107
A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A
24108
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24109
with const generics
24110
- K= 3
24111
*/
24112
static KRML_MUSTINLINE void
24113
libcrux_ml_kem_matrix_sample_matrix_A_91(
24114
  Eurydice_arr_c10 *A_transpose,
24115
  const Eurydice_arr_31 *seed,
24116
  bool transpose
24117
)
24118
0
{
24119
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++)
24120
0
  {
24121
0
    size_t i1 = i0;
24122
0
    Eurydice_arr_810 seeds;
24123
0
    Eurydice_arr_31 repeat_expression[3U];
24124
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24125
0
    {
24126
0
      repeat_expression[i] =
24127
0
        core_array__core__clone__Clone_for__T__N___clone((size_t)34U,
24128
0
          seed,
24129
0
          uint8_t,
24130
0
          Eurydice_arr_31);
24131
0
    }
24132
0
    memcpy(seeds.data, repeat_expression, (size_t)3U * sizeof (Eurydice_arr_31));
24133
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24134
0
    {
24135
0
      size_t j = i;
24136
0
      seeds.data[j].data[32U] = (uint8_t)i1;
24137
0
      seeds.data[j].data[33U] = (uint8_t)j;
24138
0
    }
24139
0
    Eurydice_arr_bb0 sampled = libcrux_ml_kem_sampling_sample_from_xof_91(&seeds);
24140
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24141
0
    {
24142
0
      size_t j = i;
24143
0
      Eurydice_arr_9e sample = sampled.data[j];
24144
0
      if (transpose)
24145
0
      {
24146
0
        A_transpose->data[j].data[i1] = sample;
24147
0
      }
24148
0
      else
24149
0
      {
24150
0
        A_transpose->data[i1].data[j] = sample;
24151
0
      }
24152
0
    }
24153
0
  }
24154
0
}
24155
24156
/**
24157
A monomorphic instance of libcrux_ml_kem.ind_cpa.build_unpacked_public_key_mut
24158
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24159
with const generics
24160
- K= 3
24161
- T_AS_NTT_ENCODED_SIZE= 1152
24162
*/
24163
static KRML_MUSTINLINE void
24164
libcrux_ml_kem_ind_cpa_build_unpacked_public_key_mut_05(
24165
  Eurydice_borrow_slice_u8 public_key,
24166
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 *unpacked_public_key
24167
)
24168
0
{
24169
0
  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_68(Eurydice_slice_subslice_to_shared_72(public_key,
24170
0
      (size_t)1152U),
24171
0
    &unpacked_public_key->t_as_ntt);
24172
0
  Eurydice_borrow_slice_u8
24173
0
  seed = Eurydice_slice_subslice_from_shared_6d(public_key, (size_t)1152U);
24174
0
  Eurydice_arr_c10 *uu____0 = &unpacked_public_key->A;
24175
  /* original Rust expression is not an lvalue in C */
24176
0
  Eurydice_arr_31 lvalue = libcrux_ml_kem_utils_into_padded_array_de(seed);
24177
0
  libcrux_ml_kem_matrix_sample_matrix_A_91(uu____0, &lvalue, false);
24178
0
}
24179
24180
/**
24181
A monomorphic instance of libcrux_ml_kem.ind_cpa.build_unpacked_public_key
24182
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24183
with const generics
24184
- K= 3
24185
- T_AS_NTT_ENCODED_SIZE= 1152
24186
*/
24187
static KRML_MUSTINLINE libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
24188
libcrux_ml_kem_ind_cpa_build_unpacked_public_key_05(Eurydice_borrow_slice_u8 public_key)
24189
0
{
24190
0
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
24191
0
  unpacked_public_key = libcrux_ml_kem_ind_cpa_unpacked_default_8b_68();
24192
0
  libcrux_ml_kem_ind_cpa_build_unpacked_public_key_mut_05(public_key, &unpacked_public_key);
24193
0
  return unpacked_public_key;
24194
0
}
24195
24196
/**
24197
A monomorphic instance of n-tuple
24198
with types Eurydice_arr_bb0, libcrux_ml_kem_polynomial_PolynomialRingElement_1d
24199
24200
*/
24201
typedef struct tuple_c6_s
24202
{
24203
  Eurydice_arr_bb0 fst;
24204
  Eurydice_arr_9e snd;
24205
}
24206
tuple_c6;
24207
24208
/**
24209
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@2]> for libcrux_ml_kem::ind_cpa::encrypt_c1::closure<Vector, Hasher, K, C1_LEN, U_COMPRESSION_FACTOR, BLOCK_LEN, ETA1, ETA1_RANDOMNESS_SIZE, ETA2, ETA2_RANDOMNESS_SIZE>[TraitClause@0, TraitClause@1, TraitClause@2, TraitClause@3]}
24210
*/
24211
/**
24212
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt_c1.call_mut_f1
24213
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24214
with const generics
24215
- K= 3
24216
- C1_LEN= 960
24217
- U_COMPRESSION_FACTOR= 10
24218
- BLOCK_LEN= 320
24219
- ETA1= 2
24220
- ETA1_RANDOMNESS_SIZE= 128
24221
- ETA2= 2
24222
- ETA2_RANDOMNESS_SIZE= 128
24223
*/
24224
static inline Eurydice_arr_9e
24225
libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_f1_87(void **_, size_t tupled_args)
24226
0
{
24227
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
24228
0
}
24229
24230
/**
24231
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRFxN
24232
with const generics
24233
- K= 3
24234
- LEN= 128
24235
*/
24236
static inline Eurydice_arr_58
24237
libcrux_ml_kem_hash_functions_portable_PRFxN_3b(const Eurydice_arr_fd *input)
24238
0
{
24239
0
  Eurydice_arr_58
24240
0
  out = { .data = { { .data = { 0U } }, { .data = { 0U } }, { .data = { 0U } } } };
24241
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24242
0
  {
24243
0
    size_t i0 = i;
24244
0
    libcrux_sha3_portable_shake256(Eurydice_array_to_slice_mut_78(&out.data[i0]),
24245
0
      Eurydice_array_to_slice_shared_b5(&input->data[i0]));
24246
0
  }
24247
0
  return out;
24248
0
}
24249
24250
/**
24251
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
24252
*/
24253
/**
24254
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRFxN_4a
24255
with const generics
24256
- K= 3
24257
- LEN= 128
24258
*/
24259
static inline Eurydice_arr_58
24260
libcrux_ml_kem_hash_functions_portable_PRFxN_4a_3b(const Eurydice_arr_fd *input)
24261
0
{
24262
0
  return libcrux_ml_kem_hash_functions_portable_PRFxN_3b(input);
24263
0
}
24264
24265
/**
24266
 Given a series of uniformly random bytes in `randomness`, for some number `eta`,
24267
 the `sample_from_binomial_distribution_{eta}` functions sample
24268
 a ring element from a binomial distribution centered at 0 that uses two sets
24269
 of `eta` coin flips. If, for example,
24270
 `eta = ETA`, each ring coefficient is a value `v` such
24271
 such that `v ∈ {-ETA, -ETA + 1, ..., 0, ..., ETA + 1, ETA}` and:
24272
24273
 ```plaintext
24274
 - If v < 0, Pr[v] = Pr[-v]
24275
 - If v >= 0, Pr[v] = BINOMIAL_COEFFICIENT(2 * ETA; ETA - v) / 2 ^ (2 * ETA)
24276
 ```
24277
24278
 The values `v < 0` are mapped to the appropriate `KyberFieldElement`.
24279
24280
 The expected value is:
24281
24282
 ```plaintext
24283
 E[X] = (-ETA)Pr[-ETA] + (-(ETA - 1))Pr[-(ETA - 1)] + ... + (ETA - 1)Pr[ETA - 1] + (ETA)Pr[ETA]
24284
      = 0 since Pr[-v] = Pr[v] when v < 0.
24285
 ```
24286
24287
 And the variance is:
24288
24289
 ```plaintext
24290
 Var(X) = E[(X - E[X])^2]
24291
        = E[X^2]
24292
        = sum_(v=-ETA to ETA)v^2 * (BINOMIAL_COEFFICIENT(2 * ETA; ETA - v) / 2^(2 * ETA))
24293
        = ETA / 2
24294
 ```
24295
24296
 This function implements <strong>Algorithm 7</strong> of the NIST FIPS 203 standard, which is
24297
 reproduced below:
24298
24299
 ```plaintext
24300
 Input: byte array B ∈ 𝔹^{64η}.
24301
 Output: array f ∈ ℤ₂₅₆.
24302
24303
 b ← BytesToBits(B)
24304
 for (i ← 0; i < 256; i++)
24305
     x ← ∑(j=0 to η - 1) b[2iη + j]
24306
     y ← ∑(j=0 to η - 1) b[2iη + η + j]
24307
     f[i] ← x−y mod q
24308
 end for
24309
 return f
24310
 ```
24311
24312
 The NIST FIPS 203 standard can be found at
24313
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
24314
*/
24315
/**
24316
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_binomial_distribution_2
24317
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24318
with const generics
24319
24320
*/
24321
static KRML_MUSTINLINE Eurydice_arr_9e
24322
libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_ea(
24323
  Eurydice_borrow_slice_u8 randomness
24324
)
24325
0
{
24326
0
  Eurydice_arr_04 sampled_i16s = { .data = { 0U } };
24327
0
  for (size_t i0 = (size_t)0U; i0 < randomness.meta / (size_t)4U; i0++)
24328
0
  {
24329
0
    size_t chunk_number = i0;
24330
0
    Eurydice_borrow_slice_u8
24331
0
    byte_chunk =
24332
0
      Eurydice_slice_subslice_shared_c8(randomness,
24333
0
        (
24334
0
          KRML_CLITERAL(core_ops_range_Range_87){
24335
0
            .start = chunk_number * (size_t)4U,
24336
0
            .end = chunk_number * (size_t)4U + (size_t)4U
24337
0
          }
24338
0
        ));
24339
0
    uint32_t
24340
0
    random_bits_as_u32 =
24341
0
      (((uint32_t)byte_chunk.ptr[0U] | (uint32_t)byte_chunk.ptr[1U] << 8U) |
24342
0
        (uint32_t)byte_chunk.ptr[2U] << 16U)
24343
0
      | (uint32_t)byte_chunk.ptr[3U] << 24U;
24344
0
    uint32_t even_bits = random_bits_as_u32 & 1431655765U;
24345
0
    uint32_t odd_bits = random_bits_as_u32 >> 1U & 1431655765U;
24346
0
    uint32_t coin_toss_outcomes = even_bits + odd_bits;
24347
0
    for (uint32_t i = 0U; i < 32U / 4U; i++)
24348
0
    {
24349
0
      uint32_t outcome_set = i;
24350
0
      uint32_t outcome_set0 = outcome_set * 4U;
24351
0
      int16_t outcome_1 = (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 3U);
24352
0
      int16_t outcome_2 = (int16_t)(coin_toss_outcomes >> (uint32_t)(outcome_set0 + 2U) & 3U);
24353
0
      size_t offset = (size_t)(outcome_set0 >> 2U);
24354
0
      sampled_i16s.data[(size_t)8U * chunk_number + offset] = outcome_1 - outcome_2;
24355
0
    }
24356
0
  }
24357
0
  return
24358
0
    libcrux_ml_kem_polynomial_from_i16_array_d6_ea(Eurydice_array_to_slice_shared_99(&sampled_i16s));
24359
0
}
24360
24361
/**
24362
A monomorphic instance of libcrux_ml_kem.sampling.sample_from_binomial_distribution
24363
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24364
with const generics
24365
- ETA= 2
24366
*/
24367
static KRML_MUSTINLINE Eurydice_arr_9e
24368
libcrux_ml_kem_sampling_sample_from_binomial_distribution_66(
24369
  Eurydice_borrow_slice_u8 randomness
24370
)
24371
0
{
24372
0
  return libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_ea(randomness);
24373
0
}
24374
24375
/**
24376
A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_7
24377
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24378
with const generics
24379
24380
*/
24381
static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_7_ea(Eurydice_arr_9e *re)
24382
0
{
24383
0
  size_t step = LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT / (size_t)2U;
24384
0
  for (size_t i = (size_t)0U; i < step; i++)
24385
0
  {
24386
0
    size_t j = i;
24387
0
    Eurydice_arr_d6
24388
0
    t = libcrux_ml_kem_vector_portable_multiply_by_constant_b8(re->data[j + step], -1600);
24389
0
    re->data[j + step] = libcrux_ml_kem_vector_portable_sub_b8(re->data[j], &t);
24390
0
    Eurydice_arr_d6 uu____1 = libcrux_ml_kem_vector_portable_add_b8(re->data[j], &t);
24391
0
    re->data[j] = uu____1;
24392
0
  }
24393
0
}
24394
24395
/**
24396
A monomorphic instance of libcrux_ml_kem.ntt.ntt_binomially_sampled_ring_element
24397
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24398
with const generics
24399
24400
*/
24401
static KRML_MUSTINLINE void
24402
libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_ea(Eurydice_arr_9e *re)
24403
0
{
24404
0
  libcrux_ml_kem_ntt_ntt_at_layer_7_ea(re);
24405
0
  size_t zeta_i = (size_t)1U;
24406
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)6U, (size_t)11207U);
24407
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i,
24408
0
    re,
24409
0
    (size_t)5U,
24410
0
    (size_t)11207U + (size_t)3328U);
24411
0
  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i,
24412
0
    re,
24413
0
    (size_t)4U,
24414
0
    (size_t)11207U + (size_t)2U * (size_t)3328U);
24415
0
  libcrux_ml_kem_ntt_ntt_at_layer_3_ea(&zeta_i, re, (size_t)11207U + (size_t)3U * (size_t)3328U);
24416
0
  libcrux_ml_kem_ntt_ntt_at_layer_2_ea(&zeta_i, re, (size_t)11207U + (size_t)4U * (size_t)3328U);
24417
0
  libcrux_ml_kem_ntt_ntt_at_layer_1_ea(&zeta_i, re, (size_t)11207U + (size_t)5U * (size_t)3328U);
24418
0
  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
24419
0
}
24420
24421
/**
24422
 Sample a vector of ring elements from a centered binomial distribution and
24423
 convert them into their NTT representations.
24424
*/
24425
/**
24426
A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_vector_cbd_then_ntt
24427
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24428
with const generics
24429
- K= 3
24430
- ETA= 2
24431
- ETA_RANDOMNESS_SIZE= 128
24432
*/
24433
static KRML_MUSTINLINE uint8_t
24434
libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_bf(
24435
  Eurydice_arr_bb0 *re_as_ntt,
24436
  const Eurydice_arr_fa0 *prf_input,
24437
  uint8_t domain_separator
24438
)
24439
0
{
24440
0
  Eurydice_arr_fd prf_inputs;
24441
0
  Eurydice_arr_fa0 repeat_expression[3U];
24442
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24443
0
  {
24444
0
    repeat_expression[i] =
24445
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)33U,
24446
0
        prf_input,
24447
0
        uint8_t,
24448
0
        Eurydice_arr_fa0);
24449
0
  }
24450
0
  memcpy(prf_inputs.data, repeat_expression, (size_t)3U * sizeof (Eurydice_arr_fa0));
24451
0
  domain_separator = libcrux_ml_kem_utils_prf_input_inc_78(&prf_inputs, domain_separator);
24452
0
  Eurydice_arr_58 prf_outputs = libcrux_ml_kem_hash_functions_portable_PRFxN_4a_3b(&prf_inputs);
24453
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24454
0
  {
24455
0
    size_t i0 = i;
24456
0
    Eurydice_arr_9e
24457
0
    uu____0 =
24458
0
      libcrux_ml_kem_sampling_sample_from_binomial_distribution_66(Eurydice_array_to_slice_shared_78(&prf_outputs.data[i0]));
24459
0
    re_as_ntt->data[i0] = uu____0;
24460
0
    libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_ea(&re_as_ntt->data[i0]);
24461
0
  }
24462
0
  return domain_separator;
24463
0
}
24464
24465
/**
24466
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@2]> for libcrux_ml_kem::ind_cpa::encrypt_c1::closure#1<Vector, Hasher, K, C1_LEN, U_COMPRESSION_FACTOR, BLOCK_LEN, ETA1, ETA1_RANDOMNESS_SIZE, ETA2, ETA2_RANDOMNESS_SIZE>[TraitClause@0, TraitClause@1, TraitClause@2, TraitClause@3]}
24467
*/
24468
/**
24469
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt_c1.call_mut_dd
24470
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24471
with const generics
24472
- K= 3
24473
- C1_LEN= 960
24474
- U_COMPRESSION_FACTOR= 10
24475
- BLOCK_LEN= 320
24476
- ETA1= 2
24477
- ETA1_RANDOMNESS_SIZE= 128
24478
- ETA2= 2
24479
- ETA2_RANDOMNESS_SIZE= 128
24480
*/
24481
static inline Eurydice_arr_9e
24482
libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_dd_87(void **_, size_t tupled_args)
24483
0
{
24484
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
24485
0
}
24486
24487
/**
24488
 Sample a vector of ring elements from a centered binomial distribution.
24489
*/
24490
/**
24491
A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_ring_element_cbd
24492
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24493
with const generics
24494
- K= 3
24495
- ETA2_RANDOMNESS_SIZE= 128
24496
- ETA2= 2
24497
*/
24498
static KRML_MUSTINLINE uint8_t
24499
libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_bf(
24500
  const Eurydice_arr_fa0 *prf_input,
24501
  uint8_t domain_separator,
24502
  Eurydice_arr_bb0 *error_1
24503
)
24504
0
{
24505
0
  Eurydice_arr_fd prf_inputs;
24506
0
  Eurydice_arr_fa0 repeat_expression[3U];
24507
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24508
0
  {
24509
0
    repeat_expression[i] =
24510
0
      core_array__core__clone__Clone_for__T__N___clone((size_t)33U,
24511
0
        prf_input,
24512
0
        uint8_t,
24513
0
        Eurydice_arr_fa0);
24514
0
  }
24515
0
  memcpy(prf_inputs.data, repeat_expression, (size_t)3U * sizeof (Eurydice_arr_fa0));
24516
0
  domain_separator = libcrux_ml_kem_utils_prf_input_inc_78(&prf_inputs, domain_separator);
24517
0
  Eurydice_arr_58 prf_outputs = libcrux_ml_kem_hash_functions_portable_PRFxN_4a_3b(&prf_inputs);
24518
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24519
0
  {
24520
0
    size_t i0 = i;
24521
0
    Eurydice_arr_9e
24522
0
    uu____0 =
24523
0
      libcrux_ml_kem_sampling_sample_from_binomial_distribution_66(Eurydice_array_to_slice_shared_78(&prf_outputs.data[i0]));
24524
0
    error_1->data[i0] = uu____0;
24525
0
  }
24526
0
  return domain_separator;
24527
0
}
24528
24529
/**
24530
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF
24531
with const generics
24532
- LEN= 128
24533
*/
24534
static inline Eurydice_arr_89
24535
libcrux_ml_kem_hash_functions_portable_PRF_ec(Eurydice_borrow_slice_u8 input)
24536
0
{
24537
0
  Eurydice_arr_89 digest = { .data = { 0U } };
24538
0
  libcrux_sha3_portable_shake256(Eurydice_array_to_slice_mut_78(&digest), input);
24539
0
  return digest;
24540
0
}
24541
24542
/**
24543
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
24544
*/
24545
/**
24546
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF_4a
24547
with const generics
24548
- K= 3
24549
- LEN= 128
24550
*/
24551
static inline Eurydice_arr_89
24552
libcrux_ml_kem_hash_functions_portable_PRF_4a_3b0(Eurydice_borrow_slice_u8 input)
24553
0
{
24554
0
  return libcrux_ml_kem_hash_functions_portable_PRF_ec(input);
24555
0
}
24556
24557
/**
24558
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]> for libcrux_ml_kem::matrix::compute_vector_u::closure<Vector, K>[TraitClause@0, TraitClause@1]}
24559
*/
24560
/**
24561
A monomorphic instance of libcrux_ml_kem.matrix.compute_vector_u.call_mut_a8
24562
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24563
with const generics
24564
- K= 3
24565
*/
24566
static inline Eurydice_arr_9e
24567
libcrux_ml_kem_matrix_compute_vector_u_call_mut_a8_68(void **_, size_t tupled_args)
24568
0
{
24569
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
24570
0
}
24571
24572
/**
24573
A monomorphic instance of libcrux_ml_kem.polynomial.add_error_reduce
24574
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24575
with const generics
24576
24577
*/
24578
static KRML_MUSTINLINE void
24579
libcrux_ml_kem_polynomial_add_error_reduce_ea(
24580
  Eurydice_arr_9e *myself,
24581
  const Eurydice_arr_9e *error
24582
)
24583
0
{
24584
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
24585
0
  {
24586
0
    size_t j = i;
24587
0
    Eurydice_arr_d6
24588
0
    coefficient_normal_form =
24589
0
      libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(myself->data[j],
24590
0
        1441);
24591
0
    Eurydice_arr_d6
24592
0
    sum = libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form, &error->data[j]);
24593
0
    Eurydice_arr_d6 red = libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum);
24594
0
    myself->data[j] = red;
24595
0
  }
24596
0
}
24597
24598
/**
24599
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
24600
*/
24601
/**
24602
A monomorphic instance of libcrux_ml_kem.polynomial.add_error_reduce_d6
24603
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24604
with const generics
24605
24606
*/
24607
static KRML_MUSTINLINE void
24608
libcrux_ml_kem_polynomial_add_error_reduce_d6_ea(
24609
  Eurydice_arr_9e *self,
24610
  const Eurydice_arr_9e *error
24611
)
24612
0
{
24613
0
  libcrux_ml_kem_polynomial_add_error_reduce_ea(self, error);
24614
0
}
24615
24616
/**
24617
 Compute u := InvertNTT(Aᵀ ◦ r̂) + e₁
24618
*/
24619
/**
24620
A monomorphic instance of libcrux_ml_kem.matrix.compute_vector_u
24621
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24622
with const generics
24623
- K= 3
24624
*/
24625
static KRML_MUSTINLINE Eurydice_arr_bb0
24626
libcrux_ml_kem_matrix_compute_vector_u_68(
24627
  const Eurydice_arr_c10 *a_as_ntt,
24628
  const Eurydice_arr_bb0 *r_as_ntt,
24629
  const Eurydice_arr_bb0 *error_1
24630
)
24631
0
{
24632
0
  Eurydice_arr_bb0 arr_struct;
24633
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24634
0
  {
24635
    /* original Rust expression is not an lvalue in C */
24636
0
    void *lvalue = (void *)0U;
24637
0
    arr_struct.data[i] = libcrux_ml_kem_matrix_compute_vector_u_call_mut_a8_68(&lvalue, i);
24638
0
  }
24639
0
  Eurydice_arr_bb0 result = arr_struct;
24640
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++)
24641
0
  {
24642
0
    size_t i1 = i0;
24643
0
    const Eurydice_arr_bb0 *row = &a_as_ntt->data[i1];
24644
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24645
0
    {
24646
0
      size_t j = i;
24647
0
      const Eurydice_arr_9e *a_element = &row->data[j];
24648
0
      Eurydice_arr_9e
24649
0
      product = libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(a_element, &r_as_ntt->data[j]);
24650
0
      libcrux_ml_kem_polynomial_add_to_ring_element_d6_68(&result.data[i1], &product);
24651
0
    }
24652
0
    libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_68(&result.data[i1]);
24653
0
    libcrux_ml_kem_polynomial_add_error_reduce_d6_ea(&result.data[i1], &error_1->data[i1]);
24654
0
  }
24655
0
  return result;
24656
0
}
24657
24658
/**
24659
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress
24660
with const generics
24661
- COEFFICIENT_BITS= 10
24662
*/
24663
static KRML_MUSTINLINE Eurydice_arr_d6
24664
libcrux_ml_kem_vector_portable_compress_compress_ef(Eurydice_arr_d6 a)
24665
0
{
24666
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
24667
0
  {
24668
0
    size_t i0 = i;
24669
0
    int16_t
24670
0
    uu____0 =
24671
0
      libcrux_secrets_int_as_i16_f5(libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient((uint8_t)10,
24672
0
          libcrux_secrets_int_as_u16_f5(a.data[i0])));
24673
0
    a.data[i0] = uu____0;
24674
0
  }
24675
0
  return a;
24676
0
}
24677
24678
/**
24679
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
24680
*/
24681
/**
24682
A monomorphic instance of libcrux_ml_kem.vector.portable.compress_b8
24683
with const generics
24684
- COEFFICIENT_BITS= 10
24685
*/
24686
static inline Eurydice_arr_d6 libcrux_ml_kem_vector_portable_compress_b8_ef(Eurydice_arr_d6 a)
24687
0
{
24688
0
  return libcrux_ml_kem_vector_portable_compress_compress_ef(a);
24689
0
}
24690
24691
/**
24692
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_10
24693
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24694
with const generics
24695
- OUT_LEN= 320
24696
*/
24697
static KRML_MUSTINLINE Eurydice_arr_b0
24698
libcrux_ml_kem_serialize_compress_then_serialize_10_e1(const Eurydice_arr_9e *re)
24699
0
{
24700
0
  Eurydice_arr_b0 serialized = { .data = { 0U } };
24701
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
24702
0
  {
24703
0
    size_t i0 = i;
24704
0
    Eurydice_arr_d6
24705
0
    coefficient =
24706
0
      libcrux_ml_kem_vector_portable_compress_b8_ef(libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(re->data[i0]));
24707
0
    Eurydice_arr_fc bytes = libcrux_ml_kem_vector_portable_serialize_10_b8(coefficient);
24708
0
    Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d413(&serialized,
24709
0
        (
24710
0
          KRML_CLITERAL(core_ops_range_Range_87){
24711
0
            .start = (size_t)20U * i0,
24712
0
            .end = (size_t)20U * i0 + (size_t)20U
24713
0
          }
24714
0
        )),
24715
0
      Eurydice_array_to_slice_shared_8f(&bytes),
24716
0
      uint8_t);
24717
0
  }
24718
0
  return serialized;
24719
0
}
24720
24721
/**
24722
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_ring_element_u
24723
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24724
with const generics
24725
- COMPRESSION_FACTOR= 10
24726
- OUT_LEN= 320
24727
*/
24728
static KRML_MUSTINLINE Eurydice_arr_b0
24729
libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_f7(const Eurydice_arr_9e *re)
24730
0
{
24731
0
  return libcrux_ml_kem_serialize_compress_then_serialize_10_e1(re);
24732
0
}
24733
24734
/**
24735
 Call [`compress_then_serialize_ring_element_u`] on each ring element.
24736
*/
24737
/**
24738
A monomorphic instance of libcrux_ml_kem.ind_cpa.compress_then_serialize_u
24739
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24740
with const generics
24741
- K= 3
24742
- OUT_LEN= 960
24743
- COMPRESSION_FACTOR= 10
24744
- BLOCK_LEN= 320
24745
*/
24746
static KRML_MUSTINLINE void
24747
libcrux_ml_kem_ind_cpa_compress_then_serialize_u_21(
24748
  Eurydice_arr_bb0 input,
24749
  Eurydice_mut_borrow_slice_u8 out
24750
)
24751
0
{
24752
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24753
0
  {
24754
0
    size_t i0 = i;
24755
0
    Eurydice_arr_9e re = input.data[i0];
24756
0
    Eurydice_mut_borrow_slice_u8
24757
0
    uu____0 =
24758
0
      Eurydice_slice_subslice_mut_c8(out,
24759
0
        (
24760
0
          KRML_CLITERAL(core_ops_range_Range_87){
24761
0
            .start = i0 * ((size_t)960U / (size_t)3U),
24762
0
            .end = (i0 + (size_t)1U) * ((size_t)960U / (size_t)3U)
24763
0
          }
24764
0
        ));
24765
    /* original Rust expression is not an lvalue in C */
24766
0
    Eurydice_arr_b0
24767
0
    lvalue = libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_f7(&re);
24768
0
    Eurydice_slice_copy(uu____0, Eurydice_array_to_slice_shared_56(&lvalue), uint8_t);
24769
0
  }
24770
0
}
24771
24772
/**
24773
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt_c1
24774
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
24775
with const generics
24776
- K= 3
24777
- C1_LEN= 960
24778
- U_COMPRESSION_FACTOR= 10
24779
- BLOCK_LEN= 320
24780
- ETA1= 2
24781
- ETA1_RANDOMNESS_SIZE= 128
24782
- ETA2= 2
24783
- ETA2_RANDOMNESS_SIZE= 128
24784
*/
24785
static KRML_MUSTINLINE tuple_c6
24786
libcrux_ml_kem_ind_cpa_encrypt_c1_87(
24787
  Eurydice_borrow_slice_u8 randomness,
24788
  const Eurydice_arr_c10 *matrix,
24789
  Eurydice_mut_borrow_slice_u8 ciphertext
24790
)
24791
0
{
24792
0
  Eurydice_arr_fa0 prf_input = libcrux_ml_kem_utils_into_padded_array_29(randomness);
24793
0
  Eurydice_arr_bb0 arr_struct0;
24794
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24795
0
  {
24796
    /* original Rust expression is not an lvalue in C */
24797
0
    void *lvalue = (void *)0U;
24798
0
    arr_struct0.data[i] = libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_f1_87(&lvalue, i);
24799
0
  }
24800
0
  Eurydice_arr_bb0 r_as_ntt = arr_struct0;
24801
0
  uint8_t
24802
0
  domain_separator0 =
24803
0
    libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_bf(&r_as_ntt,
24804
0
      &prf_input,
24805
0
      0U);
24806
0
  Eurydice_arr_bb0 arr_struct;
24807
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24808
0
  {
24809
    /* original Rust expression is not an lvalue in C */
24810
0
    void *lvalue = (void *)0U;
24811
0
    arr_struct.data[i] = libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_dd_87(&lvalue, i);
24812
0
  }
24813
0
  Eurydice_arr_bb0 error_1 = arr_struct;
24814
0
  uint8_t
24815
0
  domain_separator =
24816
0
    libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_bf(&prf_input,
24817
0
      domain_separator0,
24818
0
      &error_1);
24819
0
  prf_input.data[32U] = domain_separator;
24820
0
  Eurydice_arr_89
24821
0
  prf_output =
24822
0
    libcrux_ml_kem_hash_functions_portable_PRF_4a_3b0(Eurydice_array_to_slice_shared_b5(&prf_input));
24823
0
  Eurydice_arr_9e
24824
0
  error_2 =
24825
0
    libcrux_ml_kem_sampling_sample_from_binomial_distribution_66(Eurydice_array_to_slice_shared_78(&prf_output));
24826
0
  Eurydice_arr_bb0 u = libcrux_ml_kem_matrix_compute_vector_u_68(matrix, &r_as_ntt, &error_1);
24827
0
  libcrux_ml_kem_ind_cpa_compress_then_serialize_u_21(u, ciphertext);
24828
0
  return (KRML_CLITERAL(tuple_c6){ .fst = r_as_ntt, .snd = error_2 });
24829
0
}
24830
24831
/**
24832
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_message
24833
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24834
with const generics
24835
24836
*/
24837
static KRML_MUSTINLINE Eurydice_arr_9e
24838
libcrux_ml_kem_serialize_deserialize_then_decompress_message_ea(
24839
  const Eurydice_arr_ec *serialized
24840
)
24841
0
{
24842
0
  Eurydice_arr_9e re = libcrux_ml_kem_polynomial_ZERO_d6_ea();
24843
0
  for (size_t i = (size_t)0U; i < (size_t)16U; i++)
24844
0
  {
24845
0
    size_t i0 = i;
24846
0
    Eurydice_arr_d6
24847
0
    coefficient_compressed =
24848
0
      libcrux_ml_kem_vector_portable_deserialize_1_b8(Eurydice_array_to_subslice_shared_d4(serialized,
24849
0
          (
24850
0
            KRML_CLITERAL(core_ops_range_Range_87){
24851
0
              .start = (size_t)2U * i0,
24852
0
              .end = (size_t)2U * i0 + (size_t)2U
24853
0
            }
24854
0
          )));
24855
0
    Eurydice_arr_d6
24856
0
    uu____0 = libcrux_ml_kem_vector_portable_decompress_1_b8(coefficient_compressed);
24857
0
    re.data[i0] = uu____0;
24858
0
  }
24859
0
  return re;
24860
0
}
24861
24862
/**
24863
A monomorphic instance of libcrux_ml_kem.polynomial.add_message_error_reduce
24864
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24865
with const generics
24866
24867
*/
24868
static KRML_MUSTINLINE Eurydice_arr_9e
24869
libcrux_ml_kem_polynomial_add_message_error_reduce_ea(
24870
  const Eurydice_arr_9e *myself,
24871
  const Eurydice_arr_9e *message,
24872
  Eurydice_arr_9e result
24873
)
24874
0
{
24875
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
24876
0
  {
24877
0
    size_t i0 = i;
24878
0
    Eurydice_arr_d6
24879
0
    coefficient_normal_form =
24880
0
      libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(result.data[i0],
24881
0
        1441);
24882
0
    Eurydice_arr_d6
24883
0
    sum1 = libcrux_ml_kem_vector_portable_add_b8(myself->data[i0], &message->data[i0]);
24884
0
    Eurydice_arr_d6 sum2 = libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form, &sum1);
24885
0
    Eurydice_arr_d6 red = libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum2);
24886
0
    result.data[i0] = red;
24887
0
  }
24888
0
  return result;
24889
0
}
24890
24891
/**
24892
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
24893
*/
24894
/**
24895
A monomorphic instance of libcrux_ml_kem.polynomial.add_message_error_reduce_d6
24896
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24897
with const generics
24898
24899
*/
24900
static KRML_MUSTINLINE Eurydice_arr_9e
24901
libcrux_ml_kem_polynomial_add_message_error_reduce_d6_ea(
24902
  const Eurydice_arr_9e *self,
24903
  const Eurydice_arr_9e *message,
24904
  Eurydice_arr_9e result
24905
)
24906
0
{
24907
0
  return libcrux_ml_kem_polynomial_add_message_error_reduce_ea(self, message, result);
24908
0
}
24909
24910
/**
24911
 Compute InverseNTT(tᵀ ◦ r̂) + e₂ + message
24912
*/
24913
/**
24914
A monomorphic instance of libcrux_ml_kem.matrix.compute_ring_element_v
24915
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24916
with const generics
24917
- K= 3
24918
*/
24919
static KRML_MUSTINLINE Eurydice_arr_9e
24920
libcrux_ml_kem_matrix_compute_ring_element_v_68(
24921
  const Eurydice_arr_bb0 *t_as_ntt,
24922
  const Eurydice_arr_bb0 *r_as_ntt,
24923
  const Eurydice_arr_9e *error_2,
24924
  const Eurydice_arr_9e *message
24925
)
24926
0
{
24927
0
  Eurydice_arr_9e result = libcrux_ml_kem_polynomial_ZERO_d6_ea();
24928
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
24929
0
  {
24930
0
    size_t i0 = i;
24931
0
    Eurydice_arr_9e
24932
0
    product =
24933
0
      libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(&t_as_ntt->data[i0],
24934
0
        &r_as_ntt->data[i0]);
24935
0
    libcrux_ml_kem_polynomial_add_to_ring_element_d6_68(&result, &product);
24936
0
  }
24937
0
  libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_68(&result);
24938
0
  return libcrux_ml_kem_polynomial_add_message_error_reduce_d6_ea(error_2, message, result);
24939
0
}
24940
24941
/**
24942
A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress
24943
with const generics
24944
- COEFFICIENT_BITS= 4
24945
*/
24946
static KRML_MUSTINLINE Eurydice_arr_d6
24947
libcrux_ml_kem_vector_portable_compress_compress_d1(Eurydice_arr_d6 a)
24948
0
{
24949
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++)
24950
0
  {
24951
0
    size_t i0 = i;
24952
0
    int16_t
24953
0
    uu____0 =
24954
0
      libcrux_secrets_int_as_i16_f5(libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient((uint8_t)4,
24955
0
          libcrux_secrets_int_as_u16_f5(a.data[i0])));
24956
0
    a.data[i0] = uu____0;
24957
0
  }
24958
0
  return a;
24959
0
}
24960
24961
/**
24962
This function found in impl {libcrux_ml_kem::vector::traits::Operations for libcrux_ml_kem::vector::portable::vector_type::PortableVector}
24963
*/
24964
/**
24965
A monomorphic instance of libcrux_ml_kem.vector.portable.compress_b8
24966
with const generics
24967
- COEFFICIENT_BITS= 4
24968
*/
24969
static inline Eurydice_arr_d6 libcrux_ml_kem_vector_portable_compress_b8_d1(Eurydice_arr_d6 a)
24970
0
{
24971
0
  return libcrux_ml_kem_vector_portable_compress_compress_d1(a);
24972
0
}
24973
24974
/**
24975
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_4
24976
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
24977
with const generics
24978
24979
*/
24980
static KRML_MUSTINLINE void
24981
libcrux_ml_kem_serialize_compress_then_serialize_4_ea(
24982
  Eurydice_arr_9e re,
24983
  Eurydice_mut_borrow_slice_u8 serialized
24984
)
24985
0
{
24986
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
24987
0
  {
24988
0
    size_t i0 = i;
24989
0
    Eurydice_arr_d6
24990
0
    coefficient =
24991
0
      libcrux_ml_kem_vector_portable_compress_b8_d1(libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(re.data[i0]));
24992
0
    Eurydice_array_u8x8 bytes = libcrux_ml_kem_vector_portable_serialize_4_b8(coefficient);
24993
0
    Eurydice_slice_copy(Eurydice_slice_subslice_mut_c8(serialized,
24994
0
        (
24995
0
          KRML_CLITERAL(core_ops_range_Range_87){
24996
0
            .start = (size_t)8U * i0,
24997
0
            .end = (size_t)8U * i0 + (size_t)8U
24998
0
          }
24999
0
        )),
25000
0
      Eurydice_array_to_slice_shared_6e(&bytes),
25001
0
      uint8_t);
25002
0
  }
25003
0
}
25004
25005
/**
25006
A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_ring_element_v
25007
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25008
with const generics
25009
- K= 3
25010
- COMPRESSION_FACTOR= 4
25011
- OUT_LEN= 128
25012
*/
25013
static KRML_MUSTINLINE void
25014
libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_30(
25015
  Eurydice_arr_9e re,
25016
  Eurydice_mut_borrow_slice_u8 out
25017
)
25018
0
{
25019
0
  libcrux_ml_kem_serialize_compress_then_serialize_4_ea(re, out);
25020
0
}
25021
25022
/**
25023
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt_c2
25024
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25025
with const generics
25026
- K= 3
25027
- V_COMPRESSION_FACTOR= 4
25028
- C2_LEN= 128
25029
*/
25030
static KRML_MUSTINLINE void
25031
libcrux_ml_kem_ind_cpa_encrypt_c2_30(
25032
  const Eurydice_arr_bb0 *t_as_ntt,
25033
  const Eurydice_arr_bb0 *r_as_ntt,
25034
  const Eurydice_arr_9e *error_2,
25035
  const Eurydice_arr_ec *message,
25036
  Eurydice_mut_borrow_slice_u8 ciphertext
25037
)
25038
0
{
25039
0
  Eurydice_arr_9e
25040
0
  message_as_ring_element =
25041
0
    libcrux_ml_kem_serialize_deserialize_then_decompress_message_ea(message);
25042
0
  Eurydice_arr_9e
25043
0
  v =
25044
0
    libcrux_ml_kem_matrix_compute_ring_element_v_68(t_as_ntt,
25045
0
      r_as_ntt,
25046
0
      error_2,
25047
0
      &message_as_ring_element);
25048
0
  libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_30(v, ciphertext);
25049
0
}
25050
25051
/**
25052
 This function implements <strong>Algorithm 13</strong> of the
25053
 NIST FIPS 203 specification; this is the Kyber CPA-PKE encryption algorithm.
25054
25055
 Algorithm 13 is reproduced below:
25056
25057
 ```plaintext
25058
 Input: encryption key ekₚₖₑ ∈ 𝔹^{384k+32}.
25059
 Input: message m ∈ 𝔹^{32}.
25060
 Input: encryption randomness r ∈ 𝔹^{32}.
25061
 Output: ciphertext c ∈ 𝔹^{32(dᵤk + dᵥ)}.
25062
25063
 N ← 0
25064
 t̂ ← ByteDecode₁₂(ekₚₖₑ[0:384k])
25065
 ρ ← ekₚₖₑ[384k: 384k + 32]
25066
 for (i ← 0; i < k; i++)
25067
     for(j ← 0; j < k; j++)
25068
         Â[i,j] ← SampleNTT(XOF(ρ, i, j))
25069
     end for
25070
 end for
25071
 for(i ← 0; i < k; i++)
25072
     r[i] ← SamplePolyCBD_{η₁}(PRF_{η₁}(r,N))
25073
     N ← N + 1
25074
 end for
25075
 for(i ← 0; i < k; i++)
25076
     e₁[i] ← SamplePolyCBD_{η₂}(PRF_{η₂}(r,N))
25077
     N ← N + 1
25078
 end for
25079
 e₂ ← SamplePolyCBD_{η₂}(PRF_{η₂}(r,N))
25080
 r̂ ← NTT(r)
25081
 u ← NTT-¹(Âᵀ ◦ r̂) + e₁
25082
 μ ← Decompress₁(ByteDecode₁(m)))
25083
 v ← NTT-¹(t̂ᵀ ◦ rˆ) + e₂ + μ
25084
 c₁ ← ByteEncode_{dᵤ}(Compress_{dᵤ}(u))
25085
 c₂ ← ByteEncode_{dᵥ}(Compress_{dᵥ}(v))
25086
 return c ← (c₁ ‖ c₂)
25087
 ```
25088
25089
 The NIST FIPS 203 standard can be found at
25090
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
25091
*/
25092
/**
25093
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt_unpacked
25094
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25095
with const generics
25096
- K= 3
25097
- CIPHERTEXT_SIZE= 1088
25098
- T_AS_NTT_ENCODED_SIZE= 1152
25099
- C1_LEN= 960
25100
- C2_LEN= 128
25101
- U_COMPRESSION_FACTOR= 10
25102
- V_COMPRESSION_FACTOR= 4
25103
- BLOCK_LEN= 320
25104
- ETA1= 2
25105
- ETA1_RANDOMNESS_SIZE= 128
25106
- ETA2= 2
25107
- ETA2_RANDOMNESS_SIZE= 128
25108
*/
25109
static KRML_MUSTINLINE Eurydice_arr_2b
25110
libcrux_ml_kem_ind_cpa_encrypt_unpacked_d5(
25111
  const libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 *public_key,
25112
  const Eurydice_arr_ec *message,
25113
  Eurydice_borrow_slice_u8 randomness
25114
)
25115
0
{
25116
0
  Eurydice_arr_2b ciphertext = { .data = { 0U } };
25117
0
  tuple_c6
25118
0
  uu____0 =
25119
0
    libcrux_ml_kem_ind_cpa_encrypt_c1_87(randomness,
25120
0
      &public_key->A,
25121
0
      Eurydice_array_to_subslice_mut_d414(&ciphertext,
25122
0
        (KRML_CLITERAL(core_ops_range_Range_87){ .start = (size_t)0U, .end = (size_t)960U })));
25123
0
  Eurydice_arr_bb0 r_as_ntt = uu____0.fst;
25124
0
  Eurydice_arr_9e error_2 = uu____0.snd;
25125
0
  libcrux_ml_kem_ind_cpa_encrypt_c2_30(&public_key->t_as_ntt,
25126
0
    &r_as_ntt,
25127
0
    &error_2,
25128
0
    message,
25129
0
    Eurydice_array_to_subslice_from_mut_5f3(&ciphertext, (size_t)960U));
25130
0
  return ciphertext;
25131
0
}
25132
25133
/**
25134
A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt
25135
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25136
with const generics
25137
- K= 3
25138
- CIPHERTEXT_SIZE= 1088
25139
- T_AS_NTT_ENCODED_SIZE= 1152
25140
- C1_LEN= 960
25141
- C2_LEN= 128
25142
- U_COMPRESSION_FACTOR= 10
25143
- V_COMPRESSION_FACTOR= 4
25144
- BLOCK_LEN= 320
25145
- ETA1= 2
25146
- ETA1_RANDOMNESS_SIZE= 128
25147
- ETA2= 2
25148
- ETA2_RANDOMNESS_SIZE= 128
25149
*/
25150
static KRML_MUSTINLINE Eurydice_arr_2b
25151
libcrux_ml_kem_ind_cpa_encrypt_d5(
25152
  Eurydice_borrow_slice_u8 public_key,
25153
  const Eurydice_arr_ec *message,
25154
  Eurydice_borrow_slice_u8 randomness
25155
)
25156
0
{
25157
0
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
25158
0
  unpacked_public_key = libcrux_ml_kem_ind_cpa_build_unpacked_public_key_05(public_key);
25159
0
  return libcrux_ml_kem_ind_cpa_encrypt_unpacked_d5(&unpacked_public_key, message, randomness);
25160
0
}
25161
25162
/**
25163
This function found in impl {libcrux_ml_kem::variant::Variant for libcrux_ml_kem::variant::MlKem}
25164
*/
25165
/**
25166
A monomorphic instance of libcrux_ml_kem.variant.kdf_39
25167
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25168
with const generics
25169
- K= 3
25170
- CIPHERTEXT_SIZE= 1088
25171
*/
25172
static KRML_MUSTINLINE Eurydice_arr_ec
25173
libcrux_ml_kem_variant_kdf_39_52(
25174
  Eurydice_borrow_slice_u8 shared_secret,
25175
  const Eurydice_arr_2b *_
25176
)
25177
0
{
25178
0
  Eurydice_arr_ec out = { .data = { 0U } };
25179
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_01(&out), shared_secret, uint8_t);
25180
0
  return out;
25181
0
}
25182
25183
/**
25184
 This code verifies on some machines, runs out of memory on others
25185
*/
25186
/**
25187
A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate
25188
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
25189
with const generics
25190
- K= 3
25191
- SECRET_KEY_SIZE= 2400
25192
- CPA_SECRET_KEY_SIZE= 1152
25193
- PUBLIC_KEY_SIZE= 1184
25194
- CIPHERTEXT_SIZE= 1088
25195
- T_AS_NTT_ENCODED_SIZE= 1152
25196
- C1_SIZE= 960
25197
- C2_SIZE= 128
25198
- VECTOR_U_COMPRESSION_FACTOR= 10
25199
- VECTOR_V_COMPRESSION_FACTOR= 4
25200
- C1_BLOCK_SIZE= 320
25201
- ETA1= 2
25202
- ETA1_RANDOMNESS_SIZE= 128
25203
- ETA2= 2
25204
- ETA2_RANDOMNESS_SIZE= 128
25205
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
25206
*/
25207
static KRML_MUSTINLINE Eurydice_arr_ec
25208
libcrux_ml_kem_ind_cca_decapsulate_fd(
25209
  const Eurydice_arr_7d *private_key,
25210
  const Eurydice_arr_2b *ciphertext
25211
)
25212
0
{
25213
0
  Eurydice_borrow_slice_u8_x4
25214
0
  uu____0 =
25215
0
    libcrux_ml_kem_types_unpack_private_key_64(Eurydice_array_to_slice_shared_51(private_key));
25216
0
  Eurydice_borrow_slice_u8 ind_cpa_secret_key = uu____0.fst;
25217
0
  Eurydice_borrow_slice_u8 ind_cpa_public_key = uu____0.snd;
25218
0
  Eurydice_borrow_slice_u8 ind_cpa_public_key_hash = uu____0.thd;
25219
0
  Eurydice_borrow_slice_u8 implicit_rejection_value = uu____0.f3;
25220
0
  Eurydice_arr_ec decrypted = libcrux_ml_kem_ind_cpa_decrypt_01(ind_cpa_secret_key, ciphertext);
25221
0
  Eurydice_arr_c7
25222
0
  to_hash0 =
25223
0
    libcrux_ml_kem_utils_into_padded_array_c9(Eurydice_array_to_slice_shared_01(&decrypted));
25224
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_from_mut_5f1(&to_hash0,
25225
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE),
25226
0
    ind_cpa_public_key_hash,
25227
0
    uint8_t);
25228
0
  Eurydice_arr_c7
25229
0
  hashed =
25230
0
    libcrux_ml_kem_hash_functions_portable_G_4a_78(Eurydice_array_to_slice_shared_17(&to_hash0));
25231
0
  Eurydice_borrow_slice_u8_x2
25232
0
  uu____1 =
25233
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_17(&hashed),
25234
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
25235
0
      uint8_t,
25236
0
      Eurydice_borrow_slice_u8_x2);
25237
0
  Eurydice_borrow_slice_u8 shared_secret0 = uu____1.fst;
25238
0
  Eurydice_borrow_slice_u8 pseudorandomness = uu____1.snd;
25239
0
  Eurydice_arr_af to_hash = libcrux_ml_kem_utils_into_padded_array_66(implicit_rejection_value);
25240
0
  Eurydice_mut_borrow_slice_u8
25241
0
  uu____2 =
25242
0
    Eurydice_array_to_subslice_from_mut_5f2(&to_hash,
25243
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE);
25244
0
  Eurydice_slice_copy(uu____2, libcrux_ml_kem_types_as_ref_c1_52(ciphertext), uint8_t);
25245
0
  Eurydice_arr_ec
25246
0
  implicit_rejection_shared_secret =
25247
0
    libcrux_ml_kem_hash_functions_portable_PRF_4a_3b(Eurydice_array_to_slice_shared_81(&to_hash));
25248
0
  Eurydice_arr_2b
25249
0
  expected_ciphertext =
25250
0
    libcrux_ml_kem_ind_cpa_encrypt_d5(ind_cpa_public_key,
25251
0
      &decrypted,
25252
0
      pseudorandomness);
25253
0
  Eurydice_borrow_slice_u8
25254
0
  uu____3 = Eurydice_array_to_slice_shared_01(&implicit_rejection_shared_secret);
25255
0
  Eurydice_arr_ec
25256
0
  implicit_rejection_shared_secret0 =
25257
0
    libcrux_ml_kem_variant_kdf_39_52(uu____3,
25258
0
      libcrux_ml_kem_types_as_slice_a9_52(ciphertext));
25259
0
  Eurydice_arr_ec
25260
0
  shared_secret =
25261
0
    libcrux_ml_kem_variant_kdf_39_52(shared_secret0,
25262
0
      libcrux_ml_kem_types_as_slice_a9_52(ciphertext));
25263
0
  Eurydice_borrow_slice_u8 uu____4 = libcrux_ml_kem_types_as_ref_c1_52(ciphertext);
25264
0
  return
25265
0
    libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time(uu____4,
25266
0
      Eurydice_array_to_slice_shared_06(&expected_ciphertext),
25267
0
      Eurydice_array_to_slice_shared_01(&shared_secret),
25268
0
      Eurydice_array_to_slice_shared_01(&implicit_rejection_shared_secret0));
25269
0
}
25270
25271
/**
25272
 Portable decapsulate
25273
*/
25274
/**
25275
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.decapsulate
25276
with const generics
25277
- K= 3
25278
- SECRET_KEY_SIZE= 2400
25279
- CPA_SECRET_KEY_SIZE= 1152
25280
- PUBLIC_KEY_SIZE= 1184
25281
- CIPHERTEXT_SIZE= 1088
25282
- T_AS_NTT_ENCODED_SIZE= 1152
25283
- C1_SIZE= 960
25284
- C2_SIZE= 128
25285
- VECTOR_U_COMPRESSION_FACTOR= 10
25286
- VECTOR_V_COMPRESSION_FACTOR= 4
25287
- C1_BLOCK_SIZE= 320
25288
- ETA1= 2
25289
- ETA1_RANDOMNESS_SIZE= 128
25290
- ETA2= 2
25291
- ETA2_RANDOMNESS_SIZE= 128
25292
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
25293
*/
25294
static inline Eurydice_arr_ec
25295
libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_19(
25296
  const Eurydice_arr_7d *private_key,
25297
  const Eurydice_arr_2b *ciphertext
25298
)
25299
0
{
25300
0
  return libcrux_ml_kem_ind_cca_decapsulate_fd(private_key, ciphertext);
25301
0
}
25302
25303
/**
25304
 Decapsulate ML-KEM 768
25305
25306
 Generates an [`MlKemSharedSecret`].
25307
 The input is a reference to an [`MlKem768PrivateKey`] and an [`MlKem768Ciphertext`].
25308
*/
25309
static inline Eurydice_arr_ec
25310
libcrux_ml_kem_mlkem768_portable_decapsulate(
25311
  const Eurydice_arr_7d *private_key,
25312
  const Eurydice_arr_2b *ciphertext
25313
)
25314
0
{
25315
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_19(private_key, ciphertext);
25316
0
}
25317
25318
/**
25319
This function found in impl {libcrux_ml_kem::variant::Variant for libcrux_ml_kem::variant::MlKem}
25320
*/
25321
/**
25322
A monomorphic instance of libcrux_ml_kem.variant.entropy_preprocess_39
25323
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25324
with const generics
25325
- K= 3
25326
*/
25327
static KRML_MUSTINLINE Eurydice_arr_ec
25328
libcrux_ml_kem_variant_entropy_preprocess_39_13(Eurydice_borrow_slice_u8 randomness)
25329
0
{
25330
0
  Eurydice_arr_ec out = { .data = { 0U } };
25331
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_01(&out), randomness, uint8_t);
25332
0
  return out;
25333
0
}
25334
25335
/**
25336
This function found in impl {libcrux_ml_kem::hash_functions::Hash<K> for libcrux_ml_kem::hash_functions::portable::PortableHash<K>}
25337
*/
25338
/**
25339
A monomorphic instance of libcrux_ml_kem.hash_functions.portable.H_4a
25340
with const generics
25341
- K= 3
25342
*/
25343
static inline Eurydice_arr_ec
25344
libcrux_ml_kem_hash_functions_portable_H_4a_78(Eurydice_borrow_slice_u8 input)
25345
0
{
25346
0
  return libcrux_ml_kem_hash_functions_portable_H(input);
25347
0
}
25348
25349
/**
25350
A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate
25351
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
25352
with const generics
25353
- K= 3
25354
- CIPHERTEXT_SIZE= 1088
25355
- PUBLIC_KEY_SIZE= 1184
25356
- T_AS_NTT_ENCODED_SIZE= 1152
25357
- C1_SIZE= 960
25358
- C2_SIZE= 128
25359
- VECTOR_U_COMPRESSION_FACTOR= 10
25360
- VECTOR_V_COMPRESSION_FACTOR= 4
25361
- C1_BLOCK_SIZE= 320
25362
- ETA1= 2
25363
- ETA1_RANDOMNESS_SIZE= 128
25364
- ETA2= 2
25365
- ETA2_RANDOMNESS_SIZE= 128
25366
*/
25367
static KRML_MUSTINLINE tuple_f4
25368
libcrux_ml_kem_ind_cca_encapsulate_99(
25369
  const Eurydice_arr_5f *public_key,
25370
  const Eurydice_arr_ec *randomness
25371
)
25372
0
{
25373
0
  Eurydice_arr_ec
25374
0
  randomness0 =
25375
0
    libcrux_ml_kem_variant_entropy_preprocess_39_13(Eurydice_array_to_slice_shared_01(randomness));
25376
0
  Eurydice_arr_c7
25377
0
  to_hash =
25378
0
    libcrux_ml_kem_utils_into_padded_array_c9(Eurydice_array_to_slice_shared_01(&randomness0));
25379
0
  Eurydice_mut_borrow_slice_u8
25380
0
  uu____0 =
25381
0
    Eurydice_array_to_subslice_from_mut_5f1(&to_hash,
25382
0
      LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE);
25383
  /* original Rust expression is not an lvalue in C */
25384
0
  Eurydice_arr_ec
25385
0
  lvalue =
25386
0
    libcrux_ml_kem_hash_functions_portable_H_4a_78(Eurydice_array_to_slice_shared_ff(libcrux_ml_kem_types_as_slice_e6_3d(public_key)));
25387
0
  Eurydice_slice_copy(uu____0, Eurydice_array_to_slice_shared_01(&lvalue), uint8_t);
25388
0
  Eurydice_arr_c7
25389
0
  hashed =
25390
0
    libcrux_ml_kem_hash_functions_portable_G_4a_78(Eurydice_array_to_slice_shared_17(&to_hash));
25391
0
  Eurydice_borrow_slice_u8_x2
25392
0
  uu____1 =
25393
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_17(&hashed),
25394
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
25395
0
      uint8_t,
25396
0
      Eurydice_borrow_slice_u8_x2);
25397
0
  Eurydice_borrow_slice_u8 shared_secret = uu____1.fst;
25398
0
  Eurydice_borrow_slice_u8 pseudorandomness = uu____1.snd;
25399
0
  Eurydice_arr_2b
25400
0
  ciphertext =
25401
0
    libcrux_ml_kem_ind_cpa_encrypt_d5(Eurydice_array_to_slice_shared_ff(libcrux_ml_kem_types_as_slice_e6_3d(public_key)),
25402
0
      &randomness0,
25403
0
      pseudorandomness);
25404
0
  Eurydice_arr_2b uu____2 = libcrux_ml_kem_types_from_19_52(ciphertext);
25405
0
  return
25406
0
    (
25407
0
      KRML_CLITERAL(tuple_f4){
25408
0
        .fst = uu____2,
25409
0
        .snd = libcrux_ml_kem_variant_kdf_39_52(shared_secret, &ciphertext)
25410
0
      }
25411
0
    );
25412
0
}
25413
25414
/**
25415
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.encapsulate
25416
with const generics
25417
- K= 3
25418
- CIPHERTEXT_SIZE= 1088
25419
- PUBLIC_KEY_SIZE= 1184
25420
- T_AS_NTT_ENCODED_SIZE= 1152
25421
- C1_SIZE= 960
25422
- C2_SIZE= 128
25423
- VECTOR_U_COMPRESSION_FACTOR= 10
25424
- VECTOR_V_COMPRESSION_FACTOR= 4
25425
- C1_BLOCK_SIZE= 320
25426
- ETA1= 2
25427
- ETA1_RANDOMNESS_SIZE= 128
25428
- ETA2= 2
25429
- ETA2_RANDOMNESS_SIZE= 128
25430
*/
25431
static inline tuple_f4
25432
libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_26(
25433
  const Eurydice_arr_5f *public_key,
25434
  const Eurydice_arr_ec *randomness
25435
)
25436
0
{
25437
0
  return libcrux_ml_kem_ind_cca_encapsulate_99(public_key, randomness);
25438
0
}
25439
25440
/**
25441
 Encapsulate ML-KEM 768
25442
25443
 Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple.
25444
 The input is a reference to an [`MlKem768PublicKey`] and [`SHARED_SECRET_SIZE`]
25445
 bytes of `randomness`.
25446
*/
25447
static inline tuple_f4
25448
libcrux_ml_kem_mlkem768_portable_encapsulate(
25449
  const Eurydice_arr_5f *public_key,
25450
  Eurydice_arr_ec randomness
25451
)
25452
0
{
25453
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_26(public_key, &randomness);
25454
0
}
25455
25456
/**
25457
This function found in impl {core::default::Default for libcrux_ml_kem::ind_cpa::unpacked::IndCpaPrivateKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
25458
*/
25459
/**
25460
A monomorphic instance of libcrux_ml_kem.ind_cpa.unpacked.default_70
25461
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25462
with const generics
25463
- K= 3
25464
*/
25465
static inline Eurydice_arr_bb0 libcrux_ml_kem_ind_cpa_unpacked_default_70_68(void)
25466
0
{
25467
0
  Eurydice_arr_bb0 lit;
25468
0
  Eurydice_arr_9e repeat_expression[3U];
25469
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
25470
0
  {
25471
0
    repeat_expression[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
25472
0
  }
25473
0
  memcpy(lit.data, repeat_expression, (size_t)3U * sizeof (Eurydice_arr_9e));
25474
0
  return lit;
25475
0
}
25476
25477
/**
25478
This function found in impl {libcrux_ml_kem::variant::Variant for libcrux_ml_kem::variant::MlKem}
25479
*/
25480
/**
25481
A monomorphic instance of libcrux_ml_kem.variant.cpa_keygen_seed_39
25482
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25483
with const generics
25484
- K= 3
25485
*/
25486
static KRML_MUSTINLINE Eurydice_arr_c7
25487
libcrux_ml_kem_variant_cpa_keygen_seed_39_13(Eurydice_borrow_slice_u8 key_generation_seed)
25488
0
{
25489
0
  Eurydice_arr_fa0 seed = { .data = { 0U } };
25490
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d412(&seed,
25491
0
      (
25492
0
        KRML_CLITERAL(core_ops_range_Range_87){
25493
0
          .start = (size_t)0U,
25494
0
          .end = LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE
25495
0
        }
25496
0
      )),
25497
0
    key_generation_seed,
25498
0
    uint8_t);
25499
0
  seed.data[LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE] = (uint8_t)(size_t)3U;
25500
0
  return
25501
0
    libcrux_ml_kem_hash_functions_portable_G_4a_78(Eurydice_array_to_slice_shared_b5(&seed));
25502
0
}
25503
25504
/**
25505
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@3]> for libcrux_ml_kem::ind_cpa::generate_keypair_unpacked::closure<Vector, Hasher, Scheme, K, ETA1, ETA1_RANDOMNESS_SIZE>[TraitClause@0, TraitClause@1, TraitClause@2, TraitClause@3, TraitClause@4, TraitClause@5]}
25506
*/
25507
/**
25508
A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair_unpacked.call_mut_73
25509
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
25510
with const generics
25511
- K= 3
25512
- ETA1= 2
25513
- ETA1_RANDOMNESS_SIZE= 128
25514
*/
25515
static inline Eurydice_arr_9e
25516
libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_call_mut_73_39(void **_, size_t tupled_args)
25517
0
{
25518
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
25519
0
}
25520
25521
/**
25522
A monomorphic instance of libcrux_ml_kem.polynomial.to_standard_domain
25523
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25524
with const generics
25525
25526
*/
25527
static KRML_MUSTINLINE Eurydice_arr_d6
25528
libcrux_ml_kem_polynomial_to_standard_domain_ea(Eurydice_arr_d6 vector)
25529
0
{
25530
0
  return
25531
0
    libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(vector,
25532
0
      LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS);
25533
0
}
25534
25535
/**
25536
A monomorphic instance of libcrux_ml_kem.polynomial.add_standard_error_reduce
25537
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25538
with const generics
25539
25540
*/
25541
static KRML_MUSTINLINE void
25542
libcrux_ml_kem_polynomial_add_standard_error_reduce_ea(
25543
  Eurydice_arr_9e *myself,
25544
  const Eurydice_arr_9e *error
25545
)
25546
0
{
25547
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
25548
0
  {
25549
0
    size_t j = i;
25550
0
    Eurydice_arr_d6
25551
0
    coefficient_normal_form = libcrux_ml_kem_polynomial_to_standard_domain_ea(myself->data[j]);
25552
0
    Eurydice_arr_d6
25553
0
    sum = libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form, &error->data[j]);
25554
0
    Eurydice_arr_d6 red = libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum);
25555
0
    myself->data[j] = red;
25556
0
  }
25557
0
}
25558
25559
/**
25560
This function found in impl {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]}
25561
*/
25562
/**
25563
A monomorphic instance of libcrux_ml_kem.polynomial.add_standard_error_reduce_d6
25564
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25565
with const generics
25566
25567
*/
25568
static KRML_MUSTINLINE void
25569
libcrux_ml_kem_polynomial_add_standard_error_reduce_d6_ea(
25570
  Eurydice_arr_9e *self,
25571
  const Eurydice_arr_9e *error
25572
)
25573
0
{
25574
0
  libcrux_ml_kem_polynomial_add_standard_error_reduce_ea(self, error);
25575
0
}
25576
25577
/**
25578
 Compute  ◦ ŝ + ê
25579
*/
25580
/**
25581
A monomorphic instance of libcrux_ml_kem.matrix.compute_As_plus_e
25582
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25583
with const generics
25584
- K= 3
25585
*/
25586
static KRML_MUSTINLINE void
25587
libcrux_ml_kem_matrix_compute_As_plus_e_68(
25588
  Eurydice_arr_bb0 *t_as_ntt,
25589
  const Eurydice_arr_c10 *matrix_A,
25590
  const Eurydice_arr_bb0 *s_as_ntt,
25591
  const Eurydice_arr_bb0 *error_as_ntt
25592
)
25593
0
{
25594
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
25595
0
  {
25596
0
    size_t i0 = i;
25597
0
    const Eurydice_arr_bb0 *row = &matrix_A->data[i0];
25598
0
    Eurydice_arr_9e uu____0 = libcrux_ml_kem_polynomial_ZERO_d6_ea();
25599
0
    t_as_ntt->data[i0] = uu____0;
25600
0
    for (size_t i1 = (size_t)0U; i1 < (size_t)3U; i1++)
25601
0
    {
25602
0
      size_t j = i1;
25603
0
      const Eurydice_arr_9e *matrix_element = &row->data[j];
25604
0
      Eurydice_arr_9e
25605
0
      product = libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(matrix_element, &s_as_ntt->data[j]);
25606
0
      libcrux_ml_kem_polynomial_add_to_ring_element_d6_68(&t_as_ntt->data[i0], &product);
25607
0
    }
25608
0
    libcrux_ml_kem_polynomial_add_standard_error_reduce_d6_ea(&t_as_ntt->data[i0],
25609
0
      &error_as_ntt->data[i0]);
25610
0
  }
25611
0
}
25612
25613
/**
25614
 This function implements most of <strong>Algorithm 12</strong> of the
25615
 NIST FIPS 203 specification; this is the Kyber CPA-PKE key generation algorithm.
25616
25617
 We say "most of" since Algorithm 12 samples the required randomness within
25618
 the function itself, whereas this implementation expects it to be provided
25619
 through the `key_generation_seed` parameter.
25620
25621
 Algorithm 12 is reproduced below:
25622
25623
 ```plaintext
25624
 Output: encryption key ekₚₖₑ ∈ 𝔹^{384k+32}.
25625
 Output: decryption key dkₚₖₑ ∈ 𝔹^{384k}.
25626
25627
 d ←$ B
25628
 (ρ,σ) ← G(d)
25629
 N ← 0
25630
 for (i ← 0; i < k; i++)
25631
     for(j ← 0; j < k; j++)
25632
         Â[i,j] ← SampleNTT(XOF(ρ, i, j))
25633
     end for
25634
 end for
25635
 for(i ← 0; i < k; i++)
25636
     s[i] ← SamplePolyCBD_{η₁}(PRF_{η₁}(σ,N))
25637
     N ← N + 1
25638
 end for
25639
 for(i ← 0; i < k; i++)
25640
     e[i] ← SamplePolyCBD_{η₂}(PRF_{η₂}(σ,N))
25641
     N ← N + 1
25642
 end for
25643
 ŝ ← NTT(s)
25644
 ê ← NTT(e)
25645
 t̂ ← Â◦ŝ + ê
25646
 ekₚₖₑ ← ByteEncode₁₂(t̂) ‖ ρ
25647
 dkₚₖₑ ← ByteEncode₁₂(ŝ)
25648
 ```
25649
25650
 The NIST FIPS 203 standard can be found at
25651
 <https://csrc.nist.gov/pubs/fips/203/ipd>.
25652
*/
25653
/**
25654
A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair_unpacked
25655
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
25656
with const generics
25657
- K= 3
25658
- ETA1= 2
25659
- ETA1_RANDOMNESS_SIZE= 128
25660
*/
25661
static KRML_MUSTINLINE void
25662
libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_39(
25663
  Eurydice_borrow_slice_u8 key_generation_seed,
25664
  Eurydice_arr_bb0 *private_key,
25665
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 *public_key
25666
)
25667
0
{
25668
0
  Eurydice_arr_c7 hashed = libcrux_ml_kem_variant_cpa_keygen_seed_39_13(key_generation_seed);
25669
0
  Eurydice_borrow_slice_u8_x2
25670
0
  uu____0 =
25671
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_17(&hashed),
25672
0
      (size_t)32U,
25673
0
      uint8_t,
25674
0
      Eurydice_borrow_slice_u8_x2);
25675
0
  Eurydice_borrow_slice_u8 seed_for_A = uu____0.fst;
25676
0
  Eurydice_borrow_slice_u8 seed_for_secret_and_error = uu____0.snd;
25677
0
  Eurydice_arr_c10 *uu____1 = &public_key->A;
25678
  /* original Rust expression is not an lvalue in C */
25679
0
  Eurydice_arr_31 lvalue0 = libcrux_ml_kem_utils_into_padded_array_de(seed_for_A);
25680
0
  libcrux_ml_kem_matrix_sample_matrix_A_91(uu____1, &lvalue0, true);
25681
0
  Eurydice_arr_fa0
25682
0
  prf_input = libcrux_ml_kem_utils_into_padded_array_29(seed_for_secret_and_error);
25683
0
  uint8_t
25684
0
  domain_separator =
25685
0
    libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_bf(private_key,
25686
0
      &prf_input,
25687
0
      0U);
25688
0
  Eurydice_arr_bb0 arr_struct;
25689
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
25690
0
  {
25691
    /* original Rust expression is not an lvalue in C */
25692
0
    void *lvalue = (void *)0U;
25693
0
    arr_struct.data[i] =
25694
0
      libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_call_mut_73_39(&lvalue,
25695
0
        i);
25696
0
  }
25697
0
  Eurydice_arr_bb0 error_as_ntt = arr_struct;
25698
0
  libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_bf(&error_as_ntt,
25699
0
    &prf_input,
25700
0
    domain_separator);
25701
0
  libcrux_ml_kem_matrix_compute_As_plus_e_68(&public_key->t_as_ntt,
25702
0
    &public_key->A,
25703
0
    &private_key[0U],
25704
0
    &error_as_ntt);
25705
0
  Eurydice_arr_ec arr;
25706
0
  memcpy(arr.data, seed_for_A.ptr, (size_t)32U * sizeof (uint8_t));
25707
0
  Eurydice_arr_ec
25708
0
  uu____2 =
25709
0
    core_result_unwrap_26_39((
25710
0
        KRML_CLITERAL(core_result_Result_07){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
25711
0
      ));
25712
0
  public_key->seed_for_A = uu____2;
25713
0
}
25714
25715
/**
25716
A monomorphic instance of libcrux_ml_kem.serialize.serialize_uncompressed_ring_element
25717
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25718
with const generics
25719
25720
*/
25721
static KRML_MUSTINLINE Eurydice_arr_b20
25722
libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_ea(const Eurydice_arr_9e *re)
25723
0
{
25724
0
  Eurydice_arr_b20 serialized = { .data = { 0U } };
25725
0
  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++)
25726
0
  {
25727
0
    size_t i0 = i;
25728
0
    Eurydice_arr_d6
25729
0
    coefficient = libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(re->data[i0]);
25730
0
    Eurydice_arr_94 bytes = libcrux_ml_kem_vector_portable_serialize_12_b8(coefficient);
25731
0
    Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d415(&serialized,
25732
0
        (
25733
0
          KRML_CLITERAL(core_ops_range_Range_87){
25734
0
            .start = (size_t)24U * i0,
25735
0
            .end = (size_t)24U * i0 + (size_t)24U
25736
0
          }
25737
0
        )),
25738
0
      Eurydice_array_to_slice_shared_ed(&bytes),
25739
0
      uint8_t);
25740
0
  }
25741
0
  return serialized;
25742
0
}
25743
25744
/**
25745
 Call [`serialize_uncompressed_ring_element`] for each ring element.
25746
*/
25747
/**
25748
A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_vector
25749
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25750
with const generics
25751
- K= 3
25752
*/
25753
static KRML_MUSTINLINE void
25754
libcrux_ml_kem_ind_cpa_serialize_vector_68(
25755
  const Eurydice_arr_bb0 *key,
25756
  Eurydice_mut_borrow_slice_u8 out
25757
)
25758
0
{
25759
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
25760
0
  {
25761
0
    size_t i0 = i;
25762
0
    Eurydice_arr_9e re = key->data[i0];
25763
0
    Eurydice_mut_borrow_slice_u8
25764
0
    uu____0 =
25765
0
      Eurydice_slice_subslice_mut_c8(out,
25766
0
        (
25767
0
          KRML_CLITERAL(core_ops_range_Range_87){
25768
0
            .start = i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
25769
0
            .end = (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT
25770
0
          }
25771
0
        ));
25772
    /* original Rust expression is not an lvalue in C */
25773
0
    Eurydice_arr_b20 lvalue = libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_ea(&re);
25774
0
    Eurydice_slice_copy(uu____0, Eurydice_array_to_slice_shared_a9(&lvalue), uint8_t);
25775
0
  }
25776
0
}
25777
25778
/**
25779
 Concatenate `t` and `ρ` into the public key.
25780
*/
25781
/**
25782
A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_public_key_mut
25783
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25784
with const generics
25785
- K= 3
25786
- PUBLIC_KEY_SIZE= 1184
25787
*/
25788
static KRML_MUSTINLINE void
25789
libcrux_ml_kem_ind_cpa_serialize_public_key_mut_b6(
25790
  const Eurydice_arr_bb0 *t_as_ntt,
25791
  Eurydice_borrow_slice_u8 seed_for_a,
25792
  Eurydice_arr_5f *serialized
25793
)
25794
0
{
25795
0
  libcrux_ml_kem_ind_cpa_serialize_vector_68(t_as_ntt,
25796
0
    Eurydice_array_to_subslice_mut_d416(serialized,
25797
0
      (
25798
0
        KRML_CLITERAL(core_ops_range_Range_87){
25799
0
          .start = (size_t)0U,
25800
0
          .end = libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U)
25801
0
        }
25802
0
      )));
25803
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_from_mut_5f4(serialized,
25804
0
      libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U)),
25805
0
    seed_for_a,
25806
0
    uint8_t);
25807
0
}
25808
25809
/**
25810
 Concatenate `t` and `ρ` into the public key.
25811
*/
25812
/**
25813
A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_public_key
25814
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25815
with const generics
25816
- K= 3
25817
- PUBLIC_KEY_SIZE= 1184
25818
*/
25819
static KRML_MUSTINLINE Eurydice_arr_5f
25820
libcrux_ml_kem_ind_cpa_serialize_public_key_b6(
25821
  const Eurydice_arr_bb0 *t_as_ntt,
25822
  Eurydice_borrow_slice_u8 seed_for_a
25823
)
25824
0
{
25825
0
  Eurydice_arr_5f public_key_serialized = { .data = { 0U } };
25826
0
  libcrux_ml_kem_ind_cpa_serialize_public_key_mut_b6(t_as_ntt,
25827
0
    seed_for_a,
25828
0
    &public_key_serialized);
25829
0
  return public_key_serialized;
25830
0
}
25831
25832
/**
25833
 Serialize the secret key from the unpacked key pair generation.
25834
*/
25835
/**
25836
A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_unpacked_secret_key
25837
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
25838
with const generics
25839
- K= 3
25840
- PRIVATE_KEY_SIZE= 1152
25841
- PUBLIC_KEY_SIZE= 1184
25842
*/
25843
static inline libcrux_ml_kem_utils_extraction_helper_Keypair768
25844
libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_30(
25845
  const libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 *public_key,
25846
  const Eurydice_arr_bb0 *private_key
25847
)
25848
0
{
25849
0
  Eurydice_arr_5f
25850
0
  public_key_serialized =
25851
0
    libcrux_ml_kem_ind_cpa_serialize_public_key_b6(&public_key->t_as_ntt,
25852
0
      Eurydice_array_to_slice_shared_01(&public_key->seed_for_A));
25853
0
  Eurydice_arr_0e secret_key_serialized = { .data = { 0U } };
25854
0
  libcrux_ml_kem_ind_cpa_serialize_vector_68(private_key,
25855
0
    Eurydice_array_to_slice_mut_f4(&secret_key_serialized));
25856
0
  return
25857
0
    (
25858
0
      KRML_CLITERAL(libcrux_ml_kem_utils_extraction_helper_Keypair768){
25859
0
        .fst = secret_key_serialized,
25860
0
        .snd = public_key_serialized
25861
0
      }
25862
0
    );
25863
0
}
25864
25865
/**
25866
A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair
25867
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
25868
with const generics
25869
- K= 3
25870
- PRIVATE_KEY_SIZE= 1152
25871
- PUBLIC_KEY_SIZE= 1184
25872
- ETA1= 2
25873
- ETA1_RANDOMNESS_SIZE= 128
25874
*/
25875
static KRML_MUSTINLINE libcrux_ml_kem_utils_extraction_helper_Keypair768
25876
libcrux_ml_kem_ind_cpa_generate_keypair_30(Eurydice_borrow_slice_u8 key_generation_seed)
25877
0
{
25878
0
  Eurydice_arr_bb0 private_key = libcrux_ml_kem_ind_cpa_unpacked_default_70_68();
25879
0
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
25880
0
  public_key = libcrux_ml_kem_ind_cpa_unpacked_default_8b_68();
25881
0
  libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_39(key_generation_seed,
25882
0
    &private_key,
25883
0
    &public_key);
25884
0
  return libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_30(&public_key, &private_key);
25885
0
}
25886
25887
/**
25888
 Serialize the secret key.
25889
*/
25890
/**
25891
A monomorphic instance of libcrux_ml_kem.ind_cca.serialize_kem_secret_key_mut
25892
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25893
with const generics
25894
- K= 3
25895
- SERIALIZED_KEY_LEN= 2400
25896
*/
25897
static KRML_MUSTINLINE void
25898
libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_52(
25899
  Eurydice_borrow_slice_u8 private_key,
25900
  Eurydice_borrow_slice_u8 public_key,
25901
  Eurydice_borrow_slice_u8 implicit_rejection_value,
25902
  Eurydice_arr_7d *serialized
25903
)
25904
0
{
25905
0
  size_t pointer = (size_t)0U;
25906
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d417(serialized,
25907
0
      (
25908
0
        KRML_CLITERAL(core_ops_range_Range_87){
25909
0
          .start = pointer,
25910
0
          .end = pointer + private_key.meta
25911
0
        }
25912
0
      )),
25913
0
    private_key,
25914
0
    uint8_t);
25915
0
  pointer += private_key.meta;
25916
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d417(serialized,
25917
0
      (KRML_CLITERAL(core_ops_range_Range_87){ .start = pointer, .end = pointer + public_key.meta })),
25918
0
    public_key,
25919
0
    uint8_t);
25920
0
  pointer += public_key.meta;
25921
0
  Eurydice_mut_borrow_slice_u8
25922
0
  uu____0 =
25923
0
    Eurydice_array_to_subslice_mut_d417(serialized,
25924
0
      (
25925
0
        KRML_CLITERAL(core_ops_range_Range_87){
25926
0
          .start = pointer,
25927
0
          .end = pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE
25928
0
        }
25929
0
      ));
25930
  /* original Rust expression is not an lvalue in C */
25931
0
  Eurydice_arr_ec lvalue = libcrux_ml_kem_hash_functions_portable_H_4a_78(public_key);
25932
0
  Eurydice_slice_copy(uu____0, Eurydice_array_to_slice_shared_01(&lvalue), uint8_t);
25933
0
  pointer += LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE;
25934
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_mut_d417(serialized,
25935
0
      (
25936
0
        KRML_CLITERAL(core_ops_range_Range_87){
25937
0
          .start = pointer,
25938
0
          .end = pointer + implicit_rejection_value.meta
25939
0
        }
25940
0
      )),
25941
0
    implicit_rejection_value,
25942
0
    uint8_t);
25943
0
}
25944
25945
/**
25946
A monomorphic instance of libcrux_ml_kem.ind_cca.serialize_kem_secret_key
25947
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
25948
with const generics
25949
- K= 3
25950
- SERIALIZED_KEY_LEN= 2400
25951
*/
25952
static KRML_MUSTINLINE Eurydice_arr_7d
25953
libcrux_ml_kem_ind_cca_serialize_kem_secret_key_52(
25954
  Eurydice_borrow_slice_u8 private_key,
25955
  Eurydice_borrow_slice_u8 public_key,
25956
  Eurydice_borrow_slice_u8 implicit_rejection_value
25957
)
25958
0
{
25959
0
  Eurydice_arr_7d out = { .data = { 0U } };
25960
0
  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_52(private_key,
25961
0
    public_key,
25962
0
    implicit_rejection_value,
25963
0
    &out);
25964
0
  return out;
25965
0
}
25966
25967
/**
25968
 Packed API
25969
25970
 Generate a key pair.
25971
25972
 Depending on the `Vector` and `Hasher` used, this requires different hardware
25973
 features
25974
*/
25975
/**
25976
A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair
25977
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
25978
with const generics
25979
- K= 3
25980
- CPA_PRIVATE_KEY_SIZE= 1152
25981
- PRIVATE_KEY_SIZE= 2400
25982
- PUBLIC_KEY_SIZE= 1184
25983
- ETA1= 2
25984
- ETA1_RANDOMNESS_SIZE= 128
25985
*/
25986
static KRML_MUSTINLINE libcrux_ml_kem_mlkem768_MlKem768KeyPair
25987
libcrux_ml_kem_ind_cca_generate_keypair_b8(const Eurydice_arr_c7 *randomness)
25988
0
{
25989
0
  Eurydice_borrow_slice_u8
25990
0
  ind_cpa_keypair_randomness =
25991
0
    Eurydice_array_to_subslice_shared_d47(randomness,
25992
0
      (
25993
0
        KRML_CLITERAL(core_ops_range_Range_87){
25994
0
          .start = (size_t)0U,
25995
0
          .end = LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE
25996
0
        }
25997
0
      ));
25998
0
  Eurydice_borrow_slice_u8
25999
0
  implicit_rejection_value =
26000
0
    Eurydice_array_to_subslice_from_shared_5f1(randomness,
26001
0
      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE);
26002
0
  libcrux_ml_kem_utils_extraction_helper_Keypair768
26003
0
  uu____0 = libcrux_ml_kem_ind_cpa_generate_keypair_30(ind_cpa_keypair_randomness);
26004
0
  Eurydice_arr_0e ind_cpa_private_key = uu____0.fst;
26005
0
  Eurydice_arr_5f public_key = uu____0.snd;
26006
0
  Eurydice_arr_7d
26007
0
  secret_key_serialized =
26008
0
    libcrux_ml_kem_ind_cca_serialize_kem_secret_key_52(Eurydice_array_to_slice_shared_f4(&ind_cpa_private_key),
26009
0
      Eurydice_array_to_slice_shared_ff(&public_key),
26010
0
      implicit_rejection_value);
26011
0
  Eurydice_arr_7d private_key = libcrux_ml_kem_types_from_b2_79(secret_key_serialized);
26012
0
  return
26013
0
    libcrux_ml_kem_types_from_17_bc(private_key,
26014
0
      libcrux_ml_kem_types_from_51_3d(public_key));
26015
0
}
26016
26017
/**
26018
 Portable generate key pair.
26019
*/
26020
/**
26021
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.generate_keypair
26022
with const generics
26023
- K= 3
26024
- CPA_PRIVATE_KEY_SIZE= 1152
26025
- PRIVATE_KEY_SIZE= 2400
26026
- PUBLIC_KEY_SIZE= 1184
26027
- ETA1= 2
26028
- ETA1_RANDOMNESS_SIZE= 128
26029
*/
26030
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
26031
libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_e9(
26032
  const Eurydice_arr_c7 *randomness
26033
)
26034
0
{
26035
0
  return libcrux_ml_kem_ind_cca_generate_keypair_b8(randomness);
26036
0
}
26037
26038
/**
26039
 Generate ML-KEM 768 Key Pair
26040
*/
26041
static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair
26042
libcrux_ml_kem_mlkem768_portable_generate_key_pair(Eurydice_arr_c7 randomness)
26043
0
{
26044
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_e9(&randomness);
26045
0
}
26046
26047
/**
26048
 Validate an ML-KEM private key.
26049
26050
 This implements the Hash check in 7.3 3.
26051
*/
26052
/**
26053
A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key_only
26054
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
26055
with const generics
26056
- K= 3
26057
- SECRET_KEY_SIZE= 2400
26058
*/
26059
static KRML_MUSTINLINE bool
26060
libcrux_ml_kem_ind_cca_validate_private_key_only_52(const Eurydice_arr_7d *private_key)
26061
0
{
26062
0
  Eurydice_arr_ec
26063
0
  t =
26064
0
    libcrux_ml_kem_hash_functions_portable_H_4a_78(Eurydice_array_to_subslice_shared_d48(private_key,
26065
0
        (
26066
0
          KRML_CLITERAL(core_ops_range_Range_87){
26067
0
            .start = (size_t)384U * (size_t)3U,
26068
0
            .end = (size_t)768U * (size_t)3U + (size_t)32U
26069
0
          }
26070
0
        )));
26071
0
  Eurydice_borrow_slice_u8
26072
0
  expected =
26073
0
    Eurydice_array_to_subslice_shared_d48(private_key,
26074
0
      (
26075
0
        KRML_CLITERAL(core_ops_range_Range_87){
26076
0
          .start = (size_t)768U * (size_t)3U + (size_t)32U,
26077
0
          .end = (size_t)768U * (size_t)3U + (size_t)64U
26078
0
        }
26079
0
      ));
26080
0
  return Eurydice_array_eq_slice_shared((size_t)32U, &t, &expected, uint8_t, bool);
26081
0
}
26082
26083
/**
26084
 Validate an ML-KEM private key.
26085
26086
 This implements the Hash check in 7.3 3.
26087
 Note that the size checks in 7.2 1 and 2 are covered by the `SECRET_KEY_SIZE`
26088
 and `CIPHERTEXT_SIZE` in the `private_key` and `ciphertext` types.
26089
*/
26090
/**
26091
A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key
26092
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
26093
with const generics
26094
- K= 3
26095
- SECRET_KEY_SIZE= 2400
26096
- CIPHERTEXT_SIZE= 1088
26097
*/
26098
static KRML_MUSTINLINE bool
26099
libcrux_ml_kem_ind_cca_validate_private_key_ba(
26100
  const Eurydice_arr_7d *private_key,
26101
  const Eurydice_arr_2b *_ciphertext
26102
)
26103
0
{
26104
0
  return libcrux_ml_kem_ind_cca_validate_private_key_only_52(private_key);
26105
0
}
26106
26107
/**
26108
 Private key validation
26109
*/
26110
/**
26111
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.validate_private_key
26112
with const generics
26113
- K= 3
26114
- SECRET_KEY_SIZE= 2400
26115
- CIPHERTEXT_SIZE= 1088
26116
*/
26117
static KRML_MUSTINLINE bool
26118
libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_d3(
26119
  const Eurydice_arr_7d *private_key,
26120
  const Eurydice_arr_2b *ciphertext
26121
)
26122
0
{
26123
0
  return libcrux_ml_kem_ind_cca_validate_private_key_ba(private_key, ciphertext);
26124
0
}
26125
26126
/**
26127
 Validate a private key.
26128
26129
 Returns `true` if valid, and `false` otherwise.
26130
*/
26131
static inline bool
26132
libcrux_ml_kem_mlkem768_portable_validate_private_key(
26133
  const Eurydice_arr_7d *private_key,
26134
  const Eurydice_arr_2b *ciphertext
26135
)
26136
0
{
26137
0
  return
26138
0
    libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_d3(private_key,
26139
0
      ciphertext);
26140
0
}
26141
26142
/**
26143
 Private key validation
26144
*/
26145
/**
26146
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.validate_private_key_only
26147
with const generics
26148
- K= 3
26149
- SECRET_KEY_SIZE= 2400
26150
*/
26151
static KRML_MUSTINLINE bool
26152
libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_only_3b(
26153
  const Eurydice_arr_7d *private_key
26154
)
26155
0
{
26156
0
  return libcrux_ml_kem_ind_cca_validate_private_key_only_52(private_key);
26157
0
}
26158
26159
/**
26160
 Validate the private key only.
26161
26162
 Returns `true` if valid, and `false` otherwise.
26163
*/
26164
static inline bool
26165
libcrux_ml_kem_mlkem768_portable_validate_private_key_only(const Eurydice_arr_7d *private_key)
26166
0
{
26167
0
  return
26168
0
    libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_only_3b(private_key);
26169
0
}
26170
26171
/**
26172
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]> for libcrux_ml_kem::serialize::deserialize_ring_elements_reduced_out::closure<Vector, K>[TraitClause@0, TraitClause@1]}
26173
*/
26174
/**
26175
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_ring_elements_reduced_out.call_mut_0b
26176
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26177
with const generics
26178
- K= 3
26179
*/
26180
static inline Eurydice_arr_9e
26181
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_call_mut_0b_68(
26182
  void **_,
26183
  size_t tupled_args
26184
)
26185
0
{
26186
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
26187
0
}
26188
26189
/**
26190
 This function deserializes ring elements and reduces the result by the field
26191
 modulus.
26192
26193
 This function MUST NOT be used on secret inputs.
26194
*/
26195
/**
26196
A monomorphic instance of libcrux_ml_kem.serialize.deserialize_ring_elements_reduced_out
26197
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26198
with const generics
26199
- K= 3
26200
*/
26201
static KRML_MUSTINLINE Eurydice_arr_bb0
26202
libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_68(
26203
  Eurydice_borrow_slice_u8 public_key
26204
)
26205
0
{
26206
0
  Eurydice_arr_bb0 arr_struct;
26207
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
26208
0
  {
26209
    /* original Rust expression is not an lvalue in C */
26210
0
    void *lvalue = (void *)0U;
26211
0
    arr_struct.data[i] =
26212
0
      libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_call_mut_0b_68(&lvalue,
26213
0
        i);
26214
0
  }
26215
0
  Eurydice_arr_bb0 deserialized_pk = arr_struct;
26216
0
  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_68(public_key, &deserialized_pk);
26217
0
  return deserialized_pk;
26218
0
}
26219
26220
/**
26221
 Validate an ML-KEM public key.
26222
26223
 This implements the Modulus check in 7.2 2.
26224
 Note that the size check in 7.2 1 is covered by the `PUBLIC_KEY_SIZE` in the
26225
 `public_key` type.
26226
*/
26227
/**
26228
A monomorphic instance of libcrux_ml_kem.ind_cca.validate_public_key
26229
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26230
with const generics
26231
- K= 3
26232
- PUBLIC_KEY_SIZE= 1184
26233
*/
26234
static KRML_MUSTINLINE bool
26235
libcrux_ml_kem_ind_cca_validate_public_key_b6(const Eurydice_arr_5f *public_key)
26236
0
{
26237
0
  Eurydice_arr_bb0
26238
0
  deserialized_pk =
26239
0
    libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_68(Eurydice_array_to_subslice_to_shared_210(public_key,
26240
0
        libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U)));
26241
0
  Eurydice_arr_5f
26242
0
  public_key_serialized =
26243
0
    libcrux_ml_kem_ind_cpa_serialize_public_key_b6(&deserialized_pk,
26244
0
      Eurydice_array_to_subslice_from_shared_5f2(public_key,
26245
0
        libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U)));
26246
0
  return Eurydice_array_eq((size_t)1184U, public_key, &public_key_serialized, uint8_t);
26247
0
}
26248
26249
/**
26250
 Public key validation
26251
*/
26252
/**
26253
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.validate_public_key
26254
with const generics
26255
- K= 3
26256
- PUBLIC_KEY_SIZE= 1184
26257
*/
26258
static KRML_MUSTINLINE bool
26259
libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_3b(
26260
  const Eurydice_arr_5f *public_key
26261
)
26262
0
{
26263
0
  return libcrux_ml_kem_ind_cca_validate_public_key_b6(public_key);
26264
0
}
26265
26266
/**
26267
 Validate a public key.
26268
26269
 Returns `true` if valid, and `false` otherwise.
26270
*/
26271
static inline bool
26272
libcrux_ml_kem_mlkem768_portable_validate_public_key(const Eurydice_arr_5f *public_key)
26273
0
{
26274
0
  return libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_3b(public_key);
26275
0
}
26276
26277
/**
26278
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.MlKemPublicKeyUnpacked
26279
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26280
with const generics
26281
- $3size_t
26282
*/
26283
typedef struct libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51_s
26284
{
26285
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 ind_cpa_public_key;
26286
  Eurydice_arr_ec public_key_hash;
26287
}
26288
libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51;
26289
26290
typedef libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51
26291
libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768PublicKeyUnpacked;
26292
26293
/**
26294
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.MlKemPrivateKeyUnpacked
26295
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26296
with const generics
26297
- $3size_t
26298
*/
26299
typedef struct libcrux_ml_kem_ind_cca_unpacked_MlKemPrivateKeyUnpacked_51_s
26300
{
26301
  Eurydice_arr_bb0 ind_cpa_private_key;
26302
  Eurydice_arr_ec implicit_rejection_value;
26303
}
26304
libcrux_ml_kem_ind_cca_unpacked_MlKemPrivateKeyUnpacked_51;
26305
26306
typedef struct libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked_s
26307
{
26308
  libcrux_ml_kem_ind_cca_unpacked_MlKemPrivateKeyUnpacked_51 private_key;
26309
  libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 public_key;
26310
}
26311
libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked;
26312
26313
/**
26314
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.decapsulate
26315
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
26316
with const generics
26317
- K= 3
26318
- SECRET_KEY_SIZE= 2400
26319
- CPA_SECRET_KEY_SIZE= 1152
26320
- PUBLIC_KEY_SIZE= 1184
26321
- CIPHERTEXT_SIZE= 1088
26322
- T_AS_NTT_ENCODED_SIZE= 1152
26323
- C1_SIZE= 960
26324
- C2_SIZE= 128
26325
- VECTOR_U_COMPRESSION_FACTOR= 10
26326
- VECTOR_V_COMPRESSION_FACTOR= 4
26327
- C1_BLOCK_SIZE= 320
26328
- ETA1= 2
26329
- ETA1_RANDOMNESS_SIZE= 128
26330
- ETA2= 2
26331
- ETA2_RANDOMNESS_SIZE= 128
26332
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
26333
*/
26334
static KRML_MUSTINLINE Eurydice_arr_ec
26335
libcrux_ml_kem_ind_cca_unpacked_decapsulate_0c(
26336
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair,
26337
  const Eurydice_arr_2b *ciphertext
26338
)
26339
0
{
26340
0
  Eurydice_arr_ec
26341
0
  decrypted =
26342
0
    libcrux_ml_kem_ind_cpa_decrypt_unpacked_01(&key_pair->private_key.ind_cpa_private_key,
26343
0
      ciphertext);
26344
0
  Eurydice_arr_c7
26345
0
  to_hash0 =
26346
0
    libcrux_ml_kem_utils_into_padded_array_c9(Eurydice_array_to_slice_shared_01(&decrypted));
26347
0
  Eurydice_mut_borrow_slice_u8
26348
0
  uu____0 =
26349
0
    Eurydice_array_to_subslice_from_mut_5f1(&to_hash0,
26350
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE);
26351
0
  Eurydice_slice_copy(uu____0,
26352
0
    Eurydice_array_to_slice_shared_01(&key_pair->public_key.public_key_hash),
26353
0
    uint8_t);
26354
0
  Eurydice_arr_c7
26355
0
  hashed =
26356
0
    libcrux_ml_kem_hash_functions_portable_G_4a_78(Eurydice_array_to_slice_shared_17(&to_hash0));
26357
0
  Eurydice_borrow_slice_u8_x2
26358
0
  uu____1 =
26359
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_17(&hashed),
26360
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
26361
0
      uint8_t,
26362
0
      Eurydice_borrow_slice_u8_x2);
26363
0
  Eurydice_borrow_slice_u8 shared_secret = uu____1.fst;
26364
0
  Eurydice_borrow_slice_u8 pseudorandomness = uu____1.snd;
26365
0
  Eurydice_arr_af
26366
0
  to_hash =
26367
0
    libcrux_ml_kem_utils_into_padded_array_66(Eurydice_array_to_slice_shared_01(&key_pair->private_key.implicit_rejection_value));
26368
0
  Eurydice_mut_borrow_slice_u8
26369
0
  uu____2 =
26370
0
    Eurydice_array_to_subslice_from_mut_5f2(&to_hash,
26371
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE);
26372
0
  Eurydice_slice_copy(uu____2, libcrux_ml_kem_types_as_ref_c1_52(ciphertext), uint8_t);
26373
0
  Eurydice_arr_ec
26374
0
  implicit_rejection_shared_secret =
26375
0
    libcrux_ml_kem_hash_functions_portable_PRF_4a_3b(Eurydice_array_to_slice_shared_81(&to_hash));
26376
0
  Eurydice_arr_2b
26377
0
  expected_ciphertext =
26378
0
    libcrux_ml_kem_ind_cpa_encrypt_unpacked_d5(&key_pair->public_key.ind_cpa_public_key,
26379
0
      &decrypted,
26380
0
      pseudorandomness);
26381
0
  Eurydice_borrow_slice_u8 uu____3 = libcrux_ml_kem_types_as_ref_c1_52(ciphertext);
26382
0
  uint8_t
26383
0
  selector =
26384
0
    libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(uu____3,
26385
0
      Eurydice_array_to_slice_shared_06(&expected_ciphertext));
26386
0
  return
26387
0
    libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(shared_secret,
26388
0
      Eurydice_array_to_slice_shared_01(&implicit_rejection_shared_secret),
26389
0
      selector);
26390
0
}
26391
26392
/**
26393
 Unpacked decapsulate
26394
*/
26395
/**
26396
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.unpacked.decapsulate
26397
with const generics
26398
- K= 3
26399
- SECRET_KEY_SIZE= 2400
26400
- CPA_SECRET_KEY_SIZE= 1152
26401
- PUBLIC_KEY_SIZE= 1184
26402
- CIPHERTEXT_SIZE= 1088
26403
- T_AS_NTT_ENCODED_SIZE= 1152
26404
- C1_SIZE= 960
26405
- C2_SIZE= 128
26406
- VECTOR_U_COMPRESSION_FACTOR= 10
26407
- VECTOR_V_COMPRESSION_FACTOR= 4
26408
- C1_BLOCK_SIZE= 320
26409
- ETA1= 2
26410
- ETA1_RANDOMNESS_SIZE= 128
26411
- ETA2= 2
26412
- ETA2_RANDOMNESS_SIZE= 128
26413
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
26414
*/
26415
static KRML_MUSTINLINE Eurydice_arr_ec
26416
libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_decapsulate_19(
26417
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair,
26418
  const Eurydice_arr_2b *ciphertext
26419
)
26420
0
{
26421
0
  return libcrux_ml_kem_ind_cca_unpacked_decapsulate_0c(key_pair, ciphertext);
26422
0
}
26423
26424
/**
26425
 Decapsulate ML-KEM 768 (unpacked)
26426
26427
 Generates an [`MlKemSharedSecret`].
26428
 The input is a reference to an unpacked key pair of type [`MlKem768KeyPairUnpacked`]
26429
 and an [`MlKem768Ciphertext`].
26430
*/
26431
static inline Eurydice_arr_ec
26432
libcrux_ml_kem_mlkem768_portable_unpacked_decapsulate(
26433
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *private_key,
26434
  const Eurydice_arr_2b *ciphertext
26435
)
26436
0
{
26437
0
  return
26438
0
    libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_decapsulate_19(private_key,
26439
0
      ciphertext);
26440
0
}
26441
26442
/**
26443
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.encaps_prepare
26444
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
26445
with const generics
26446
- K= 3
26447
*/
26448
static inline Eurydice_arr_c7
26449
libcrux_ml_kem_ind_cca_unpacked_encaps_prepare_13(
26450
  Eurydice_borrow_slice_u8 randomness,
26451
  Eurydice_borrow_slice_u8 pk_hash
26452
)
26453
0
{
26454
0
  Eurydice_arr_c7 to_hash = libcrux_ml_kem_utils_into_padded_array_c9(randomness);
26455
0
  Eurydice_slice_copy(Eurydice_array_to_subslice_from_mut_5f1(&to_hash,
26456
0
      LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE),
26457
0
    pk_hash,
26458
0
    uint8_t);
26459
0
  return
26460
0
    libcrux_ml_kem_hash_functions_portable_G_4a_78(Eurydice_array_to_slice_shared_17(&to_hash));
26461
0
}
26462
26463
/**
26464
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.encapsulate
26465
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
26466
with const generics
26467
- K= 3
26468
- CIPHERTEXT_SIZE= 1088
26469
- PUBLIC_KEY_SIZE= 1184
26470
- T_AS_NTT_ENCODED_SIZE= 1152
26471
- C1_SIZE= 960
26472
- C2_SIZE= 128
26473
- VECTOR_U_COMPRESSION_FACTOR= 10
26474
- VECTOR_V_COMPRESSION_FACTOR= 4
26475
- VECTOR_U_BLOCK_LEN= 320
26476
- ETA1= 2
26477
- ETA1_RANDOMNESS_SIZE= 128
26478
- ETA2= 2
26479
- ETA2_RANDOMNESS_SIZE= 128
26480
*/
26481
static KRML_MUSTINLINE tuple_f4
26482
libcrux_ml_kem_ind_cca_unpacked_encapsulate_a7(
26483
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *public_key,
26484
  const Eurydice_arr_ec *randomness
26485
)
26486
0
{
26487
0
  Eurydice_arr_c7
26488
0
  hashed =
26489
0
    libcrux_ml_kem_ind_cca_unpacked_encaps_prepare_13(Eurydice_array_to_slice_shared_01(randomness),
26490
0
      Eurydice_array_to_slice_shared_01(&public_key->public_key_hash));
26491
0
  Eurydice_borrow_slice_u8_x2
26492
0
  uu____0 =
26493
0
    Eurydice_slice_split_at(Eurydice_array_to_slice_shared_17(&hashed),
26494
0
      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
26495
0
      uint8_t,
26496
0
      Eurydice_borrow_slice_u8_x2);
26497
0
  Eurydice_borrow_slice_u8 shared_secret = uu____0.fst;
26498
0
  Eurydice_borrow_slice_u8 pseudorandomness = uu____0.snd;
26499
0
  Eurydice_arr_2b
26500
0
  ciphertext =
26501
0
    libcrux_ml_kem_ind_cpa_encrypt_unpacked_d5(&public_key->ind_cpa_public_key,
26502
0
      randomness,
26503
0
      pseudorandomness);
26504
0
  Eurydice_arr_ec shared_secret_array = { .data = { 0U } };
26505
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_01(&shared_secret_array),
26506
0
    shared_secret,
26507
0
    uint8_t);
26508
0
  return
26509
0
    (
26510
0
      KRML_CLITERAL(tuple_f4){
26511
0
        .fst = libcrux_ml_kem_types_from_19_52(ciphertext),
26512
0
        .snd = shared_secret_array
26513
0
      }
26514
0
    );
26515
0
}
26516
26517
/**
26518
 Unpacked encapsulate
26519
*/
26520
/**
26521
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.unpacked.encapsulate
26522
with const generics
26523
- K= 3
26524
- CIPHERTEXT_SIZE= 1088
26525
- PUBLIC_KEY_SIZE= 1184
26526
- T_AS_NTT_ENCODED_SIZE= 1152
26527
- C1_SIZE= 960
26528
- C2_SIZE= 128
26529
- VECTOR_U_COMPRESSION_FACTOR= 10
26530
- VECTOR_V_COMPRESSION_FACTOR= 4
26531
- VECTOR_U_BLOCK_LEN= 320
26532
- ETA1= 2
26533
- ETA1_RANDOMNESS_SIZE= 128
26534
- ETA2= 2
26535
- ETA2_RANDOMNESS_SIZE= 128
26536
*/
26537
static KRML_MUSTINLINE tuple_f4
26538
libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_encapsulate_26(
26539
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *public_key,
26540
  const Eurydice_arr_ec *randomness
26541
)
26542
0
{
26543
0
  return libcrux_ml_kem_ind_cca_unpacked_encapsulate_a7(public_key, randomness);
26544
0
}
26545
26546
/**
26547
 Encapsulate ML-KEM 768 (unpacked)
26548
26549
 Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple.
26550
 The input is a reference to an unpacked public key of type [`MlKem768PublicKeyUnpacked`],
26551
 the SHA3-256 hash of this public key, and [`SHARED_SECRET_SIZE`] bytes of `randomness`.
26552
*/
26553
static inline tuple_f4
26554
libcrux_ml_kem_mlkem768_portable_unpacked_encapsulate(
26555
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *public_key,
26556
  Eurydice_arr_ec randomness
26557
)
26558
0
{
26559
0
  return
26560
0
    libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_encapsulate_26(public_key,
26561
0
      &randomness);
26562
0
}
26563
26564
/**
26565
This function found in impl {core::ops::function::FnMut<(usize), libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]> for libcrux_ml_kem::ind_cca::unpacked::transpose_a::closure::closure<Vector, K>[TraitClause@0, TraitClause@1]}
26566
*/
26567
/**
26568
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.transpose_a.closure.call_mut_b4
26569
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26570
with const generics
26571
- K= 3
26572
*/
26573
static inline Eurydice_arr_9e
26574
libcrux_ml_kem_ind_cca_unpacked_transpose_a_closure_call_mut_b4_68(
26575
  void **_,
26576
  size_t tupled_args
26577
)
26578
0
{
26579
0
  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
26580
0
}
26581
26582
/**
26583
This function found in impl {core::ops::function::FnMut<(usize), [libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@1]; K]> for libcrux_ml_kem::ind_cca::unpacked::transpose_a::closure<Vector, K>[TraitClause@0, TraitClause@1]}
26584
*/
26585
/**
26586
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.transpose_a.call_mut_22
26587
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26588
with const generics
26589
- K= 3
26590
*/
26591
static inline Eurydice_arr_bb0
26592
libcrux_ml_kem_ind_cca_unpacked_transpose_a_call_mut_22_68(void **_, size_t tupled_args)
26593
0
{
26594
0
  Eurydice_arr_bb0 arr_struct;
26595
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
26596
0
  {
26597
0
    /* original Rust expression is not an lvalue in C */
26598
0
    void *lvalue = (void *)0U;
26599
0
    arr_struct.data[i] =
26600
0
      libcrux_ml_kem_ind_cca_unpacked_transpose_a_closure_call_mut_b4_68(&lvalue,
26601
0
        i);
26602
0
  }
26603
0
  return arr_struct;
26604
0
}
26605
26606
/**
26607
This function found in impl {core::clone::Clone for libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0, TraitClause@2]}
26608
*/
26609
/**
26610
A monomorphic instance of libcrux_ml_kem.polynomial.clone_c1
26611
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26612
with const generics
26613
26614
*/
26615
static inline Eurydice_arr_9e
26616
libcrux_ml_kem_polynomial_clone_c1_ea(const Eurydice_arr_9e *self)
26617
0
{
26618
0
  return
26619
0
    core_array__core__clone__Clone_for__T__N___clone((size_t)16U,
26620
0
      self,
26621
0
      Eurydice_arr_d6,
26622
0
      Eurydice_arr_9e);
26623
0
}
26624
26625
/**
26626
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.transpose_a
26627
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26628
with const generics
26629
- K= 3
26630
*/
26631
static inline Eurydice_arr_c10
26632
libcrux_ml_kem_ind_cca_unpacked_transpose_a_68(Eurydice_arr_c10 ind_cpa_a)
26633
0
{
26634
0
  Eurydice_arr_c10 arr_struct;
26635
0
  for (size_t i = (size_t)0U; i < (size_t)3U; i++)
26636
0
  {
26637
0
    /* original Rust expression is not an lvalue in C */
26638
0
    void *lvalue = (void *)0U;
26639
0
    arr_struct.data[i] = libcrux_ml_kem_ind_cca_unpacked_transpose_a_call_mut_22_68(&lvalue, i);
26640
0
  }
26641
0
  Eurydice_arr_c10 A = arr_struct;
26642
0
  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++)
26643
0
  {
26644
0
    size_t i1 = i0;
26645
0
    for (size_t i = (size_t)0U; i < (size_t)3U; i++)
26646
0
    {
26647
0
      size_t j = i;
26648
0
      Eurydice_arr_9e uu____0 = libcrux_ml_kem_polynomial_clone_c1_ea(&ind_cpa_a.data[j].data[i1]);
26649
0
      A.data[i1].data[j] = uu____0;
26650
0
    }
26651
0
  }
26652
0
  return A;
26653
0
}
26654
26655
/**
26656
 Generate Unpacked Keys
26657
*/
26658
/**
26659
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.generate_keypair
26660
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_variant_MlKem
26661
with const generics
26662
- K= 3
26663
- CPA_PRIVATE_KEY_SIZE= 1152
26664
- PRIVATE_KEY_SIZE= 2400
26665
- PUBLIC_KEY_SIZE= 1184
26666
- ETA1= 2
26667
- ETA1_RANDOMNESS_SIZE= 128
26668
*/
26669
static KRML_MUSTINLINE void
26670
libcrux_ml_kem_ind_cca_unpacked_generate_keypair_b8(
26671
  Eurydice_arr_c7 randomness,
26672
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *out
26673
)
26674
0
{
26675
0
  Eurydice_borrow_slice_u8
26676
0
  ind_cpa_keypair_randomness =
26677
0
    Eurydice_array_to_subslice_shared_d47(&randomness,
26678
0
      (
26679
0
        KRML_CLITERAL(core_ops_range_Range_87){
26680
0
          .start = (size_t)0U,
26681
0
          .end = LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE
26682
0
        }
26683
0
      ));
26684
0
  Eurydice_borrow_slice_u8
26685
0
  implicit_rejection_value =
26686
0
    Eurydice_array_to_subslice_from_shared_5f1(&randomness,
26687
0
      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE);
26688
0
  libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_39(ind_cpa_keypair_randomness,
26689
0
    &out->private_key.ind_cpa_private_key,
26690
0
    &out->public_key.ind_cpa_public_key);
26691
0
  Eurydice_arr_c10
26692
0
  A = libcrux_ml_kem_ind_cca_unpacked_transpose_a_68(out->public_key.ind_cpa_public_key.A);
26693
0
  out->public_key.ind_cpa_public_key.A = A;
26694
0
  Eurydice_arr_5f
26695
0
  pk_serialized =
26696
0
    libcrux_ml_kem_ind_cpa_serialize_public_key_b6(&out->public_key.ind_cpa_public_key.t_as_ntt,
26697
0
      Eurydice_array_to_slice_shared_01(&out->public_key.ind_cpa_public_key.seed_for_A));
26698
0
  Eurydice_arr_ec
26699
0
  uu____0 =
26700
0
    libcrux_ml_kem_hash_functions_portable_H_4a_78(Eurydice_array_to_slice_shared_ff(&pk_serialized));
26701
0
  out->public_key.public_key_hash = uu____0;
26702
0
  Eurydice_arr_ec arr;
26703
0
  memcpy(arr.data, implicit_rejection_value.ptr, (size_t)32U * sizeof (uint8_t));
26704
0
  Eurydice_arr_ec
26705
0
  uu____1 =
26706
0
    core_result_unwrap_26_39((
26707
0
        KRML_CLITERAL(core_result_Result_07){ .tag = core_result_Ok, .val = { .case_Ok = arr } }
26708
0
      ));
26709
0
  out->private_key.implicit_rejection_value = uu____1;
26710
0
}
26711
26712
/**
26713
 Generate a key pair
26714
*/
26715
/**
26716
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.unpacked.generate_keypair
26717
with const generics
26718
- K= 3
26719
- CPA_PRIVATE_KEY_SIZE= 1152
26720
- PRIVATE_KEY_SIZE= 2400
26721
- PUBLIC_KEY_SIZE= 1184
26722
- ETA1= 2
26723
- ETA1_RANDOMNESS_SIZE= 128
26724
*/
26725
static KRML_MUSTINLINE void
26726
libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_generate_keypair_e9(
26727
  Eurydice_arr_c7 randomness,
26728
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *out
26729
)
26730
0
{
26731
0
  libcrux_ml_kem_ind_cca_unpacked_generate_keypair_b8(randomness, out);
26732
0
}
26733
26734
/**
26735
 Generate ML-KEM 768 Key Pair in "unpacked" form.
26736
*/
26737
static inline void
26738
libcrux_ml_kem_mlkem768_portable_unpacked_generate_key_pair_mut(
26739
  Eurydice_arr_c7 randomness,
26740
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair
26741
)
26742
0
{
26743
0
  libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_generate_keypair_e9(randomness,
26744
0
    key_pair);
26745
0
}
26746
26747
/**
26748
This function found in impl {core::default::Default for libcrux_ml_kem::ind_cca::unpacked::MlKemPublicKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
26749
*/
26750
/**
26751
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.default_30
26752
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26753
with const generics
26754
- K= 3
26755
*/
26756
static KRML_MUSTINLINE libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51
26757
libcrux_ml_kem_ind_cca_unpacked_default_30_68(void)
26758
0
{
26759
0
  return
26760
0
    (
26761
0
      KRML_CLITERAL(libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51){
26762
0
        .ind_cpa_public_key = libcrux_ml_kem_ind_cpa_unpacked_default_8b_68(),
26763
0
        .public_key_hash = { .data = { 0U } }
26764
0
      }
26765
0
    );
26766
0
}
26767
26768
/**
26769
This function found in impl {core::default::Default for libcrux_ml_kem::ind_cca::unpacked::MlKemKeyPairUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
26770
*/
26771
/**
26772
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.default_7b
26773
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26774
with const generics
26775
- K= 3
26776
*/
26777
static KRML_MUSTINLINE libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked
26778
libcrux_ml_kem_ind_cca_unpacked_default_7b_68(void)
26779
0
{
26780
0
  libcrux_ml_kem_ind_cca_unpacked_MlKemPrivateKeyUnpacked_51
26781
0
  uu____0 =
26782
0
    {
26783
0
      .ind_cpa_private_key = libcrux_ml_kem_ind_cpa_unpacked_default_70_68(),
26784
0
      .implicit_rejection_value = { .data = { 0U } }
26785
0
    };
26786
0
  return
26787
0
    (
26788
0
      KRML_CLITERAL(libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked){
26789
0
        .private_key = uu____0,
26790
0
        .public_key = libcrux_ml_kem_ind_cca_unpacked_default_30_68()
26791
0
      }
26792
0
    );
26793
0
}
26794
26795
/**
26796
 Generate ML-KEM 768 Key Pair in "unpacked" form.
26797
*/
26798
static inline libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked
26799
libcrux_ml_kem_mlkem768_portable_unpacked_generate_key_pair(Eurydice_arr_c7 randomness)
26800
0
{
26801
0
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked
26802
0
  key_pair = libcrux_ml_kem_ind_cca_unpacked_default_7b_68();
26803
0
  libcrux_ml_kem_mlkem768_portable_unpacked_generate_key_pair_mut(randomness, &key_pair);
26804
0
  return key_pair;
26805
0
}
26806
26807
/**
26808
 Create a new, empty unpacked key.
26809
*/
26810
static inline libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked
26811
libcrux_ml_kem_mlkem768_portable_unpacked_init_key_pair(void)
26812
0
{
26813
0
  return libcrux_ml_kem_ind_cca_unpacked_default_7b_68();
26814
0
}
26815
26816
/**
26817
 Create a new, empty unpacked public key.
26818
*/
26819
static inline libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51
26820
libcrux_ml_kem_mlkem768_portable_unpacked_init_public_key(void)
26821
0
{
26822
0
  return libcrux_ml_kem_ind_cca_unpacked_default_30_68();
26823
0
}
26824
26825
/**
26826
 Take a serialized private key and generate an unpacked key pair from it.
26827
*/
26828
/**
26829
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.keys_from_private_key
26830
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26831
with const generics
26832
- K= 3
26833
- SECRET_KEY_SIZE= 2400
26834
- CPA_SECRET_KEY_SIZE= 1152
26835
- PUBLIC_KEY_SIZE= 1184
26836
- T_AS_NTT_ENCODED_SIZE= 1152
26837
*/
26838
static KRML_MUSTINLINE void
26839
libcrux_ml_kem_ind_cca_unpacked_keys_from_private_key_01(
26840
  const Eurydice_arr_7d *private_key,
26841
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair
26842
)
26843
0
{
26844
0
  Eurydice_borrow_slice_u8_x4
26845
0
  uu____0 =
26846
0
    libcrux_ml_kem_types_unpack_private_key_64(Eurydice_array_to_slice_shared_51(private_key));
26847
0
  Eurydice_borrow_slice_u8 ind_cpa_secret_key = uu____0.fst;
26848
0
  Eurydice_borrow_slice_u8 ind_cpa_public_key = uu____0.snd;
26849
0
  Eurydice_borrow_slice_u8 ind_cpa_public_key_hash = uu____0.thd;
26850
0
  Eurydice_borrow_slice_u8 implicit_rejection_value = uu____0.f3;
26851
0
  libcrux_ml_kem_ind_cpa_deserialize_vector_68(ind_cpa_secret_key,
26852
0
    &key_pair->private_key.ind_cpa_private_key);
26853
0
  libcrux_ml_kem_ind_cpa_build_unpacked_public_key_mut_05(ind_cpa_public_key,
26854
0
    &key_pair->public_key.ind_cpa_public_key);
26855
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_01(&key_pair->public_key.public_key_hash),
26856
0
    ind_cpa_public_key_hash,
26857
0
    uint8_t);
26858
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_01(&key_pair->private_key.implicit_rejection_value),
26859
0
    implicit_rejection_value,
26860
0
    uint8_t);
26861
0
  Eurydice_slice_copy(Eurydice_array_to_slice_mut_01(&key_pair->public_key.ind_cpa_public_key.seed_for_A),
26862
0
    Eurydice_slice_subslice_from_shared_6d(ind_cpa_public_key, (size_t)1152U),
26863
0
    uint8_t);
26864
0
}
26865
26866
/**
26867
 Take a serialized private key and generate an unpacked key pair from it.
26868
*/
26869
/**
26870
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.unpacked.keypair_from_private_key
26871
with const generics
26872
- K= 3
26873
- SECRET_KEY_SIZE= 2400
26874
- CPA_SECRET_KEY_SIZE= 1152
26875
- PUBLIC_KEY_SIZE= 1184
26876
- T_AS_NTT_ENCODED_SIZE= 1152
26877
*/
26878
static KRML_MUSTINLINE void
26879
libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_keypair_from_private_key_71(
26880
  const Eurydice_arr_7d *private_key,
26881
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair
26882
)
26883
0
{
26884
0
  libcrux_ml_kem_ind_cca_unpacked_keys_from_private_key_01(private_key, key_pair);
26885
0
}
26886
26887
/**
26888
 Get an unpacked key from a private key.
26889
*/
26890
static inline void
26891
libcrux_ml_kem_mlkem768_portable_unpacked_key_pair_from_private_mut(
26892
  const Eurydice_arr_7d *private_key,
26893
  libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair
26894
)
26895
0
{
26896
0
  libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_keypair_from_private_key_71(private_key,
26897
0
    key_pair);
26898
0
}
26899
26900
/**
26901
 Get the serialized private key.
26902
*/
26903
/**
26904
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemKeyPairUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
26905
*/
26906
/**
26907
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.serialized_private_key_mut_11
26908
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26909
with const generics
26910
- K= 3
26911
- CPA_PRIVATE_KEY_SIZE= 1152
26912
- PRIVATE_KEY_SIZE= 2400
26913
- PUBLIC_KEY_SIZE= 1184
26914
*/
26915
static KRML_MUSTINLINE void
26916
libcrux_ml_kem_ind_cca_unpacked_serialized_private_key_mut_11_21(
26917
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *self,
26918
  Eurydice_arr_7d *serialized
26919
)
26920
0
{
26921
0
  libcrux_ml_kem_utils_extraction_helper_Keypair768
26922
0
  uu____0 =
26923
0
    libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_30(&self->public_key.ind_cpa_public_key,
26924
0
      &self->private_key.ind_cpa_private_key);
26925
0
  Eurydice_arr_0e ind_cpa_private_key = uu____0.fst;
26926
0
  Eurydice_arr_5f ind_cpa_public_key = uu____0.snd;
26927
0
  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_52(Eurydice_array_to_slice_shared_f4(&ind_cpa_private_key),
26928
0
    Eurydice_array_to_slice_shared_ff(&ind_cpa_public_key),
26929
0
    Eurydice_array_to_slice_shared_01(&self->private_key.implicit_rejection_value),
26930
0
    serialized);
26931
0
}
26932
26933
/**
26934
 Get the serialized private key.
26935
*/
26936
/**
26937
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemKeyPairUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
26938
*/
26939
/**
26940
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.serialized_private_key_11
26941
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26942
with const generics
26943
- K= 3
26944
- CPA_PRIVATE_KEY_SIZE= 1152
26945
- PRIVATE_KEY_SIZE= 2400
26946
- PUBLIC_KEY_SIZE= 1184
26947
*/
26948
static KRML_MUSTINLINE Eurydice_arr_7d
26949
libcrux_ml_kem_ind_cca_unpacked_serialized_private_key_11_21(
26950
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *self
26951
)
26952
0
{
26953
0
  Eurydice_arr_7d sk = libcrux_ml_kem_types_default_d3_79();
26954
0
  libcrux_ml_kem_ind_cca_unpacked_serialized_private_key_mut_11_21(self, &sk);
26955
0
  return sk;
26956
0
}
26957
26958
/**
26959
 Get the serialized private key.
26960
*/
26961
static inline Eurydice_arr_7d
26962
libcrux_ml_kem_mlkem768_portable_unpacked_key_pair_serialized_private_key(
26963
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair
26964
)
26965
0
{
26966
0
  return libcrux_ml_kem_ind_cca_unpacked_serialized_private_key_11_21(key_pair);
26967
0
}
26968
26969
/**
26970
 Get the serialized private key.
26971
*/
26972
static inline void
26973
libcrux_ml_kem_mlkem768_portable_unpacked_key_pair_serialized_private_key_mut(
26974
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair,
26975
  Eurydice_arr_7d *serialized
26976
)
26977
0
{
26978
0
  libcrux_ml_kem_ind_cca_unpacked_serialized_private_key_mut_11_21(key_pair, serialized);
26979
0
}
26980
26981
/**
26982
 Get the serialized public key.
26983
*/
26984
/**
26985
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemPublicKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
26986
*/
26987
/**
26988
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.serialized_dd
26989
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
26990
with const generics
26991
- K= 3
26992
- PUBLIC_KEY_SIZE= 1184
26993
*/
26994
static KRML_MUSTINLINE Eurydice_arr_5f
26995
libcrux_ml_kem_ind_cca_unpacked_serialized_dd_b6(
26996
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *self
26997
)
26998
0
{
26999
0
  return
27000
0
    libcrux_ml_kem_types_from_51_3d(libcrux_ml_kem_ind_cpa_serialize_public_key_b6(&self->ind_cpa_public_key.t_as_ntt,
27001
0
        Eurydice_array_to_slice_shared_01(&self->ind_cpa_public_key.seed_for_A)));
27002
0
}
27003
27004
/**
27005
 Get the serialized public key.
27006
*/
27007
/**
27008
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemKeyPairUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
27009
*/
27010
/**
27011
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.serialized_public_key_11
27012
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
27013
with const generics
27014
- K= 3
27015
- PUBLIC_KEY_SIZE= 1184
27016
*/
27017
static KRML_MUSTINLINE Eurydice_arr_5f
27018
libcrux_ml_kem_ind_cca_unpacked_serialized_public_key_11_b6(
27019
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *self
27020
)
27021
0
{
27022
0
  return libcrux_ml_kem_ind_cca_unpacked_serialized_dd_b6(&self->public_key);
27023
0
}
27024
27025
/**
27026
 Get the serialized public key.
27027
*/
27028
static inline Eurydice_arr_5f
27029
libcrux_ml_kem_mlkem768_portable_unpacked_key_pair_serialized_public_key(
27030
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair
27031
)
27032
0
{
27033
0
  return libcrux_ml_kem_ind_cca_unpacked_serialized_public_key_11_b6(key_pair);
27034
0
}
27035
27036
/**
27037
 Get the serialized public key.
27038
*/
27039
/**
27040
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemPublicKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
27041
*/
27042
/**
27043
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.serialized_mut_dd
27044
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
27045
with const generics
27046
- K= 3
27047
- PUBLIC_KEY_SIZE= 1184
27048
*/
27049
static KRML_MUSTINLINE void
27050
libcrux_ml_kem_ind_cca_unpacked_serialized_mut_dd_b6(
27051
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *self,
27052
  Eurydice_arr_5f *serialized
27053
)
27054
0
{
27055
0
  libcrux_ml_kem_ind_cpa_serialize_public_key_mut_b6(&self->ind_cpa_public_key.t_as_ntt,
27056
0
    Eurydice_array_to_slice_shared_01(&self->ind_cpa_public_key.seed_for_A),
27057
0
    serialized);
27058
0
}
27059
27060
/**
27061
 Get the serialized public key.
27062
*/
27063
/**
27064
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemKeyPairUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
27065
*/
27066
/**
27067
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.serialized_public_key_mut_11
27068
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
27069
with const generics
27070
- K= 3
27071
- PUBLIC_KEY_SIZE= 1184
27072
*/
27073
static KRML_MUSTINLINE void
27074
libcrux_ml_kem_ind_cca_unpacked_serialized_public_key_mut_11_b6(
27075
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *self,
27076
  Eurydice_arr_5f *serialized
27077
)
27078
0
{
27079
0
  libcrux_ml_kem_ind_cca_unpacked_serialized_mut_dd_b6(&self->public_key, serialized);
27080
0
}
27081
27082
/**
27083
 Get the serialized public key.
27084
*/
27085
static inline void
27086
libcrux_ml_kem_mlkem768_portable_unpacked_key_pair_serialized_public_key_mut(
27087
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair,
27088
  Eurydice_arr_5f *serialized
27089
)
27090
0
{
27091
0
  libcrux_ml_kem_ind_cca_unpacked_serialized_public_key_mut_11_b6(key_pair, serialized);
27092
0
}
27093
27094
/**
27095
This function found in impl {core::clone::Clone for libcrux_ml_kem::ind_cpa::unpacked::IndCpaPublicKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@2]}
27096
*/
27097
/**
27098
A monomorphic instance of libcrux_ml_kem.ind_cpa.unpacked.clone_91
27099
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
27100
with const generics
27101
- K= 3
27102
*/
27103
static inline libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
27104
libcrux_ml_kem_ind_cpa_unpacked_clone_91_68(
27105
  const libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51 *self
27106
)
27107
0
{
27108
0
  Eurydice_arr_bb0
27109
0
  uu____0 =
27110
0
    core_array__core__clone__Clone_for__T__N___clone((size_t)3U,
27111
0
      &self->t_as_ntt,
27112
0
      Eurydice_arr_9e,
27113
0
      Eurydice_arr_bb0);
27114
0
  Eurydice_arr_ec
27115
0
  uu____1 =
27116
0
    core_array__core__clone__Clone_for__T__N___clone((size_t)32U,
27117
0
      &self->seed_for_A,
27118
0
      uint8_t,
27119
0
      Eurydice_arr_ec);
27120
0
  return
27121
0
    (
27122
0
      KRML_CLITERAL(libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51){
27123
0
        .t_as_ntt = uu____0,
27124
0
        .seed_for_A = uu____1,
27125
0
        .A = core_array__core__clone__Clone_for__T__N___clone((size_t)3U,
27126
0
          &self->A,
27127
0
          Eurydice_arr_bb0,
27128
0
          Eurydice_arr_c10)
27129
0
      }
27130
0
    );
27131
0
}
27132
27133
/**
27134
This function found in impl {core::clone::Clone for libcrux_ml_kem::ind_cca::unpacked::MlKemPublicKeyUnpacked<Vector, K>[TraitClause@0, TraitClause@2]}
27135
*/
27136
/**
27137
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.clone_d7
27138
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
27139
with const generics
27140
- K= 3
27141
*/
27142
static inline libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51
27143
libcrux_ml_kem_ind_cca_unpacked_clone_d7_68(
27144
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *self
27145
)
27146
0
{
27147
0
  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_51
27148
0
  uu____0 = libcrux_ml_kem_ind_cpa_unpacked_clone_91_68(&self->ind_cpa_public_key);
27149
0
  return
27150
0
    (
27151
0
      KRML_CLITERAL(libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51){
27152
0
        .ind_cpa_public_key = uu____0,
27153
0
        .public_key_hash = core_array__core__clone__Clone_for__T__N___clone((size_t)32U,
27154
0
          &self->public_key_hash,
27155
0
          uint8_t,
27156
0
          Eurydice_arr_ec)
27157
0
      }
27158
0
    );
27159
0
}
27160
27161
/**
27162
 Get the serialized public key.
27163
*/
27164
/**
27165
This function found in impl {libcrux_ml_kem::ind_cca::unpacked::MlKemKeyPairUnpacked<Vector, K>[TraitClause@0, TraitClause@1]}
27166
*/
27167
/**
27168
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.public_key_11
27169
with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
27170
with const generics
27171
- K= 3
27172
*/
27173
static KRML_MUSTINLINE const
27174
libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51
27175
*libcrux_ml_kem_ind_cca_unpacked_public_key_11_68(
27176
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *self
27177
)
27178
0
{
27179
0
  return &self->public_key;
27180
0
}
27181
27182
/**
27183
 Get the unpacked public key.
27184
*/
27185
static inline void
27186
libcrux_ml_kem_mlkem768_portable_unpacked_public_key(
27187
  const libcrux_ml_kem_mlkem768_portable_unpacked_MlKem768KeyPairUnpacked *key_pair,
27188
  libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *pk
27189
)
27190
0
{
27191
0
  libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51
27192
0
  uu____0 =
27193
0
    libcrux_ml_kem_ind_cca_unpacked_clone_d7_68(libcrux_ml_kem_ind_cca_unpacked_public_key_11_68(key_pair));
27194
0
  pk[0U] = uu____0;
27195
0
}
27196
27197
/**
27198
 Get the serialized public key.
27199
*/
27200
static inline void
27201
libcrux_ml_kem_mlkem768_portable_unpacked_serialized_public_key(
27202
  const libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *public_key,
27203
  Eurydice_arr_5f *serialized
27204
)
27205
0
{
27206
0
  libcrux_ml_kem_ind_cca_unpacked_serialized_mut_dd_b6(public_key, serialized);
27207
0
}
27208
27209
/**
27210
 Generate an unpacked key from a serialized key.
27211
*/
27212
/**
27213
A monomorphic instance of libcrux_ml_kem.ind_cca.unpacked.unpack_public_key
27214
with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], libcrux_ml_kem_vector_portable_vector_type_PortableVector
27215
with const generics
27216
- K= 3
27217
- T_AS_NTT_ENCODED_SIZE= 1152
27218
- PUBLIC_KEY_SIZE= 1184
27219
*/
27220
static KRML_MUSTINLINE void
27221
libcrux_ml_kem_ind_cca_unpacked_unpack_public_key_22(
27222
  const Eurydice_arr_5f *public_key,
27223
  libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *unpacked_public_key
27224
)
27225
0
{
27226
0
  Eurydice_borrow_slice_u8
27227
0
  uu____0 = Eurydice_array_to_subslice_to_shared_210(public_key, (size_t)1152U);
27228
0
  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_68(uu____0,
27229
0
    &unpacked_public_key->ind_cpa_public_key.t_as_ntt);
27230
0
  unpacked_public_key->ind_cpa_public_key.seed_for_A =
27231
0
    libcrux_ml_kem_utils_into_padded_array_ce(Eurydice_array_to_subslice_from_shared_5f2(public_key,
27232
0
        (size_t)1152U));
27233
0
  Eurydice_arr_c10 *uu____2 = &unpacked_public_key->ind_cpa_public_key.A;
27234
0
  /* original Rust expression is not an lvalue in C */
27235
0
  Eurydice_arr_31
27236
0
  lvalue =
27237
0
    libcrux_ml_kem_utils_into_padded_array_de(Eurydice_array_to_subslice_from_shared_5f2(public_key,
27238
0
        (size_t)1152U));
27239
0
  libcrux_ml_kem_matrix_sample_matrix_A_91(uu____2, &lvalue, false);
27240
0
  Eurydice_arr_ec
27241
0
  uu____3 =
27242
0
    libcrux_ml_kem_hash_functions_portable_H_4a_78(Eurydice_array_to_slice_shared_ff(libcrux_ml_kem_types_as_slice_e6_3d(public_key)));
27243
0
  unpacked_public_key->public_key_hash = uu____3;
27244
0
}
27245
27246
/**
27247
 Get the unpacked public key.
27248
*/
27249
/**
27250
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.portable.unpacked.unpack_public_key
27251
with const generics
27252
- K= 3
27253
- T_AS_NTT_ENCODED_SIZE= 1152
27254
- PUBLIC_KEY_SIZE= 1184
27255
*/
27256
static KRML_MUSTINLINE void
27257
libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_unpack_public_key_d3(
27258
  const Eurydice_arr_5f *public_key,
27259
  libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *unpacked_public_key
27260
)
27261
0
{
27262
0
  libcrux_ml_kem_ind_cca_unpacked_unpack_public_key_22(public_key, unpacked_public_key);
27263
0
}
27264
27265
/**
27266
 Get the unpacked public key.
27267
*/
27268
static inline void
27269
libcrux_ml_kem_mlkem768_portable_unpacked_unpacked_public_key(
27270
  const Eurydice_arr_5f *public_key,
27271
  libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_51 *unpacked_public_key
27272
)
27273
0
{
27274
0
  libcrux_ml_kem_ind_cca_instantiations_portable_unpacked_unpack_public_key_d3(public_key,
27275
0
    unpacked_public_key);
27276
0
}
27277
27278
#if defined(__cplusplus)
27279
}
27280
#endif
27281
27282
#define libcrux_mlkem768_portable_H_DEFINED
27283
#endif /* libcrux_mlkem768_portable_H */
27284
27285
27286
/* rename some types to be a bit more ergonomic */
27287
27288
/* ML-KEM 768 */
27289
typedef Eurydice_arr_c7 libcrux_mlkem768_keypair_rnd;
27290
typedef Eurydice_arr_ec libcrux_mlkem768_enc_rnd;
27291
typedef libcrux_ml_kem_mlkem768_MlKem768KeyPair libcrux_mlkem768_keypair;
27292
typedef Eurydice_arr_5f libcrux_mlkem768_pk;
27293
typedef Eurydice_arr_7d libcrux_mlkem768_sk;
27294
typedef Eurydice_arr_2b libcrux_mlkem768_ciphertext;
27295
typedef tuple_f4 libcrux_mlkem768_enc_result;
27296
typedef Eurydice_arr_ec libcrux_mlkem768_dec_result;
27297
/* ML-DSA 44 */
27298
typedef Eurydice_arr_ec libcrux_mldsa44_keypair_rnd;
27299
typedef libcrux_ml_dsa_ml_dsa_generic_ml_dsa_44_MLDSA44KeyPair
27300
    libcrux_mldsa44_keypair;
27301
typedef Eurydice_arr_10 libcrux_mldsa44_sk;
27302
typedef Eurydice_arr_02 libcrux_mldsa44_pk;
27303
typedef Eurydice_borrow_slice_u8 libcrux_mldsa44_message;
27304
typedef Eurydice_arr_ec libcrux_mldsa44_sign_rnd;
27305
typedef core_result_Result_48 libcrux_mldsa44_sign_result;
27306
typedef core_result_Result_41 libcrux_mldsa44_verify_result;
27307
typedef Eurydice_arr_85 libcrux_mldsa44_signature;
27308
/* ML-DSA 65 */
27309
typedef Eurydice_arr_ec libcrux_mldsa65_keypair_rnd;
27310
typedef libcrux_ml_dsa_ml_dsa_generic_ml_dsa_65_MLDSA65KeyPair
27311
    libcrux_mldsa65_keypair;
27312
typedef Eurydice_arr_24 libcrux_mldsa65_sk;
27313
typedef Eurydice_arr_29 libcrux_mldsa65_pk;
27314
typedef Eurydice_borrow_slice_u8 libcrux_mldsa65_message;
27315
typedef Eurydice_arr_ec libcrux_mldsa65_sign_rnd;
27316
typedef core_result_Result_8c libcrux_mldsa65_sign_result;
27317
typedef core_result_Result_41 libcrux_mldsa65_verify_result;
27318
typedef Eurydice_arr_0c libcrux_mldsa65_signature;
27319
/* ML-DSA 87 */
27320
typedef Eurydice_arr_ec libcrux_mldsa87_keypair_rnd;
27321
typedef libcrux_ml_dsa_ml_dsa_generic_ml_dsa_87_MLDSA87KeyPair
27322
    libcrux_mldsa87_keypair;
27323
typedef Eurydice_arr_e2 libcrux_mldsa87_sk;
27324
typedef Eurydice_arr_43 libcrux_mldsa87_pk;
27325
typedef Eurydice_borrow_slice_u8 libcrux_mldsa87_message;
27326
typedef Eurydice_arr_ec libcrux_mldsa87_sign_rnd;
27327
typedef core_result_Result_8b libcrux_mldsa87_sign_result;
27328
typedef core_result_Result_41 libcrux_mldsa87_verify_result;
27329
typedef Eurydice_arr_93 libcrux_mldsa87_signature;
27330
27331
0
#define LIBCRUX_RESULT_OK core_result_Ok
27332