/src/hpn-ssh/libcrux_mlkem768_sha3.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* $OpenBSD: libcrux_mlkem768_sha3.h,v 1.2 2024/10/27 02:06:01 djm Exp $ */ |
2 | | |
3 | | /* Extracted from libcrux revision 84c5d87b3092c59294345aa269ceefe0eb97cc35 */ |
4 | | |
5 | | /* |
6 | | * MIT License |
7 | | * |
8 | | * Copyright (c) 2024 Cryspen |
9 | | * |
10 | | * Permission is hereby granted, free of charge, to any person obtaining a copy |
11 | | * of this software and associated documentation files (the "Software"), to deal |
12 | | * in the Software without restriction, including without limitation the rights |
13 | | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
14 | | * copies of the Software, and to permit persons to whom the Software is |
15 | | * furnished to do so, subject to the following conditions: |
16 | | * |
17 | | * The above copyright notice and this permission notice shall be included in all |
18 | | * copies or substantial portions of the Software. |
19 | | * |
20 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
21 | | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
22 | | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
23 | | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
24 | | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
25 | | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
26 | | * SOFTWARE. |
27 | | */ |
28 | | |
29 | | #if !defined(__GNUC__) || (__GNUC__ < 2) |
30 | | # define __attribute__(x) |
31 | | #endif |
32 | | #define KRML_MUSTINLINE inline |
33 | | #define KRML_NOINLINE __attribute__((noinline, unused)) |
34 | | #define KRML_HOST_EPRINTF(...) |
35 | 0 | #define KRML_HOST_EXIT(x) fatal_f("internal error") |
36 | | |
37 | | /* from libcrux/libcrux-ml-kem/cg/eurydice_glue.h */ |
38 | | /* |
39 | | * SPDX-FileCopyrightText: 2024 Eurydice Contributors |
40 | | * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com> |
41 | | * |
42 | | * SPDX-License-Identifier: MIT or Apache-2.0 |
43 | | */ |
44 | | |
45 | | #pragma once |
46 | | |
47 | | #if defined(__cplusplus) |
48 | | extern "C" { |
49 | | #endif |
50 | | |
51 | | |
52 | | |
53 | | // SLICES, ARRAYS, ETC. |
54 | | |
55 | | // The MSVC C++ compiler does not support compound literals. |
56 | | // This CLITERAL is used to turn `(type){...}` into `type{...}` when using a C++ |
57 | | // compiler. |
58 | | #if defined(__cplusplus) |
59 | | #define CLITERAL(type) type |
60 | | #else |
61 | 0 | #define CLITERAL(type) (type) |
62 | | #endif |
63 | | |
64 | | // We represent a slice as a pair of an (untyped) pointer, along with the length |
65 | | // of the slice, i.e. the number of elements in the slice (this is NOT the |
66 | | // number of bytes). This design choice has two important consequences. |
67 | | // - if you need to use `ptr`, you MUST cast it to a proper type *before* |
68 | | // performing pointer |
69 | | // arithmetic on it (remember that C desugars pointer arithmetic based on the |
70 | | // type of the address) |
71 | | // - if you need to use `len` for a C style function (e.g. memcpy, memcmp), you |
72 | | // need to multiply it |
73 | | // by sizeof t, where t is the type of the elements. |
74 | | // |
75 | | // Empty slices have `len == 0` and `ptr` always needs to be valid pointer that |
76 | | // is not NULL (otherwise the construction in EURYDICE_SLICE computes `NULL + |
77 | | // start`). |
78 | | typedef struct { |
79 | | void *ptr; |
80 | | size_t len; |
81 | | } Eurydice_slice; |
82 | | |
83 | | // Helper macro to create a slice out of a pointer x, a start index in x |
84 | | // (included), and an end index in x (excluded). The argument x must be suitably |
85 | | // cast to something that can decay (see remark above about how pointer |
86 | | // arithmetic works in C), meaning either pointer or array type. |
87 | | #define EURYDICE_SLICE(x, start, end) \ |
88 | 0 | (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start}) |
89 | 0 | #define EURYDICE_SLICE_LEN(s, _) s.len |
90 | | // This macro is a pain because in case the dereferenced element type is an |
91 | | // array, you cannot simply write `t x` as it would yield `int[4] x` instead, |
92 | | // which is NOT correct C syntax, so we add a dedicated phase in Eurydice that |
93 | | // adds an extra argument to this macro at the last minute so that we have the |
94 | | // correct type of *pointers* to elements. |
95 | 0 | #define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i]) |
96 | | #define Eurydice_slice_subslice(s, r, t, _) \ |
97 | | EURYDICE_SLICE((t *)s.ptr, r.start, r.end) |
98 | | // Variant for when the start and end indices are statically known (i.e., the |
99 | | // range argument `r` is a literal). |
100 | | #define Eurydice_slice_subslice2(s, start, end, t) \ |
101 | 0 | EURYDICE_SLICE((t *)s.ptr, start, end) |
102 | | #define Eurydice_slice_subslice_to(s, subslice_end_pos, t, _) \ |
103 | 0 | EURYDICE_SLICE((t *)s.ptr, 0, subslice_end_pos) |
104 | | #define Eurydice_slice_subslice_from(s, subslice_start_pos, t, _) \ |
105 | 0 | EURYDICE_SLICE((t *)s.ptr, subslice_start_pos, s.len) |
106 | | #define Eurydice_array_to_slice(end, x, t) \ |
107 | 0 | EURYDICE_SLICE(x, 0, \ |
108 | 0 | end) /* x is already at an array type, no need for cast */ |
109 | | #define Eurydice_array_to_subslice(_arraylen, x, r, t, _) \ |
110 | | EURYDICE_SLICE((t *)x, r.start, r.end) |
111 | | // Same as above, variant for when start and end are statically known |
112 | | #define Eurydice_array_to_subslice2(x, start, end, t) \ |
113 | 0 | EURYDICE_SLICE((t *)x, start, end) |
114 | | #define Eurydice_array_to_subslice_to(_size, x, r, t, _range_t) \ |
115 | 0 | EURYDICE_SLICE((t *)x, 0, r) |
116 | | #define Eurydice_array_to_subslice_from(size, x, r, t, _range_t) \ |
117 | 0 | EURYDICE_SLICE((t *)x, r, size) |
118 | 0 | #define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t) |
119 | | #define Eurydice_slice_copy(dst, src, t) \ |
120 | 0 | memcpy(dst.ptr, src.ptr, dst.len * sizeof(t)) |
121 | | #define core_array___Array_T__N__23__as_slice(len_, ptr_, t, _ret_t) \ |
122 | | ((Eurydice_slice){.ptr = ptr_, .len = len_}) |
123 | | |
124 | | #define core_array___core__clone__Clone_for__Array_T__N___20__clone( \ |
125 | | len, src, dst, elem_type, _ret_t) \ |
126 | | (memcpy(dst, src, len * sizeof(elem_type))) |
127 | | #define TryFromSliceError uint8_t |
128 | | |
129 | | #define Eurydice_array_eq(sz, a1, a2, t, _) \ |
130 | 0 | (memcmp(a1, a2, sz * sizeof(t)) == 0) |
131 | | #define core_array_equality___core__cmp__PartialEq__Array_U__N___for__Array_T__N____eq( \ |
132 | | sz, a1, a2, t, _, _ret_t) \ |
133 | 0 | Eurydice_array_eq(sz, a1, a2, t, _) |
134 | | #define core_array_equality___core__cmp__PartialEq__0___Slice_U____for__Array_T__N___3__eq( \ |
135 | | sz, a1, a2, t, _, _ret_t) \ |
136 | | Eurydice_array_eq(sz, a1, ((a2)->ptr), t, _) |
137 | | |
138 | | #define Eurydice_slice_split_at(slice, mid, element_type, ret_t) \ |
139 | 0 | (CLITERAL(ret_t){ \ |
140 | 0 | .fst = EURYDICE_SLICE((element_type *)slice.ptr, 0, mid), \ |
141 | 0 | .snd = EURYDICE_SLICE((element_type *)slice.ptr, mid, slice.len)}) |
142 | | #define Eurydice_slice_split_at_mut(slice, mid, element_type, ret_t) \ |
143 | 0 | (CLITERAL(ret_t){ \ |
144 | 0 | .fst = {.ptr = slice.ptr, .len = mid}, \ |
145 | 0 | .snd = {.ptr = (char *)slice.ptr + mid * sizeof(element_type), \ |
146 | 0 | .len = slice.len - mid}}) |
147 | | |
148 | | // Conversion of slice to an array, rewritten (by Eurydice) to name the |
149 | | // destination array, since arrays are not values in C. |
150 | | // N.B.: see note in karamel/lib/Inlining.ml if you change this. |
151 | | #define Eurydice_slice_to_array2(dst, src, _, t_arr) \ |
152 | 0 | Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \ |
153 | 0 | sizeof(t_arr)) |
154 | | |
155 | | static inline void Eurydice_slice_to_array3(uint8_t *dst_tag, char *dst_ok, |
156 | 0 | Eurydice_slice src, size_t sz) { |
157 | 0 | *dst_tag = 0; |
158 | 0 | memcpy(dst_ok, src.ptr, sz); |
159 | 0 | } |
160 | | |
161 | | // CORE STUFF (conversions, endianness, ...) |
162 | | |
163 | 0 | static inline void core_num__u64_9__to_le_bytes(uint64_t v, uint8_t buf[8]) { |
164 | 0 | v = htole64(v); |
165 | 0 | memcpy(buf, &v, sizeof(v)); |
166 | 0 | } |
167 | 0 | static inline uint64_t core_num__u64_9__from_le_bytes(uint8_t buf[8]) { |
168 | 0 | uint64_t v; |
169 | 0 | memcpy(&v, buf, sizeof(v)); |
170 | 0 | return le64toh(v); |
171 | 0 | } |
172 | | |
173 | 0 | static inline uint32_t core_num__u32_8__from_le_bytes(uint8_t buf[4]) { |
174 | 0 | uint32_t v; |
175 | 0 | memcpy(&v, buf, sizeof(v)); |
176 | 0 | return le32toh(v); |
177 | 0 | } |
178 | | |
179 | 0 | static inline uint32_t core_num__u8_6__count_ones(uint8_t x0) { |
180 | 0 | #if defined(_MSC_VER) |
181 | 0 | return __popcnt(x0); |
182 | 0 | #elif !defined(MISSING_BUILTIN_POPCOUNT) |
183 | 0 | return __builtin_popcount(x0); |
184 | 0 | #else |
185 | 0 | const uint8_t v[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; |
186 | 0 | return v[x0 & 0xf] + v[(x0 >> 4) & 0xf]; |
187 | 0 |
|
188 | 0 | #endif |
189 | 0 | } |
190 | | |
191 | | // unsigned overflow wraparound semantics in C |
192 | 0 | static inline uint16_t core_num__u16_7__wrapping_add(uint16_t x, uint16_t y) { |
193 | 0 | return x + y; |
194 | 0 | } |
195 | 0 | static inline uint8_t core_num__u8_6__wrapping_sub(uint8_t x, uint8_t y) { |
196 | 0 | return x - y; |
197 | 0 | } |
198 | | |
199 | | // ITERATORS |
200 | | |
201 | | #define Eurydice_range_iter_next(iter_ptr, t, ret_t) \ |
202 | 0 | (((iter_ptr)->start == (iter_ptr)->end) \ |
203 | 0 | ? (CLITERAL(ret_t){.tag = None}) \ |
204 | 0 | : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++})) |
205 | | |
206 | | #define core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next \ |
207 | 0 | Eurydice_range_iter_next |
208 | | |
209 | | // See note in karamel/lib/Inlining.ml if you change this |
210 | 0 | #define Eurydice_into_iter(x, t, _ret_t) (x) |
211 | | #define core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter \ |
212 | 0 | Eurydice_into_iter |
213 | | |
214 | | #if defined(__cplusplus) |
215 | | } |
216 | | #endif |
217 | | |
218 | | /* from libcrux/libcrux-ml-kem/cg/libcrux_core.h */ |
219 | | /* |
220 | | * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com> |
221 | | * |
222 | | * SPDX-License-Identifier: MIT or Apache-2.0 |
223 | | * |
224 | | * This code was generated with the following revisions: |
225 | | * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4 |
226 | | * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb |
227 | | * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908 |
228 | | * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty |
229 | | * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee |
230 | | */ |
231 | | |
232 | | #ifndef __libcrux_core_H |
233 | | #define __libcrux_core_H |
234 | | |
235 | | #if defined(__cplusplus) |
236 | | extern "C" { |
237 | | #endif |
238 | | |
239 | | |
240 | | /** |
241 | | A monomorphic instance of core.ops.range.Range |
242 | | with types size_t |
243 | | |
244 | | */ |
245 | | typedef struct core_ops_range_Range_b3_s { |
246 | | size_t start; |
247 | | size_t end; |
248 | | } core_ops_range_Range_b3; |
249 | | |
250 | 0 | #define Ok 0 |
251 | | #define Err 1 |
252 | | |
253 | | typedef uint8_t Result_86_tags; |
254 | | |
255 | 0 | #define None 0 |
256 | 0 | #define Some 1 |
257 | | |
258 | | typedef uint8_t Option_ef_tags; |
259 | | |
260 | | /** |
261 | | A monomorphic instance of core.option.Option |
262 | | with types size_t |
263 | | |
264 | | */ |
265 | | typedef struct Option_b3_s { |
266 | | Option_ef_tags tag; |
267 | | size_t f0; |
268 | | } Option_b3; |
269 | | |
270 | | static inline uint16_t core_num__u16_7__wrapping_add(uint16_t x0, uint16_t x1); |
271 | | |
272 | 0 | #define CORE_NUM__U32_8__BITS (32U) |
273 | | |
274 | | static inline uint64_t core_num__u64_9__from_le_bytes(uint8_t x0[8U]); |
275 | | |
276 | | static inline void core_num__u64_9__to_le_bytes(uint64_t x0, uint8_t x1[8U]); |
277 | | |
278 | | static inline uint32_t core_num__u8_6__count_ones(uint8_t x0); |
279 | | |
280 | | static inline uint8_t core_num__u8_6__wrapping_sub(uint8_t x0, uint8_t x1); |
281 | | |
282 | 0 | #define LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE ((size_t)32U) |
283 | | |
284 | | #define LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT ((size_t)12U) |
285 | | |
286 | 0 | #define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U) |
287 | | |
288 | | #define LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT \ |
289 | 0 | (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)12U) |
290 | | |
291 | | #define LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT \ |
292 | 0 | (LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U) |
293 | | |
294 | 0 | #define LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE ((size_t)32U) |
295 | | |
296 | 0 | #define LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE ((size_t)32U) |
297 | | |
298 | | typedef struct libcrux_ml_kem_utils_extraction_helper_Keypair768_s { |
299 | | uint8_t fst[1152U]; |
300 | | uint8_t snd[1184U]; |
301 | | } libcrux_ml_kem_utils_extraction_helper_Keypair768; |
302 | | |
303 | | /** |
304 | | A monomorphic instance of core.result.Result |
305 | | with types uint8_t[24size_t], core_array_TryFromSliceError |
306 | | |
307 | | */ |
308 | | typedef struct Result_6f_s { |
309 | | Result_86_tags tag; |
310 | | union { |
311 | | uint8_t case_Ok[24U]; |
312 | | TryFromSliceError case_Err; |
313 | | } val; |
314 | | } Result_6f; |
315 | | |
316 | | /** |
317 | | This function found in impl {core::result::Result<T, E>} |
318 | | */ |
319 | | /** |
320 | | A monomorphic instance of core.result.unwrap_41 |
321 | | with types uint8_t[24size_t], core_array_TryFromSliceError |
322 | | |
323 | | */ |
324 | 0 | static inline void unwrap_41_1c(Result_6f self, uint8_t ret[24U]) { |
325 | 0 | if (self.tag == Ok) { |
326 | 0 | uint8_t f0[24U]; |
327 | 0 | memcpy(f0, self.val.case_Ok, (size_t)24U * sizeof(uint8_t)); |
328 | 0 | memcpy(ret, f0, (size_t)24U * sizeof(uint8_t)); |
329 | 0 | } else { |
330 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
331 | 0 | "unwrap not Ok"); |
332 | 0 | KRML_HOST_EXIT(255U); |
333 | 0 | } |
334 | 0 | } |
335 | | |
336 | | /** |
337 | | A monomorphic instance of core.result.Result |
338 | | with types uint8_t[20size_t], core_array_TryFromSliceError |
339 | | |
340 | | */ |
341 | | typedef struct Result_7a_s { |
342 | | Result_86_tags tag; |
343 | | union { |
344 | | uint8_t case_Ok[20U]; |
345 | | TryFromSliceError case_Err; |
346 | | } val; |
347 | | } Result_7a; |
348 | | |
349 | | /** |
350 | | This function found in impl {core::result::Result<T, E>} |
351 | | */ |
352 | | /** |
353 | | A monomorphic instance of core.result.unwrap_41 |
354 | | with types uint8_t[20size_t], core_array_TryFromSliceError |
355 | | |
356 | | */ |
357 | 0 | static inline void unwrap_41_34(Result_7a self, uint8_t ret[20U]) { |
358 | 0 | if (self.tag == Ok) { |
359 | 0 | uint8_t f0[20U]; |
360 | 0 | memcpy(f0, self.val.case_Ok, (size_t)20U * sizeof(uint8_t)); |
361 | 0 | memcpy(ret, f0, (size_t)20U * sizeof(uint8_t)); |
362 | 0 | } else { |
363 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
364 | 0 | "unwrap not Ok"); |
365 | 0 | KRML_HOST_EXIT(255U); |
366 | 0 | } |
367 | 0 | } |
368 | | |
369 | | /** |
370 | | A monomorphic instance of core.result.Result |
371 | | with types uint8_t[10size_t], core_array_TryFromSliceError |
372 | | |
373 | | */ |
374 | | typedef struct Result_cd_s { |
375 | | Result_86_tags tag; |
376 | | union { |
377 | | uint8_t case_Ok[10U]; |
378 | | TryFromSliceError case_Err; |
379 | | } val; |
380 | | } Result_cd; |
381 | | |
382 | | /** |
383 | | This function found in impl {core::result::Result<T, E>} |
384 | | */ |
385 | | /** |
386 | | A monomorphic instance of core.result.unwrap_41 |
387 | | with types uint8_t[10size_t], core_array_TryFromSliceError |
388 | | |
389 | | */ |
390 | 0 | static inline void unwrap_41_e8(Result_cd self, uint8_t ret[10U]) { |
391 | 0 | if (self.tag == Ok) { |
392 | 0 | uint8_t f0[10U]; |
393 | 0 | memcpy(f0, self.val.case_Ok, (size_t)10U * sizeof(uint8_t)); |
394 | 0 | memcpy(ret, f0, (size_t)10U * sizeof(uint8_t)); |
395 | 0 | } else { |
396 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
397 | 0 | "unwrap not Ok"); |
398 | 0 | KRML_HOST_EXIT(255U); |
399 | 0 | } |
400 | 0 | } |
401 | | |
402 | | typedef struct Eurydice_slice_uint8_t_4size_t__x2_s { |
403 | | Eurydice_slice fst[4U]; |
404 | | Eurydice_slice snd[4U]; |
405 | | } Eurydice_slice_uint8_t_4size_t__x2; |
406 | | |
407 | | typedef struct libcrux_ml_kem_mlkem768_MlKem768Ciphertext_s { |
408 | | uint8_t value[1088U]; |
409 | | } libcrux_ml_kem_mlkem768_MlKem768Ciphertext; |
410 | | |
411 | | /** |
412 | | A reference to the raw byte slice. |
413 | | */ |
414 | | /** |
415 | | This function found in impl {libcrux_ml_kem::types::MlKemCiphertext<SIZE>#6} |
416 | | */ |
417 | | /** |
418 | | A monomorphic instance of libcrux_ml_kem.types.as_slice_d4 |
419 | | with const generics |
420 | | - SIZE= 1088 |
421 | | */ |
422 | | static inline uint8_t *libcrux_ml_kem_types_as_slice_d4_1d( |
423 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *self) { |
424 | 0 | return self->value; |
425 | 0 | } |
426 | | |
427 | | /** |
428 | | A monomorphic instance of libcrux_ml_kem.types.MlKemPublicKey |
429 | | with const generics |
430 | | - $1184size_t |
431 | | */ |
432 | | typedef struct libcrux_ml_kem_types_MlKemPublicKey_15_s { |
433 | | uint8_t value[1184U]; |
434 | | } libcrux_ml_kem_types_MlKemPublicKey_15; |
435 | | |
436 | | /** |
437 | | This function found in impl {(core::convert::From<@Array<u8, SIZE>> for |
438 | | libcrux_ml_kem::types::MlKemPublicKey<SIZE>)#14} |
439 | | */ |
440 | | /** |
441 | | A monomorphic instance of libcrux_ml_kem.types.from_b6 |
442 | | with const generics |
443 | | - SIZE= 1184 |
444 | | */ |
445 | | static inline libcrux_ml_kem_types_MlKemPublicKey_15 |
446 | 0 | libcrux_ml_kem_types_from_b6_da(uint8_t value[1184U]) { |
447 | | /* Passing arrays by value in Rust generates a copy in C */ |
448 | 0 | uint8_t copy_of_value[1184U]; |
449 | 0 | memcpy(copy_of_value, value, (size_t)1184U * sizeof(uint8_t)); |
450 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 lit; |
451 | 0 | memcpy(lit.value, copy_of_value, (size_t)1184U * sizeof(uint8_t)); |
452 | 0 | return lit; |
453 | 0 | } |
454 | | |
455 | | /** |
456 | | A monomorphic instance of libcrux_ml_kem.types.MlKemPrivateKey |
457 | | with const generics |
458 | | - $2400size_t |
459 | | */ |
460 | | typedef struct libcrux_ml_kem_types_MlKemPrivateKey_55_s { |
461 | | uint8_t value[2400U]; |
462 | | } libcrux_ml_kem_types_MlKemPrivateKey_55; |
463 | | |
464 | | typedef struct libcrux_ml_kem_mlkem768_MlKem768KeyPair_s { |
465 | | libcrux_ml_kem_types_MlKemPrivateKey_55 sk; |
466 | | libcrux_ml_kem_types_MlKemPublicKey_15 pk; |
467 | | } libcrux_ml_kem_mlkem768_MlKem768KeyPair; |
468 | | |
469 | | /** |
470 | | Create a new [`MlKemKeyPair`] from the secret and public key. |
471 | | */ |
472 | | /** |
473 | | This function found in impl |
474 | | {libcrux_ml_kem::types::MlKemKeyPair<PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE>} |
475 | | */ |
476 | | /** |
477 | | A monomorphic instance of libcrux_ml_kem.types.from_17 |
478 | | with const generics |
479 | | - PRIVATE_KEY_SIZE= 2400 |
480 | | - PUBLIC_KEY_SIZE= 1184 |
481 | | */ |
482 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
483 | | libcrux_ml_kem_types_from_17_35(libcrux_ml_kem_types_MlKemPrivateKey_55 sk, |
484 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 pk) { |
485 | 0 | return ( |
486 | 0 | CLITERAL(libcrux_ml_kem_mlkem768_MlKem768KeyPair){.sk = sk, .pk = pk}); |
487 | 0 | } |
488 | | |
489 | | /** |
490 | | This function found in impl {(core::convert::From<@Array<u8, SIZE>> for |
491 | | libcrux_ml_kem::types::MlKemPrivateKey<SIZE>)#8} |
492 | | */ |
493 | | /** |
494 | | A monomorphic instance of libcrux_ml_kem.types.from_05 |
495 | | with const generics |
496 | | - SIZE= 2400 |
497 | | */ |
498 | | static inline libcrux_ml_kem_types_MlKemPrivateKey_55 |
499 | 0 | libcrux_ml_kem_types_from_05_f2(uint8_t value[2400U]) { |
500 | | /* Passing arrays by value in Rust generates a copy in C */ |
501 | 0 | uint8_t copy_of_value[2400U]; |
502 | 0 | memcpy(copy_of_value, value, (size_t)2400U * sizeof(uint8_t)); |
503 | 0 | libcrux_ml_kem_types_MlKemPrivateKey_55 lit; |
504 | 0 | memcpy(lit.value, copy_of_value, (size_t)2400U * sizeof(uint8_t)); |
505 | 0 | return lit; |
506 | 0 | } |
507 | | |
508 | | /** |
509 | | A monomorphic instance of core.result.Result |
510 | | with types uint8_t[32size_t], core_array_TryFromSliceError |
511 | | |
512 | | */ |
513 | | typedef struct Result_00_s { |
514 | | Result_86_tags tag; |
515 | | union { |
516 | | uint8_t case_Ok[32U]; |
517 | | TryFromSliceError case_Err; |
518 | | } val; |
519 | | } Result_00; |
520 | | |
521 | | /** |
522 | | This function found in impl {core::result::Result<T, E>} |
523 | | */ |
524 | | /** |
525 | | A monomorphic instance of core.result.unwrap_41 |
526 | | with types uint8_t[32size_t], core_array_TryFromSliceError |
527 | | |
528 | | */ |
529 | 0 | static inline void unwrap_41_83(Result_00 self, uint8_t ret[32U]) { |
530 | 0 | if (self.tag == Ok) { |
531 | 0 | uint8_t f0[32U]; |
532 | 0 | memcpy(f0, self.val.case_Ok, (size_t)32U * sizeof(uint8_t)); |
533 | 0 | memcpy(ret, f0, (size_t)32U * sizeof(uint8_t)); |
534 | 0 | } else { |
535 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
536 | 0 | "unwrap not Ok"); |
537 | 0 | KRML_HOST_EXIT(255U); |
538 | 0 | } |
539 | 0 | } |
540 | | |
541 | | /** |
542 | | A monomorphic instance of K. |
543 | | with types libcrux_ml_kem_types_MlKemCiphertext[[$1088size_t]], |
544 | | uint8_t[32size_t] |
545 | | |
546 | | */ |
547 | | typedef struct tuple_3c_s { |
548 | | libcrux_ml_kem_mlkem768_MlKem768Ciphertext fst; |
549 | | uint8_t snd[32U]; |
550 | | } tuple_3c; |
551 | | |
552 | | /** |
553 | | This function found in impl {(core::convert::From<@Array<u8, SIZE>> for |
554 | | libcrux_ml_kem::types::MlKemCiphertext<SIZE>)#2} |
555 | | */ |
556 | | /** |
557 | | A monomorphic instance of libcrux_ml_kem.types.from_01 |
558 | | with const generics |
559 | | - SIZE= 1088 |
560 | | */ |
561 | | static inline libcrux_ml_kem_mlkem768_MlKem768Ciphertext |
562 | 0 | libcrux_ml_kem_types_from_01_9f(uint8_t value[1088U]) { |
563 | | /* Passing arrays by value in Rust generates a copy in C */ |
564 | 0 | uint8_t copy_of_value[1088U]; |
565 | 0 | memcpy(copy_of_value, value, (size_t)1088U * sizeof(uint8_t)); |
566 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext lit; |
567 | 0 | memcpy(lit.value, copy_of_value, (size_t)1088U * sizeof(uint8_t)); |
568 | 0 | return lit; |
569 | 0 | } |
570 | | |
571 | | /** |
572 | | A reference to the raw byte slice. |
573 | | */ |
574 | | /** |
575 | | This function found in impl {libcrux_ml_kem::types::MlKemPublicKey<SIZE>#18} |
576 | | */ |
577 | | /** |
578 | | A monomorphic instance of libcrux_ml_kem.types.as_slice_cb |
579 | | with const generics |
580 | | - SIZE= 1184 |
581 | | */ |
582 | | static inline uint8_t *libcrux_ml_kem_types_as_slice_cb_50( |
583 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 *self) { |
584 | 0 | return self->value; |
585 | 0 | } |
586 | | |
587 | | /** |
588 | | Pad the `slice` with `0`s at the end. |
589 | | */ |
590 | | /** |
591 | | A monomorphic instance of libcrux_ml_kem.utils.into_padded_array |
592 | | with const generics |
593 | | - LEN= 33 |
594 | | */ |
595 | | static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea2( |
596 | 0 | Eurydice_slice slice, uint8_t ret[33U]) { |
597 | 0 | uint8_t out[33U] = {0U}; |
598 | 0 | uint8_t *uu____0 = out; |
599 | 0 | Eurydice_slice_copy( |
600 | 0 | Eurydice_array_to_subslice2(uu____0, (size_t)0U, |
601 | 0 | Eurydice_slice_len(slice, uint8_t), uint8_t), |
602 | 0 | slice, uint8_t); |
603 | 0 | memcpy(ret, out, (size_t)33U * sizeof(uint8_t)); |
604 | 0 | } |
605 | | |
606 | | /** |
607 | | Pad the `slice` with `0`s at the end. |
608 | | */ |
609 | | /** |
610 | | A monomorphic instance of libcrux_ml_kem.utils.into_padded_array |
611 | | with const generics |
612 | | - LEN= 34 |
613 | | */ |
614 | | static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea1( |
615 | 0 | Eurydice_slice slice, uint8_t ret[34U]) { |
616 | 0 | uint8_t out[34U] = {0U}; |
617 | 0 | uint8_t *uu____0 = out; |
618 | 0 | Eurydice_slice_copy( |
619 | 0 | Eurydice_array_to_subslice2(uu____0, (size_t)0U, |
620 | 0 | Eurydice_slice_len(slice, uint8_t), uint8_t), |
621 | 0 | slice, uint8_t); |
622 | 0 | memcpy(ret, out, (size_t)34U * sizeof(uint8_t)); |
623 | 0 | } |
624 | | |
625 | | /** |
626 | | This function found in impl {(core::convert::AsRef<@Slice<u8>> for |
627 | | libcrux_ml_kem::types::MlKemCiphertext<SIZE>)#1} |
628 | | */ |
629 | | /** |
630 | | A monomorphic instance of libcrux_ml_kem.types.as_ref_00 |
631 | | with const generics |
632 | | - SIZE= 1088 |
633 | | */ |
634 | | static inline Eurydice_slice libcrux_ml_kem_types_as_ref_00_24( |
635 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *self) { |
636 | 0 | return Eurydice_array_to_slice((size_t)1088U, self->value, uint8_t); |
637 | 0 | } |
638 | | |
639 | | /** |
640 | | Pad the `slice` with `0`s at the end. |
641 | | */ |
642 | | /** |
643 | | A monomorphic instance of libcrux_ml_kem.utils.into_padded_array |
644 | | with const generics |
645 | | - LEN= 1120 |
646 | | */ |
647 | | static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea0( |
648 | 0 | Eurydice_slice slice, uint8_t ret[1120U]) { |
649 | 0 | uint8_t out[1120U] = {0U}; |
650 | 0 | uint8_t *uu____0 = out; |
651 | 0 | Eurydice_slice_copy( |
652 | 0 | Eurydice_array_to_subslice2(uu____0, (size_t)0U, |
653 | 0 | Eurydice_slice_len(slice, uint8_t), uint8_t), |
654 | 0 | slice, uint8_t); |
655 | 0 | memcpy(ret, out, (size_t)1120U * sizeof(uint8_t)); |
656 | 0 | } |
657 | | |
658 | | /** |
659 | | Pad the `slice` with `0`s at the end. |
660 | | */ |
661 | | /** |
662 | | A monomorphic instance of libcrux_ml_kem.utils.into_padded_array |
663 | | with const generics |
664 | | - LEN= 64 |
665 | | */ |
666 | | static KRML_MUSTINLINE void libcrux_ml_kem_utils_into_padded_array_ea( |
667 | 0 | Eurydice_slice slice, uint8_t ret[64U]) { |
668 | 0 | uint8_t out[64U] = {0U}; |
669 | 0 | uint8_t *uu____0 = out; |
670 | 0 | Eurydice_slice_copy( |
671 | 0 | Eurydice_array_to_subslice2(uu____0, (size_t)0U, |
672 | 0 | Eurydice_slice_len(slice, uint8_t), uint8_t), |
673 | 0 | slice, uint8_t); |
674 | 0 | memcpy(ret, out, (size_t)64U * sizeof(uint8_t)); |
675 | 0 | } |
676 | | |
677 | | /** |
678 | | A monomorphic instance of core.result.Result |
679 | | with types int16_t[16size_t], core_array_TryFromSliceError |
680 | | |
681 | | */ |
682 | | typedef struct Result_c0_s { |
683 | | Result_86_tags tag; |
684 | | union { |
685 | | int16_t case_Ok[16U]; |
686 | | TryFromSliceError case_Err; |
687 | | } val; |
688 | | } Result_c0; |
689 | | |
690 | | /** |
691 | | This function found in impl {core::result::Result<T, E>} |
692 | | */ |
693 | | /** |
694 | | A monomorphic instance of core.result.unwrap_41 |
695 | | with types int16_t[16size_t], core_array_TryFromSliceError |
696 | | |
697 | | */ |
698 | 0 | static inline void unwrap_41_f9(Result_c0 self, int16_t ret[16U]) { |
699 | 0 | if (self.tag == Ok) { |
700 | 0 | int16_t f0[16U]; |
701 | 0 | memcpy(f0, self.val.case_Ok, (size_t)16U * sizeof(int16_t)); |
702 | 0 | memcpy(ret, f0, (size_t)16U * sizeof(int16_t)); |
703 | 0 | } else { |
704 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
705 | 0 | "unwrap not Ok"); |
706 | 0 | KRML_HOST_EXIT(255U); |
707 | 0 | } |
708 | 0 | } |
709 | | |
710 | | /** |
711 | | A monomorphic instance of core.result.Result |
712 | | with types uint8_t[8size_t], core_array_TryFromSliceError |
713 | | |
714 | | */ |
715 | | typedef struct Result_56_s { |
716 | | Result_86_tags tag; |
717 | | union { |
718 | | uint8_t case_Ok[8U]; |
719 | | TryFromSliceError case_Err; |
720 | | } val; |
721 | | } Result_56; |
722 | | |
723 | | /** |
724 | | This function found in impl {core::result::Result<T, E>} |
725 | | */ |
726 | | /** |
727 | | A monomorphic instance of core.result.unwrap_41 |
728 | | with types uint8_t[8size_t], core_array_TryFromSliceError |
729 | | |
730 | | */ |
731 | 0 | static inline void unwrap_41_ac(Result_56 self, uint8_t ret[8U]) { |
732 | 0 | if (self.tag == Ok) { |
733 | 0 | uint8_t f0[8U]; |
734 | 0 | memcpy(f0, self.val.case_Ok, (size_t)8U * sizeof(uint8_t)); |
735 | 0 | memcpy(ret, f0, (size_t)8U * sizeof(uint8_t)); |
736 | 0 | } else { |
737 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
738 | 0 | "unwrap not Ok"); |
739 | 0 | KRML_HOST_EXIT(255U); |
740 | 0 | } |
741 | 0 | } |
742 | | |
743 | | typedef struct Eurydice_slice_uint8_t_x2_s { |
744 | | Eurydice_slice fst; |
745 | | Eurydice_slice snd; |
746 | | } Eurydice_slice_uint8_t_x2; |
747 | | |
748 | | typedef struct Eurydice_slice_uint8_t_1size_t__x2_s { |
749 | | Eurydice_slice fst[1U]; |
750 | | Eurydice_slice snd[1U]; |
751 | | } Eurydice_slice_uint8_t_1size_t__x2; |
752 | | |
753 | | #if defined(__cplusplus) |
754 | | } |
755 | | #endif |
756 | | |
757 | | #define __libcrux_core_H_DEFINED |
758 | | #endif |
759 | | |
760 | | /* from libcrux/libcrux-ml-kem/cg/libcrux_ct_ops.h */ |
761 | | /* |
762 | | * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com> |
763 | | * |
764 | | * SPDX-License-Identifier: MIT or Apache-2.0 |
765 | | * |
766 | | * This code was generated with the following revisions: |
767 | | * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4 |
768 | | * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb |
769 | | * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908 |
770 | | * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty |
771 | | * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee |
772 | | */ |
773 | | |
774 | | #ifndef __libcrux_ct_ops_H |
775 | | #define __libcrux_ct_ops_H |
776 | | |
777 | | #if defined(__cplusplus) |
778 | | extern "C" { |
779 | | #endif |
780 | | |
781 | | |
782 | | /** |
783 | | Return 1 if `value` is not zero and 0 otherwise. |
784 | | */ |
785 | 0 | static inline uint8_t libcrux_ml_kem_constant_time_ops_inz(uint8_t value) { |
786 | 0 | uint16_t value0 = (uint16_t)value; |
787 | 0 | uint16_t result = (((uint32_t)value0 | |
788 | 0 | (uint32_t)core_num__u16_7__wrapping_add(~value0, 1U)) & |
789 | 0 | 0xFFFFU) >> |
790 | 0 | 8U & |
791 | 0 | 1U; |
792 | 0 | return (uint8_t)result; |
793 | 0 | } |
794 | | |
795 | | static KRML_NOINLINE uint8_t |
796 | 0 | libcrux_ml_kem_constant_time_ops_is_non_zero(uint8_t value) { |
797 | 0 | return libcrux_ml_kem_constant_time_ops_inz(value); |
798 | 0 | } |
799 | | |
800 | | /** |
801 | | Return 1 if the bytes of `lhs` and `rhs` do not exactly |
802 | | match and 0 otherwise. |
803 | | */ |
804 | | static inline uint8_t libcrux_ml_kem_constant_time_ops_compare( |
805 | 0 | Eurydice_slice lhs, Eurydice_slice rhs) { |
806 | 0 | uint8_t r = 0U; |
807 | 0 | for (size_t i = (size_t)0U; i < Eurydice_slice_len(lhs, uint8_t); i++) { |
808 | 0 | size_t i0 = i; |
809 | 0 | r = (uint32_t)r | |
810 | 0 | ((uint32_t)Eurydice_slice_index(lhs, i0, uint8_t, uint8_t *) ^ |
811 | 0 | (uint32_t)Eurydice_slice_index(rhs, i0, uint8_t, uint8_t *)); |
812 | 0 | } |
813 | 0 | return libcrux_ml_kem_constant_time_ops_is_non_zero(r); |
814 | 0 | } |
815 | | |
816 | | static KRML_NOINLINE uint8_t |
817 | | libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time( |
818 | 0 | Eurydice_slice lhs, Eurydice_slice rhs) { |
819 | 0 | return libcrux_ml_kem_constant_time_ops_compare(lhs, rhs); |
820 | 0 | } |
821 | | |
822 | | /** |
823 | | If `selector` is not zero, return the bytes in `rhs`; return the bytes in |
824 | | `lhs` otherwise. |
825 | | */ |
826 | | static inline void libcrux_ml_kem_constant_time_ops_select_ct( |
827 | | Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector, |
828 | 0 | uint8_t ret[32U]) { |
829 | 0 | uint8_t mask = core_num__u8_6__wrapping_sub( |
830 | 0 | libcrux_ml_kem_constant_time_ops_is_non_zero(selector), 1U); |
831 | 0 | uint8_t out[32U] = {0U}; |
832 | 0 | for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE; |
833 | 0 | i++) { |
834 | 0 | size_t i0 = i; |
835 | 0 | out[i0] = ((uint32_t)Eurydice_slice_index(lhs, i0, uint8_t, uint8_t *) & |
836 | 0 | (uint32_t)mask) | |
837 | 0 | ((uint32_t)Eurydice_slice_index(rhs, i0, uint8_t, uint8_t *) & |
838 | 0 | (uint32_t)~mask); |
839 | 0 | } |
840 | 0 | memcpy(ret, out, (size_t)32U * sizeof(uint8_t)); |
841 | 0 | } |
842 | | |
843 | | static KRML_NOINLINE void |
844 | | libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time( |
845 | | Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector, |
846 | 0 | uint8_t ret[32U]) { |
847 | 0 | libcrux_ml_kem_constant_time_ops_select_ct(lhs, rhs, selector, ret); |
848 | 0 | } |
849 | | |
850 | | static inline void |
851 | | libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time( |
852 | | Eurydice_slice lhs_c, Eurydice_slice rhs_c, Eurydice_slice lhs_s, |
853 | 0 | Eurydice_slice rhs_s, uint8_t ret[32U]) { |
854 | 0 | uint8_t selector = |
855 | 0 | libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time( |
856 | 0 | lhs_c, rhs_c); |
857 | 0 | uint8_t ret0[32U]; |
858 | 0 | libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time( |
859 | 0 | lhs_s, rhs_s, selector, ret0); |
860 | 0 | memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t)); |
861 | 0 | } |
862 | | |
863 | | #if defined(__cplusplus) |
864 | | } |
865 | | #endif |
866 | | |
867 | | #define __libcrux_ct_ops_H_DEFINED |
868 | | #endif |
869 | | |
870 | | /* from libcrux/libcrux-ml-kem/cg/libcrux_sha3_portable.h */ |
871 | | /* |
872 | | * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com> |
873 | | * |
874 | | * SPDX-License-Identifier: MIT or Apache-2.0 |
875 | | * |
876 | | * This code was generated with the following revisions: |
877 | | * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4 |
878 | | * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb |
879 | | * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908 |
880 | | * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty |
881 | | * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee |
882 | | */ |
883 | | |
884 | | #ifndef __libcrux_sha3_portable_H |
885 | | #define __libcrux_sha3_portable_H |
886 | | |
887 | | #if defined(__cplusplus) |
888 | | extern "C" { |
889 | | #endif |
890 | | |
891 | | |
892 | | static const uint64_t libcrux_sha3_generic_keccak_ROUNDCONSTANTS[24U] = { |
893 | | 1ULL, |
894 | | 32898ULL, |
895 | | 9223372036854808714ULL, |
896 | | 9223372039002292224ULL, |
897 | | 32907ULL, |
898 | | 2147483649ULL, |
899 | | 9223372039002292353ULL, |
900 | | 9223372036854808585ULL, |
901 | | 138ULL, |
902 | | 136ULL, |
903 | | 2147516425ULL, |
904 | | 2147483658ULL, |
905 | | 2147516555ULL, |
906 | | 9223372036854775947ULL, |
907 | | 9223372036854808713ULL, |
908 | | 9223372036854808579ULL, |
909 | | 9223372036854808578ULL, |
910 | | 9223372036854775936ULL, |
911 | | 32778ULL, |
912 | | 9223372039002259466ULL, |
913 | | 9223372039002292353ULL, |
914 | | 9223372036854808704ULL, |
915 | | 2147483649ULL, |
916 | | 9223372039002292232ULL}; |
917 | | |
918 | | /** |
919 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
920 | | usize> for u64)} |
921 | | */ |
922 | 0 | static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_zero_5a(void) { |
923 | 0 | return 0ULL; |
924 | 0 | } |
925 | | |
926 | | static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak__veor5q_u64( |
927 | 0 | uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) { |
928 | 0 | uint64_t ab = a ^ b; |
929 | 0 | uint64_t cd = c ^ d; |
930 | 0 | uint64_t abcd = ab ^ cd; |
931 | 0 | return abcd ^ e; |
932 | 0 | } |
933 | | |
934 | | /** |
935 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
936 | | usize> for u64)} |
937 | | */ |
938 | | static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_xor5_5a( |
939 | 0 | uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) { |
940 | 0 | return libcrux_sha3_portable_keccak__veor5q_u64(a, b, c, d, e); |
941 | 0 | } |
942 | | |
943 | | /** |
944 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
945 | | with const generics |
946 | | - LEFT= 1 |
947 | | - RIGHT= 63 |
948 | | */ |
949 | | static KRML_MUSTINLINE uint64_t |
950 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb(uint64_t x) { |
951 | 0 | return x << (uint32_t)(int32_t)1 | x >> (uint32_t)(int32_t)63; |
952 | 0 | } |
953 | | |
954 | | static KRML_MUSTINLINE uint64_t |
955 | 0 | libcrux_sha3_portable_keccak__vrax1q_u64(uint64_t a, uint64_t b) { |
956 | 0 | uint64_t uu____0 = a; |
957 | 0 | return uu____0 ^ libcrux_sha3_portable_keccak_rotate_left_cb(b); |
958 | 0 | } |
959 | | |
960 | | /** |
961 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
962 | | usize> for u64)} |
963 | | */ |
964 | | static KRML_MUSTINLINE uint64_t |
965 | 0 | libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(uint64_t a, uint64_t b) { |
966 | 0 | return libcrux_sha3_portable_keccak__vrax1q_u64(a, b); |
967 | 0 | } |
968 | | |
969 | | static KRML_MUSTINLINE uint64_t |
970 | 0 | libcrux_sha3_portable_keccak__vbcaxq_u64(uint64_t a, uint64_t b, uint64_t c) { |
971 | 0 | return a ^ (b & ~c); |
972 | 0 | } |
973 | | |
974 | | /** |
975 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
976 | | usize> for u64)} |
977 | | */ |
978 | | static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_and_not_xor_5a( |
979 | 0 | uint64_t a, uint64_t b, uint64_t c) { |
980 | 0 | return libcrux_sha3_portable_keccak__vbcaxq_u64(a, b, c); |
981 | 0 | } |
982 | | |
983 | | static KRML_MUSTINLINE uint64_t |
984 | 0 | libcrux_sha3_portable_keccak__veorq_n_u64(uint64_t a, uint64_t c) { |
985 | 0 | return a ^ c; |
986 | 0 | } |
987 | | |
988 | | /** |
989 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
990 | | usize> for u64)} |
991 | | */ |
992 | | static KRML_MUSTINLINE uint64_t |
993 | 0 | libcrux_sha3_portable_keccak_xor_constant_5a(uint64_t a, uint64_t c) { |
994 | 0 | return libcrux_sha3_portable_keccak__veorq_n_u64(a, c); |
995 | 0 | } |
996 | | |
997 | | /** |
998 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
999 | | usize> for u64)} |
1000 | | */ |
1001 | | static KRML_MUSTINLINE uint64_t |
1002 | 0 | libcrux_sha3_portable_keccak_xor_5a(uint64_t a, uint64_t b) { |
1003 | 0 | return a ^ b; |
1004 | 0 | } |
1005 | | |
1006 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_slice_1( |
1007 | 0 | Eurydice_slice a[1U], size_t start, size_t len, Eurydice_slice ret[1U]) { |
1008 | 0 | ret[0U] = Eurydice_slice_subslice2(a[0U], start, start + len, uint8_t); |
1009 | 0 | } |
1010 | | |
1011 | | /** |
1012 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1013 | | usize> for u64)} |
1014 | | */ |
1015 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_slice_n_5a( |
1016 | 0 | Eurydice_slice a[1U], size_t start, size_t len, Eurydice_slice ret[1U]) { |
1017 | | /* Passing arrays by value in Rust generates a copy in C */ |
1018 | 0 | Eurydice_slice copy_of_a[1U]; |
1019 | 0 | memcpy(copy_of_a, a, (size_t)1U * sizeof(Eurydice_slice)); |
1020 | 0 | Eurydice_slice ret0[1U]; |
1021 | 0 | libcrux_sha3_portable_keccak_slice_1(copy_of_a, start, len, ret0); |
1022 | 0 | memcpy(ret, ret0, (size_t)1U * sizeof(Eurydice_slice)); |
1023 | 0 | } |
1024 | | |
1025 | | static KRML_MUSTINLINE Eurydice_slice_uint8_t_1size_t__x2 |
1026 | | libcrux_sha3_portable_keccak_split_at_mut_1(Eurydice_slice out[1U], |
1027 | 0 | size_t mid) { |
1028 | 0 | Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at_mut( |
1029 | 0 | out[0U], mid, uint8_t, Eurydice_slice_uint8_t_x2); |
1030 | 0 | Eurydice_slice out00 = uu____0.fst; |
1031 | 0 | Eurydice_slice out01 = uu____0.snd; |
1032 | 0 | Eurydice_slice_uint8_t_1size_t__x2 lit; |
1033 | 0 | lit.fst[0U] = out00; |
1034 | 0 | lit.snd[0U] = out01; |
1035 | 0 | return lit; |
1036 | 0 | } |
1037 | | |
1038 | | /** |
1039 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1040 | | usize> for u64)} |
1041 | | */ |
1042 | | static KRML_MUSTINLINE Eurydice_slice_uint8_t_1size_t__x2 |
1043 | | libcrux_sha3_portable_keccak_split_at_mut_n_5a(Eurydice_slice a[1U], |
1044 | 0 | size_t mid) { |
1045 | 0 | return libcrux_sha3_portable_keccak_split_at_mut_1(a, mid); |
1046 | 0 | } |
1047 | | |
1048 | | /** |
1049 | | A monomorphic instance of libcrux_sha3.generic_keccak.KeccakState |
1050 | | with types uint64_t |
1051 | | with const generics |
1052 | | - $1size_t |
1053 | | */ |
1054 | | typedef struct libcrux_sha3_generic_keccak_KeccakState_48_s { |
1055 | | uint64_t st[5U][5U]; |
1056 | | } libcrux_sha3_generic_keccak_KeccakState_48; |
1057 | | |
1058 | | /** |
1059 | | Create a new Shake128 x4 state. |
1060 | | */ |
1061 | | /** |
1062 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakState<T, |
1063 | | N>[TraitClause@0]#1} |
1064 | | */ |
1065 | | /** |
1066 | | A monomorphic instance of libcrux_sha3.generic_keccak.new_1e |
1067 | | with types uint64_t |
1068 | | with const generics |
1069 | | - N= 1 |
1070 | | */ |
1071 | | static KRML_MUSTINLINE libcrux_sha3_generic_keccak_KeccakState_48 |
1072 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(void) { |
1073 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 lit; |
1074 | 0 | lit.st[0U][0U] = libcrux_sha3_portable_keccak_zero_5a(); |
1075 | 0 | lit.st[0U][1U] = libcrux_sha3_portable_keccak_zero_5a(); |
1076 | 0 | lit.st[0U][2U] = libcrux_sha3_portable_keccak_zero_5a(); |
1077 | 0 | lit.st[0U][3U] = libcrux_sha3_portable_keccak_zero_5a(); |
1078 | 0 | lit.st[0U][4U] = libcrux_sha3_portable_keccak_zero_5a(); |
1079 | 0 | lit.st[1U][0U] = libcrux_sha3_portable_keccak_zero_5a(); |
1080 | 0 | lit.st[1U][1U] = libcrux_sha3_portable_keccak_zero_5a(); |
1081 | 0 | lit.st[1U][2U] = libcrux_sha3_portable_keccak_zero_5a(); |
1082 | 0 | lit.st[1U][3U] = libcrux_sha3_portable_keccak_zero_5a(); |
1083 | 0 | lit.st[1U][4U] = libcrux_sha3_portable_keccak_zero_5a(); |
1084 | 0 | lit.st[2U][0U] = libcrux_sha3_portable_keccak_zero_5a(); |
1085 | 0 | lit.st[2U][1U] = libcrux_sha3_portable_keccak_zero_5a(); |
1086 | 0 | lit.st[2U][2U] = libcrux_sha3_portable_keccak_zero_5a(); |
1087 | 0 | lit.st[2U][3U] = libcrux_sha3_portable_keccak_zero_5a(); |
1088 | 0 | lit.st[2U][4U] = libcrux_sha3_portable_keccak_zero_5a(); |
1089 | 0 | lit.st[3U][0U] = libcrux_sha3_portable_keccak_zero_5a(); |
1090 | 0 | lit.st[3U][1U] = libcrux_sha3_portable_keccak_zero_5a(); |
1091 | 0 | lit.st[3U][2U] = libcrux_sha3_portable_keccak_zero_5a(); |
1092 | 0 | lit.st[3U][3U] = libcrux_sha3_portable_keccak_zero_5a(); |
1093 | 0 | lit.st[3U][4U] = libcrux_sha3_portable_keccak_zero_5a(); |
1094 | 0 | lit.st[4U][0U] = libcrux_sha3_portable_keccak_zero_5a(); |
1095 | 0 | lit.st[4U][1U] = libcrux_sha3_portable_keccak_zero_5a(); |
1096 | 0 | lit.st[4U][2U] = libcrux_sha3_portable_keccak_zero_5a(); |
1097 | 0 | lit.st[4U][3U] = libcrux_sha3_portable_keccak_zero_5a(); |
1098 | 0 | lit.st[4U][4U] = libcrux_sha3_portable_keccak_zero_5a(); |
1099 | 0 | return lit; |
1100 | 0 | } |
1101 | | |
1102 | | /** |
1103 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block |
1104 | | with const generics |
1105 | | - RATE= 72 |
1106 | | */ |
1107 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c( |
1108 | 0 | uint64_t (*s)[5U], Eurydice_slice blocks[1U]) { |
1109 | 0 | for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) { |
1110 | 0 | size_t i0 = i; |
1111 | 0 | uint8_t uu____0[8U]; |
1112 | 0 | Result_56 dst; |
1113 | 0 | Eurydice_slice_to_array2( |
1114 | 0 | &dst, |
1115 | 0 | Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0, |
1116 | 0 | (size_t)8U * i0 + (size_t)8U, uint8_t), |
1117 | 0 | Eurydice_slice, uint8_t[8U]); |
1118 | 0 | unwrap_41_ac(dst, uu____0); |
1119 | 0 | size_t uu____1 = i0 / (size_t)5U; |
1120 | 0 | size_t uu____2 = i0 % (size_t)5U; |
1121 | 0 | s[uu____1][uu____2] = |
1122 | 0 | s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0); |
1123 | 0 | } |
1124 | 0 | } |
1125 | | |
1126 | | /** |
1127 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1128 | | usize> for u64)} |
1129 | | */ |
1130 | | /** |
1131 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a |
1132 | | with const generics |
1133 | | - RATE= 72 |
1134 | | */ |
1135 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b8( |
1136 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
1137 | 0 | uint64_t(*uu____0)[5U] = a; |
1138 | | /* Passing arrays by value in Rust generates a copy in C */ |
1139 | 0 | Eurydice_slice copy_of_b[1U]; |
1140 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice)); |
1141 | 0 | libcrux_sha3_portable_keccak_load_block_2c(uu____0, copy_of_b); |
1142 | 0 | } |
1143 | | |
1144 | | /** |
1145 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1146 | | with const generics |
1147 | | - LEFT= 36 |
1148 | | - RIGHT= 28 |
1149 | | */ |
1150 | | static KRML_MUSTINLINE uint64_t |
1151 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb0(uint64_t x) { |
1152 | 0 | return x << (uint32_t)(int32_t)36 | x >> (uint32_t)(int32_t)28; |
1153 | 0 | } |
1154 | | |
1155 | | /** |
1156 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1157 | | with const generics |
1158 | | - LEFT= 36 |
1159 | | - RIGHT= 28 |
1160 | | */ |
1161 | | static KRML_MUSTINLINE uint64_t |
1162 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_42(uint64_t a, uint64_t b) { |
1163 | 0 | uint64_t ab = a ^ b; |
1164 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb0(ab); |
1165 | 0 | } |
1166 | | |
1167 | | /** |
1168 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1169 | | usize> for u64)} |
1170 | | */ |
1171 | | /** |
1172 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1173 | | with const generics |
1174 | | - LEFT= 36 |
1175 | | - RIGHT= 28 |
1176 | | */ |
1177 | | static KRML_MUSTINLINE uint64_t |
1178 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb(uint64_t a, uint64_t b) { |
1179 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_42(a, b); |
1180 | 0 | } |
1181 | | |
1182 | | /** |
1183 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1184 | | with const generics |
1185 | | - LEFT= 3 |
1186 | | - RIGHT= 61 |
1187 | | */ |
1188 | | static KRML_MUSTINLINE uint64_t |
1189 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb1(uint64_t x) { |
1190 | 0 | return x << (uint32_t)(int32_t)3 | x >> (uint32_t)(int32_t)61; |
1191 | 0 | } |
1192 | | |
1193 | | /** |
1194 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1195 | | with const generics |
1196 | | - LEFT= 3 |
1197 | | - RIGHT= 61 |
1198 | | */ |
1199 | | static KRML_MUSTINLINE uint64_t |
1200 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_420(uint64_t a, uint64_t b) { |
1201 | 0 | uint64_t ab = a ^ b; |
1202 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb1(ab); |
1203 | 0 | } |
1204 | | |
1205 | | /** |
1206 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1207 | | usize> for u64)} |
1208 | | */ |
1209 | | /** |
1210 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1211 | | with const generics |
1212 | | - LEFT= 3 |
1213 | | - RIGHT= 61 |
1214 | | */ |
1215 | | static KRML_MUSTINLINE uint64_t |
1216 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0(uint64_t a, uint64_t b) { |
1217 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_420(a, b); |
1218 | 0 | } |
1219 | | |
1220 | | /** |
1221 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1222 | | with const generics |
1223 | | - LEFT= 41 |
1224 | | - RIGHT= 23 |
1225 | | */ |
1226 | | static KRML_MUSTINLINE uint64_t |
1227 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb2(uint64_t x) { |
1228 | 0 | return x << (uint32_t)(int32_t)41 | x >> (uint32_t)(int32_t)23; |
1229 | 0 | } |
1230 | | |
1231 | | /** |
1232 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1233 | | with const generics |
1234 | | - LEFT= 41 |
1235 | | - RIGHT= 23 |
1236 | | */ |
1237 | | static KRML_MUSTINLINE uint64_t |
1238 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_421(uint64_t a, uint64_t b) { |
1239 | 0 | uint64_t ab = a ^ b; |
1240 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb2(ab); |
1241 | 0 | } |
1242 | | |
1243 | | /** |
1244 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1245 | | usize> for u64)} |
1246 | | */ |
1247 | | /** |
1248 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1249 | | with const generics |
1250 | | - LEFT= 41 |
1251 | | - RIGHT= 23 |
1252 | | */ |
1253 | | static KRML_MUSTINLINE uint64_t |
1254 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1(uint64_t a, uint64_t b) { |
1255 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_421(a, b); |
1256 | 0 | } |
1257 | | |
1258 | | /** |
1259 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1260 | | with const generics |
1261 | | - LEFT= 18 |
1262 | | - RIGHT= 46 |
1263 | | */ |
1264 | | static KRML_MUSTINLINE uint64_t |
1265 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb3(uint64_t x) { |
1266 | 0 | return x << (uint32_t)(int32_t)18 | x >> (uint32_t)(int32_t)46; |
1267 | 0 | } |
1268 | | |
1269 | | /** |
1270 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1271 | | with const generics |
1272 | | - LEFT= 18 |
1273 | | - RIGHT= 46 |
1274 | | */ |
1275 | | static KRML_MUSTINLINE uint64_t |
1276 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_422(uint64_t a, uint64_t b) { |
1277 | 0 | uint64_t ab = a ^ b; |
1278 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb3(ab); |
1279 | 0 | } |
1280 | | |
1281 | | /** |
1282 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1283 | | usize> for u64)} |
1284 | | */ |
1285 | | /** |
1286 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1287 | | with const generics |
1288 | | - LEFT= 18 |
1289 | | - RIGHT= 46 |
1290 | | */ |
1291 | | static KRML_MUSTINLINE uint64_t |
1292 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2(uint64_t a, uint64_t b) { |
1293 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_422(a, b); |
1294 | 0 | } |
1295 | | |
1296 | | /** |
1297 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1298 | | with const generics |
1299 | | - LEFT= 1 |
1300 | | - RIGHT= 63 |
1301 | | */ |
1302 | | static KRML_MUSTINLINE uint64_t |
1303 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_423(uint64_t a, uint64_t b) { |
1304 | 0 | uint64_t ab = a ^ b; |
1305 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb(ab); |
1306 | 0 | } |
1307 | | |
1308 | | /** |
1309 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1310 | | usize> for u64)} |
1311 | | */ |
1312 | | /** |
1313 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1314 | | with const generics |
1315 | | - LEFT= 1 |
1316 | | - RIGHT= 63 |
1317 | | */ |
1318 | | static KRML_MUSTINLINE uint64_t |
1319 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3(uint64_t a, uint64_t b) { |
1320 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_423(a, b); |
1321 | 0 | } |
1322 | | |
1323 | | /** |
1324 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1325 | | with const generics |
1326 | | - LEFT= 44 |
1327 | | - RIGHT= 20 |
1328 | | */ |
1329 | | static KRML_MUSTINLINE uint64_t |
1330 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb4(uint64_t x) { |
1331 | 0 | return x << (uint32_t)(int32_t)44 | x >> (uint32_t)(int32_t)20; |
1332 | 0 | } |
1333 | | |
1334 | | /** |
1335 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1336 | | with const generics |
1337 | | - LEFT= 44 |
1338 | | - RIGHT= 20 |
1339 | | */ |
1340 | | static KRML_MUSTINLINE uint64_t |
1341 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_424(uint64_t a, uint64_t b) { |
1342 | 0 | uint64_t ab = a ^ b; |
1343 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb4(ab); |
1344 | 0 | } |
1345 | | |
1346 | | /** |
1347 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1348 | | usize> for u64)} |
1349 | | */ |
1350 | | /** |
1351 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1352 | | with const generics |
1353 | | - LEFT= 44 |
1354 | | - RIGHT= 20 |
1355 | | */ |
1356 | | static KRML_MUSTINLINE uint64_t |
1357 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4(uint64_t a, uint64_t b) { |
1358 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_424(a, b); |
1359 | 0 | } |
1360 | | |
1361 | | /** |
1362 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1363 | | with const generics |
1364 | | - LEFT= 10 |
1365 | | - RIGHT= 54 |
1366 | | */ |
1367 | | static KRML_MUSTINLINE uint64_t |
1368 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb5(uint64_t x) { |
1369 | 0 | return x << (uint32_t)(int32_t)10 | x >> (uint32_t)(int32_t)54; |
1370 | 0 | } |
1371 | | |
1372 | | /** |
1373 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1374 | | with const generics |
1375 | | - LEFT= 10 |
1376 | | - RIGHT= 54 |
1377 | | */ |
1378 | | static KRML_MUSTINLINE uint64_t |
1379 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_425(uint64_t a, uint64_t b) { |
1380 | 0 | uint64_t ab = a ^ b; |
1381 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb5(ab); |
1382 | 0 | } |
1383 | | |
1384 | | /** |
1385 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1386 | | usize> for u64)} |
1387 | | */ |
1388 | | /** |
1389 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1390 | | with const generics |
1391 | | - LEFT= 10 |
1392 | | - RIGHT= 54 |
1393 | | */ |
1394 | | static KRML_MUSTINLINE uint64_t |
1395 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5(uint64_t a, uint64_t b) { |
1396 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_425(a, b); |
1397 | 0 | } |
1398 | | |
1399 | | /** |
1400 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1401 | | with const generics |
1402 | | - LEFT= 45 |
1403 | | - RIGHT= 19 |
1404 | | */ |
1405 | | static KRML_MUSTINLINE uint64_t |
1406 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb6(uint64_t x) { |
1407 | 0 | return x << (uint32_t)(int32_t)45 | x >> (uint32_t)(int32_t)19; |
1408 | 0 | } |
1409 | | |
1410 | | /** |
1411 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1412 | | with const generics |
1413 | | - LEFT= 45 |
1414 | | - RIGHT= 19 |
1415 | | */ |
1416 | | static KRML_MUSTINLINE uint64_t |
1417 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_426(uint64_t a, uint64_t b) { |
1418 | 0 | uint64_t ab = a ^ b; |
1419 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb6(ab); |
1420 | 0 | } |
1421 | | |
1422 | | /** |
1423 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1424 | | usize> for u64)} |
1425 | | */ |
1426 | | /** |
1427 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1428 | | with const generics |
1429 | | - LEFT= 45 |
1430 | | - RIGHT= 19 |
1431 | | */ |
1432 | | static KRML_MUSTINLINE uint64_t |
1433 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6(uint64_t a, uint64_t b) { |
1434 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_426(a, b); |
1435 | 0 | } |
1436 | | |
1437 | | /** |
1438 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1439 | | with const generics |
1440 | | - LEFT= 2 |
1441 | | - RIGHT= 62 |
1442 | | */ |
1443 | | static KRML_MUSTINLINE uint64_t |
1444 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb7(uint64_t x) { |
1445 | 0 | return x << (uint32_t)(int32_t)2 | x >> (uint32_t)(int32_t)62; |
1446 | 0 | } |
1447 | | |
1448 | | /** |
1449 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1450 | | with const generics |
1451 | | - LEFT= 2 |
1452 | | - RIGHT= 62 |
1453 | | */ |
1454 | | static KRML_MUSTINLINE uint64_t |
1455 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_427(uint64_t a, uint64_t b) { |
1456 | 0 | uint64_t ab = a ^ b; |
1457 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb7(ab); |
1458 | 0 | } |
1459 | | |
1460 | | /** |
1461 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1462 | | usize> for u64)} |
1463 | | */ |
1464 | | /** |
1465 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1466 | | with const generics |
1467 | | - LEFT= 2 |
1468 | | - RIGHT= 62 |
1469 | | */ |
1470 | | static KRML_MUSTINLINE uint64_t |
1471 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7(uint64_t a, uint64_t b) { |
1472 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_427(a, b); |
1473 | 0 | } |
1474 | | |
1475 | | /** |
1476 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1477 | | with const generics |
1478 | | - LEFT= 62 |
1479 | | - RIGHT= 2 |
1480 | | */ |
1481 | | static KRML_MUSTINLINE uint64_t |
1482 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb8(uint64_t x) { |
1483 | 0 | return x << (uint32_t)(int32_t)62 | x >> (uint32_t)(int32_t)2; |
1484 | 0 | } |
1485 | | |
1486 | | /** |
1487 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1488 | | with const generics |
1489 | | - LEFT= 62 |
1490 | | - RIGHT= 2 |
1491 | | */ |
1492 | | static KRML_MUSTINLINE uint64_t |
1493 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_428(uint64_t a, uint64_t b) { |
1494 | 0 | uint64_t ab = a ^ b; |
1495 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb8(ab); |
1496 | 0 | } |
1497 | | |
1498 | | /** |
1499 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1500 | | usize> for u64)} |
1501 | | */ |
1502 | | /** |
1503 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1504 | | with const generics |
1505 | | - LEFT= 62 |
1506 | | - RIGHT= 2 |
1507 | | */ |
1508 | | static KRML_MUSTINLINE uint64_t |
1509 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8(uint64_t a, uint64_t b) { |
1510 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_428(a, b); |
1511 | 0 | } |
1512 | | |
1513 | | /** |
1514 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1515 | | with const generics |
1516 | | - LEFT= 6 |
1517 | | - RIGHT= 58 |
1518 | | */ |
1519 | | static KRML_MUSTINLINE uint64_t |
1520 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb9(uint64_t x) { |
1521 | 0 | return x << (uint32_t)(int32_t)6 | x >> (uint32_t)(int32_t)58; |
1522 | 0 | } |
1523 | | |
1524 | | /** |
1525 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1526 | | with const generics |
1527 | | - LEFT= 6 |
1528 | | - RIGHT= 58 |
1529 | | */ |
1530 | | static KRML_MUSTINLINE uint64_t |
1531 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_429(uint64_t a, uint64_t b) { |
1532 | 0 | uint64_t ab = a ^ b; |
1533 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb9(ab); |
1534 | 0 | } |
1535 | | |
1536 | | /** |
1537 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1538 | | usize> for u64)} |
1539 | | */ |
1540 | | /** |
1541 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1542 | | with const generics |
1543 | | - LEFT= 6 |
1544 | | - RIGHT= 58 |
1545 | | */ |
1546 | | static KRML_MUSTINLINE uint64_t |
1547 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9(uint64_t a, uint64_t b) { |
1548 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_429(a, b); |
1549 | 0 | } |
1550 | | |
1551 | | /** |
1552 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1553 | | with const generics |
1554 | | - LEFT= 43 |
1555 | | - RIGHT= 21 |
1556 | | */ |
1557 | | static KRML_MUSTINLINE uint64_t |
1558 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb10(uint64_t x) { |
1559 | 0 | return x << (uint32_t)(int32_t)43 | x >> (uint32_t)(int32_t)21; |
1560 | 0 | } |
1561 | | |
1562 | | /** |
1563 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1564 | | with const generics |
1565 | | - LEFT= 43 |
1566 | | - RIGHT= 21 |
1567 | | */ |
1568 | | static KRML_MUSTINLINE uint64_t |
1569 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4210(uint64_t a, uint64_t b) { |
1570 | 0 | uint64_t ab = a ^ b; |
1571 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb10(ab); |
1572 | 0 | } |
1573 | | |
1574 | | /** |
1575 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1576 | | usize> for u64)} |
1577 | | */ |
1578 | | /** |
1579 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1580 | | with const generics |
1581 | | - LEFT= 43 |
1582 | | - RIGHT= 21 |
1583 | | */ |
1584 | | static KRML_MUSTINLINE uint64_t |
1585 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10(uint64_t a, uint64_t b) { |
1586 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4210(a, b); |
1587 | 0 | } |
1588 | | |
1589 | | /** |
1590 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1591 | | with const generics |
1592 | | - LEFT= 15 |
1593 | | - RIGHT= 49 |
1594 | | */ |
1595 | | static KRML_MUSTINLINE uint64_t |
1596 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb11(uint64_t x) { |
1597 | 0 | return x << (uint32_t)(int32_t)15 | x >> (uint32_t)(int32_t)49; |
1598 | 0 | } |
1599 | | |
1600 | | /** |
1601 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1602 | | with const generics |
1603 | | - LEFT= 15 |
1604 | | - RIGHT= 49 |
1605 | | */ |
1606 | | static KRML_MUSTINLINE uint64_t |
1607 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4211(uint64_t a, uint64_t b) { |
1608 | 0 | uint64_t ab = a ^ b; |
1609 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb11(ab); |
1610 | 0 | } |
1611 | | |
1612 | | /** |
1613 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1614 | | usize> for u64)} |
1615 | | */ |
1616 | | /** |
1617 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1618 | | with const generics |
1619 | | - LEFT= 15 |
1620 | | - RIGHT= 49 |
1621 | | */ |
1622 | | static KRML_MUSTINLINE uint64_t |
1623 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11(uint64_t a, uint64_t b) { |
1624 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4211(a, b); |
1625 | 0 | } |
1626 | | |
1627 | | /** |
1628 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1629 | | with const generics |
1630 | | - LEFT= 61 |
1631 | | - RIGHT= 3 |
1632 | | */ |
1633 | | static KRML_MUSTINLINE uint64_t |
1634 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb12(uint64_t x) { |
1635 | 0 | return x << (uint32_t)(int32_t)61 | x >> (uint32_t)(int32_t)3; |
1636 | 0 | } |
1637 | | |
1638 | | /** |
1639 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1640 | | with const generics |
1641 | | - LEFT= 61 |
1642 | | - RIGHT= 3 |
1643 | | */ |
1644 | | static KRML_MUSTINLINE uint64_t |
1645 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4212(uint64_t a, uint64_t b) { |
1646 | 0 | uint64_t ab = a ^ b; |
1647 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb12(ab); |
1648 | 0 | } |
1649 | | |
1650 | | /** |
1651 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1652 | | usize> for u64)} |
1653 | | */ |
1654 | | /** |
1655 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1656 | | with const generics |
1657 | | - LEFT= 61 |
1658 | | - RIGHT= 3 |
1659 | | */ |
1660 | | static KRML_MUSTINLINE uint64_t |
1661 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12(uint64_t a, uint64_t b) { |
1662 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4212(a, b); |
1663 | 0 | } |
1664 | | |
1665 | | /** |
1666 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1667 | | with const generics |
1668 | | - LEFT= 28 |
1669 | | - RIGHT= 36 |
1670 | | */ |
1671 | | static KRML_MUSTINLINE uint64_t |
1672 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb13(uint64_t x) { |
1673 | 0 | return x << (uint32_t)(int32_t)28 | x >> (uint32_t)(int32_t)36; |
1674 | 0 | } |
1675 | | |
1676 | | /** |
1677 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1678 | | with const generics |
1679 | | - LEFT= 28 |
1680 | | - RIGHT= 36 |
1681 | | */ |
1682 | | static KRML_MUSTINLINE uint64_t |
1683 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4213(uint64_t a, uint64_t b) { |
1684 | 0 | uint64_t ab = a ^ b; |
1685 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb13(ab); |
1686 | 0 | } |
1687 | | |
1688 | | /** |
1689 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1690 | | usize> for u64)} |
1691 | | */ |
1692 | | /** |
1693 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1694 | | with const generics |
1695 | | - LEFT= 28 |
1696 | | - RIGHT= 36 |
1697 | | */ |
1698 | | static KRML_MUSTINLINE uint64_t |
1699 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13(uint64_t a, uint64_t b) { |
1700 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4213(a, b); |
1701 | 0 | } |
1702 | | |
1703 | | /** |
1704 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1705 | | with const generics |
1706 | | - LEFT= 55 |
1707 | | - RIGHT= 9 |
1708 | | */ |
1709 | | static KRML_MUSTINLINE uint64_t |
1710 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb14(uint64_t x) { |
1711 | 0 | return x << (uint32_t)(int32_t)55 | x >> (uint32_t)(int32_t)9; |
1712 | 0 | } |
1713 | | |
1714 | | /** |
1715 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1716 | | with const generics |
1717 | | - LEFT= 55 |
1718 | | - RIGHT= 9 |
1719 | | */ |
1720 | | static KRML_MUSTINLINE uint64_t |
1721 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4214(uint64_t a, uint64_t b) { |
1722 | 0 | uint64_t ab = a ^ b; |
1723 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb14(ab); |
1724 | 0 | } |
1725 | | |
1726 | | /** |
1727 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1728 | | usize> for u64)} |
1729 | | */ |
1730 | | /** |
1731 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1732 | | with const generics |
1733 | | - LEFT= 55 |
1734 | | - RIGHT= 9 |
1735 | | */ |
1736 | | static KRML_MUSTINLINE uint64_t |
1737 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14(uint64_t a, uint64_t b) { |
1738 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4214(a, b); |
1739 | 0 | } |
1740 | | |
1741 | | /** |
1742 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1743 | | with const generics |
1744 | | - LEFT= 25 |
1745 | | - RIGHT= 39 |
1746 | | */ |
1747 | | static KRML_MUSTINLINE uint64_t |
1748 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb15(uint64_t x) { |
1749 | 0 | return x << (uint32_t)(int32_t)25 | x >> (uint32_t)(int32_t)39; |
1750 | 0 | } |
1751 | | |
1752 | | /** |
1753 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1754 | | with const generics |
1755 | | - LEFT= 25 |
1756 | | - RIGHT= 39 |
1757 | | */ |
1758 | | static KRML_MUSTINLINE uint64_t |
1759 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4215(uint64_t a, uint64_t b) { |
1760 | 0 | uint64_t ab = a ^ b; |
1761 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb15(ab); |
1762 | 0 | } |
1763 | | |
1764 | | /** |
1765 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1766 | | usize> for u64)} |
1767 | | */ |
1768 | | /** |
1769 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1770 | | with const generics |
1771 | | - LEFT= 25 |
1772 | | - RIGHT= 39 |
1773 | | */ |
1774 | | static KRML_MUSTINLINE uint64_t |
1775 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15(uint64_t a, uint64_t b) { |
1776 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4215(a, b); |
1777 | 0 | } |
1778 | | |
1779 | | /** |
1780 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1781 | | with const generics |
1782 | | - LEFT= 21 |
1783 | | - RIGHT= 43 |
1784 | | */ |
1785 | | static KRML_MUSTINLINE uint64_t |
1786 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb16(uint64_t x) { |
1787 | 0 | return x << (uint32_t)(int32_t)21 | x >> (uint32_t)(int32_t)43; |
1788 | 0 | } |
1789 | | |
1790 | | /** |
1791 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1792 | | with const generics |
1793 | | - LEFT= 21 |
1794 | | - RIGHT= 43 |
1795 | | */ |
1796 | | static KRML_MUSTINLINE uint64_t |
1797 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4216(uint64_t a, uint64_t b) { |
1798 | 0 | uint64_t ab = a ^ b; |
1799 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb16(ab); |
1800 | 0 | } |
1801 | | |
1802 | | /** |
1803 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1804 | | usize> for u64)} |
1805 | | */ |
1806 | | /** |
1807 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1808 | | with const generics |
1809 | | - LEFT= 21 |
1810 | | - RIGHT= 43 |
1811 | | */ |
1812 | | static KRML_MUSTINLINE uint64_t |
1813 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16(uint64_t a, uint64_t b) { |
1814 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4216(a, b); |
1815 | 0 | } |
1816 | | |
1817 | | /** |
1818 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1819 | | with const generics |
1820 | | - LEFT= 56 |
1821 | | - RIGHT= 8 |
1822 | | */ |
1823 | | static KRML_MUSTINLINE uint64_t |
1824 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb17(uint64_t x) { |
1825 | 0 | return x << (uint32_t)(int32_t)56 | x >> (uint32_t)(int32_t)8; |
1826 | 0 | } |
1827 | | |
1828 | | /** |
1829 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1830 | | with const generics |
1831 | | - LEFT= 56 |
1832 | | - RIGHT= 8 |
1833 | | */ |
1834 | | static KRML_MUSTINLINE uint64_t |
1835 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4217(uint64_t a, uint64_t b) { |
1836 | 0 | uint64_t ab = a ^ b; |
1837 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb17(ab); |
1838 | 0 | } |
1839 | | |
1840 | | /** |
1841 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1842 | | usize> for u64)} |
1843 | | */ |
1844 | | /** |
1845 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1846 | | with const generics |
1847 | | - LEFT= 56 |
1848 | | - RIGHT= 8 |
1849 | | */ |
1850 | | static KRML_MUSTINLINE uint64_t |
1851 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17(uint64_t a, uint64_t b) { |
1852 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4217(a, b); |
1853 | 0 | } |
1854 | | |
1855 | | /** |
1856 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1857 | | with const generics |
1858 | | - LEFT= 27 |
1859 | | - RIGHT= 37 |
1860 | | */ |
1861 | | static KRML_MUSTINLINE uint64_t |
1862 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb18(uint64_t x) { |
1863 | 0 | return x << (uint32_t)(int32_t)27 | x >> (uint32_t)(int32_t)37; |
1864 | 0 | } |
1865 | | |
1866 | | /** |
1867 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1868 | | with const generics |
1869 | | - LEFT= 27 |
1870 | | - RIGHT= 37 |
1871 | | */ |
1872 | | static KRML_MUSTINLINE uint64_t |
1873 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4218(uint64_t a, uint64_t b) { |
1874 | 0 | uint64_t ab = a ^ b; |
1875 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb18(ab); |
1876 | 0 | } |
1877 | | |
1878 | | /** |
1879 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1880 | | usize> for u64)} |
1881 | | */ |
1882 | | /** |
1883 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1884 | | with const generics |
1885 | | - LEFT= 27 |
1886 | | - RIGHT= 37 |
1887 | | */ |
1888 | | static KRML_MUSTINLINE uint64_t |
1889 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18(uint64_t a, uint64_t b) { |
1890 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4218(a, b); |
1891 | 0 | } |
1892 | | |
1893 | | /** |
1894 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1895 | | with const generics |
1896 | | - LEFT= 20 |
1897 | | - RIGHT= 44 |
1898 | | */ |
1899 | | static KRML_MUSTINLINE uint64_t |
1900 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb19(uint64_t x) { |
1901 | 0 | return x << (uint32_t)(int32_t)20 | x >> (uint32_t)(int32_t)44; |
1902 | 0 | } |
1903 | | |
1904 | | /** |
1905 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1906 | | with const generics |
1907 | | - LEFT= 20 |
1908 | | - RIGHT= 44 |
1909 | | */ |
1910 | | static KRML_MUSTINLINE uint64_t |
1911 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4219(uint64_t a, uint64_t b) { |
1912 | 0 | uint64_t ab = a ^ b; |
1913 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb19(ab); |
1914 | 0 | } |
1915 | | |
1916 | | /** |
1917 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1918 | | usize> for u64)} |
1919 | | */ |
1920 | | /** |
1921 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1922 | | with const generics |
1923 | | - LEFT= 20 |
1924 | | - RIGHT= 44 |
1925 | | */ |
1926 | | static KRML_MUSTINLINE uint64_t |
1927 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19(uint64_t a, uint64_t b) { |
1928 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4219(a, b); |
1929 | 0 | } |
1930 | | |
1931 | | /** |
1932 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1933 | | with const generics |
1934 | | - LEFT= 39 |
1935 | | - RIGHT= 25 |
1936 | | */ |
1937 | | static KRML_MUSTINLINE uint64_t |
1938 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb20(uint64_t x) { |
1939 | 0 | return x << (uint32_t)(int32_t)39 | x >> (uint32_t)(int32_t)25; |
1940 | 0 | } |
1941 | | |
1942 | | /** |
1943 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1944 | | with const generics |
1945 | | - LEFT= 39 |
1946 | | - RIGHT= 25 |
1947 | | */ |
1948 | | static KRML_MUSTINLINE uint64_t |
1949 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4220(uint64_t a, uint64_t b) { |
1950 | 0 | uint64_t ab = a ^ b; |
1951 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb20(ab); |
1952 | 0 | } |
1953 | | |
1954 | | /** |
1955 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1956 | | usize> for u64)} |
1957 | | */ |
1958 | | /** |
1959 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1960 | | with const generics |
1961 | | - LEFT= 39 |
1962 | | - RIGHT= 25 |
1963 | | */ |
1964 | | static KRML_MUSTINLINE uint64_t |
1965 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20(uint64_t a, uint64_t b) { |
1966 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4220(a, b); |
1967 | 0 | } |
1968 | | |
1969 | | /** |
1970 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
1971 | | with const generics |
1972 | | - LEFT= 8 |
1973 | | - RIGHT= 56 |
1974 | | */ |
1975 | | static KRML_MUSTINLINE uint64_t |
1976 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb21(uint64_t x) { |
1977 | 0 | return x << (uint32_t)(int32_t)8 | x >> (uint32_t)(int32_t)56; |
1978 | 0 | } |
1979 | | |
1980 | | /** |
1981 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
1982 | | with const generics |
1983 | | - LEFT= 8 |
1984 | | - RIGHT= 56 |
1985 | | */ |
1986 | | static KRML_MUSTINLINE uint64_t |
1987 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4221(uint64_t a, uint64_t b) { |
1988 | 0 | uint64_t ab = a ^ b; |
1989 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb21(ab); |
1990 | 0 | } |
1991 | | |
1992 | | /** |
1993 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
1994 | | usize> for u64)} |
1995 | | */ |
1996 | | /** |
1997 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
1998 | | with const generics |
1999 | | - LEFT= 8 |
2000 | | - RIGHT= 56 |
2001 | | */ |
2002 | | static KRML_MUSTINLINE uint64_t |
2003 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21(uint64_t a, uint64_t b) { |
2004 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4221(a, b); |
2005 | 0 | } |
2006 | | |
2007 | | /** |
2008 | | A monomorphic instance of libcrux_sha3.portable_keccak.rotate_left |
2009 | | with const generics |
2010 | | - LEFT= 14 |
2011 | | - RIGHT= 50 |
2012 | | */ |
2013 | | static KRML_MUSTINLINE uint64_t |
2014 | 0 | libcrux_sha3_portable_keccak_rotate_left_cb22(uint64_t x) { |
2015 | 0 | return x << (uint32_t)(int32_t)14 | x >> (uint32_t)(int32_t)50; |
2016 | 0 | } |
2017 | | |
2018 | | /** |
2019 | | A monomorphic instance of libcrux_sha3.portable_keccak._vxarq_u64 |
2020 | | with const generics |
2021 | | - LEFT= 14 |
2022 | | - RIGHT= 50 |
2023 | | */ |
2024 | | static KRML_MUSTINLINE uint64_t |
2025 | 0 | libcrux_sha3_portable_keccak__vxarq_u64_4222(uint64_t a, uint64_t b) { |
2026 | 0 | uint64_t ab = a ^ b; |
2027 | 0 | return libcrux_sha3_portable_keccak_rotate_left_cb22(ab); |
2028 | 0 | } |
2029 | | |
2030 | | /** |
2031 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2032 | | usize> for u64)} |
2033 | | */ |
2034 | | /** |
2035 | | A monomorphic instance of libcrux_sha3.portable_keccak.xor_and_rotate_5a |
2036 | | with const generics |
2037 | | - LEFT= 14 |
2038 | | - RIGHT= 50 |
2039 | | */ |
2040 | | static KRML_MUSTINLINE uint64_t |
2041 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22(uint64_t a, uint64_t b) { |
2042 | 0 | return libcrux_sha3_portable_keccak__vxarq_u64_4222(a, b); |
2043 | 0 | } |
2044 | | |
2045 | | /** |
2046 | | A monomorphic instance of libcrux_sha3.generic_keccak.theta_rho |
2047 | | with types uint64_t |
2048 | | with const generics |
2049 | | - N= 1 |
2050 | | */ |
2051 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_theta_rho_16( |
2052 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s) { |
2053 | 0 | uint64_t c[5U] = { |
2054 | 0 | libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][0U], s->st[1U][0U], |
2055 | 0 | s->st[2U][0U], s->st[3U][0U], |
2056 | 0 | s->st[4U][0U]), |
2057 | 0 | libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][1U], s->st[1U][1U], |
2058 | 0 | s->st[2U][1U], s->st[3U][1U], |
2059 | 0 | s->st[4U][1U]), |
2060 | 0 | libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][2U], s->st[1U][2U], |
2061 | 0 | s->st[2U][2U], s->st[3U][2U], |
2062 | 0 | s->st[4U][2U]), |
2063 | 0 | libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][3U], s->st[1U][3U], |
2064 | 0 | s->st[2U][3U], s->st[3U][3U], |
2065 | 0 | s->st[4U][3U]), |
2066 | 0 | libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][4U], s->st[1U][4U], |
2067 | 0 | s->st[2U][4U], s->st[3U][4U], |
2068 | 0 | s->st[4U][4U])}; |
2069 | 0 | uint64_t uu____0 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a( |
2070 | 0 | c[((size_t)0U + (size_t)4U) % (size_t)5U], |
2071 | 0 | c[((size_t)0U + (size_t)1U) % (size_t)5U]); |
2072 | 0 | uint64_t uu____1 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a( |
2073 | 0 | c[((size_t)1U + (size_t)4U) % (size_t)5U], |
2074 | 0 | c[((size_t)1U + (size_t)1U) % (size_t)5U]); |
2075 | 0 | uint64_t uu____2 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a( |
2076 | 0 | c[((size_t)2U + (size_t)4U) % (size_t)5U], |
2077 | 0 | c[((size_t)2U + (size_t)1U) % (size_t)5U]); |
2078 | 0 | uint64_t uu____3 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a( |
2079 | 0 | c[((size_t)3U + (size_t)4U) % (size_t)5U], |
2080 | 0 | c[((size_t)3U + (size_t)1U) % (size_t)5U]); |
2081 | 0 | uint64_t t[5U] = {uu____0, uu____1, uu____2, uu____3, |
2082 | 0 | libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a( |
2083 | 0 | c[((size_t)4U + (size_t)4U) % (size_t)5U], |
2084 | 0 | c[((size_t)4U + (size_t)1U) % (size_t)5U])}; |
2085 | 0 | s->st[0U][0U] = libcrux_sha3_portable_keccak_xor_5a(s->st[0U][0U], t[0U]); |
2086 | 0 | s->st[1U][0U] = |
2087 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb(s->st[1U][0U], t[0U]); |
2088 | 0 | s->st[2U][0U] = |
2089 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0(s->st[2U][0U], t[0U]); |
2090 | 0 | s->st[3U][0U] = |
2091 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1(s->st[3U][0U], t[0U]); |
2092 | 0 | s->st[4U][0U] = |
2093 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2(s->st[4U][0U], t[0U]); |
2094 | 0 | s->st[0U][1U] = |
2095 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3(s->st[0U][1U], t[1U]); |
2096 | 0 | s->st[1U][1U] = |
2097 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4(s->st[1U][1U], t[1U]); |
2098 | 0 | s->st[2U][1U] = |
2099 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5(s->st[2U][1U], t[1U]); |
2100 | 0 | s->st[3U][1U] = |
2101 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6(s->st[3U][1U], t[1U]); |
2102 | 0 | s->st[4U][1U] = |
2103 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7(s->st[4U][1U], t[1U]); |
2104 | 0 | s->st[0U][2U] = |
2105 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8(s->st[0U][2U], t[2U]); |
2106 | 0 | s->st[1U][2U] = |
2107 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9(s->st[1U][2U], t[2U]); |
2108 | 0 | s->st[2U][2U] = |
2109 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10(s->st[2U][2U], t[2U]); |
2110 | 0 | s->st[3U][2U] = |
2111 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11(s->st[3U][2U], t[2U]); |
2112 | 0 | s->st[4U][2U] = |
2113 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12(s->st[4U][2U], t[2U]); |
2114 | 0 | s->st[0U][3U] = |
2115 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13(s->st[0U][3U], t[3U]); |
2116 | 0 | s->st[1U][3U] = |
2117 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14(s->st[1U][3U], t[3U]); |
2118 | 0 | s->st[2U][3U] = |
2119 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15(s->st[2U][3U], t[3U]); |
2120 | 0 | s->st[3U][3U] = |
2121 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16(s->st[3U][3U], t[3U]); |
2122 | 0 | s->st[4U][3U] = |
2123 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17(s->st[4U][3U], t[3U]); |
2124 | 0 | s->st[0U][4U] = |
2125 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18(s->st[0U][4U], t[4U]); |
2126 | 0 | s->st[1U][4U] = |
2127 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19(s->st[1U][4U], t[4U]); |
2128 | 0 | s->st[2U][4U] = |
2129 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20(s->st[2U][4U], t[4U]); |
2130 | 0 | s->st[3U][4U] = |
2131 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21(s->st[3U][4U], t[4U]); |
2132 | 0 | uint64_t uu____27 = |
2133 | 0 | libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22(s->st[4U][4U], t[4U]); |
2134 | 0 | s->st[4U][4U] = uu____27; |
2135 | 0 | } |
2136 | | |
2137 | | /** |
2138 | | A monomorphic instance of libcrux_sha3.generic_keccak.pi |
2139 | | with types uint64_t |
2140 | | with const generics |
2141 | | - N= 1 |
2142 | | */ |
2143 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_pi_1d( |
2144 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s) { |
2145 | 0 | uint64_t old[5U][5U]; |
2146 | 0 | memcpy(old, s->st, (size_t)5U * sizeof(uint64_t[5U])); |
2147 | 0 | s->st[0U][1U] = old[1U][1U]; |
2148 | 0 | s->st[0U][2U] = old[2U][2U]; |
2149 | 0 | s->st[0U][3U] = old[3U][3U]; |
2150 | 0 | s->st[0U][4U] = old[4U][4U]; |
2151 | 0 | s->st[1U][0U] = old[0U][3U]; |
2152 | 0 | s->st[1U][1U] = old[1U][4U]; |
2153 | 0 | s->st[1U][2U] = old[2U][0U]; |
2154 | 0 | s->st[1U][3U] = old[3U][1U]; |
2155 | 0 | s->st[1U][4U] = old[4U][2U]; |
2156 | 0 | s->st[2U][0U] = old[0U][1U]; |
2157 | 0 | s->st[2U][1U] = old[1U][2U]; |
2158 | 0 | s->st[2U][2U] = old[2U][3U]; |
2159 | 0 | s->st[2U][3U] = old[3U][4U]; |
2160 | 0 | s->st[2U][4U] = old[4U][0U]; |
2161 | 0 | s->st[3U][0U] = old[0U][4U]; |
2162 | 0 | s->st[3U][1U] = old[1U][0U]; |
2163 | 0 | s->st[3U][2U] = old[2U][1U]; |
2164 | 0 | s->st[3U][3U] = old[3U][2U]; |
2165 | 0 | s->st[3U][4U] = old[4U][3U]; |
2166 | 0 | s->st[4U][0U] = old[0U][2U]; |
2167 | 0 | s->st[4U][1U] = old[1U][3U]; |
2168 | 0 | s->st[4U][2U] = old[2U][4U]; |
2169 | 0 | s->st[4U][3U] = old[3U][0U]; |
2170 | 0 | s->st[4U][4U] = old[4U][1U]; |
2171 | 0 | } |
2172 | | |
2173 | | /** |
2174 | | A monomorphic instance of libcrux_sha3.generic_keccak.chi |
2175 | | with types uint64_t |
2176 | | with const generics |
2177 | | - N= 1 |
2178 | | */ |
2179 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_chi_12( |
2180 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s) { |
2181 | 0 | uint64_t old[5U][5U]; |
2182 | 0 | memcpy(old, s->st, (size_t)5U * sizeof(uint64_t[5U])); |
2183 | 0 | for (size_t i0 = (size_t)0U; i0 < (size_t)5U; i0++) { |
2184 | 0 | size_t i1 = i0; |
2185 | 0 | for (size_t i = (size_t)0U; i < (size_t)5U; i++) { |
2186 | 0 | size_t j = i; |
2187 | 0 | s->st[i1][j] = libcrux_sha3_portable_keccak_and_not_xor_5a( |
2188 | 0 | s->st[i1][j], old[i1][(j + (size_t)2U) % (size_t)5U], |
2189 | 0 | old[i1][(j + (size_t)1U) % (size_t)5U]); |
2190 | 0 | } |
2191 | 0 | } |
2192 | 0 | } |
2193 | | |
2194 | | /** |
2195 | | A monomorphic instance of libcrux_sha3.generic_keccak.iota |
2196 | | with types uint64_t |
2197 | | with const generics |
2198 | | - N= 1 |
2199 | | */ |
2200 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_iota_62( |
2201 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, size_t i) { |
2202 | 0 | s->st[0U][0U] = libcrux_sha3_portable_keccak_xor_constant_5a( |
2203 | 0 | s->st[0U][0U], libcrux_sha3_generic_keccak_ROUNDCONSTANTS[i]); |
2204 | 0 | } |
2205 | | |
2206 | | /** |
2207 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccakf1600 |
2208 | | with types uint64_t |
2209 | | with const generics |
2210 | | - N= 1 |
2211 | | */ |
2212 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccakf1600_21( |
2213 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s) { |
2214 | 0 | for (size_t i = (size_t)0U; i < (size_t)24U; i++) { |
2215 | 0 | size_t i0 = i; |
2216 | 0 | libcrux_sha3_generic_keccak_theta_rho_16(s); |
2217 | 0 | libcrux_sha3_generic_keccak_pi_1d(s); |
2218 | 0 | libcrux_sha3_generic_keccak_chi_12(s); |
2219 | 0 | libcrux_sha3_generic_keccak_iota_62(s, i0); |
2220 | 0 | } |
2221 | 0 | } |
2222 | | |
2223 | | /** |
2224 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block |
2225 | | with types uint64_t |
2226 | | with const generics |
2227 | | - N= 1 |
2228 | | - RATE= 72 |
2229 | | */ |
2230 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df( |
2231 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) { |
2232 | 0 | uint64_t(*uu____0)[5U] = s->st; |
2233 | 0 | Eurydice_slice uu____1[1U]; |
2234 | 0 | memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice)); |
2235 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b8(uu____0, uu____1); |
2236 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2237 | 0 | } |
2238 | | |
2239 | | /** |
2240 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full |
2241 | | with const generics |
2242 | | - RATE= 72 |
2243 | | */ |
2244 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df( |
2245 | 0 | uint64_t (*s)[5U], uint8_t blocks[1U][200U]) { |
2246 | 0 | Eurydice_slice buf[1U] = { |
2247 | 0 | Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)}; |
2248 | 0 | libcrux_sha3_portable_keccak_load_block_2c(s, buf); |
2249 | 0 | } |
2250 | | |
2251 | | /** |
2252 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2253 | | usize> for u64)} |
2254 | | */ |
2255 | | /** |
2256 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a |
2257 | | with const generics |
2258 | | - RATE= 72 |
2259 | | */ |
2260 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d2( |
2261 | 0 | uint64_t (*a)[5U], uint8_t b[1U][200U]) { |
2262 | 0 | uint64_t(*uu____0)[5U] = a; |
2263 | | /* Passing arrays by value in Rust generates a copy in C */ |
2264 | 0 | uint8_t copy_of_b[1U][200U]; |
2265 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U])); |
2266 | 0 | libcrux_sha3_portable_keccak_load_block_full_df(uu____0, copy_of_b); |
2267 | 0 | } |
2268 | | |
2269 | | /** |
2270 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final |
2271 | | with types uint64_t |
2272 | | with const generics |
2273 | | - N= 1 |
2274 | | - RATE= 72 |
2275 | | - DELIM= 6 |
2276 | | */ |
2277 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c7( |
2278 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) { |
2279 | 0 | size_t last_len = Eurydice_slice_len(last[0U], uint8_t); |
2280 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
2281 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2282 | 0 | size_t i0 = i; |
2283 | 0 | if (last_len > (size_t)0U) { |
2284 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
2285 | 0 | blocks[i0], (size_t)0U, last_len, uint8_t); |
2286 | 0 | Eurydice_slice_copy(uu____0, last[i0], uint8_t); |
2287 | 0 | } |
2288 | 0 | blocks[i0][last_len] = 6U; |
2289 | 0 | size_t uu____1 = i0; |
2290 | 0 | size_t uu____2 = (size_t)72U - (size_t)1U; |
2291 | 0 | blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U; |
2292 | 0 | } |
2293 | 0 | uint64_t(*uu____3)[5U] = s->st; |
2294 | 0 | uint8_t uu____4[1U][200U]; |
2295 | 0 | memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
2296 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d2(uu____3, uu____4); |
2297 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2298 | 0 | } |
2299 | | |
2300 | | /** |
2301 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block |
2302 | | with const generics |
2303 | | - RATE= 72 |
2304 | | */ |
2305 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_58( |
2306 | 0 | uint64_t (*s)[5U], Eurydice_slice out[1U]) { |
2307 | 0 | for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) { |
2308 | 0 | size_t i0 = i; |
2309 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
2310 | 0 | out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t); |
2311 | 0 | uint8_t ret[8U]; |
2312 | 0 | core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
2313 | 0 | Eurydice_slice_copy( |
2314 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
2315 | 0 | } |
2316 | 0 | } |
2317 | | |
2318 | | /** |
2319 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full |
2320 | | with const generics |
2321 | | - RATE= 72 |
2322 | | */ |
2323 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d( |
2324 | 0 | uint64_t (*s)[5U], uint8_t ret[1U][200U]) { |
2325 | 0 | uint8_t out[200U] = {0U}; |
2326 | 0 | Eurydice_slice buf[1U] = { |
2327 | 0 | Eurydice_array_to_slice((size_t)200U, out, uint8_t)}; |
2328 | 0 | libcrux_sha3_portable_keccak_store_block_58(s, buf); |
2329 | | /* Passing arrays by value in Rust generates a copy in C */ |
2330 | 0 | uint8_t copy_of_out[200U]; |
2331 | 0 | memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t)); |
2332 | 0 | memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t)); |
2333 | 0 | } |
2334 | | |
2335 | | /** |
2336 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2337 | | usize> for u64)} |
2338 | | */ |
2339 | | /** |
2340 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a |
2341 | | with const generics |
2342 | | - RATE= 72 |
2343 | | */ |
2344 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_5a_29( |
2345 | 0 | uint64_t (*a)[5U], uint8_t ret[1U][200U]) { |
2346 | 0 | libcrux_sha3_portable_keccak_store_block_full_2d(a, ret); |
2347 | 0 | } |
2348 | | |
2349 | | /** |
2350 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last |
2351 | | with types uint64_t |
2352 | | with const generics |
2353 | | - N= 1 |
2354 | | - RATE= 72 |
2355 | | */ |
2356 | | static KRML_MUSTINLINE void |
2357 | | libcrux_sha3_generic_keccak_squeeze_first_and_last_c5( |
2358 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
2359 | 0 | uint8_t b[1U][200U]; |
2360 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_29(s->st, b); |
2361 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2362 | 0 | size_t i0 = i; |
2363 | 0 | Eurydice_slice uu____0 = out[i0]; |
2364 | 0 | uint8_t *uu____1 = b[i0]; |
2365 | 0 | core_ops_range_Range_b3 lit; |
2366 | 0 | lit.start = (size_t)0U; |
2367 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
2368 | 0 | Eurydice_slice_copy( |
2369 | 0 | uu____0, |
2370 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
2371 | 0 | core_ops_range_Range_b3), |
2372 | 0 | uint8_t); |
2373 | 0 | } |
2374 | 0 | } |
2375 | | |
2376 | | /** |
2377 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2378 | | usize> for u64)} |
2379 | | */ |
2380 | | /** |
2381 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a |
2382 | | with const generics |
2383 | | - RATE= 72 |
2384 | | */ |
2385 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_59( |
2386 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
2387 | 0 | libcrux_sha3_portable_keccak_store_block_58(a, b); |
2388 | 0 | } |
2389 | | |
2390 | | /** |
2391 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block |
2392 | | with types uint64_t |
2393 | | with const generics |
2394 | | - N= 1 |
2395 | | - RATE= 72 |
2396 | | */ |
2397 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_84( |
2398 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
2399 | 0 | libcrux_sha3_portable_keccak_store_block_5a_59(s->st, out); |
2400 | 0 | } |
2401 | | |
2402 | | /** |
2403 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block |
2404 | | with types uint64_t |
2405 | | with const generics |
2406 | | - N= 1 |
2407 | | - RATE= 72 |
2408 | | */ |
2409 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc( |
2410 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
2411 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2412 | 0 | libcrux_sha3_portable_keccak_store_block_5a_59(s->st, out); |
2413 | 0 | } |
2414 | | |
2415 | | /** |
2416 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last |
2417 | | with types uint64_t |
2418 | | with const generics |
2419 | | - N= 1 |
2420 | | - RATE= 72 |
2421 | | */ |
2422 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf( |
2423 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) { |
2424 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&s); |
2425 | 0 | uint8_t b[1U][200U]; |
2426 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_29(s.st, b); |
2427 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2428 | 0 | size_t i0 = i; |
2429 | 0 | Eurydice_slice uu____0 = out[i0]; |
2430 | 0 | uint8_t *uu____1 = b[i0]; |
2431 | 0 | core_ops_range_Range_b3 lit; |
2432 | 0 | lit.start = (size_t)0U; |
2433 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
2434 | 0 | Eurydice_slice_copy( |
2435 | 0 | uu____0, |
2436 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
2437 | 0 | core_ops_range_Range_b3), |
2438 | 0 | uint8_t); |
2439 | 0 | } |
2440 | 0 | } |
2441 | | |
2442 | | /** |
2443 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccak |
2444 | | with types uint64_t |
2445 | | with const generics |
2446 | | - N= 1 |
2447 | | - RATE= 72 |
2448 | | - DELIM= 6 |
2449 | | */ |
2450 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e9( |
2451 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
2452 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s = |
2453 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(); |
2454 | 0 | for (size_t i = (size_t)0U; |
2455 | 0 | i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)72U; i++) { |
2456 | 0 | size_t i0 = i; |
2457 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s; |
2458 | | /* Passing arrays by value in Rust generates a copy in C */ |
2459 | 0 | Eurydice_slice copy_of_data[1U]; |
2460 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2461 | 0 | Eurydice_slice ret[1U]; |
2462 | 0 | libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)72U, |
2463 | 0 | (size_t)72U, ret); |
2464 | 0 | libcrux_sha3_generic_keccak_absorb_block_df(uu____0, ret); |
2465 | 0 | } |
2466 | 0 | size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)72U; |
2467 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s; |
2468 | | /* Passing arrays by value in Rust generates a copy in C */ |
2469 | 0 | Eurydice_slice copy_of_data[1U]; |
2470 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2471 | 0 | Eurydice_slice ret[1U]; |
2472 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
2473 | 0 | copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret); |
2474 | 0 | libcrux_sha3_generic_keccak_absorb_final_c7(uu____2, ret); |
2475 | 0 | size_t outlen = Eurydice_slice_len(out[0U], uint8_t); |
2476 | 0 | size_t blocks = outlen / (size_t)72U; |
2477 | 0 | size_t last = outlen - outlen % (size_t)72U; |
2478 | 0 | if (blocks == (size_t)0U) { |
2479 | 0 | libcrux_sha3_generic_keccak_squeeze_first_and_last_c5(&s, out); |
2480 | 0 | } else { |
2481 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____4 = |
2482 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)72U); |
2483 | 0 | Eurydice_slice o0[1U]; |
2484 | 0 | memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice)); |
2485 | 0 | Eurydice_slice o1[1U]; |
2486 | 0 | memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice)); |
2487 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_84(&s, o0); |
2488 | 0 | core_ops_range_Range_b3 iter = |
2489 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
2490 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
2491 | 0 | .end = blocks}), |
2492 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
2493 | 0 | while (true) { |
2494 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
2495 | 0 | &iter, size_t, Option_b3) |
2496 | 0 | .tag == None) { |
2497 | 0 | break; |
2498 | 0 | } else { |
2499 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____5 = |
2500 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)72U); |
2501 | 0 | Eurydice_slice o[1U]; |
2502 | 0 | memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice)); |
2503 | 0 | Eurydice_slice orest[1U]; |
2504 | 0 | memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice)); |
2505 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc(&s, o); |
2506 | 0 | memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice)); |
2507 | 0 | } |
2508 | 0 | } |
2509 | 0 | if (last < outlen) { |
2510 | 0 | libcrux_sha3_generic_keccak_squeeze_last_cf(s, o1); |
2511 | 0 | } |
2512 | 0 | } |
2513 | 0 | } |
2514 | | |
2515 | | /** |
2516 | | A monomorphic instance of libcrux_sha3.portable.keccakx1 |
2517 | | with const generics |
2518 | | - RATE= 72 |
2519 | | - DELIM= 6 |
2520 | | */ |
2521 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce( |
2522 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
2523 | | /* Passing arrays by value in Rust generates a copy in C */ |
2524 | 0 | Eurydice_slice copy_of_data[1U]; |
2525 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2526 | 0 | libcrux_sha3_generic_keccak_keccak_e9(copy_of_data, out); |
2527 | 0 | } |
2528 | | |
2529 | | /** |
2530 | | A portable SHA3 512 implementation. |
2531 | | */ |
2532 | | static KRML_MUSTINLINE void libcrux_sha3_portable_sha512(Eurydice_slice digest, |
2533 | 0 | Eurydice_slice data) { |
2534 | 0 | Eurydice_slice buf0[1U] = {data}; |
2535 | 0 | Eurydice_slice buf[1U] = {digest}; |
2536 | 0 | libcrux_sha3_portable_keccakx1_ce(buf0, buf); |
2537 | 0 | } |
2538 | | |
2539 | | /** |
2540 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block |
2541 | | with const generics |
2542 | | - RATE= 136 |
2543 | | */ |
2544 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c0( |
2545 | 0 | uint64_t (*s)[5U], Eurydice_slice blocks[1U]) { |
2546 | 0 | for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) { |
2547 | 0 | size_t i0 = i; |
2548 | 0 | uint8_t uu____0[8U]; |
2549 | 0 | Result_56 dst; |
2550 | 0 | Eurydice_slice_to_array2( |
2551 | 0 | &dst, |
2552 | 0 | Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0, |
2553 | 0 | (size_t)8U * i0 + (size_t)8U, uint8_t), |
2554 | 0 | Eurydice_slice, uint8_t[8U]); |
2555 | 0 | unwrap_41_ac(dst, uu____0); |
2556 | 0 | size_t uu____1 = i0 / (size_t)5U; |
2557 | 0 | size_t uu____2 = i0 % (size_t)5U; |
2558 | 0 | s[uu____1][uu____2] = |
2559 | 0 | s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0); |
2560 | 0 | } |
2561 | 0 | } |
2562 | | |
2563 | | /** |
2564 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2565 | | usize> for u64)} |
2566 | | */ |
2567 | | /** |
2568 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a |
2569 | | with const generics |
2570 | | - RATE= 136 |
2571 | | */ |
2572 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b80( |
2573 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
2574 | 0 | uint64_t(*uu____0)[5U] = a; |
2575 | | /* Passing arrays by value in Rust generates a copy in C */ |
2576 | 0 | Eurydice_slice copy_of_b[1U]; |
2577 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice)); |
2578 | 0 | libcrux_sha3_portable_keccak_load_block_2c0(uu____0, copy_of_b); |
2579 | 0 | } |
2580 | | |
2581 | | /** |
2582 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block |
2583 | | with types uint64_t |
2584 | | with const generics |
2585 | | - N= 1 |
2586 | | - RATE= 136 |
2587 | | */ |
2588 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df0( |
2589 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) { |
2590 | 0 | uint64_t(*uu____0)[5U] = s->st; |
2591 | 0 | Eurydice_slice uu____1[1U]; |
2592 | 0 | memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice)); |
2593 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b80(uu____0, uu____1); |
2594 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2595 | 0 | } |
2596 | | |
2597 | | /** |
2598 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full |
2599 | | with const generics |
2600 | | - RATE= 136 |
2601 | | */ |
2602 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df0( |
2603 | 0 | uint64_t (*s)[5U], uint8_t blocks[1U][200U]) { |
2604 | 0 | Eurydice_slice buf[1U] = { |
2605 | 0 | Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)}; |
2606 | 0 | libcrux_sha3_portable_keccak_load_block_2c0(s, buf); |
2607 | 0 | } |
2608 | | |
2609 | | /** |
2610 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2611 | | usize> for u64)} |
2612 | | */ |
2613 | | /** |
2614 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a |
2615 | | with const generics |
2616 | | - RATE= 136 |
2617 | | */ |
2618 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d20( |
2619 | 0 | uint64_t (*a)[5U], uint8_t b[1U][200U]) { |
2620 | 0 | uint64_t(*uu____0)[5U] = a; |
2621 | | /* Passing arrays by value in Rust generates a copy in C */ |
2622 | 0 | uint8_t copy_of_b[1U][200U]; |
2623 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U])); |
2624 | 0 | libcrux_sha3_portable_keccak_load_block_full_df0(uu____0, copy_of_b); |
2625 | 0 | } |
2626 | | |
2627 | | /** |
2628 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final |
2629 | | with types uint64_t |
2630 | | with const generics |
2631 | | - N= 1 |
2632 | | - RATE= 136 |
2633 | | - DELIM= 6 |
2634 | | */ |
2635 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c70( |
2636 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) { |
2637 | 0 | size_t last_len = Eurydice_slice_len(last[0U], uint8_t); |
2638 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
2639 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2640 | 0 | size_t i0 = i; |
2641 | 0 | if (last_len > (size_t)0U) { |
2642 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
2643 | 0 | blocks[i0], (size_t)0U, last_len, uint8_t); |
2644 | 0 | Eurydice_slice_copy(uu____0, last[i0], uint8_t); |
2645 | 0 | } |
2646 | 0 | blocks[i0][last_len] = 6U; |
2647 | 0 | size_t uu____1 = i0; |
2648 | 0 | size_t uu____2 = (size_t)136U - (size_t)1U; |
2649 | 0 | blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U; |
2650 | 0 | } |
2651 | 0 | uint64_t(*uu____3)[5U] = s->st; |
2652 | 0 | uint8_t uu____4[1U][200U]; |
2653 | 0 | memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
2654 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____3, uu____4); |
2655 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2656 | 0 | } |
2657 | | |
2658 | | /** |
2659 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block |
2660 | | with const generics |
2661 | | - RATE= 136 |
2662 | | */ |
2663 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_580( |
2664 | 0 | uint64_t (*s)[5U], Eurydice_slice out[1U]) { |
2665 | 0 | for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) { |
2666 | 0 | size_t i0 = i; |
2667 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
2668 | 0 | out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t); |
2669 | 0 | uint8_t ret[8U]; |
2670 | 0 | core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
2671 | 0 | Eurydice_slice_copy( |
2672 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
2673 | 0 | } |
2674 | 0 | } |
2675 | | |
2676 | | /** |
2677 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full |
2678 | | with const generics |
2679 | | - RATE= 136 |
2680 | | */ |
2681 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d0( |
2682 | 0 | uint64_t (*s)[5U], uint8_t ret[1U][200U]) { |
2683 | 0 | uint8_t out[200U] = {0U}; |
2684 | 0 | Eurydice_slice buf[1U] = { |
2685 | 0 | Eurydice_array_to_slice((size_t)200U, out, uint8_t)}; |
2686 | 0 | libcrux_sha3_portable_keccak_store_block_580(s, buf); |
2687 | | /* Passing arrays by value in Rust generates a copy in C */ |
2688 | 0 | uint8_t copy_of_out[200U]; |
2689 | 0 | memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t)); |
2690 | 0 | memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t)); |
2691 | 0 | } |
2692 | | |
2693 | | /** |
2694 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2695 | | usize> for u64)} |
2696 | | */ |
2697 | | /** |
2698 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a |
2699 | | with const generics |
2700 | | - RATE= 136 |
2701 | | */ |
2702 | | static KRML_MUSTINLINE void |
2703 | | libcrux_sha3_portable_keccak_store_block_full_5a_290(uint64_t (*a)[5U], |
2704 | 0 | uint8_t ret[1U][200U]) { |
2705 | 0 | libcrux_sha3_portable_keccak_store_block_full_2d0(a, ret); |
2706 | 0 | } |
2707 | | |
2708 | | /** |
2709 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last |
2710 | | with types uint64_t |
2711 | | with const generics |
2712 | | - N= 1 |
2713 | | - RATE= 136 |
2714 | | */ |
2715 | | static KRML_MUSTINLINE void |
2716 | | libcrux_sha3_generic_keccak_squeeze_first_and_last_c50( |
2717 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
2718 | 0 | uint8_t b[1U][200U]; |
2719 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_290(s->st, b); |
2720 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2721 | 0 | size_t i0 = i; |
2722 | 0 | Eurydice_slice uu____0 = out[i0]; |
2723 | 0 | uint8_t *uu____1 = b[i0]; |
2724 | 0 | core_ops_range_Range_b3 lit; |
2725 | 0 | lit.start = (size_t)0U; |
2726 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
2727 | 0 | Eurydice_slice_copy( |
2728 | 0 | uu____0, |
2729 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
2730 | 0 | core_ops_range_Range_b3), |
2731 | 0 | uint8_t); |
2732 | 0 | } |
2733 | 0 | } |
2734 | | |
2735 | | /** |
2736 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
2737 | | usize> for u64)} |
2738 | | */ |
2739 | | /** |
2740 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a |
2741 | | with const generics |
2742 | | - RATE= 136 |
2743 | | */ |
2744 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_590( |
2745 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
2746 | 0 | libcrux_sha3_portable_keccak_store_block_580(a, b); |
2747 | 0 | } |
2748 | | |
2749 | | /** |
2750 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block |
2751 | | with types uint64_t |
2752 | | with const generics |
2753 | | - N= 1 |
2754 | | - RATE= 136 |
2755 | | */ |
2756 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_840( |
2757 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
2758 | 0 | libcrux_sha3_portable_keccak_store_block_5a_590(s->st, out); |
2759 | 0 | } |
2760 | | |
2761 | | /** |
2762 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block |
2763 | | with types uint64_t |
2764 | | with const generics |
2765 | | - N= 1 |
2766 | | - RATE= 136 |
2767 | | */ |
2768 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc0( |
2769 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
2770 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2771 | 0 | libcrux_sha3_portable_keccak_store_block_5a_590(s->st, out); |
2772 | 0 | } |
2773 | | |
2774 | | /** |
2775 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last |
2776 | | with types uint64_t |
2777 | | with const generics |
2778 | | - N= 1 |
2779 | | - RATE= 136 |
2780 | | */ |
2781 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf0( |
2782 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) { |
2783 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&s); |
2784 | 0 | uint8_t b[1U][200U]; |
2785 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_290(s.st, b); |
2786 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2787 | 0 | size_t i0 = i; |
2788 | 0 | Eurydice_slice uu____0 = out[i0]; |
2789 | 0 | uint8_t *uu____1 = b[i0]; |
2790 | 0 | core_ops_range_Range_b3 lit; |
2791 | 0 | lit.start = (size_t)0U; |
2792 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
2793 | 0 | Eurydice_slice_copy( |
2794 | 0 | uu____0, |
2795 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
2796 | 0 | core_ops_range_Range_b3), |
2797 | 0 | uint8_t); |
2798 | 0 | } |
2799 | 0 | } |
2800 | | |
2801 | | /** |
2802 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccak |
2803 | | with types uint64_t |
2804 | | with const generics |
2805 | | - N= 1 |
2806 | | - RATE= 136 |
2807 | | - DELIM= 6 |
2808 | | */ |
2809 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e90( |
2810 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
2811 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s = |
2812 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(); |
2813 | 0 | for (size_t i = (size_t)0U; |
2814 | 0 | i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)136U; i++) { |
2815 | 0 | size_t i0 = i; |
2816 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s; |
2817 | | /* Passing arrays by value in Rust generates a copy in C */ |
2818 | 0 | Eurydice_slice copy_of_data[1U]; |
2819 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2820 | 0 | Eurydice_slice ret[1U]; |
2821 | 0 | libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)136U, |
2822 | 0 | (size_t)136U, ret); |
2823 | 0 | libcrux_sha3_generic_keccak_absorb_block_df0(uu____0, ret); |
2824 | 0 | } |
2825 | 0 | size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)136U; |
2826 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s; |
2827 | | /* Passing arrays by value in Rust generates a copy in C */ |
2828 | 0 | Eurydice_slice copy_of_data[1U]; |
2829 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2830 | 0 | Eurydice_slice ret[1U]; |
2831 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
2832 | 0 | copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret); |
2833 | 0 | libcrux_sha3_generic_keccak_absorb_final_c70(uu____2, ret); |
2834 | 0 | size_t outlen = Eurydice_slice_len(out[0U], uint8_t); |
2835 | 0 | size_t blocks = outlen / (size_t)136U; |
2836 | 0 | size_t last = outlen - outlen % (size_t)136U; |
2837 | 0 | if (blocks == (size_t)0U) { |
2838 | 0 | libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(&s, out); |
2839 | 0 | } else { |
2840 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____4 = |
2841 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)136U); |
2842 | 0 | Eurydice_slice o0[1U]; |
2843 | 0 | memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice)); |
2844 | 0 | Eurydice_slice o1[1U]; |
2845 | 0 | memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice)); |
2846 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_840(&s, o0); |
2847 | 0 | core_ops_range_Range_b3 iter = |
2848 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
2849 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
2850 | 0 | .end = blocks}), |
2851 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
2852 | 0 | while (true) { |
2853 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
2854 | 0 | &iter, size_t, Option_b3) |
2855 | 0 | .tag == None) { |
2856 | 0 | break; |
2857 | 0 | } else { |
2858 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____5 = |
2859 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)136U); |
2860 | 0 | Eurydice_slice o[1U]; |
2861 | 0 | memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice)); |
2862 | 0 | Eurydice_slice orest[1U]; |
2863 | 0 | memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice)); |
2864 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc0(&s, o); |
2865 | 0 | memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice)); |
2866 | 0 | } |
2867 | 0 | } |
2868 | 0 | if (last < outlen) { |
2869 | 0 | libcrux_sha3_generic_keccak_squeeze_last_cf0(s, o1); |
2870 | 0 | } |
2871 | 0 | } |
2872 | 0 | } |
2873 | | |
2874 | | /** |
2875 | | A monomorphic instance of libcrux_sha3.portable.keccakx1 |
2876 | | with const generics |
2877 | | - RATE= 136 |
2878 | | - DELIM= 6 |
2879 | | */ |
2880 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce0( |
2881 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
2882 | | /* Passing arrays by value in Rust generates a copy in C */ |
2883 | 0 | Eurydice_slice copy_of_data[1U]; |
2884 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2885 | 0 | libcrux_sha3_generic_keccak_keccak_e90(copy_of_data, out); |
2886 | 0 | } |
2887 | | |
2888 | | /** |
2889 | | A portable SHA3 256 implementation. |
2890 | | */ |
2891 | | static KRML_MUSTINLINE void libcrux_sha3_portable_sha256(Eurydice_slice digest, |
2892 | 0 | Eurydice_slice data) { |
2893 | 0 | Eurydice_slice buf0[1U] = {data}; |
2894 | 0 | Eurydice_slice buf[1U] = {digest}; |
2895 | 0 | libcrux_sha3_portable_keccakx1_ce0(buf0, buf); |
2896 | 0 | } |
2897 | | |
2898 | | /** |
2899 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final |
2900 | | with types uint64_t |
2901 | | with const generics |
2902 | | - N= 1 |
2903 | | - RATE= 136 |
2904 | | - DELIM= 31 |
2905 | | */ |
2906 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c71( |
2907 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) { |
2908 | 0 | size_t last_len = Eurydice_slice_len(last[0U], uint8_t); |
2909 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
2910 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
2911 | 0 | size_t i0 = i; |
2912 | 0 | if (last_len > (size_t)0U) { |
2913 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
2914 | 0 | blocks[i0], (size_t)0U, last_len, uint8_t); |
2915 | 0 | Eurydice_slice_copy(uu____0, last[i0], uint8_t); |
2916 | 0 | } |
2917 | 0 | blocks[i0][last_len] = 31U; |
2918 | 0 | size_t uu____1 = i0; |
2919 | 0 | size_t uu____2 = (size_t)136U - (size_t)1U; |
2920 | 0 | blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U; |
2921 | 0 | } |
2922 | 0 | uint64_t(*uu____3)[5U] = s->st; |
2923 | 0 | uint8_t uu____4[1U][200U]; |
2924 | 0 | memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
2925 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____3, uu____4); |
2926 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
2927 | 0 | } |
2928 | | |
2929 | | /** |
2930 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccak |
2931 | | with types uint64_t |
2932 | | with const generics |
2933 | | - N= 1 |
2934 | | - RATE= 136 |
2935 | | - DELIM= 31 |
2936 | | */ |
2937 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e91( |
2938 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
2939 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s = |
2940 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(); |
2941 | 0 | for (size_t i = (size_t)0U; |
2942 | 0 | i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)136U; i++) { |
2943 | 0 | size_t i0 = i; |
2944 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s; |
2945 | | /* Passing arrays by value in Rust generates a copy in C */ |
2946 | 0 | Eurydice_slice copy_of_data[1U]; |
2947 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2948 | 0 | Eurydice_slice ret[1U]; |
2949 | 0 | libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)136U, |
2950 | 0 | (size_t)136U, ret); |
2951 | 0 | libcrux_sha3_generic_keccak_absorb_block_df0(uu____0, ret); |
2952 | 0 | } |
2953 | 0 | size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)136U; |
2954 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s; |
2955 | | /* Passing arrays by value in Rust generates a copy in C */ |
2956 | 0 | Eurydice_slice copy_of_data[1U]; |
2957 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
2958 | 0 | Eurydice_slice ret[1U]; |
2959 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
2960 | 0 | copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret); |
2961 | 0 | libcrux_sha3_generic_keccak_absorb_final_c71(uu____2, ret); |
2962 | 0 | size_t outlen = Eurydice_slice_len(out[0U], uint8_t); |
2963 | 0 | size_t blocks = outlen / (size_t)136U; |
2964 | 0 | size_t last = outlen - outlen % (size_t)136U; |
2965 | 0 | if (blocks == (size_t)0U) { |
2966 | 0 | libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(&s, out); |
2967 | 0 | } else { |
2968 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____4 = |
2969 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)136U); |
2970 | 0 | Eurydice_slice o0[1U]; |
2971 | 0 | memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice)); |
2972 | 0 | Eurydice_slice o1[1U]; |
2973 | 0 | memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice)); |
2974 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_840(&s, o0); |
2975 | 0 | core_ops_range_Range_b3 iter = |
2976 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
2977 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
2978 | 0 | .end = blocks}), |
2979 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
2980 | 0 | while (true) { |
2981 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
2982 | 0 | &iter, size_t, Option_b3) |
2983 | 0 | .tag == None) { |
2984 | 0 | break; |
2985 | 0 | } else { |
2986 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____5 = |
2987 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)136U); |
2988 | 0 | Eurydice_slice o[1U]; |
2989 | 0 | memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice)); |
2990 | 0 | Eurydice_slice orest[1U]; |
2991 | 0 | memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice)); |
2992 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc0(&s, o); |
2993 | 0 | memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice)); |
2994 | 0 | } |
2995 | 0 | } |
2996 | 0 | if (last < outlen) { |
2997 | 0 | libcrux_sha3_generic_keccak_squeeze_last_cf0(s, o1); |
2998 | 0 | } |
2999 | 0 | } |
3000 | 0 | } |
3001 | | |
3002 | | /** |
3003 | | A monomorphic instance of libcrux_sha3.portable.keccakx1 |
3004 | | with const generics |
3005 | | - RATE= 136 |
3006 | | - DELIM= 31 |
3007 | | */ |
3008 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce1( |
3009 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
3010 | | /* Passing arrays by value in Rust generates a copy in C */ |
3011 | 0 | Eurydice_slice copy_of_data[1U]; |
3012 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3013 | 0 | libcrux_sha3_generic_keccak_keccak_e91(copy_of_data, out); |
3014 | 0 | } |
3015 | | |
3016 | | /** |
3017 | | A portable SHAKE256 implementation. |
3018 | | */ |
3019 | | static KRML_MUSTINLINE void libcrux_sha3_portable_shake256( |
3020 | 0 | Eurydice_slice digest, Eurydice_slice data) { |
3021 | 0 | Eurydice_slice buf0[1U] = {data}; |
3022 | 0 | Eurydice_slice buf[1U] = {digest}; |
3023 | 0 | libcrux_sha3_portable_keccakx1_ce1(buf0, buf); |
3024 | 0 | } |
3025 | | |
3026 | | typedef libcrux_sha3_generic_keccak_KeccakState_48 |
3027 | | libcrux_sha3_portable_KeccakState; |
3028 | | |
3029 | | /** |
3030 | | Create a new SHAKE-128 state object. |
3031 | | */ |
3032 | | static KRML_MUSTINLINE libcrux_sha3_generic_keccak_KeccakState_48 |
3033 | 0 | libcrux_sha3_portable_incremental_shake128_init(void) { |
3034 | 0 | return libcrux_sha3_generic_keccak_new_1e_f4(); |
3035 | 0 | } |
3036 | | |
3037 | | /** |
3038 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block |
3039 | | with const generics |
3040 | | - RATE= 168 |
3041 | | */ |
3042 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c1( |
3043 | 0 | uint64_t (*s)[5U], Eurydice_slice blocks[1U]) { |
3044 | 0 | for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) { |
3045 | 0 | size_t i0 = i; |
3046 | 0 | uint8_t uu____0[8U]; |
3047 | 0 | Result_56 dst; |
3048 | 0 | Eurydice_slice_to_array2( |
3049 | 0 | &dst, |
3050 | 0 | Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0, |
3051 | 0 | (size_t)8U * i0 + (size_t)8U, uint8_t), |
3052 | 0 | Eurydice_slice, uint8_t[8U]); |
3053 | 0 | unwrap_41_ac(dst, uu____0); |
3054 | 0 | size_t uu____1 = i0 / (size_t)5U; |
3055 | 0 | size_t uu____2 = i0 % (size_t)5U; |
3056 | 0 | s[uu____1][uu____2] = |
3057 | 0 | s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0); |
3058 | 0 | } |
3059 | 0 | } |
3060 | | |
3061 | | /** |
3062 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full |
3063 | | with const generics |
3064 | | - RATE= 168 |
3065 | | */ |
3066 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df1( |
3067 | 0 | uint64_t (*s)[5U], uint8_t blocks[1U][200U]) { |
3068 | 0 | Eurydice_slice buf[1U] = { |
3069 | 0 | Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)}; |
3070 | 0 | libcrux_sha3_portable_keccak_load_block_2c1(s, buf); |
3071 | 0 | } |
3072 | | |
3073 | | /** |
3074 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3075 | | usize> for u64)} |
3076 | | */ |
3077 | | /** |
3078 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a |
3079 | | with const generics |
3080 | | - RATE= 168 |
3081 | | */ |
3082 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d21( |
3083 | 0 | uint64_t (*a)[5U], uint8_t b[1U][200U]) { |
3084 | 0 | uint64_t(*uu____0)[5U] = a; |
3085 | | /* Passing arrays by value in Rust generates a copy in C */ |
3086 | 0 | uint8_t copy_of_b[1U][200U]; |
3087 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U])); |
3088 | 0 | libcrux_sha3_portable_keccak_load_block_full_df1(uu____0, copy_of_b); |
3089 | 0 | } |
3090 | | |
3091 | | /** |
3092 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final |
3093 | | with types uint64_t |
3094 | | with const generics |
3095 | | - N= 1 |
3096 | | - RATE= 168 |
3097 | | - DELIM= 31 |
3098 | | */ |
3099 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c72( |
3100 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) { |
3101 | 0 | size_t last_len = Eurydice_slice_len(last[0U], uint8_t); |
3102 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
3103 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3104 | 0 | size_t i0 = i; |
3105 | 0 | if (last_len > (size_t)0U) { |
3106 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
3107 | 0 | blocks[i0], (size_t)0U, last_len, uint8_t); |
3108 | 0 | Eurydice_slice_copy(uu____0, last[i0], uint8_t); |
3109 | 0 | } |
3110 | 0 | blocks[i0][last_len] = 31U; |
3111 | 0 | size_t uu____1 = i0; |
3112 | 0 | size_t uu____2 = (size_t)168U - (size_t)1U; |
3113 | 0 | blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U; |
3114 | 0 | } |
3115 | 0 | uint64_t(*uu____3)[5U] = s->st; |
3116 | 0 | uint8_t uu____4[1U][200U]; |
3117 | 0 | memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
3118 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d21(uu____3, uu____4); |
3119 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3120 | 0 | } |
3121 | | |
3122 | | /** |
3123 | | Absorb |
3124 | | */ |
3125 | | static KRML_MUSTINLINE void |
3126 | | libcrux_sha3_portable_incremental_shake128_absorb_final( |
3127 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice data0) { |
3128 | 0 | Eurydice_slice buf[1U] = {data0}; |
3129 | 0 | libcrux_sha3_generic_keccak_absorb_final_c72(s, buf); |
3130 | 0 | } |
3131 | | |
3132 | | /** |
3133 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block |
3134 | | with const generics |
3135 | | - RATE= 168 |
3136 | | */ |
3137 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_581( |
3138 | 0 | uint64_t (*s)[5U], Eurydice_slice out[1U]) { |
3139 | 0 | for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) { |
3140 | 0 | size_t i0 = i; |
3141 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
3142 | 0 | out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t); |
3143 | 0 | uint8_t ret[8U]; |
3144 | 0 | core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
3145 | 0 | Eurydice_slice_copy( |
3146 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
3147 | 0 | } |
3148 | 0 | } |
3149 | | |
3150 | | /** |
3151 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3152 | | usize> for u64)} |
3153 | | */ |
3154 | | /** |
3155 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a |
3156 | | with const generics |
3157 | | - RATE= 168 |
3158 | | */ |
3159 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_591( |
3160 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
3161 | 0 | libcrux_sha3_portable_keccak_store_block_581(a, b); |
3162 | 0 | } |
3163 | | |
3164 | | /** |
3165 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block |
3166 | | with types uint64_t |
3167 | | with const generics |
3168 | | - N= 1 |
3169 | | - RATE= 168 |
3170 | | */ |
3171 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc1( |
3172 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3173 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3174 | 0 | libcrux_sha3_portable_keccak_store_block_5a_591(s->st, out); |
3175 | 0 | } |
3176 | | |
3177 | | /** |
3178 | | Squeeze another block |
3179 | | */ |
3180 | | static KRML_MUSTINLINE void |
3181 | | libcrux_sha3_portable_incremental_shake128_squeeze_next_block( |
3182 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) { |
3183 | 0 | Eurydice_slice buf[1U] = {out0}; |
3184 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, buf); |
3185 | 0 | } |
3186 | | |
3187 | | /** |
3188 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block |
3189 | | with types uint64_t |
3190 | | with const generics |
3191 | | - N= 1 |
3192 | | - RATE= 168 |
3193 | | */ |
3194 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_841( |
3195 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3196 | 0 | libcrux_sha3_portable_keccak_store_block_5a_591(s->st, out); |
3197 | 0 | } |
3198 | | |
3199 | | /** |
3200 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_three_blocks |
3201 | | with types uint64_t |
3202 | | with const generics |
3203 | | - N= 1 |
3204 | | - RATE= 168 |
3205 | | */ |
3206 | | static KRML_MUSTINLINE void |
3207 | | libcrux_sha3_generic_keccak_squeeze_first_three_blocks_cc( |
3208 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3209 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____0 = |
3210 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U); |
3211 | 0 | Eurydice_slice o0[1U]; |
3212 | 0 | memcpy(o0, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice)); |
3213 | 0 | Eurydice_slice o10[1U]; |
3214 | 0 | memcpy(o10, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice)); |
3215 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_841(s, o0); |
3216 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____1 = |
3217 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o10, (size_t)168U); |
3218 | 0 | Eurydice_slice o1[1U]; |
3219 | 0 | memcpy(o1, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice)); |
3220 | 0 | Eurydice_slice o2[1U]; |
3221 | 0 | memcpy(o2, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice)); |
3222 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o1); |
3223 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o2); |
3224 | 0 | } |
3225 | | |
3226 | | /** |
3227 | | Squeeze three blocks |
3228 | | */ |
3229 | | static KRML_MUSTINLINE void |
3230 | | libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks( |
3231 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) { |
3232 | 0 | Eurydice_slice buf[1U] = {out0}; |
3233 | 0 | libcrux_sha3_generic_keccak_squeeze_first_three_blocks_cc(s, buf); |
3234 | 0 | } |
3235 | | |
3236 | | #define libcrux_sha3_Sha224 0 |
3237 | | #define libcrux_sha3_Sha256 1 |
3238 | | #define libcrux_sha3_Sha384 2 |
3239 | | #define libcrux_sha3_Sha512 3 |
3240 | | |
3241 | | typedef uint8_t libcrux_sha3_Algorithm; |
3242 | | |
3243 | | /** |
3244 | | Returns the output size of a digest. |
3245 | | */ |
3246 | 0 | static inline size_t libcrux_sha3_digest_size(libcrux_sha3_Algorithm mode) { |
3247 | 0 | size_t uu____0; |
3248 | 0 | switch (mode) { |
3249 | 0 | case libcrux_sha3_Sha224: { |
3250 | 0 | uu____0 = (size_t)28U; |
3251 | 0 | break; |
3252 | 0 | } |
3253 | 0 | case libcrux_sha3_Sha256: { |
3254 | 0 | uu____0 = (size_t)32U; |
3255 | 0 | break; |
3256 | 0 | } |
3257 | 0 | case libcrux_sha3_Sha384: { |
3258 | 0 | uu____0 = (size_t)48U; |
3259 | 0 | break; |
3260 | 0 | } |
3261 | 0 | case libcrux_sha3_Sha512: { |
3262 | 0 | uu____0 = (size_t)64U; |
3263 | 0 | break; |
3264 | 0 | } |
3265 | 0 | default: { |
3266 | 0 | KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, |
3267 | 0 | __LINE__); |
3268 | 0 | KRML_HOST_EXIT(253U); |
3269 | 0 | } |
3270 | 0 | } |
3271 | 0 | return uu____0; |
3272 | 0 | } |
3273 | | |
3274 | | /** |
3275 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block |
3276 | | with const generics |
3277 | | - RATE= 144 |
3278 | | */ |
3279 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c2( |
3280 | 0 | uint64_t (*s)[5U], Eurydice_slice blocks[1U]) { |
3281 | 0 | for (size_t i = (size_t)0U; i < (size_t)144U / (size_t)8U; i++) { |
3282 | 0 | size_t i0 = i; |
3283 | 0 | uint8_t uu____0[8U]; |
3284 | 0 | Result_56 dst; |
3285 | 0 | Eurydice_slice_to_array2( |
3286 | 0 | &dst, |
3287 | 0 | Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0, |
3288 | 0 | (size_t)8U * i0 + (size_t)8U, uint8_t), |
3289 | 0 | Eurydice_slice, uint8_t[8U]); |
3290 | 0 | unwrap_41_ac(dst, uu____0); |
3291 | 0 | size_t uu____1 = i0 / (size_t)5U; |
3292 | 0 | size_t uu____2 = i0 % (size_t)5U; |
3293 | 0 | s[uu____1][uu____2] = |
3294 | 0 | s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0); |
3295 | 0 | } |
3296 | 0 | } |
3297 | | |
3298 | | /** |
3299 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3300 | | usize> for u64)} |
3301 | | */ |
3302 | | /** |
3303 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a |
3304 | | with const generics |
3305 | | - RATE= 144 |
3306 | | */ |
3307 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b81( |
3308 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
3309 | 0 | uint64_t(*uu____0)[5U] = a; |
3310 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3311 | 0 | Eurydice_slice copy_of_b[1U]; |
3312 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice)); |
3313 | 0 | libcrux_sha3_portable_keccak_load_block_2c2(uu____0, copy_of_b); |
3314 | 0 | } |
3315 | | |
3316 | | /** |
3317 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block |
3318 | | with types uint64_t |
3319 | | with const generics |
3320 | | - N= 1 |
3321 | | - RATE= 144 |
3322 | | */ |
3323 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df1( |
3324 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) { |
3325 | 0 | uint64_t(*uu____0)[5U] = s->st; |
3326 | 0 | Eurydice_slice uu____1[1U]; |
3327 | 0 | memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice)); |
3328 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b81(uu____0, uu____1); |
3329 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3330 | 0 | } |
3331 | | |
3332 | | /** |
3333 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full |
3334 | | with const generics |
3335 | | - RATE= 144 |
3336 | | */ |
3337 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df2( |
3338 | 0 | uint64_t (*s)[5U], uint8_t blocks[1U][200U]) { |
3339 | 0 | Eurydice_slice buf[1U] = { |
3340 | 0 | Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)}; |
3341 | 0 | libcrux_sha3_portable_keccak_load_block_2c2(s, buf); |
3342 | 0 | } |
3343 | | |
3344 | | /** |
3345 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3346 | | usize> for u64)} |
3347 | | */ |
3348 | | /** |
3349 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a |
3350 | | with const generics |
3351 | | - RATE= 144 |
3352 | | */ |
3353 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d22( |
3354 | 0 | uint64_t (*a)[5U], uint8_t b[1U][200U]) { |
3355 | 0 | uint64_t(*uu____0)[5U] = a; |
3356 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3357 | 0 | uint8_t copy_of_b[1U][200U]; |
3358 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U])); |
3359 | 0 | libcrux_sha3_portable_keccak_load_block_full_df2(uu____0, copy_of_b); |
3360 | 0 | } |
3361 | | |
3362 | | /** |
3363 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final |
3364 | | with types uint64_t |
3365 | | with const generics |
3366 | | - N= 1 |
3367 | | - RATE= 144 |
3368 | | - DELIM= 6 |
3369 | | */ |
3370 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c73( |
3371 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) { |
3372 | 0 | size_t last_len = Eurydice_slice_len(last[0U], uint8_t); |
3373 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
3374 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3375 | 0 | size_t i0 = i; |
3376 | 0 | if (last_len > (size_t)0U) { |
3377 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
3378 | 0 | blocks[i0], (size_t)0U, last_len, uint8_t); |
3379 | 0 | Eurydice_slice_copy(uu____0, last[i0], uint8_t); |
3380 | 0 | } |
3381 | 0 | blocks[i0][last_len] = 6U; |
3382 | 0 | size_t uu____1 = i0; |
3383 | 0 | size_t uu____2 = (size_t)144U - (size_t)1U; |
3384 | 0 | blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U; |
3385 | 0 | } |
3386 | 0 | uint64_t(*uu____3)[5U] = s->st; |
3387 | 0 | uint8_t uu____4[1U][200U]; |
3388 | 0 | memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
3389 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d22(uu____3, uu____4); |
3390 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3391 | 0 | } |
3392 | | |
3393 | | /** |
3394 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block |
3395 | | with const generics |
3396 | | - RATE= 144 |
3397 | | */ |
3398 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_582( |
3399 | 0 | uint64_t (*s)[5U], Eurydice_slice out[1U]) { |
3400 | 0 | for (size_t i = (size_t)0U; i < (size_t)144U / (size_t)8U; i++) { |
3401 | 0 | size_t i0 = i; |
3402 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
3403 | 0 | out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t); |
3404 | 0 | uint8_t ret[8U]; |
3405 | 0 | core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
3406 | 0 | Eurydice_slice_copy( |
3407 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
3408 | 0 | } |
3409 | 0 | } |
3410 | | |
3411 | | /** |
3412 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full |
3413 | | with const generics |
3414 | | - RATE= 144 |
3415 | | */ |
3416 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d1( |
3417 | 0 | uint64_t (*s)[5U], uint8_t ret[1U][200U]) { |
3418 | 0 | uint8_t out[200U] = {0U}; |
3419 | 0 | Eurydice_slice buf[1U] = { |
3420 | 0 | Eurydice_array_to_slice((size_t)200U, out, uint8_t)}; |
3421 | 0 | libcrux_sha3_portable_keccak_store_block_582(s, buf); |
3422 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3423 | 0 | uint8_t copy_of_out[200U]; |
3424 | 0 | memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t)); |
3425 | 0 | memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t)); |
3426 | 0 | } |
3427 | | |
3428 | | /** |
3429 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3430 | | usize> for u64)} |
3431 | | */ |
3432 | | /** |
3433 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a |
3434 | | with const generics |
3435 | | - RATE= 144 |
3436 | | */ |
3437 | | static KRML_MUSTINLINE void |
3438 | | libcrux_sha3_portable_keccak_store_block_full_5a_291(uint64_t (*a)[5U], |
3439 | 0 | uint8_t ret[1U][200U]) { |
3440 | 0 | libcrux_sha3_portable_keccak_store_block_full_2d1(a, ret); |
3441 | 0 | } |
3442 | | |
3443 | | /** |
3444 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last |
3445 | | with types uint64_t |
3446 | | with const generics |
3447 | | - N= 1 |
3448 | | - RATE= 144 |
3449 | | */ |
3450 | | static KRML_MUSTINLINE void |
3451 | | libcrux_sha3_generic_keccak_squeeze_first_and_last_c51( |
3452 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3453 | 0 | uint8_t b[1U][200U]; |
3454 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_291(s->st, b); |
3455 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3456 | 0 | size_t i0 = i; |
3457 | 0 | Eurydice_slice uu____0 = out[i0]; |
3458 | 0 | uint8_t *uu____1 = b[i0]; |
3459 | 0 | core_ops_range_Range_b3 lit; |
3460 | 0 | lit.start = (size_t)0U; |
3461 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
3462 | 0 | Eurydice_slice_copy( |
3463 | 0 | uu____0, |
3464 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
3465 | 0 | core_ops_range_Range_b3), |
3466 | 0 | uint8_t); |
3467 | 0 | } |
3468 | 0 | } |
3469 | | |
3470 | | /** |
3471 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3472 | | usize> for u64)} |
3473 | | */ |
3474 | | /** |
3475 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a |
3476 | | with const generics |
3477 | | - RATE= 144 |
3478 | | */ |
3479 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_592( |
3480 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
3481 | 0 | libcrux_sha3_portable_keccak_store_block_582(a, b); |
3482 | 0 | } |
3483 | | |
3484 | | /** |
3485 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block |
3486 | | with types uint64_t |
3487 | | with const generics |
3488 | | - N= 1 |
3489 | | - RATE= 144 |
3490 | | */ |
3491 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_842( |
3492 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3493 | 0 | libcrux_sha3_portable_keccak_store_block_5a_592(s->st, out); |
3494 | 0 | } |
3495 | | |
3496 | | /** |
3497 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block |
3498 | | with types uint64_t |
3499 | | with const generics |
3500 | | - N= 1 |
3501 | | - RATE= 144 |
3502 | | */ |
3503 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc2( |
3504 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3505 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3506 | 0 | libcrux_sha3_portable_keccak_store_block_5a_592(s->st, out); |
3507 | 0 | } |
3508 | | |
3509 | | /** |
3510 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last |
3511 | | with types uint64_t |
3512 | | with const generics |
3513 | | - N= 1 |
3514 | | - RATE= 144 |
3515 | | */ |
3516 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf1( |
3517 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) { |
3518 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&s); |
3519 | 0 | uint8_t b[1U][200U]; |
3520 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_291(s.st, b); |
3521 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3522 | 0 | size_t i0 = i; |
3523 | 0 | Eurydice_slice uu____0 = out[i0]; |
3524 | 0 | uint8_t *uu____1 = b[i0]; |
3525 | 0 | core_ops_range_Range_b3 lit; |
3526 | 0 | lit.start = (size_t)0U; |
3527 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
3528 | 0 | Eurydice_slice_copy( |
3529 | 0 | uu____0, |
3530 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
3531 | 0 | core_ops_range_Range_b3), |
3532 | 0 | uint8_t); |
3533 | 0 | } |
3534 | 0 | } |
3535 | | |
3536 | | /** |
3537 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccak |
3538 | | with types uint64_t |
3539 | | with const generics |
3540 | | - N= 1 |
3541 | | - RATE= 144 |
3542 | | - DELIM= 6 |
3543 | | */ |
3544 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e92( |
3545 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
3546 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s = |
3547 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(); |
3548 | 0 | for (size_t i = (size_t)0U; |
3549 | 0 | i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)144U; i++) { |
3550 | 0 | size_t i0 = i; |
3551 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s; |
3552 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3553 | 0 | Eurydice_slice copy_of_data[1U]; |
3554 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3555 | 0 | Eurydice_slice ret[1U]; |
3556 | 0 | libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)144U, |
3557 | 0 | (size_t)144U, ret); |
3558 | 0 | libcrux_sha3_generic_keccak_absorb_block_df1(uu____0, ret); |
3559 | 0 | } |
3560 | 0 | size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)144U; |
3561 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s; |
3562 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3563 | 0 | Eurydice_slice copy_of_data[1U]; |
3564 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3565 | 0 | Eurydice_slice ret[1U]; |
3566 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
3567 | 0 | copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret); |
3568 | 0 | libcrux_sha3_generic_keccak_absorb_final_c73(uu____2, ret); |
3569 | 0 | size_t outlen = Eurydice_slice_len(out[0U], uint8_t); |
3570 | 0 | size_t blocks = outlen / (size_t)144U; |
3571 | 0 | size_t last = outlen - outlen % (size_t)144U; |
3572 | 0 | if (blocks == (size_t)0U) { |
3573 | 0 | libcrux_sha3_generic_keccak_squeeze_first_and_last_c51(&s, out); |
3574 | 0 | } else { |
3575 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____4 = |
3576 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)144U); |
3577 | 0 | Eurydice_slice o0[1U]; |
3578 | 0 | memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice)); |
3579 | 0 | Eurydice_slice o1[1U]; |
3580 | 0 | memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice)); |
3581 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_842(&s, o0); |
3582 | 0 | core_ops_range_Range_b3 iter = |
3583 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
3584 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
3585 | 0 | .end = blocks}), |
3586 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
3587 | 0 | while (true) { |
3588 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
3589 | 0 | &iter, size_t, Option_b3) |
3590 | 0 | .tag == None) { |
3591 | 0 | break; |
3592 | 0 | } else { |
3593 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____5 = |
3594 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)144U); |
3595 | 0 | Eurydice_slice o[1U]; |
3596 | 0 | memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice)); |
3597 | 0 | Eurydice_slice orest[1U]; |
3598 | 0 | memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice)); |
3599 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc2(&s, o); |
3600 | 0 | memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice)); |
3601 | 0 | } |
3602 | 0 | } |
3603 | 0 | if (last < outlen) { |
3604 | 0 | libcrux_sha3_generic_keccak_squeeze_last_cf1(s, o1); |
3605 | 0 | } |
3606 | 0 | } |
3607 | 0 | } |
3608 | | |
3609 | | /** |
3610 | | A monomorphic instance of libcrux_sha3.portable.keccakx1 |
3611 | | with const generics |
3612 | | - RATE= 144 |
3613 | | - DELIM= 6 |
3614 | | */ |
3615 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce2( |
3616 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
3617 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3618 | 0 | Eurydice_slice copy_of_data[1U]; |
3619 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3620 | 0 | libcrux_sha3_generic_keccak_keccak_e92(copy_of_data, out); |
3621 | 0 | } |
3622 | | |
3623 | | /** |
3624 | | A portable SHA3 224 implementation. |
3625 | | */ |
3626 | | static KRML_MUSTINLINE void libcrux_sha3_portable_sha224(Eurydice_slice digest, |
3627 | 0 | Eurydice_slice data) { |
3628 | 0 | Eurydice_slice buf0[1U] = {data}; |
3629 | 0 | Eurydice_slice buf[1U] = {digest}; |
3630 | 0 | libcrux_sha3_portable_keccakx1_ce2(buf0, buf); |
3631 | 0 | } |
3632 | | |
3633 | | /** |
3634 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block |
3635 | | with const generics |
3636 | | - RATE= 104 |
3637 | | */ |
3638 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_2c3( |
3639 | 0 | uint64_t (*s)[5U], Eurydice_slice blocks[1U]) { |
3640 | 0 | for (size_t i = (size_t)0U; i < (size_t)104U / (size_t)8U; i++) { |
3641 | 0 | size_t i0 = i; |
3642 | 0 | uint8_t uu____0[8U]; |
3643 | 0 | Result_56 dst; |
3644 | 0 | Eurydice_slice_to_array2( |
3645 | 0 | &dst, |
3646 | 0 | Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0, |
3647 | 0 | (size_t)8U * i0 + (size_t)8U, uint8_t), |
3648 | 0 | Eurydice_slice, uint8_t[8U]); |
3649 | 0 | unwrap_41_ac(dst, uu____0); |
3650 | 0 | size_t uu____1 = i0 / (size_t)5U; |
3651 | 0 | size_t uu____2 = i0 % (size_t)5U; |
3652 | 0 | s[uu____1][uu____2] = |
3653 | 0 | s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0); |
3654 | 0 | } |
3655 | 0 | } |
3656 | | |
3657 | | /** |
3658 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3659 | | usize> for u64)} |
3660 | | */ |
3661 | | /** |
3662 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a |
3663 | | with const generics |
3664 | | - RATE= 104 |
3665 | | */ |
3666 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b82( |
3667 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
3668 | 0 | uint64_t(*uu____0)[5U] = a; |
3669 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3670 | 0 | Eurydice_slice copy_of_b[1U]; |
3671 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice)); |
3672 | 0 | libcrux_sha3_portable_keccak_load_block_2c3(uu____0, copy_of_b); |
3673 | 0 | } |
3674 | | |
3675 | | /** |
3676 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block |
3677 | | with types uint64_t |
3678 | | with const generics |
3679 | | - N= 1 |
3680 | | - RATE= 104 |
3681 | | */ |
3682 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df2( |
3683 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) { |
3684 | 0 | uint64_t(*uu____0)[5U] = s->st; |
3685 | 0 | Eurydice_slice uu____1[1U]; |
3686 | 0 | memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice)); |
3687 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b82(uu____0, uu____1); |
3688 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3689 | 0 | } |
3690 | | |
3691 | | /** |
3692 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full |
3693 | | with const generics |
3694 | | - RATE= 104 |
3695 | | */ |
3696 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_df3( |
3697 | 0 | uint64_t (*s)[5U], uint8_t blocks[1U][200U]) { |
3698 | 0 | Eurydice_slice buf[1U] = { |
3699 | 0 | Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)}; |
3700 | 0 | libcrux_sha3_portable_keccak_load_block_2c3(s, buf); |
3701 | 0 | } |
3702 | | |
3703 | | /** |
3704 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3705 | | usize> for u64)} |
3706 | | */ |
3707 | | /** |
3708 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_full_5a |
3709 | | with const generics |
3710 | | - RATE= 104 |
3711 | | */ |
3712 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_full_5a_d23( |
3713 | 0 | uint64_t (*a)[5U], uint8_t b[1U][200U]) { |
3714 | 0 | uint64_t(*uu____0)[5U] = a; |
3715 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3716 | 0 | uint8_t copy_of_b[1U][200U]; |
3717 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U])); |
3718 | 0 | libcrux_sha3_portable_keccak_load_block_full_df3(uu____0, copy_of_b); |
3719 | 0 | } |
3720 | | |
3721 | | /** |
3722 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final |
3723 | | with types uint64_t |
3724 | | with const generics |
3725 | | - N= 1 |
3726 | | - RATE= 104 |
3727 | | - DELIM= 6 |
3728 | | */ |
3729 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_c74( |
3730 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) { |
3731 | 0 | size_t last_len = Eurydice_slice_len(last[0U], uint8_t); |
3732 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
3733 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3734 | 0 | size_t i0 = i; |
3735 | 0 | if (last_len > (size_t)0U) { |
3736 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
3737 | 0 | blocks[i0], (size_t)0U, last_len, uint8_t); |
3738 | 0 | Eurydice_slice_copy(uu____0, last[i0], uint8_t); |
3739 | 0 | } |
3740 | 0 | blocks[i0][last_len] = 6U; |
3741 | 0 | size_t uu____1 = i0; |
3742 | 0 | size_t uu____2 = (size_t)104U - (size_t)1U; |
3743 | 0 | blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U; |
3744 | 0 | } |
3745 | 0 | uint64_t(*uu____3)[5U] = s->st; |
3746 | 0 | uint8_t uu____4[1U][200U]; |
3747 | 0 | memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
3748 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d23(uu____3, uu____4); |
3749 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3750 | 0 | } |
3751 | | |
3752 | | /** |
3753 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block |
3754 | | with const generics |
3755 | | - RATE= 104 |
3756 | | */ |
3757 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_583( |
3758 | 0 | uint64_t (*s)[5U], Eurydice_slice out[1U]) { |
3759 | 0 | for (size_t i = (size_t)0U; i < (size_t)104U / (size_t)8U; i++) { |
3760 | 0 | size_t i0 = i; |
3761 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
3762 | 0 | out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t); |
3763 | 0 | uint8_t ret[8U]; |
3764 | 0 | core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
3765 | 0 | Eurydice_slice_copy( |
3766 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
3767 | 0 | } |
3768 | 0 | } |
3769 | | |
3770 | | /** |
3771 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full |
3772 | | with const generics |
3773 | | - RATE= 104 |
3774 | | */ |
3775 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d2( |
3776 | 0 | uint64_t (*s)[5U], uint8_t ret[1U][200U]) { |
3777 | 0 | uint8_t out[200U] = {0U}; |
3778 | 0 | Eurydice_slice buf[1U] = { |
3779 | 0 | Eurydice_array_to_slice((size_t)200U, out, uint8_t)}; |
3780 | 0 | libcrux_sha3_portable_keccak_store_block_583(s, buf); |
3781 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3782 | 0 | uint8_t copy_of_out[200U]; |
3783 | 0 | memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t)); |
3784 | 0 | memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t)); |
3785 | 0 | } |
3786 | | |
3787 | | /** |
3788 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3789 | | usize> for u64)} |
3790 | | */ |
3791 | | /** |
3792 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a |
3793 | | with const generics |
3794 | | - RATE= 104 |
3795 | | */ |
3796 | | static KRML_MUSTINLINE void |
3797 | | libcrux_sha3_portable_keccak_store_block_full_5a_292(uint64_t (*a)[5U], |
3798 | 0 | uint8_t ret[1U][200U]) { |
3799 | 0 | libcrux_sha3_portable_keccak_store_block_full_2d2(a, ret); |
3800 | 0 | } |
3801 | | |
3802 | | /** |
3803 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last |
3804 | | with types uint64_t |
3805 | | with const generics |
3806 | | - N= 1 |
3807 | | - RATE= 104 |
3808 | | */ |
3809 | | static KRML_MUSTINLINE void |
3810 | | libcrux_sha3_generic_keccak_squeeze_first_and_last_c52( |
3811 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3812 | 0 | uint8_t b[1U][200U]; |
3813 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_292(s->st, b); |
3814 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3815 | 0 | size_t i0 = i; |
3816 | 0 | Eurydice_slice uu____0 = out[i0]; |
3817 | 0 | uint8_t *uu____1 = b[i0]; |
3818 | 0 | core_ops_range_Range_b3 lit; |
3819 | 0 | lit.start = (size_t)0U; |
3820 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
3821 | 0 | Eurydice_slice_copy( |
3822 | 0 | uu____0, |
3823 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
3824 | 0 | core_ops_range_Range_b3), |
3825 | 0 | uint8_t); |
3826 | 0 | } |
3827 | 0 | } |
3828 | | |
3829 | | /** |
3830 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
3831 | | usize> for u64)} |
3832 | | */ |
3833 | | /** |
3834 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_5a |
3835 | | with const generics |
3836 | | - RATE= 104 |
3837 | | */ |
3838 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_5a_593( |
3839 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
3840 | 0 | libcrux_sha3_portable_keccak_store_block_583(a, b); |
3841 | 0 | } |
3842 | | |
3843 | | /** |
3844 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_block |
3845 | | with types uint64_t |
3846 | | with const generics |
3847 | | - N= 1 |
3848 | | - RATE= 104 |
3849 | | */ |
3850 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_first_block_843( |
3851 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3852 | 0 | libcrux_sha3_portable_keccak_store_block_5a_593(s->st, out); |
3853 | 0 | } |
3854 | | |
3855 | | /** |
3856 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_next_block |
3857 | | with types uint64_t |
3858 | | with const generics |
3859 | | - N= 1 |
3860 | | - RATE= 104 |
3861 | | */ |
3862 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_next_block_fc3( |
3863 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
3864 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
3865 | 0 | libcrux_sha3_portable_keccak_store_block_5a_593(s->st, out); |
3866 | 0 | } |
3867 | | |
3868 | | /** |
3869 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last |
3870 | | with types uint64_t |
3871 | | with const generics |
3872 | | - N= 1 |
3873 | | - RATE= 104 |
3874 | | */ |
3875 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf2( |
3876 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) { |
3877 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&s); |
3878 | 0 | uint8_t b[1U][200U]; |
3879 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_292(s.st, b); |
3880 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
3881 | 0 | size_t i0 = i; |
3882 | 0 | Eurydice_slice uu____0 = out[i0]; |
3883 | 0 | uint8_t *uu____1 = b[i0]; |
3884 | 0 | core_ops_range_Range_b3 lit; |
3885 | 0 | lit.start = (size_t)0U; |
3886 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
3887 | 0 | Eurydice_slice_copy( |
3888 | 0 | uu____0, |
3889 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
3890 | 0 | core_ops_range_Range_b3), |
3891 | 0 | uint8_t); |
3892 | 0 | } |
3893 | 0 | } |
3894 | | |
3895 | | /** |
3896 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccak |
3897 | | with types uint64_t |
3898 | | with const generics |
3899 | | - N= 1 |
3900 | | - RATE= 104 |
3901 | | - DELIM= 6 |
3902 | | */ |
3903 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e93( |
3904 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
3905 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s = |
3906 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(); |
3907 | 0 | for (size_t i = (size_t)0U; |
3908 | 0 | i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)104U; i++) { |
3909 | 0 | size_t i0 = i; |
3910 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s; |
3911 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3912 | 0 | Eurydice_slice copy_of_data[1U]; |
3913 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3914 | 0 | Eurydice_slice ret[1U]; |
3915 | 0 | libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)104U, |
3916 | 0 | (size_t)104U, ret); |
3917 | 0 | libcrux_sha3_generic_keccak_absorb_block_df2(uu____0, ret); |
3918 | 0 | } |
3919 | 0 | size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)104U; |
3920 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s; |
3921 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3922 | 0 | Eurydice_slice copy_of_data[1U]; |
3923 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3924 | 0 | Eurydice_slice ret[1U]; |
3925 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
3926 | 0 | copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret); |
3927 | 0 | libcrux_sha3_generic_keccak_absorb_final_c74(uu____2, ret); |
3928 | 0 | size_t outlen = Eurydice_slice_len(out[0U], uint8_t); |
3929 | 0 | size_t blocks = outlen / (size_t)104U; |
3930 | 0 | size_t last = outlen - outlen % (size_t)104U; |
3931 | 0 | if (blocks == (size_t)0U) { |
3932 | 0 | libcrux_sha3_generic_keccak_squeeze_first_and_last_c52(&s, out); |
3933 | 0 | } else { |
3934 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____4 = |
3935 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)104U); |
3936 | 0 | Eurydice_slice o0[1U]; |
3937 | 0 | memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice)); |
3938 | 0 | Eurydice_slice o1[1U]; |
3939 | 0 | memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice)); |
3940 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_843(&s, o0); |
3941 | 0 | core_ops_range_Range_b3 iter = |
3942 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
3943 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
3944 | 0 | .end = blocks}), |
3945 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
3946 | 0 | while (true) { |
3947 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
3948 | 0 | &iter, size_t, Option_b3) |
3949 | 0 | .tag == None) { |
3950 | 0 | break; |
3951 | 0 | } else { |
3952 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____5 = |
3953 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)104U); |
3954 | 0 | Eurydice_slice o[1U]; |
3955 | 0 | memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice)); |
3956 | 0 | Eurydice_slice orest[1U]; |
3957 | 0 | memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice)); |
3958 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc3(&s, o); |
3959 | 0 | memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice)); |
3960 | 0 | } |
3961 | 0 | } |
3962 | 0 | if (last < outlen) { |
3963 | 0 | libcrux_sha3_generic_keccak_squeeze_last_cf2(s, o1); |
3964 | 0 | } |
3965 | 0 | } |
3966 | 0 | } |
3967 | | |
3968 | | /** |
3969 | | A monomorphic instance of libcrux_sha3.portable.keccakx1 |
3970 | | with const generics |
3971 | | - RATE= 104 |
3972 | | - DELIM= 6 |
3973 | | */ |
3974 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce3( |
3975 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
3976 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
3977 | 0 | Eurydice_slice copy_of_data[1U]; |
3978 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
3979 | 0 | libcrux_sha3_generic_keccak_keccak_e93(copy_of_data, out); |
3980 | 0 | } |
3981 | | |
3982 | | /** |
3983 | | A portable SHA3 384 implementation. |
3984 | | */ |
3985 | | static KRML_MUSTINLINE void libcrux_sha3_portable_sha384(Eurydice_slice digest, |
3986 | 0 | Eurydice_slice data) { |
3987 | 0 | Eurydice_slice buf0[1U] = {data}; |
3988 | 0 | Eurydice_slice buf[1U] = {digest}; |
3989 | 0 | libcrux_sha3_portable_keccakx1_ce3(buf0, buf); |
3990 | 0 | } |
3991 | | |
3992 | | /** |
3993 | | SHA3 224 |
3994 | | |
3995 | | Preconditions: |
3996 | | - `digest.len() == 28` |
3997 | | */ |
3998 | | static KRML_MUSTINLINE void libcrux_sha3_sha224_ema(Eurydice_slice digest, |
3999 | 0 | Eurydice_slice payload) { |
4000 | 0 | libcrux_sha3_portable_sha224(digest, payload); |
4001 | 0 | } |
4002 | | |
4003 | | /** |
4004 | | SHA3 224 |
4005 | | */ |
4006 | | static KRML_MUSTINLINE void libcrux_sha3_sha224(Eurydice_slice data, |
4007 | 0 | uint8_t ret[28U]) { |
4008 | 0 | uint8_t out[28U] = {0U}; |
4009 | 0 | libcrux_sha3_sha224_ema(Eurydice_array_to_slice((size_t)28U, out, uint8_t), |
4010 | 0 | data); |
4011 | 0 | memcpy(ret, out, (size_t)28U * sizeof(uint8_t)); |
4012 | 0 | } |
4013 | | |
4014 | | /** |
4015 | | SHA3 256 |
4016 | | */ |
4017 | | static KRML_MUSTINLINE void libcrux_sha3_sha256_ema(Eurydice_slice digest, |
4018 | 0 | Eurydice_slice payload) { |
4019 | 0 | libcrux_sha3_portable_sha256(digest, payload); |
4020 | 0 | } |
4021 | | |
4022 | | /** |
4023 | | SHA3 256 |
4024 | | */ |
4025 | | static KRML_MUSTINLINE void libcrux_sha3_sha256(Eurydice_slice data, |
4026 | 0 | uint8_t ret[32U]) { |
4027 | 0 | uint8_t out[32U] = {0U}; |
4028 | 0 | libcrux_sha3_sha256_ema(Eurydice_array_to_slice((size_t)32U, out, uint8_t), |
4029 | 0 | data); |
4030 | 0 | memcpy(ret, out, (size_t)32U * sizeof(uint8_t)); |
4031 | 0 | } |
4032 | | |
4033 | | /** |
4034 | | SHA3 384 |
4035 | | */ |
4036 | | static KRML_MUSTINLINE void libcrux_sha3_sha384_ema(Eurydice_slice digest, |
4037 | 0 | Eurydice_slice payload) { |
4038 | 0 | libcrux_sha3_portable_sha384(digest, payload); |
4039 | 0 | } |
4040 | | |
4041 | | /** |
4042 | | SHA3 384 |
4043 | | */ |
4044 | | static KRML_MUSTINLINE void libcrux_sha3_sha384(Eurydice_slice data, |
4045 | 0 | uint8_t ret[48U]) { |
4046 | 0 | uint8_t out[48U] = {0U}; |
4047 | 0 | libcrux_sha3_sha384_ema(Eurydice_array_to_slice((size_t)48U, out, uint8_t), |
4048 | 0 | data); |
4049 | 0 | memcpy(ret, out, (size_t)48U * sizeof(uint8_t)); |
4050 | 0 | } |
4051 | | |
4052 | | /** |
4053 | | SHA3 512 |
4054 | | */ |
4055 | | static KRML_MUSTINLINE void libcrux_sha3_sha512_ema(Eurydice_slice digest, |
4056 | 0 | Eurydice_slice payload) { |
4057 | 0 | libcrux_sha3_portable_sha512(digest, payload); |
4058 | 0 | } |
4059 | | |
4060 | | /** |
4061 | | SHA3 512 |
4062 | | */ |
4063 | | static KRML_MUSTINLINE void libcrux_sha3_sha512(Eurydice_slice data, |
4064 | 0 | uint8_t ret[64U]) { |
4065 | 0 | uint8_t out[64U] = {0U}; |
4066 | 0 | libcrux_sha3_sha512_ema(Eurydice_array_to_slice((size_t)64U, out, uint8_t), |
4067 | 0 | data); |
4068 | 0 | memcpy(ret, out, (size_t)64U * sizeof(uint8_t)); |
4069 | 0 | } |
4070 | | |
4071 | | /** |
4072 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
4073 | | usize> for u64)} |
4074 | | */ |
4075 | | /** |
4076 | | A monomorphic instance of libcrux_sha3.portable_keccak.load_block_5a |
4077 | | with const generics |
4078 | | - RATE= 168 |
4079 | | */ |
4080 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_load_block_5a_b83( |
4081 | 0 | uint64_t (*a)[5U], Eurydice_slice b[1U]) { |
4082 | 0 | uint64_t(*uu____0)[5U] = a; |
4083 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4084 | 0 | Eurydice_slice copy_of_b[1U]; |
4085 | 0 | memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice)); |
4086 | 0 | libcrux_sha3_portable_keccak_load_block_2c1(uu____0, copy_of_b); |
4087 | 0 | } |
4088 | | |
4089 | | /** |
4090 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_block |
4091 | | with types uint64_t |
4092 | | with const generics |
4093 | | - N= 1 |
4094 | | - RATE= 168 |
4095 | | */ |
4096 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_block_df3( |
4097 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) { |
4098 | 0 | uint64_t(*uu____0)[5U] = s->st; |
4099 | 0 | Eurydice_slice uu____1[1U]; |
4100 | 0 | memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice)); |
4101 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b83(uu____0, uu____1); |
4102 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(s); |
4103 | 0 | } |
4104 | | |
4105 | | /** |
4106 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full |
4107 | | with const generics |
4108 | | - RATE= 168 |
4109 | | */ |
4110 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_block_full_2d3( |
4111 | 0 | uint64_t (*s)[5U], uint8_t ret[1U][200U]) { |
4112 | 0 | uint8_t out[200U] = {0U}; |
4113 | 0 | Eurydice_slice buf[1U] = { |
4114 | 0 | Eurydice_array_to_slice((size_t)200U, out, uint8_t)}; |
4115 | 0 | libcrux_sha3_portable_keccak_store_block_581(s, buf); |
4116 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4117 | 0 | uint8_t copy_of_out[200U]; |
4118 | 0 | memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t)); |
4119 | 0 | memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t)); |
4120 | 0 | } |
4121 | | |
4122 | | /** |
4123 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
4124 | | usize> for u64)} |
4125 | | */ |
4126 | | /** |
4127 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_block_full_5a |
4128 | | with const generics |
4129 | | - RATE= 168 |
4130 | | */ |
4131 | | static KRML_MUSTINLINE void |
4132 | | libcrux_sha3_portable_keccak_store_block_full_5a_293(uint64_t (*a)[5U], |
4133 | 0 | uint8_t ret[1U][200U]) { |
4134 | 0 | libcrux_sha3_portable_keccak_store_block_full_2d3(a, ret); |
4135 | 0 | } |
4136 | | |
4137 | | /** |
4138 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_and_last |
4139 | | with types uint64_t |
4140 | | with const generics |
4141 | | - N= 1 |
4142 | | - RATE= 168 |
4143 | | */ |
4144 | | static KRML_MUSTINLINE void |
4145 | | libcrux_sha3_generic_keccak_squeeze_first_and_last_c53( |
4146 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
4147 | 0 | uint8_t b[1U][200U]; |
4148 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_293(s->st, b); |
4149 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4150 | 0 | size_t i0 = i; |
4151 | 0 | Eurydice_slice uu____0 = out[i0]; |
4152 | 0 | uint8_t *uu____1 = b[i0]; |
4153 | 0 | core_ops_range_Range_b3 lit; |
4154 | 0 | lit.start = (size_t)0U; |
4155 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
4156 | 0 | Eurydice_slice_copy( |
4157 | 0 | uu____0, |
4158 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
4159 | 0 | core_ops_range_Range_b3), |
4160 | 0 | uint8_t); |
4161 | 0 | } |
4162 | 0 | } |
4163 | | |
4164 | | /** |
4165 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_last |
4166 | | with types uint64_t |
4167 | | with const generics |
4168 | | - N= 1 |
4169 | | - RATE= 168 |
4170 | | */ |
4171 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_last_cf3( |
4172 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s, Eurydice_slice out[1U]) { |
4173 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&s); |
4174 | 0 | uint8_t b[1U][200U]; |
4175 | 0 | libcrux_sha3_portable_keccak_store_block_full_5a_293(s.st, b); |
4176 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4177 | 0 | size_t i0 = i; |
4178 | 0 | Eurydice_slice uu____0 = out[i0]; |
4179 | 0 | uint8_t *uu____1 = b[i0]; |
4180 | 0 | core_ops_range_Range_b3 lit; |
4181 | 0 | lit.start = (size_t)0U; |
4182 | 0 | lit.end = Eurydice_slice_len(out[i0], uint8_t); |
4183 | 0 | Eurydice_slice_copy( |
4184 | 0 | uu____0, |
4185 | 0 | Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t, |
4186 | 0 | core_ops_range_Range_b3), |
4187 | 0 | uint8_t); |
4188 | 0 | } |
4189 | 0 | } |
4190 | | |
4191 | | /** |
4192 | | A monomorphic instance of libcrux_sha3.generic_keccak.keccak |
4193 | | with types uint64_t |
4194 | | with const generics |
4195 | | - N= 1 |
4196 | | - RATE= 168 |
4197 | | - DELIM= 31 |
4198 | | */ |
4199 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_keccak_e94( |
4200 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
4201 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 s = |
4202 | 0 | libcrux_sha3_generic_keccak_new_1e_f4(); |
4203 | 0 | for (size_t i = (size_t)0U; |
4204 | 0 | i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)168U; i++) { |
4205 | 0 | size_t i0 = i; |
4206 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s; |
4207 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4208 | 0 | Eurydice_slice copy_of_data[1U]; |
4209 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
4210 | 0 | Eurydice_slice ret[1U]; |
4211 | 0 | libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)168U, |
4212 | 0 | (size_t)168U, ret); |
4213 | 0 | libcrux_sha3_generic_keccak_absorb_block_df3(uu____0, ret); |
4214 | 0 | } |
4215 | 0 | size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)168U; |
4216 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s; |
4217 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4218 | 0 | Eurydice_slice copy_of_data[1U]; |
4219 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
4220 | 0 | Eurydice_slice ret[1U]; |
4221 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
4222 | 0 | copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret); |
4223 | 0 | libcrux_sha3_generic_keccak_absorb_final_c72(uu____2, ret); |
4224 | 0 | size_t outlen = Eurydice_slice_len(out[0U], uint8_t); |
4225 | 0 | size_t blocks = outlen / (size_t)168U; |
4226 | 0 | size_t last = outlen - outlen % (size_t)168U; |
4227 | 0 | if (blocks == (size_t)0U) { |
4228 | 0 | libcrux_sha3_generic_keccak_squeeze_first_and_last_c53(&s, out); |
4229 | 0 | } else { |
4230 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____4 = |
4231 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U); |
4232 | 0 | Eurydice_slice o0[1U]; |
4233 | 0 | memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice)); |
4234 | 0 | Eurydice_slice o1[1U]; |
4235 | 0 | memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice)); |
4236 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_841(&s, o0); |
4237 | 0 | core_ops_range_Range_b3 iter = |
4238 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
4239 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
4240 | 0 | .end = blocks}), |
4241 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
4242 | 0 | while (true) { |
4243 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
4244 | 0 | &iter, size_t, Option_b3) |
4245 | 0 | .tag == None) { |
4246 | 0 | break; |
4247 | 0 | } else { |
4248 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____5 = |
4249 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)168U); |
4250 | 0 | Eurydice_slice o[1U]; |
4251 | 0 | memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice)); |
4252 | 0 | Eurydice_slice orest[1U]; |
4253 | 0 | memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice)); |
4254 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(&s, o); |
4255 | 0 | memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice)); |
4256 | 0 | } |
4257 | 0 | } |
4258 | 0 | if (last < outlen) { |
4259 | 0 | libcrux_sha3_generic_keccak_squeeze_last_cf3(s, o1); |
4260 | 0 | } |
4261 | 0 | } |
4262 | 0 | } |
4263 | | |
4264 | | /** |
4265 | | A monomorphic instance of libcrux_sha3.portable.keccakx1 |
4266 | | with const generics |
4267 | | - RATE= 168 |
4268 | | - DELIM= 31 |
4269 | | */ |
4270 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccakx1_ce4( |
4271 | 0 | Eurydice_slice data[1U], Eurydice_slice out[1U]) { |
4272 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4273 | 0 | Eurydice_slice copy_of_data[1U]; |
4274 | 0 | memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice)); |
4275 | 0 | libcrux_sha3_generic_keccak_keccak_e94(copy_of_data, out); |
4276 | 0 | } |
4277 | | |
4278 | | /** |
4279 | | A portable SHAKE128 implementation. |
4280 | | */ |
4281 | | static KRML_MUSTINLINE void libcrux_sha3_portable_shake128( |
4282 | 0 | Eurydice_slice digest, Eurydice_slice data) { |
4283 | 0 | Eurydice_slice buf0[1U] = {data}; |
4284 | 0 | Eurydice_slice buf[1U] = {digest}; |
4285 | 0 | libcrux_sha3_portable_keccakx1_ce4(buf0, buf); |
4286 | 0 | } |
4287 | | |
4288 | | /** |
4289 | | SHAKE 128 |
4290 | | |
4291 | | Writes `out.len()` bytes. |
4292 | | */ |
4293 | | static KRML_MUSTINLINE void libcrux_sha3_shake128_ema(Eurydice_slice out, |
4294 | 0 | Eurydice_slice data) { |
4295 | 0 | libcrux_sha3_portable_shake128(out, data); |
4296 | 0 | } |
4297 | | |
4298 | | /** |
4299 | | SHAKE 256 |
4300 | | |
4301 | | Writes `out.len()` bytes. |
4302 | | */ |
4303 | | static KRML_MUSTINLINE void libcrux_sha3_shake256_ema(Eurydice_slice out, |
4304 | 0 | Eurydice_slice data) { |
4305 | 0 | libcrux_sha3_portable_shake256(out, data); |
4306 | 0 | } |
4307 | | |
4308 | | static const size_t libcrux_sha3_generic_keccak__PI[24U] = { |
4309 | | (size_t)6U, (size_t)12U, (size_t)18U, (size_t)24U, (size_t)3U, |
4310 | | (size_t)9U, (size_t)10U, (size_t)16U, (size_t)22U, (size_t)1U, |
4311 | | (size_t)7U, (size_t)13U, (size_t)19U, (size_t)20U, (size_t)4U, |
4312 | | (size_t)5U, (size_t)11U, (size_t)17U, (size_t)23U, (size_t)2U, |
4313 | | (size_t)8U, (size_t)14U, (size_t)15U, (size_t)21U}; |
4314 | | |
4315 | | static const size_t libcrux_sha3_generic_keccak__ROTC[24U] = { |
4316 | | (size_t)1U, (size_t)62U, (size_t)28U, (size_t)27U, (size_t)36U, |
4317 | | (size_t)44U, (size_t)6U, (size_t)55U, (size_t)20U, (size_t)3U, |
4318 | | (size_t)10U, (size_t)43U, (size_t)25U, (size_t)39U, (size_t)41U, |
4319 | | (size_t)45U, (size_t)15U, (size_t)21U, (size_t)8U, (size_t)18U, |
4320 | | (size_t)2U, (size_t)61U, (size_t)56U, (size_t)14U}; |
4321 | | |
4322 | | /** |
4323 | | A portable SHA3 224 implementation. |
4324 | | */ |
4325 | | static KRML_MUSTINLINE void libcrux_sha3_neon_sha224(Eurydice_slice digest, |
4326 | 0 | Eurydice_slice data) { |
4327 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4328 | 0 | "panic!"); |
4329 | 0 | KRML_HOST_EXIT(255U); |
4330 | 0 | } |
4331 | | |
4332 | | /** |
4333 | | A portable SHA3 256 implementation. |
4334 | | */ |
4335 | | static KRML_MUSTINLINE void libcrux_sha3_neon_sha256(Eurydice_slice digest, |
4336 | 0 | Eurydice_slice data) { |
4337 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4338 | 0 | "panic!"); |
4339 | 0 | KRML_HOST_EXIT(255U); |
4340 | 0 | } |
4341 | | |
4342 | | /** |
4343 | | A portable SHA3 384 implementation. |
4344 | | */ |
4345 | | static KRML_MUSTINLINE void libcrux_sha3_neon_sha384(Eurydice_slice digest, |
4346 | 0 | Eurydice_slice data) { |
4347 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4348 | 0 | "panic!"); |
4349 | 0 | KRML_HOST_EXIT(255U); |
4350 | 0 | } |
4351 | | |
4352 | | /** |
4353 | | A portable SHA3 512 implementation. |
4354 | | */ |
4355 | | static KRML_MUSTINLINE void libcrux_sha3_neon_sha512(Eurydice_slice digest, |
4356 | 0 | Eurydice_slice data) { |
4357 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4358 | 0 | "panic!"); |
4359 | 0 | KRML_HOST_EXIT(255U); |
4360 | 0 | } |
4361 | | |
4362 | | /** |
4363 | | Run SHAKE256 on both inputs in parallel. |
4364 | | |
4365 | | Writes the two results into `out0` and `out1` |
4366 | | */ |
4367 | | static KRML_MUSTINLINE void libcrux_sha3_neon_x2_shake256(Eurydice_slice input0, |
4368 | | Eurydice_slice input1, |
4369 | | Eurydice_slice out0, |
4370 | 0 | Eurydice_slice out1) { |
4371 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4372 | 0 | "panic!"); |
4373 | 0 | KRML_HOST_EXIT(255U); |
4374 | 0 | } |
4375 | | |
4376 | | typedef struct libcrux_sha3_neon_x2_incremental_KeccakState_s { |
4377 | | libcrux_sha3_generic_keccak_KeccakState_48 state[2U]; |
4378 | | } libcrux_sha3_neon_x2_incremental_KeccakState; |
4379 | | |
4380 | | /** |
4381 | | Initialise the `KeccakState2`. |
4382 | | */ |
4383 | | static KRML_MUSTINLINE libcrux_sha3_neon_x2_incremental_KeccakState |
4384 | 0 | libcrux_sha3_neon_x2_incremental_shake128_init(void) { |
4385 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4386 | 0 | "panic!"); |
4387 | 0 | KRML_HOST_EXIT(255U); |
4388 | 0 | } |
4389 | | |
4390 | | /** |
4391 | | Shake128 absorb `data0` and `data1` in the [`KeccakState`] `s`. |
4392 | | */ |
4393 | | static KRML_MUSTINLINE void |
4394 | | libcrux_sha3_neon_x2_incremental_shake128_absorb_final( |
4395 | | libcrux_sha3_neon_x2_incremental_KeccakState *s, Eurydice_slice data0, |
4396 | 0 | Eurydice_slice data1) { |
4397 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4398 | 0 | "panic!"); |
4399 | 0 | KRML_HOST_EXIT(255U); |
4400 | 0 | } |
4401 | | |
4402 | | /** |
4403 | | Squeeze 2 times the first three blocks in parallel in the |
4404 | | [`KeccakState`] and return the output in `out0` and `out1`. |
4405 | | */ |
4406 | | static KRML_MUSTINLINE void |
4407 | | libcrux_sha3_neon_x2_incremental_shake128_squeeze_first_three_blocks( |
4408 | | libcrux_sha3_neon_x2_incremental_KeccakState *s, Eurydice_slice out0, |
4409 | 0 | Eurydice_slice out1) { |
4410 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4411 | 0 | "panic!"); |
4412 | 0 | KRML_HOST_EXIT(255U); |
4413 | 0 | } |
4414 | | |
4415 | | /** |
4416 | | Squeeze 2 times the next block in parallel in the |
4417 | | [`KeccakState`] and return the output in `out0` and `out1`. |
4418 | | */ |
4419 | | static KRML_MUSTINLINE void |
4420 | | libcrux_sha3_neon_x2_incremental_shake128_squeeze_next_block( |
4421 | | libcrux_sha3_neon_x2_incremental_KeccakState *s, Eurydice_slice out0, |
4422 | 0 | Eurydice_slice out1) { |
4423 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
4424 | 0 | "panic!"); |
4425 | 0 | KRML_HOST_EXIT(255U); |
4426 | 0 | } |
4427 | | |
4428 | | /** |
4429 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_first_five_blocks |
4430 | | with types uint64_t |
4431 | | with const generics |
4432 | | - N= 1 |
4433 | | - RATE= 168 |
4434 | | */ |
4435 | | static KRML_MUSTINLINE void |
4436 | | libcrux_sha3_generic_keccak_squeeze_first_five_blocks_4f( |
4437 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) { |
4438 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____0 = |
4439 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U); |
4440 | 0 | Eurydice_slice o0[1U]; |
4441 | 0 | memcpy(o0, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice)); |
4442 | 0 | Eurydice_slice o10[1U]; |
4443 | 0 | memcpy(o10, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice)); |
4444 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_841(s, o0); |
4445 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____1 = |
4446 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o10, (size_t)168U); |
4447 | 0 | Eurydice_slice o1[1U]; |
4448 | 0 | memcpy(o1, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice)); |
4449 | 0 | Eurydice_slice o20[1U]; |
4450 | 0 | memcpy(o20, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice)); |
4451 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o1); |
4452 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____2 = |
4453 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o20, (size_t)168U); |
4454 | 0 | Eurydice_slice o2[1U]; |
4455 | 0 | memcpy(o2, uu____2.fst, (size_t)1U * sizeof(Eurydice_slice)); |
4456 | 0 | Eurydice_slice o30[1U]; |
4457 | 0 | memcpy(o30, uu____2.snd, (size_t)1U * sizeof(Eurydice_slice)); |
4458 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o2); |
4459 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____3 = |
4460 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(o30, (size_t)168U); |
4461 | 0 | Eurydice_slice o3[1U]; |
4462 | 0 | memcpy(o3, uu____3.fst, (size_t)1U * sizeof(Eurydice_slice)); |
4463 | 0 | Eurydice_slice o4[1U]; |
4464 | 0 | memcpy(o4, uu____3.snd, (size_t)1U * sizeof(Eurydice_slice)); |
4465 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o3); |
4466 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o4); |
4467 | 0 | } |
4468 | | |
4469 | | /** |
4470 | | Squeeze five blocks |
4471 | | */ |
4472 | | static KRML_MUSTINLINE void |
4473 | | libcrux_sha3_portable_incremental_shake128_squeeze_first_five_blocks( |
4474 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) { |
4475 | 0 | Eurydice_slice buf[1U] = {out0}; |
4476 | 0 | libcrux_sha3_generic_keccak_squeeze_first_five_blocks_4f(s, buf); |
4477 | 0 | } |
4478 | | |
4479 | | /** |
4480 | | Absorb some data for SHAKE-256 for the last time |
4481 | | */ |
4482 | | static KRML_MUSTINLINE void |
4483 | | libcrux_sha3_portable_incremental_shake256_absorb_final( |
4484 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice data) { |
4485 | 0 | Eurydice_slice buf[1U] = {data}; |
4486 | 0 | libcrux_sha3_generic_keccak_absorb_final_c71(s, buf); |
4487 | 0 | } |
4488 | | |
4489 | | /** |
4490 | | Create a new SHAKE-256 state object. |
4491 | | */ |
4492 | | static KRML_MUSTINLINE libcrux_sha3_generic_keccak_KeccakState_48 |
4493 | 0 | libcrux_sha3_portable_incremental_shake256_init(void) { |
4494 | 0 | return libcrux_sha3_generic_keccak_new_1e_f4(); |
4495 | 0 | } |
4496 | | |
4497 | | /** |
4498 | | Squeeze the first SHAKE-256 block |
4499 | | */ |
4500 | | static KRML_MUSTINLINE void |
4501 | | libcrux_sha3_portable_incremental_shake256_squeeze_first_block( |
4502 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out) { |
4503 | 0 | Eurydice_slice buf[1U] = {out}; |
4504 | 0 | libcrux_sha3_generic_keccak_squeeze_first_block_840(s, buf); |
4505 | 0 | } |
4506 | | |
4507 | | /** |
4508 | | Squeeze the next SHAKE-256 block |
4509 | | */ |
4510 | | static KRML_MUSTINLINE void |
4511 | | libcrux_sha3_portable_incremental_shake256_squeeze_next_block( |
4512 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out) { |
4513 | 0 | Eurydice_slice buf[1U] = {out}; |
4514 | 0 | libcrux_sha3_generic_keccak_squeeze_next_block_fc0(s, buf); |
4515 | 0 | } |
4516 | | |
4517 | | /** |
4518 | | A monomorphic instance of libcrux_sha3.generic_keccak.KeccakXofState |
4519 | | with types uint64_t |
4520 | | with const generics |
4521 | | - $1size_t |
4522 | | - $136size_t |
4523 | | */ |
4524 | | typedef struct libcrux_sha3_generic_keccak_KeccakXofState_4f_s { |
4525 | | libcrux_sha3_generic_keccak_KeccakState_48 inner; |
4526 | | uint8_t buf[1U][136U]; |
4527 | | size_t buf_len; |
4528 | | bool sponge; |
4529 | | } libcrux_sha3_generic_keccak_KeccakXofState_4f; |
4530 | | |
4531 | | typedef libcrux_sha3_generic_keccak_KeccakXofState_4f |
4532 | | libcrux_sha3_portable_incremental_Shake256Absorb; |
4533 | | |
4534 | | /** |
4535 | | Consume the internal buffer and the required amount of the input to pad to |
4536 | | `RATE`. |
4537 | | |
4538 | | Returns the `consumed` bytes from `inputs` if there's enough buffered |
4539 | | content to consume, and `0` otherwise. |
4540 | | If `consumed > 0` is returned, `self.buf` contains a full block to be |
4541 | | loaded. |
4542 | | */ |
4543 | | /** |
4544 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4545 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
4546 | | */ |
4547 | | /** |
4548 | | A monomorphic instance of libcrux_sha3.generic_keccak.fill_buffer_9d |
4549 | | with types uint64_t |
4550 | | with const generics |
4551 | | - PARALLEL_LANES= 1 |
4552 | | - RATE= 136 |
4553 | | */ |
4554 | | static inline size_t libcrux_sha3_generic_keccak_fill_buffer_9d_b0( |
4555 | | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, |
4556 | 0 | Eurydice_slice inputs[1U]) { |
4557 | 0 | size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t); |
4558 | 0 | size_t consumed = (size_t)0U; |
4559 | 0 | if (self->buf_len > (size_t)0U) { |
4560 | 0 | if (self->buf_len + input_len >= (size_t)136U) { |
4561 | 0 | consumed = (size_t)136U - self->buf_len; |
4562 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4563 | 0 | size_t i0 = i; |
4564 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice_from( |
4565 | 0 | (size_t)136U, self->buf[i0], self->buf_len, uint8_t, size_t); |
4566 | 0 | Eurydice_slice_copy( |
4567 | 0 | uu____0, |
4568 | 0 | Eurydice_slice_subslice_to(inputs[i0], consumed, uint8_t, size_t), |
4569 | 0 | uint8_t); |
4570 | 0 | } |
4571 | 0 | self->buf_len = self->buf_len + consumed; |
4572 | 0 | } |
4573 | 0 | } |
4574 | 0 | return consumed; |
4575 | 0 | } |
4576 | | |
4577 | | /** |
4578 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4579 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
4580 | | */ |
4581 | | /** |
4582 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_full_9d |
4583 | | with types uint64_t |
4584 | | with const generics |
4585 | | - PARALLEL_LANES= 1 |
4586 | | - RATE= 136 |
4587 | | */ |
4588 | | static inline size_t libcrux_sha3_generic_keccak_absorb_full_9d_f8( |
4589 | | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, |
4590 | 0 | Eurydice_slice inputs[1U]) { |
4591 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f *uu____0 = self; |
4592 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4593 | 0 | Eurydice_slice copy_of_inputs0[1U]; |
4594 | 0 | memcpy(copy_of_inputs0, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
4595 | 0 | size_t input_consumed = |
4596 | 0 | libcrux_sha3_generic_keccak_fill_buffer_9d_b0(uu____0, copy_of_inputs0); |
4597 | 0 | if (input_consumed > (size_t)0U) { |
4598 | 0 | Eurydice_slice borrowed[1U]; |
4599 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4600 | 0 | uint8_t buf[136U] = {0U}; |
4601 | 0 | borrowed[i] = core_array___Array_T__N__23__as_slice( |
4602 | 0 | (size_t)136U, buf, uint8_t, Eurydice_slice); |
4603 | 0 | } |
4604 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4605 | 0 | size_t i0 = i; |
4606 | 0 | borrowed[i0] = |
4607 | 0 | Eurydice_array_to_slice((size_t)136U, self->buf[i0], uint8_t); |
4608 | 0 | } |
4609 | 0 | uint64_t(*uu____2)[5U] = self->inner.st; |
4610 | 0 | Eurydice_slice uu____3[1U]; |
4611 | 0 | memcpy(uu____3, borrowed, (size_t)1U * sizeof(Eurydice_slice)); |
4612 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b80(uu____2, uu____3); |
4613 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
4614 | 0 | self->buf_len = (size_t)0U; |
4615 | 0 | } |
4616 | 0 | size_t input_to_consume = |
4617 | 0 | Eurydice_slice_len(inputs[0U], uint8_t) - input_consumed; |
4618 | 0 | size_t num_blocks = input_to_consume / (size_t)136U; |
4619 | 0 | size_t remainder = input_to_consume % (size_t)136U; |
4620 | 0 | for (size_t i = (size_t)0U; i < num_blocks; i++) { |
4621 | 0 | size_t i0 = i; |
4622 | 0 | uint64_t(*uu____4)[5U] = self->inner.st; |
4623 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4624 | 0 | Eurydice_slice copy_of_inputs[1U]; |
4625 | 0 | memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
4626 | 0 | Eurydice_slice ret[1U]; |
4627 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
4628 | 0 | copy_of_inputs, input_consumed + i0 * (size_t)136U, (size_t)136U, ret); |
4629 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b80(uu____4, ret); |
4630 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
4631 | 0 | } |
4632 | 0 | return remainder; |
4633 | 0 | } |
4634 | | |
4635 | | /** |
4636 | | Absorb |
4637 | | |
4638 | | This function takes any number of bytes to absorb and buffers if it's not |
4639 | | enough. The function assumes that all input slices in `blocks` have the same |
4640 | | length. |
4641 | | |
4642 | | Only a multiple of `RATE` blocks are absorbed. |
4643 | | For the remaining bytes [`absorb_final`] needs to be called. |
4644 | | |
4645 | | This works best with relatively small `inputs`. |
4646 | | */ |
4647 | | /** |
4648 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4649 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
4650 | | */ |
4651 | | /** |
4652 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_9d |
4653 | | with types uint64_t |
4654 | | with const generics |
4655 | | - PARALLEL_LANES= 1 |
4656 | | - RATE= 136 |
4657 | | */ |
4658 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_9d_7b( |
4659 | | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, |
4660 | 0 | Eurydice_slice inputs[1U]) { |
4661 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f *uu____0 = self; |
4662 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4663 | 0 | Eurydice_slice copy_of_inputs[1U]; |
4664 | 0 | memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
4665 | 0 | size_t input_remainder_len = |
4666 | 0 | libcrux_sha3_generic_keccak_absorb_full_9d_f8(uu____0, copy_of_inputs); |
4667 | 0 | if (input_remainder_len > (size_t)0U) { |
4668 | 0 | size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t); |
4669 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4670 | 0 | size_t i0 = i; |
4671 | 0 | Eurydice_slice uu____2 = Eurydice_array_to_subslice2( |
4672 | 0 | self->buf[i0], self->buf_len, self->buf_len + input_remainder_len, |
4673 | 0 | uint8_t); |
4674 | 0 | Eurydice_slice_copy( |
4675 | 0 | uu____2, |
4676 | 0 | Eurydice_slice_subslice_from( |
4677 | 0 | inputs[i0], input_len - input_remainder_len, uint8_t, size_t), |
4678 | 0 | uint8_t); |
4679 | 0 | } |
4680 | 0 | self->buf_len = self->buf_len + input_remainder_len; |
4681 | 0 | } |
4682 | 0 | } |
4683 | | |
4684 | | /** |
4685 | | Shake256 absorb |
4686 | | */ |
4687 | | /** |
4688 | | This function found in impl |
4689 | | {(libcrux_sha3::portable::incremental::XofAbsorb<136: usize> for |
4690 | | libcrux_sha3::portable::incremental::Shake256Absorb)#2} |
4691 | | */ |
4692 | | static inline void libcrux_sha3_portable_incremental_absorb_7d( |
4693 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, Eurydice_slice input) { |
4694 | 0 | Eurydice_slice buf[1U] = {input}; |
4695 | 0 | libcrux_sha3_generic_keccak_absorb_9d_7b(self, buf); |
4696 | 0 | } |
4697 | | |
4698 | | typedef libcrux_sha3_generic_keccak_KeccakXofState_4f |
4699 | | libcrux_sha3_portable_incremental_Shake256Squeeze; |
4700 | | |
4701 | | /** |
4702 | | Absorb a final block. |
4703 | | |
4704 | | The `inputs` block may be empty. Everything in the `inputs` block beyond |
4705 | | `RATE` bytes is ignored. |
4706 | | */ |
4707 | | /** |
4708 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4709 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
4710 | | */ |
4711 | | /** |
4712 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_9d |
4713 | | with types uint64_t |
4714 | | with const generics |
4715 | | - PARALLEL_LANES= 1 |
4716 | | - RATE= 136 |
4717 | | - DELIMITER= 31 |
4718 | | */ |
4719 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_9d_25( |
4720 | | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, |
4721 | 0 | Eurydice_slice inputs[1U]) { |
4722 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f *uu____0 = self; |
4723 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
4724 | 0 | Eurydice_slice copy_of_inputs[1U]; |
4725 | 0 | memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
4726 | 0 | size_t input_remainder_len = |
4727 | 0 | libcrux_sha3_generic_keccak_absorb_full_9d_f8(uu____0, copy_of_inputs); |
4728 | 0 | size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t); |
4729 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
4730 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
4731 | 0 | size_t i0 = i; |
4732 | 0 | if (self->buf_len > (size_t)0U) { |
4733 | 0 | Eurydice_slice uu____2 = Eurydice_array_to_subslice2( |
4734 | 0 | blocks[i0], (size_t)0U, self->buf_len, uint8_t); |
4735 | 0 | Eurydice_slice_copy(uu____2, |
4736 | 0 | Eurydice_array_to_subslice2(self->buf[i0], (size_t)0U, |
4737 | 0 | self->buf_len, uint8_t), |
4738 | 0 | uint8_t); |
4739 | 0 | } |
4740 | 0 | if (input_remainder_len > (size_t)0U) { |
4741 | 0 | Eurydice_slice uu____3 = Eurydice_array_to_subslice2( |
4742 | 0 | blocks[i0], self->buf_len, self->buf_len + input_remainder_len, |
4743 | 0 | uint8_t); |
4744 | 0 | Eurydice_slice_copy( |
4745 | 0 | uu____3, |
4746 | 0 | Eurydice_slice_subslice_from( |
4747 | 0 | inputs[i0], input_len - input_remainder_len, uint8_t, size_t), |
4748 | 0 | uint8_t); |
4749 | 0 | } |
4750 | 0 | blocks[i0][self->buf_len + input_remainder_len] = 31U; |
4751 | 0 | size_t uu____4 = i0; |
4752 | 0 | size_t uu____5 = (size_t)136U - (size_t)1U; |
4753 | 0 | blocks[uu____4][uu____5] = (uint32_t)blocks[uu____4][uu____5] | 128U; |
4754 | 0 | } |
4755 | 0 | uint64_t(*uu____6)[5U] = self->inner.st; |
4756 | 0 | uint8_t uu____7[1U][200U]; |
4757 | 0 | memcpy(uu____7, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
4758 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____6, uu____7); |
4759 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
4760 | 0 | } |
4761 | | |
4762 | | /** |
4763 | | Shake256 absorb final |
4764 | | */ |
4765 | | /** |
4766 | | This function found in impl |
4767 | | {(libcrux_sha3::portable::incremental::XofAbsorb<136: usize> for |
4768 | | libcrux_sha3::portable::incremental::Shake256Absorb)#2} |
4769 | | */ |
4770 | | static inline libcrux_sha3_generic_keccak_KeccakXofState_4f |
4771 | | libcrux_sha3_portable_incremental_absorb_final_7d( |
4772 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f self, Eurydice_slice input) { |
4773 | 0 | Eurydice_slice buf[1U] = {input}; |
4774 | 0 | libcrux_sha3_generic_keccak_absorb_final_9d_25(&self, buf); |
4775 | 0 | return self; |
4776 | 0 | } |
4777 | | |
4778 | | /** |
4779 | | An all zero block |
4780 | | */ |
4781 | | /** |
4782 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4783 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
4784 | | */ |
4785 | | /** |
4786 | | A monomorphic instance of libcrux_sha3.generic_keccak.zero_block_9d |
4787 | | with types uint64_t |
4788 | | with const generics |
4789 | | - PARALLEL_LANES= 1 |
4790 | | - RATE= 136 |
4791 | | */ |
4792 | | static inline void libcrux_sha3_generic_keccak_zero_block_9d_e6( |
4793 | 0 | uint8_t ret[136U]) { |
4794 | 0 | ret[0U] = 0U; |
4795 | 0 | ret[1U] = 0U; |
4796 | 0 | ret[2U] = 0U; |
4797 | 0 | ret[3U] = 0U; |
4798 | 0 | ret[4U] = 0U; |
4799 | 0 | ret[5U] = 0U; |
4800 | 0 | ret[6U] = 0U; |
4801 | 0 | ret[7U] = 0U; |
4802 | 0 | ret[8U] = 0U; |
4803 | 0 | ret[9U] = 0U; |
4804 | 0 | ret[10U] = 0U; |
4805 | 0 | ret[11U] = 0U; |
4806 | 0 | ret[12U] = 0U; |
4807 | 0 | ret[13U] = 0U; |
4808 | 0 | ret[14U] = 0U; |
4809 | 0 | ret[15U] = 0U; |
4810 | 0 | ret[16U] = 0U; |
4811 | 0 | ret[17U] = 0U; |
4812 | 0 | ret[18U] = 0U; |
4813 | 0 | ret[19U] = 0U; |
4814 | 0 | ret[20U] = 0U; |
4815 | 0 | ret[21U] = 0U; |
4816 | 0 | ret[22U] = 0U; |
4817 | 0 | ret[23U] = 0U; |
4818 | 0 | ret[24U] = 0U; |
4819 | 0 | ret[25U] = 0U; |
4820 | 0 | ret[26U] = 0U; |
4821 | 0 | ret[27U] = 0U; |
4822 | 0 | ret[28U] = 0U; |
4823 | 0 | ret[29U] = 0U; |
4824 | 0 | ret[30U] = 0U; |
4825 | 0 | ret[31U] = 0U; |
4826 | 0 | ret[32U] = 0U; |
4827 | 0 | ret[33U] = 0U; |
4828 | 0 | ret[34U] = 0U; |
4829 | 0 | ret[35U] = 0U; |
4830 | 0 | ret[36U] = 0U; |
4831 | 0 | ret[37U] = 0U; |
4832 | 0 | ret[38U] = 0U; |
4833 | 0 | ret[39U] = 0U; |
4834 | 0 | ret[40U] = 0U; |
4835 | 0 | ret[41U] = 0U; |
4836 | 0 | ret[42U] = 0U; |
4837 | 0 | ret[43U] = 0U; |
4838 | 0 | ret[44U] = 0U; |
4839 | 0 | ret[45U] = 0U; |
4840 | 0 | ret[46U] = 0U; |
4841 | 0 | ret[47U] = 0U; |
4842 | 0 | ret[48U] = 0U; |
4843 | 0 | ret[49U] = 0U; |
4844 | 0 | ret[50U] = 0U; |
4845 | 0 | ret[51U] = 0U; |
4846 | 0 | ret[52U] = 0U; |
4847 | 0 | ret[53U] = 0U; |
4848 | 0 | ret[54U] = 0U; |
4849 | 0 | ret[55U] = 0U; |
4850 | 0 | ret[56U] = 0U; |
4851 | 0 | ret[57U] = 0U; |
4852 | 0 | ret[58U] = 0U; |
4853 | 0 | ret[59U] = 0U; |
4854 | 0 | ret[60U] = 0U; |
4855 | 0 | ret[61U] = 0U; |
4856 | 0 | ret[62U] = 0U; |
4857 | 0 | ret[63U] = 0U; |
4858 | 0 | ret[64U] = 0U; |
4859 | 0 | ret[65U] = 0U; |
4860 | 0 | ret[66U] = 0U; |
4861 | 0 | ret[67U] = 0U; |
4862 | 0 | ret[68U] = 0U; |
4863 | 0 | ret[69U] = 0U; |
4864 | 0 | ret[70U] = 0U; |
4865 | 0 | ret[71U] = 0U; |
4866 | 0 | ret[72U] = 0U; |
4867 | 0 | ret[73U] = 0U; |
4868 | 0 | ret[74U] = 0U; |
4869 | 0 | ret[75U] = 0U; |
4870 | 0 | ret[76U] = 0U; |
4871 | 0 | ret[77U] = 0U; |
4872 | 0 | ret[78U] = 0U; |
4873 | 0 | ret[79U] = 0U; |
4874 | 0 | ret[80U] = 0U; |
4875 | 0 | ret[81U] = 0U; |
4876 | 0 | ret[82U] = 0U; |
4877 | 0 | ret[83U] = 0U; |
4878 | 0 | ret[84U] = 0U; |
4879 | 0 | ret[85U] = 0U; |
4880 | 0 | ret[86U] = 0U; |
4881 | 0 | ret[87U] = 0U; |
4882 | 0 | ret[88U] = 0U; |
4883 | 0 | ret[89U] = 0U; |
4884 | 0 | ret[90U] = 0U; |
4885 | 0 | ret[91U] = 0U; |
4886 | 0 | ret[92U] = 0U; |
4887 | 0 | ret[93U] = 0U; |
4888 | 0 | ret[94U] = 0U; |
4889 | 0 | ret[95U] = 0U; |
4890 | 0 | ret[96U] = 0U; |
4891 | 0 | ret[97U] = 0U; |
4892 | 0 | ret[98U] = 0U; |
4893 | 0 | ret[99U] = 0U; |
4894 | 0 | ret[100U] = 0U; |
4895 | 0 | ret[101U] = 0U; |
4896 | 0 | ret[102U] = 0U; |
4897 | 0 | ret[103U] = 0U; |
4898 | 0 | ret[104U] = 0U; |
4899 | 0 | ret[105U] = 0U; |
4900 | 0 | ret[106U] = 0U; |
4901 | 0 | ret[107U] = 0U; |
4902 | 0 | ret[108U] = 0U; |
4903 | 0 | ret[109U] = 0U; |
4904 | 0 | ret[110U] = 0U; |
4905 | 0 | ret[111U] = 0U; |
4906 | 0 | ret[112U] = 0U; |
4907 | 0 | ret[113U] = 0U; |
4908 | 0 | ret[114U] = 0U; |
4909 | 0 | ret[115U] = 0U; |
4910 | 0 | ret[116U] = 0U; |
4911 | 0 | ret[117U] = 0U; |
4912 | 0 | ret[118U] = 0U; |
4913 | 0 | ret[119U] = 0U; |
4914 | 0 | ret[120U] = 0U; |
4915 | 0 | ret[121U] = 0U; |
4916 | 0 | ret[122U] = 0U; |
4917 | 0 | ret[123U] = 0U; |
4918 | 0 | ret[124U] = 0U; |
4919 | 0 | ret[125U] = 0U; |
4920 | 0 | ret[126U] = 0U; |
4921 | 0 | ret[127U] = 0U; |
4922 | 0 | ret[128U] = 0U; |
4923 | 0 | ret[129U] = 0U; |
4924 | 0 | ret[130U] = 0U; |
4925 | 0 | ret[131U] = 0U; |
4926 | 0 | ret[132U] = 0U; |
4927 | 0 | ret[133U] = 0U; |
4928 | 0 | ret[134U] = 0U; |
4929 | 0 | ret[135U] = 0U; |
4930 | 0 | } |
4931 | | |
4932 | | /** |
4933 | | Generate a new keccak xof state. |
4934 | | */ |
4935 | | /** |
4936 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4937 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
4938 | | */ |
4939 | | /** |
4940 | | A monomorphic instance of libcrux_sha3.generic_keccak.new_9d |
4941 | | with types uint64_t |
4942 | | with const generics |
4943 | | - PARALLEL_LANES= 1 |
4944 | | - RATE= 136 |
4945 | | */ |
4946 | | static inline libcrux_sha3_generic_keccak_KeccakXofState_4f |
4947 | 0 | libcrux_sha3_generic_keccak_new_9d_7e(void) { |
4948 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f lit; |
4949 | 0 | lit.inner = libcrux_sha3_generic_keccak_new_1e_f4(); |
4950 | 0 | uint8_t ret[136U]; |
4951 | 0 | libcrux_sha3_generic_keccak_zero_block_9d_e6(ret); |
4952 | 0 | memcpy(lit.buf[0U], ret, (size_t)136U * sizeof(uint8_t)); |
4953 | 0 | lit.buf_len = (size_t)0U; |
4954 | 0 | lit.sponge = false; |
4955 | 0 | return lit; |
4956 | 0 | } |
4957 | | |
4958 | | /** |
4959 | | Shake256 new state |
4960 | | */ |
4961 | | /** |
4962 | | This function found in impl |
4963 | | {(libcrux_sha3::portable::incremental::XofAbsorb<136: usize> for |
4964 | | libcrux_sha3::portable::incremental::Shake256Absorb)#2} |
4965 | | */ |
4966 | | static inline libcrux_sha3_generic_keccak_KeccakXofState_4f |
4967 | 0 | libcrux_sha3_portable_incremental_new_7d(void) { |
4968 | 0 | return libcrux_sha3_generic_keccak_new_9d_7e(); |
4969 | 0 | } |
4970 | | |
4971 | | /** |
4972 | | A monomorphic instance of libcrux_sha3.generic_keccak.KeccakXofState |
4973 | | with types uint64_t |
4974 | | with const generics |
4975 | | - $1size_t |
4976 | | - $168size_t |
4977 | | */ |
4978 | | typedef struct libcrux_sha3_generic_keccak_KeccakXofState_78_s { |
4979 | | libcrux_sha3_generic_keccak_KeccakState_48 inner; |
4980 | | uint8_t buf[1U][168U]; |
4981 | | size_t buf_len; |
4982 | | bool sponge; |
4983 | | } libcrux_sha3_generic_keccak_KeccakXofState_78; |
4984 | | |
4985 | | typedef libcrux_sha3_generic_keccak_KeccakXofState_78 |
4986 | | libcrux_sha3_portable_incremental_Shake128Absorb; |
4987 | | |
4988 | | /** |
4989 | | Consume the internal buffer and the required amount of the input to pad to |
4990 | | `RATE`. |
4991 | | |
4992 | | Returns the `consumed` bytes from `inputs` if there's enough buffered |
4993 | | content to consume, and `0` otherwise. |
4994 | | If `consumed > 0` is returned, `self.buf` contains a full block to be |
4995 | | loaded. |
4996 | | */ |
4997 | | /** |
4998 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
4999 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5000 | | */ |
5001 | | /** |
5002 | | A monomorphic instance of libcrux_sha3.generic_keccak.fill_buffer_9d |
5003 | | with types uint64_t |
5004 | | with const generics |
5005 | | - PARALLEL_LANES= 1 |
5006 | | - RATE= 168 |
5007 | | */ |
5008 | | static inline size_t libcrux_sha3_generic_keccak_fill_buffer_9d_b00( |
5009 | | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, |
5010 | 0 | Eurydice_slice inputs[1U]) { |
5011 | 0 | size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t); |
5012 | 0 | size_t consumed = (size_t)0U; |
5013 | 0 | if (self->buf_len > (size_t)0U) { |
5014 | 0 | if (self->buf_len + input_len >= (size_t)168U) { |
5015 | 0 | consumed = (size_t)168U - self->buf_len; |
5016 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
5017 | 0 | size_t i0 = i; |
5018 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice_from( |
5019 | 0 | (size_t)168U, self->buf[i0], self->buf_len, uint8_t, size_t); |
5020 | 0 | Eurydice_slice_copy( |
5021 | 0 | uu____0, |
5022 | 0 | Eurydice_slice_subslice_to(inputs[i0], consumed, uint8_t, size_t), |
5023 | 0 | uint8_t); |
5024 | 0 | } |
5025 | 0 | self->buf_len = self->buf_len + consumed; |
5026 | 0 | } |
5027 | 0 | } |
5028 | 0 | return consumed; |
5029 | 0 | } |
5030 | | |
5031 | | /** |
5032 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5033 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5034 | | */ |
5035 | | /** |
5036 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_full_9d |
5037 | | with types uint64_t |
5038 | | with const generics |
5039 | | - PARALLEL_LANES= 1 |
5040 | | - RATE= 168 |
5041 | | */ |
5042 | | static inline size_t libcrux_sha3_generic_keccak_absorb_full_9d_f80( |
5043 | | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, |
5044 | 0 | Eurydice_slice inputs[1U]) { |
5045 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 *uu____0 = self; |
5046 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
5047 | 0 | Eurydice_slice copy_of_inputs0[1U]; |
5048 | 0 | memcpy(copy_of_inputs0, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
5049 | 0 | size_t input_consumed = |
5050 | 0 | libcrux_sha3_generic_keccak_fill_buffer_9d_b00(uu____0, copy_of_inputs0); |
5051 | 0 | if (input_consumed > (size_t)0U) { |
5052 | 0 | Eurydice_slice borrowed[1U]; |
5053 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
5054 | 0 | uint8_t buf[168U] = {0U}; |
5055 | 0 | borrowed[i] = core_array___Array_T__N__23__as_slice( |
5056 | 0 | (size_t)168U, buf, uint8_t, Eurydice_slice); |
5057 | 0 | } |
5058 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
5059 | 0 | size_t i0 = i; |
5060 | 0 | borrowed[i0] = |
5061 | 0 | Eurydice_array_to_slice((size_t)168U, self->buf[i0], uint8_t); |
5062 | 0 | } |
5063 | 0 | uint64_t(*uu____2)[5U] = self->inner.st; |
5064 | 0 | Eurydice_slice uu____3[1U]; |
5065 | 0 | memcpy(uu____3, borrowed, (size_t)1U * sizeof(Eurydice_slice)); |
5066 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b83(uu____2, uu____3); |
5067 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5068 | 0 | self->buf_len = (size_t)0U; |
5069 | 0 | } |
5070 | 0 | size_t input_to_consume = |
5071 | 0 | Eurydice_slice_len(inputs[0U], uint8_t) - input_consumed; |
5072 | 0 | size_t num_blocks = input_to_consume / (size_t)168U; |
5073 | 0 | size_t remainder = input_to_consume % (size_t)168U; |
5074 | 0 | for (size_t i = (size_t)0U; i < num_blocks; i++) { |
5075 | 0 | size_t i0 = i; |
5076 | 0 | uint64_t(*uu____4)[5U] = self->inner.st; |
5077 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
5078 | 0 | Eurydice_slice copy_of_inputs[1U]; |
5079 | 0 | memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
5080 | 0 | Eurydice_slice ret[1U]; |
5081 | 0 | libcrux_sha3_portable_keccak_slice_n_5a( |
5082 | 0 | copy_of_inputs, input_consumed + i0 * (size_t)168U, (size_t)168U, ret); |
5083 | 0 | libcrux_sha3_portable_keccak_load_block_5a_b83(uu____4, ret); |
5084 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5085 | 0 | } |
5086 | 0 | return remainder; |
5087 | 0 | } |
5088 | | |
5089 | | /** |
5090 | | Absorb |
5091 | | |
5092 | | This function takes any number of bytes to absorb and buffers if it's not |
5093 | | enough. The function assumes that all input slices in `blocks` have the same |
5094 | | length. |
5095 | | |
5096 | | Only a multiple of `RATE` blocks are absorbed. |
5097 | | For the remaining bytes [`absorb_final`] needs to be called. |
5098 | | |
5099 | | This works best with relatively small `inputs`. |
5100 | | */ |
5101 | | /** |
5102 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5103 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5104 | | */ |
5105 | | /** |
5106 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_9d |
5107 | | with types uint64_t |
5108 | | with const generics |
5109 | | - PARALLEL_LANES= 1 |
5110 | | - RATE= 168 |
5111 | | */ |
5112 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_9d_7b0( |
5113 | | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, |
5114 | 0 | Eurydice_slice inputs[1U]) { |
5115 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 *uu____0 = self; |
5116 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
5117 | 0 | Eurydice_slice copy_of_inputs[1U]; |
5118 | 0 | memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
5119 | 0 | size_t input_remainder_len = |
5120 | 0 | libcrux_sha3_generic_keccak_absorb_full_9d_f80(uu____0, copy_of_inputs); |
5121 | 0 | if (input_remainder_len > (size_t)0U) { |
5122 | 0 | size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t); |
5123 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
5124 | 0 | size_t i0 = i; |
5125 | 0 | Eurydice_slice uu____2 = Eurydice_array_to_subslice2( |
5126 | 0 | self->buf[i0], self->buf_len, self->buf_len + input_remainder_len, |
5127 | 0 | uint8_t); |
5128 | 0 | Eurydice_slice_copy( |
5129 | 0 | uu____2, |
5130 | 0 | Eurydice_slice_subslice_from( |
5131 | 0 | inputs[i0], input_len - input_remainder_len, uint8_t, size_t), |
5132 | 0 | uint8_t); |
5133 | 0 | } |
5134 | 0 | self->buf_len = self->buf_len + input_remainder_len; |
5135 | 0 | } |
5136 | 0 | } |
5137 | | |
5138 | | /** |
5139 | | This function found in impl |
5140 | | {(libcrux_sha3::portable::incremental::XofAbsorb<168: usize> for |
5141 | | libcrux_sha3::portable::incremental::Shake128Absorb)} |
5142 | | */ |
5143 | | static inline void libcrux_sha3_portable_incremental_absorb_1c( |
5144 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, Eurydice_slice input) { |
5145 | 0 | Eurydice_slice buf[1U] = {input}; |
5146 | 0 | libcrux_sha3_generic_keccak_absorb_9d_7b0(self, buf); |
5147 | 0 | } |
5148 | | |
5149 | | typedef libcrux_sha3_generic_keccak_KeccakXofState_78 |
5150 | | libcrux_sha3_portable_incremental_Shake128Squeeze; |
5151 | | |
5152 | | /** |
5153 | | Absorb a final block. |
5154 | | |
5155 | | The `inputs` block may be empty. Everything in the `inputs` block beyond |
5156 | | `RATE` bytes is ignored. |
5157 | | */ |
5158 | | /** |
5159 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5160 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5161 | | */ |
5162 | | /** |
5163 | | A monomorphic instance of libcrux_sha3.generic_keccak.absorb_final_9d |
5164 | | with types uint64_t |
5165 | | with const generics |
5166 | | - PARALLEL_LANES= 1 |
5167 | | - RATE= 168 |
5168 | | - DELIMITER= 31 |
5169 | | */ |
5170 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_absorb_final_9d_250( |
5171 | | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, |
5172 | 0 | Eurydice_slice inputs[1U]) { |
5173 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 *uu____0 = self; |
5174 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
5175 | 0 | Eurydice_slice copy_of_inputs[1U]; |
5176 | 0 | memcpy(copy_of_inputs, inputs, (size_t)1U * sizeof(Eurydice_slice)); |
5177 | 0 | size_t input_remainder_len = |
5178 | 0 | libcrux_sha3_generic_keccak_absorb_full_9d_f80(uu____0, copy_of_inputs); |
5179 | 0 | size_t input_len = Eurydice_slice_len(inputs[0U], uint8_t); |
5180 | 0 | uint8_t blocks[1U][200U] = {{0U}}; |
5181 | 0 | for (size_t i = (size_t)0U; i < (size_t)1U; i++) { |
5182 | 0 | size_t i0 = i; |
5183 | 0 | if (self->buf_len > (size_t)0U) { |
5184 | 0 | Eurydice_slice uu____2 = Eurydice_array_to_subslice2( |
5185 | 0 | blocks[i0], (size_t)0U, self->buf_len, uint8_t); |
5186 | 0 | Eurydice_slice_copy(uu____2, |
5187 | 0 | Eurydice_array_to_subslice2(self->buf[i0], (size_t)0U, |
5188 | 0 | self->buf_len, uint8_t), |
5189 | 0 | uint8_t); |
5190 | 0 | } |
5191 | 0 | if (input_remainder_len > (size_t)0U) { |
5192 | 0 | Eurydice_slice uu____3 = Eurydice_array_to_subslice2( |
5193 | 0 | blocks[i0], self->buf_len, self->buf_len + input_remainder_len, |
5194 | 0 | uint8_t); |
5195 | 0 | Eurydice_slice_copy( |
5196 | 0 | uu____3, |
5197 | 0 | Eurydice_slice_subslice_from( |
5198 | 0 | inputs[i0], input_len - input_remainder_len, uint8_t, size_t), |
5199 | 0 | uint8_t); |
5200 | 0 | } |
5201 | 0 | blocks[i0][self->buf_len + input_remainder_len] = 31U; |
5202 | 0 | size_t uu____4 = i0; |
5203 | 0 | size_t uu____5 = (size_t)168U - (size_t)1U; |
5204 | 0 | blocks[uu____4][uu____5] = (uint32_t)blocks[uu____4][uu____5] | 128U; |
5205 | 0 | } |
5206 | 0 | uint64_t(*uu____6)[5U] = self->inner.st; |
5207 | 0 | uint8_t uu____7[1U][200U]; |
5208 | 0 | memcpy(uu____7, blocks, (size_t)1U * sizeof(uint8_t[200U])); |
5209 | 0 | libcrux_sha3_portable_keccak_load_block_full_5a_d21(uu____6, uu____7); |
5210 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5211 | 0 | } |
5212 | | |
5213 | | /** |
5214 | | This function found in impl |
5215 | | {(libcrux_sha3::portable::incremental::XofAbsorb<168: usize> for |
5216 | | libcrux_sha3::portable::incremental::Shake128Absorb)} |
5217 | | */ |
5218 | | static inline libcrux_sha3_generic_keccak_KeccakXofState_78 |
5219 | | libcrux_sha3_portable_incremental_absorb_final_1c( |
5220 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 self, Eurydice_slice input) { |
5221 | 0 | Eurydice_slice buf[1U] = {input}; |
5222 | 0 | libcrux_sha3_generic_keccak_absorb_final_9d_250(&self, buf); |
5223 | 0 | return self; |
5224 | 0 | } |
5225 | | |
5226 | | /** |
5227 | | An all zero block |
5228 | | */ |
5229 | | /** |
5230 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5231 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5232 | | */ |
5233 | | /** |
5234 | | A monomorphic instance of libcrux_sha3.generic_keccak.zero_block_9d |
5235 | | with types uint64_t |
5236 | | with const generics |
5237 | | - PARALLEL_LANES= 1 |
5238 | | - RATE= 168 |
5239 | | */ |
5240 | | static inline void libcrux_sha3_generic_keccak_zero_block_9d_e60( |
5241 | 0 | uint8_t ret[168U]) { |
5242 | 0 | ret[0U] = 0U; |
5243 | 0 | ret[1U] = 0U; |
5244 | 0 | ret[2U] = 0U; |
5245 | 0 | ret[3U] = 0U; |
5246 | 0 | ret[4U] = 0U; |
5247 | 0 | ret[5U] = 0U; |
5248 | 0 | ret[6U] = 0U; |
5249 | 0 | ret[7U] = 0U; |
5250 | 0 | ret[8U] = 0U; |
5251 | 0 | ret[9U] = 0U; |
5252 | 0 | ret[10U] = 0U; |
5253 | 0 | ret[11U] = 0U; |
5254 | 0 | ret[12U] = 0U; |
5255 | 0 | ret[13U] = 0U; |
5256 | 0 | ret[14U] = 0U; |
5257 | 0 | ret[15U] = 0U; |
5258 | 0 | ret[16U] = 0U; |
5259 | 0 | ret[17U] = 0U; |
5260 | 0 | ret[18U] = 0U; |
5261 | 0 | ret[19U] = 0U; |
5262 | 0 | ret[20U] = 0U; |
5263 | 0 | ret[21U] = 0U; |
5264 | 0 | ret[22U] = 0U; |
5265 | 0 | ret[23U] = 0U; |
5266 | 0 | ret[24U] = 0U; |
5267 | 0 | ret[25U] = 0U; |
5268 | 0 | ret[26U] = 0U; |
5269 | 0 | ret[27U] = 0U; |
5270 | 0 | ret[28U] = 0U; |
5271 | 0 | ret[29U] = 0U; |
5272 | 0 | ret[30U] = 0U; |
5273 | 0 | ret[31U] = 0U; |
5274 | 0 | ret[32U] = 0U; |
5275 | 0 | ret[33U] = 0U; |
5276 | 0 | ret[34U] = 0U; |
5277 | 0 | ret[35U] = 0U; |
5278 | 0 | ret[36U] = 0U; |
5279 | 0 | ret[37U] = 0U; |
5280 | 0 | ret[38U] = 0U; |
5281 | 0 | ret[39U] = 0U; |
5282 | 0 | ret[40U] = 0U; |
5283 | 0 | ret[41U] = 0U; |
5284 | 0 | ret[42U] = 0U; |
5285 | 0 | ret[43U] = 0U; |
5286 | 0 | ret[44U] = 0U; |
5287 | 0 | ret[45U] = 0U; |
5288 | 0 | ret[46U] = 0U; |
5289 | 0 | ret[47U] = 0U; |
5290 | 0 | ret[48U] = 0U; |
5291 | 0 | ret[49U] = 0U; |
5292 | 0 | ret[50U] = 0U; |
5293 | 0 | ret[51U] = 0U; |
5294 | 0 | ret[52U] = 0U; |
5295 | 0 | ret[53U] = 0U; |
5296 | 0 | ret[54U] = 0U; |
5297 | 0 | ret[55U] = 0U; |
5298 | 0 | ret[56U] = 0U; |
5299 | 0 | ret[57U] = 0U; |
5300 | 0 | ret[58U] = 0U; |
5301 | 0 | ret[59U] = 0U; |
5302 | 0 | ret[60U] = 0U; |
5303 | 0 | ret[61U] = 0U; |
5304 | 0 | ret[62U] = 0U; |
5305 | 0 | ret[63U] = 0U; |
5306 | 0 | ret[64U] = 0U; |
5307 | 0 | ret[65U] = 0U; |
5308 | 0 | ret[66U] = 0U; |
5309 | 0 | ret[67U] = 0U; |
5310 | 0 | ret[68U] = 0U; |
5311 | 0 | ret[69U] = 0U; |
5312 | 0 | ret[70U] = 0U; |
5313 | 0 | ret[71U] = 0U; |
5314 | 0 | ret[72U] = 0U; |
5315 | 0 | ret[73U] = 0U; |
5316 | 0 | ret[74U] = 0U; |
5317 | 0 | ret[75U] = 0U; |
5318 | 0 | ret[76U] = 0U; |
5319 | 0 | ret[77U] = 0U; |
5320 | 0 | ret[78U] = 0U; |
5321 | 0 | ret[79U] = 0U; |
5322 | 0 | ret[80U] = 0U; |
5323 | 0 | ret[81U] = 0U; |
5324 | 0 | ret[82U] = 0U; |
5325 | 0 | ret[83U] = 0U; |
5326 | 0 | ret[84U] = 0U; |
5327 | 0 | ret[85U] = 0U; |
5328 | 0 | ret[86U] = 0U; |
5329 | 0 | ret[87U] = 0U; |
5330 | 0 | ret[88U] = 0U; |
5331 | 0 | ret[89U] = 0U; |
5332 | 0 | ret[90U] = 0U; |
5333 | 0 | ret[91U] = 0U; |
5334 | 0 | ret[92U] = 0U; |
5335 | 0 | ret[93U] = 0U; |
5336 | 0 | ret[94U] = 0U; |
5337 | 0 | ret[95U] = 0U; |
5338 | 0 | ret[96U] = 0U; |
5339 | 0 | ret[97U] = 0U; |
5340 | 0 | ret[98U] = 0U; |
5341 | 0 | ret[99U] = 0U; |
5342 | 0 | ret[100U] = 0U; |
5343 | 0 | ret[101U] = 0U; |
5344 | 0 | ret[102U] = 0U; |
5345 | 0 | ret[103U] = 0U; |
5346 | 0 | ret[104U] = 0U; |
5347 | 0 | ret[105U] = 0U; |
5348 | 0 | ret[106U] = 0U; |
5349 | 0 | ret[107U] = 0U; |
5350 | 0 | ret[108U] = 0U; |
5351 | 0 | ret[109U] = 0U; |
5352 | 0 | ret[110U] = 0U; |
5353 | 0 | ret[111U] = 0U; |
5354 | 0 | ret[112U] = 0U; |
5355 | 0 | ret[113U] = 0U; |
5356 | 0 | ret[114U] = 0U; |
5357 | 0 | ret[115U] = 0U; |
5358 | 0 | ret[116U] = 0U; |
5359 | 0 | ret[117U] = 0U; |
5360 | 0 | ret[118U] = 0U; |
5361 | 0 | ret[119U] = 0U; |
5362 | 0 | ret[120U] = 0U; |
5363 | 0 | ret[121U] = 0U; |
5364 | 0 | ret[122U] = 0U; |
5365 | 0 | ret[123U] = 0U; |
5366 | 0 | ret[124U] = 0U; |
5367 | 0 | ret[125U] = 0U; |
5368 | 0 | ret[126U] = 0U; |
5369 | 0 | ret[127U] = 0U; |
5370 | 0 | ret[128U] = 0U; |
5371 | 0 | ret[129U] = 0U; |
5372 | 0 | ret[130U] = 0U; |
5373 | 0 | ret[131U] = 0U; |
5374 | 0 | ret[132U] = 0U; |
5375 | 0 | ret[133U] = 0U; |
5376 | 0 | ret[134U] = 0U; |
5377 | 0 | ret[135U] = 0U; |
5378 | 0 | ret[136U] = 0U; |
5379 | 0 | ret[137U] = 0U; |
5380 | 0 | ret[138U] = 0U; |
5381 | 0 | ret[139U] = 0U; |
5382 | 0 | ret[140U] = 0U; |
5383 | 0 | ret[141U] = 0U; |
5384 | 0 | ret[142U] = 0U; |
5385 | 0 | ret[143U] = 0U; |
5386 | 0 | ret[144U] = 0U; |
5387 | 0 | ret[145U] = 0U; |
5388 | 0 | ret[146U] = 0U; |
5389 | 0 | ret[147U] = 0U; |
5390 | 0 | ret[148U] = 0U; |
5391 | 0 | ret[149U] = 0U; |
5392 | 0 | ret[150U] = 0U; |
5393 | 0 | ret[151U] = 0U; |
5394 | 0 | ret[152U] = 0U; |
5395 | 0 | ret[153U] = 0U; |
5396 | 0 | ret[154U] = 0U; |
5397 | 0 | ret[155U] = 0U; |
5398 | 0 | ret[156U] = 0U; |
5399 | 0 | ret[157U] = 0U; |
5400 | 0 | ret[158U] = 0U; |
5401 | 0 | ret[159U] = 0U; |
5402 | 0 | ret[160U] = 0U; |
5403 | 0 | ret[161U] = 0U; |
5404 | 0 | ret[162U] = 0U; |
5405 | 0 | ret[163U] = 0U; |
5406 | 0 | ret[164U] = 0U; |
5407 | 0 | ret[165U] = 0U; |
5408 | 0 | ret[166U] = 0U; |
5409 | 0 | ret[167U] = 0U; |
5410 | 0 | } |
5411 | | |
5412 | | /** |
5413 | | Generate a new keccak xof state. |
5414 | | */ |
5415 | | /** |
5416 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5417 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5418 | | */ |
5419 | | /** |
5420 | | A monomorphic instance of libcrux_sha3.generic_keccak.new_9d |
5421 | | with types uint64_t |
5422 | | with const generics |
5423 | | - PARALLEL_LANES= 1 |
5424 | | - RATE= 168 |
5425 | | */ |
5426 | | static inline libcrux_sha3_generic_keccak_KeccakXofState_78 |
5427 | 0 | libcrux_sha3_generic_keccak_new_9d_7e0(void) { |
5428 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 lit; |
5429 | 0 | lit.inner = libcrux_sha3_generic_keccak_new_1e_f4(); |
5430 | 0 | uint8_t ret[168U]; |
5431 | 0 | libcrux_sha3_generic_keccak_zero_block_9d_e60(ret); |
5432 | 0 | memcpy(lit.buf[0U], ret, (size_t)168U * sizeof(uint8_t)); |
5433 | 0 | lit.buf_len = (size_t)0U; |
5434 | 0 | lit.sponge = false; |
5435 | 0 | return lit; |
5436 | 0 | } |
5437 | | |
5438 | | /** |
5439 | | This function found in impl |
5440 | | {(libcrux_sha3::portable::incremental::XofAbsorb<168: usize> for |
5441 | | libcrux_sha3::portable::incremental::Shake128Absorb)} |
5442 | | */ |
5443 | | static inline libcrux_sha3_generic_keccak_KeccakXofState_78 |
5444 | 0 | libcrux_sha3_portable_incremental_new_1c(void) { |
5445 | 0 | return libcrux_sha3_generic_keccak_new_9d_7e0(); |
5446 | 0 | } |
5447 | | |
5448 | | /** |
5449 | | `out` has the exact size we want here. It must be less than or equal to `RATE`. |
5450 | | */ |
5451 | | /** |
5452 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
5453 | | usize> for u64)} |
5454 | | */ |
5455 | | /** |
5456 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_5a |
5457 | | with const generics |
5458 | | - RATE= 136 |
5459 | | */ |
5460 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_5a_1c( |
5461 | 0 | uint64_t (*state)[5U], Eurydice_slice out[1U]) { |
5462 | 0 | size_t num_full_blocks = Eurydice_slice_len(out[0U], uint8_t) / (size_t)8U; |
5463 | 0 | size_t last_block_len = Eurydice_slice_len(out[0U], uint8_t) % (size_t)8U; |
5464 | 0 | for (size_t i = (size_t)0U; i < num_full_blocks; i++) { |
5465 | 0 | size_t i0 = i; |
5466 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
5467 | 0 | out[0U], i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t); |
5468 | 0 | uint8_t ret[8U]; |
5469 | 0 | core_num__u64_9__to_le_bytes(state[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
5470 | 0 | Eurydice_slice_copy( |
5471 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
5472 | 0 | } |
5473 | 0 | if (last_block_len != (size_t)0U) { |
5474 | 0 | Eurydice_slice uu____1 = Eurydice_slice_subslice2( |
5475 | 0 | out[0U], num_full_blocks * (size_t)8U, |
5476 | 0 | num_full_blocks * (size_t)8U + last_block_len, uint8_t); |
5477 | 0 | uint8_t ret[8U]; |
5478 | 0 | core_num__u64_9__to_le_bytes( |
5479 | 0 | state[num_full_blocks / (size_t)5U][num_full_blocks % (size_t)5U], ret); |
5480 | 0 | Eurydice_slice_copy( |
5481 | 0 | uu____1, |
5482 | 0 | Eurydice_array_to_subslice2(ret, (size_t)0U, last_block_len, uint8_t), |
5483 | 0 | uint8_t); |
5484 | 0 | } |
5485 | 0 | } |
5486 | | |
5487 | | /** |
5488 | | Squeeze `N` x `LEN` bytes. |
5489 | | */ |
5490 | | /** |
5491 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5492 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5493 | | */ |
5494 | | /** |
5495 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_9d |
5496 | | with types uint64_t |
5497 | | with const generics |
5498 | | - PARALLEL_LANES= 1 |
5499 | | - RATE= 136 |
5500 | | */ |
5501 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_9d_96( |
5502 | | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, |
5503 | 0 | Eurydice_slice out[1U]) { |
5504 | 0 | if (self->sponge) { |
5505 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5506 | 0 | } |
5507 | 0 | size_t out_len = Eurydice_slice_len(out[0U], uint8_t); |
5508 | 0 | size_t blocks = out_len / (size_t)136U; |
5509 | 0 | size_t last = out_len - out_len % (size_t)136U; |
5510 | 0 | size_t mid; |
5511 | 0 | if ((size_t)136U >= out_len) { |
5512 | 0 | mid = out_len; |
5513 | 0 | } else { |
5514 | 0 | mid = (size_t)136U; |
5515 | 0 | } |
5516 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____0 = |
5517 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, mid); |
5518 | 0 | Eurydice_slice out00[1U]; |
5519 | 0 | memcpy(out00, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice)); |
5520 | 0 | Eurydice_slice out_rest[1U]; |
5521 | 0 | memcpy(out_rest, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice)); |
5522 | 0 | libcrux_sha3_portable_keccak_store_5a_1c(self->inner.st, out00); |
5523 | 0 | core_ops_range_Range_b3 iter = |
5524 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
5525 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
5526 | 0 | .end = blocks}), |
5527 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
5528 | 0 | while (true) { |
5529 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
5530 | 0 | &iter, size_t, Option_b3) |
5531 | 0 | .tag == None) { |
5532 | 0 | break; |
5533 | 0 | } else { |
5534 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____1 = |
5535 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out_rest, |
5536 | 0 | (size_t)136U); |
5537 | 0 | Eurydice_slice out0[1U]; |
5538 | 0 | memcpy(out0, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice)); |
5539 | 0 | Eurydice_slice tmp[1U]; |
5540 | 0 | memcpy(tmp, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice)); |
5541 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5542 | 0 | libcrux_sha3_portable_keccak_store_5a_1c(self->inner.st, out0); |
5543 | 0 | memcpy(out_rest, tmp, (size_t)1U * sizeof(Eurydice_slice)); |
5544 | 0 | } |
5545 | 0 | } |
5546 | 0 | if (last < out_len) { |
5547 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5548 | 0 | libcrux_sha3_portable_keccak_store_5a_1c(self->inner.st, out_rest); |
5549 | 0 | } |
5550 | 0 | self->sponge = true; |
5551 | 0 | } |
5552 | | |
5553 | | /** |
5554 | | Shake256 squeeze |
5555 | | */ |
5556 | | /** |
5557 | | This function found in impl |
5558 | | {(libcrux_sha3::portable::incremental::XofSqueeze<136: usize> for |
5559 | | libcrux_sha3::portable::incremental::Shake256Squeeze)#3} |
5560 | | */ |
5561 | | static inline void libcrux_sha3_portable_incremental_squeeze_8a( |
5562 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_4f *self, Eurydice_slice out) { |
5563 | 0 | Eurydice_slice buf[1U] = {out}; |
5564 | 0 | libcrux_sha3_generic_keccak_squeeze_9d_96(self, buf); |
5565 | 0 | } |
5566 | | |
5567 | | /** |
5568 | | `out` has the exact size we want here. It must be less than or equal to `RATE`. |
5569 | | */ |
5570 | | /** |
5571 | | This function found in impl {(libcrux_sha3::traits::internal::KeccakItem<1: |
5572 | | usize> for u64)} |
5573 | | */ |
5574 | | /** |
5575 | | A monomorphic instance of libcrux_sha3.portable_keccak.store_5a |
5576 | | with const generics |
5577 | | - RATE= 168 |
5578 | | */ |
5579 | | static KRML_MUSTINLINE void libcrux_sha3_portable_keccak_store_5a_1c0( |
5580 | 0 | uint64_t (*state)[5U], Eurydice_slice out[1U]) { |
5581 | 0 | size_t num_full_blocks = Eurydice_slice_len(out[0U], uint8_t) / (size_t)8U; |
5582 | 0 | size_t last_block_len = Eurydice_slice_len(out[0U], uint8_t) % (size_t)8U; |
5583 | 0 | for (size_t i = (size_t)0U; i < num_full_blocks; i++) { |
5584 | 0 | size_t i0 = i; |
5585 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
5586 | 0 | out[0U], i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t); |
5587 | 0 | uint8_t ret[8U]; |
5588 | 0 | core_num__u64_9__to_le_bytes(state[i0 / (size_t)5U][i0 % (size_t)5U], ret); |
5589 | 0 | Eurydice_slice_copy( |
5590 | 0 | uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t); |
5591 | 0 | } |
5592 | 0 | if (last_block_len != (size_t)0U) { |
5593 | 0 | Eurydice_slice uu____1 = Eurydice_slice_subslice2( |
5594 | 0 | out[0U], num_full_blocks * (size_t)8U, |
5595 | 0 | num_full_blocks * (size_t)8U + last_block_len, uint8_t); |
5596 | 0 | uint8_t ret[8U]; |
5597 | 0 | core_num__u64_9__to_le_bytes( |
5598 | 0 | state[num_full_blocks / (size_t)5U][num_full_blocks % (size_t)5U], ret); |
5599 | 0 | Eurydice_slice_copy( |
5600 | 0 | uu____1, |
5601 | 0 | Eurydice_array_to_subslice2(ret, (size_t)0U, last_block_len, uint8_t), |
5602 | 0 | uint8_t); |
5603 | 0 | } |
5604 | 0 | } |
5605 | | |
5606 | | /** |
5607 | | Squeeze `N` x `LEN` bytes. |
5608 | | */ |
5609 | | /** |
5610 | | This function found in impl {libcrux_sha3::generic_keccak::KeccakXofState<STATE, |
5611 | | PARALLEL_LANES, RATE>[TraitClause@0]#2} |
5612 | | */ |
5613 | | /** |
5614 | | A monomorphic instance of libcrux_sha3.generic_keccak.squeeze_9d |
5615 | | with types uint64_t |
5616 | | with const generics |
5617 | | - PARALLEL_LANES= 1 |
5618 | | - RATE= 168 |
5619 | | */ |
5620 | | static KRML_MUSTINLINE void libcrux_sha3_generic_keccak_squeeze_9d_960( |
5621 | | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, |
5622 | 0 | Eurydice_slice out[1U]) { |
5623 | 0 | if (self->sponge) { |
5624 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5625 | 0 | } |
5626 | 0 | size_t out_len = Eurydice_slice_len(out[0U], uint8_t); |
5627 | 0 | size_t blocks = out_len / (size_t)168U; |
5628 | 0 | size_t last = out_len - out_len % (size_t)168U; |
5629 | 0 | size_t mid; |
5630 | 0 | if ((size_t)168U >= out_len) { |
5631 | 0 | mid = out_len; |
5632 | 0 | } else { |
5633 | 0 | mid = (size_t)168U; |
5634 | 0 | } |
5635 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____0 = |
5636 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, mid); |
5637 | 0 | Eurydice_slice out00[1U]; |
5638 | 0 | memcpy(out00, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice)); |
5639 | 0 | Eurydice_slice out_rest[1U]; |
5640 | 0 | memcpy(out_rest, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice)); |
5641 | 0 | libcrux_sha3_portable_keccak_store_5a_1c0(self->inner.st, out00); |
5642 | 0 | core_ops_range_Range_b3 iter = |
5643 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
5644 | 0 | (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U, |
5645 | 0 | .end = blocks}), |
5646 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
5647 | 0 | while (true) { |
5648 | 0 | if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
5649 | 0 | &iter, size_t, Option_b3) |
5650 | 0 | .tag == None) { |
5651 | 0 | break; |
5652 | 0 | } else { |
5653 | 0 | Eurydice_slice_uint8_t_1size_t__x2 uu____1 = |
5654 | 0 | libcrux_sha3_portable_keccak_split_at_mut_n_5a(out_rest, |
5655 | 0 | (size_t)168U); |
5656 | 0 | Eurydice_slice out0[1U]; |
5657 | 0 | memcpy(out0, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice)); |
5658 | 0 | Eurydice_slice tmp[1U]; |
5659 | 0 | memcpy(tmp, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice)); |
5660 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5661 | 0 | libcrux_sha3_portable_keccak_store_5a_1c0(self->inner.st, out0); |
5662 | 0 | memcpy(out_rest, tmp, (size_t)1U * sizeof(Eurydice_slice)); |
5663 | 0 | } |
5664 | 0 | } |
5665 | 0 | if (last < out_len) { |
5666 | 0 | libcrux_sha3_generic_keccak_keccakf1600_21(&self->inner); |
5667 | 0 | libcrux_sha3_portable_keccak_store_5a_1c0(self->inner.st, out_rest); |
5668 | 0 | } |
5669 | 0 | self->sponge = true; |
5670 | 0 | } |
5671 | | |
5672 | | /** |
5673 | | Shake128 squeeze |
5674 | | */ |
5675 | | /** |
5676 | | This function found in impl |
5677 | | {(libcrux_sha3::portable::incremental::XofSqueeze<168: usize> for |
5678 | | libcrux_sha3::portable::incremental::Shake128Squeeze)#1} |
5679 | | */ |
5680 | | static inline void libcrux_sha3_portable_incremental_squeeze_10( |
5681 | 0 | libcrux_sha3_generic_keccak_KeccakXofState_78 *self, Eurydice_slice out) { |
5682 | 0 | Eurydice_slice buf[1U] = {out}; |
5683 | 0 | libcrux_sha3_generic_keccak_squeeze_9d_960(self, buf); |
5684 | 0 | } |
5685 | | |
5686 | | /** |
5687 | | This function found in impl {(core::clone::Clone for |
5688 | | libcrux_sha3::portable::KeccakState)} |
5689 | | */ |
5690 | | static inline libcrux_sha3_generic_keccak_KeccakState_48 |
5691 | | libcrux_sha3_portable_clone_3d( |
5692 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 *self) { |
5693 | 0 | return self[0U]; |
5694 | 0 | } |
5695 | | |
5696 | | /** |
5697 | | This function found in impl {(core::convert::From<libcrux_sha3::Algorithm> for |
5698 | | u32)#1} |
5699 | | */ |
5700 | 0 | static inline uint32_t libcrux_sha3_from_eb(libcrux_sha3_Algorithm v) { |
5701 | 0 | uint32_t uu____0; |
5702 | 0 | switch (v) { |
5703 | 0 | case libcrux_sha3_Sha224: { |
5704 | 0 | uu____0 = 1U; |
5705 | 0 | break; |
5706 | 0 | } |
5707 | 0 | case libcrux_sha3_Sha256: { |
5708 | 0 | uu____0 = 2U; |
5709 | 0 | break; |
5710 | 0 | } |
5711 | 0 | case libcrux_sha3_Sha384: { |
5712 | 0 | uu____0 = 3U; |
5713 | 0 | break; |
5714 | 0 | } |
5715 | 0 | case libcrux_sha3_Sha512: { |
5716 | 0 | uu____0 = 4U; |
5717 | 0 | break; |
5718 | 0 | } |
5719 | 0 | default: { |
5720 | 0 | KRML_HOST_EPRINTF("KaRaMeL incomplete match at %s:%d\n", __FILE__, |
5721 | 0 | __LINE__); |
5722 | 0 | KRML_HOST_EXIT(253U); |
5723 | 0 | } |
5724 | 0 | } |
5725 | 0 | return uu____0; |
5726 | 0 | } |
5727 | | |
5728 | | /** |
5729 | | This function found in impl {(core::convert::From<u32> for |
5730 | | libcrux_sha3::Algorithm)} |
5731 | | */ |
5732 | 0 | static inline libcrux_sha3_Algorithm libcrux_sha3_from_2d(uint32_t v) { |
5733 | 0 | libcrux_sha3_Algorithm uu____0; |
5734 | 0 | switch (v) { |
5735 | 0 | case 1U: { |
5736 | 0 | uu____0 = libcrux_sha3_Sha224; |
5737 | 0 | break; |
5738 | 0 | } |
5739 | 0 | case 2U: { |
5740 | 0 | uu____0 = libcrux_sha3_Sha256; |
5741 | 0 | break; |
5742 | 0 | } |
5743 | 0 | case 3U: { |
5744 | 0 | uu____0 = libcrux_sha3_Sha384; |
5745 | 0 | break; |
5746 | 0 | } |
5747 | 0 | case 4U: { |
5748 | 0 | uu____0 = libcrux_sha3_Sha512; |
5749 | 0 | break; |
5750 | 0 | } |
5751 | 0 | default: { |
5752 | 0 | KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__, |
5753 | 0 | "panic!"); |
5754 | 0 | KRML_HOST_EXIT(255U); |
5755 | 0 | } |
5756 | 0 | } |
5757 | 0 | return uu____0; |
5758 | 0 | } |
5759 | | |
5760 | | typedef uint8_t libcrux_sha3_Sha3_512Digest[64U]; |
5761 | | |
5762 | | typedef uint8_t libcrux_sha3_Sha3_384Digest[48U]; |
5763 | | |
5764 | | typedef uint8_t libcrux_sha3_Sha3_256Digest[32U]; |
5765 | | |
5766 | | typedef uint8_t libcrux_sha3_Sha3_224Digest[28U]; |
5767 | | |
5768 | | #if defined(__cplusplus) |
5769 | | } |
5770 | | #endif |
5771 | | |
5772 | | #define __libcrux_sha3_portable_H_DEFINED |
5773 | | #endif |
5774 | | |
5775 | | /* from libcrux/libcrux-ml-kem/cg/libcrux_mlkem768_portable.h */ |
5776 | | /* |
5777 | | * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com> |
5778 | | * |
5779 | | * SPDX-License-Identifier: MIT or Apache-2.0 |
5780 | | * |
5781 | | * This code was generated with the following revisions: |
5782 | | * Charon: 6b5e110342a771a3e1c739b10294b1778e4be8b4 |
5783 | | * Eurydice: 31be7d65ca5d6acdacfb33652e478d24dd85c1cb |
5784 | | * Karamel: 3205d3365ea2790b02368f79fcee38e38d0b5908 |
5785 | | * F*: a32b316e521fa4f239b610ec8f1d15e78d62cbe8-dirty |
5786 | | * Libcrux: 4ad532b206174114dd4140b718e7794a28fc59ee |
5787 | | */ |
5788 | | |
5789 | | #ifndef __libcrux_mlkem768_portable_H |
5790 | | #define __libcrux_mlkem768_portable_H |
5791 | | |
5792 | | #if defined(__cplusplus) |
5793 | | extern "C" { |
5794 | | #endif |
5795 | | |
5796 | | |
5797 | | #define LIBCRUX_ML_KEM_HASH_FUNCTIONS_BLOCK_SIZE ((size_t)168U) |
5798 | | |
5799 | | #define LIBCRUX_ML_KEM_HASH_FUNCTIONS_THREE_BLOCKS \ |
5800 | | (LIBCRUX_ML_KEM_HASH_FUNCTIONS_BLOCK_SIZE * (size_t)3U) |
5801 | | |
5802 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_G( |
5803 | 0 | Eurydice_slice input, uint8_t ret[64U]) { |
5804 | 0 | uint8_t digest[64U] = {0U}; |
5805 | 0 | libcrux_sha3_portable_sha512( |
5806 | 0 | Eurydice_array_to_slice((size_t)64U, digest, uint8_t), input); |
5807 | 0 | memcpy(ret, digest, (size_t)64U * sizeof(uint8_t)); |
5808 | 0 | } |
5809 | | |
5810 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_H( |
5811 | 0 | Eurydice_slice input, uint8_t ret[32U]) { |
5812 | 0 | uint8_t digest[32U] = {0U}; |
5813 | 0 | libcrux_sha3_portable_sha256( |
5814 | 0 | Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input); |
5815 | 0 | memcpy(ret, digest, (size_t)32U * sizeof(uint8_t)); |
5816 | 0 | } |
5817 | | |
5818 | | #define LIBCRUX_ML_KEM_IND_CCA_ENCAPS_SEED_SIZE \ |
5819 | | (LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE) |
5820 | | |
5821 | | #define LIBCRUX_ML_KEM_IND_CCA_KEY_GENERATION_SEED_SIZE \ |
5822 | | (LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE + \ |
5823 | | LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE) |
5824 | | |
5825 | | typedef uint8_t libcrux_ml_kem_ind_cca_MlKemSharedSecret[32U]; |
5826 | | |
5827 | | static const int16_t libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[128U] = |
5828 | | {(int16_t)-1044, (int16_t)-758, (int16_t)-359, (int16_t)-1517, |
5829 | | (int16_t)1493, (int16_t)1422, (int16_t)287, (int16_t)202, |
5830 | | (int16_t)-171, (int16_t)622, (int16_t)1577, (int16_t)182, |
5831 | | (int16_t)962, (int16_t)-1202, (int16_t)-1474, (int16_t)1468, |
5832 | | (int16_t)573, (int16_t)-1325, (int16_t)264, (int16_t)383, |
5833 | | (int16_t)-829, (int16_t)1458, (int16_t)-1602, (int16_t)-130, |
5834 | | (int16_t)-681, (int16_t)1017, (int16_t)732, (int16_t)608, |
5835 | | (int16_t)-1542, (int16_t)411, (int16_t)-205, (int16_t)-1571, |
5836 | | (int16_t)1223, (int16_t)652, (int16_t)-552, (int16_t)1015, |
5837 | | (int16_t)-1293, (int16_t)1491, (int16_t)-282, (int16_t)-1544, |
5838 | | (int16_t)516, (int16_t)-8, (int16_t)-320, (int16_t)-666, |
5839 | | (int16_t)-1618, (int16_t)-1162, (int16_t)126, (int16_t)1469, |
5840 | | (int16_t)-853, (int16_t)-90, (int16_t)-271, (int16_t)830, |
5841 | | (int16_t)107, (int16_t)-1421, (int16_t)-247, (int16_t)-951, |
5842 | | (int16_t)-398, (int16_t)961, (int16_t)-1508, (int16_t)-725, |
5843 | | (int16_t)448, (int16_t)-1065, (int16_t)677, (int16_t)-1275, |
5844 | | (int16_t)-1103, (int16_t)430, (int16_t)555, (int16_t)843, |
5845 | | (int16_t)-1251, (int16_t)871, (int16_t)1550, (int16_t)105, |
5846 | | (int16_t)422, (int16_t)587, (int16_t)177, (int16_t)-235, |
5847 | | (int16_t)-291, (int16_t)-460, (int16_t)1574, (int16_t)1653, |
5848 | | (int16_t)-246, (int16_t)778, (int16_t)1159, (int16_t)-147, |
5849 | | (int16_t)-777, (int16_t)1483, (int16_t)-602, (int16_t)1119, |
5850 | | (int16_t)-1590, (int16_t)644, (int16_t)-872, (int16_t)349, |
5851 | | (int16_t)418, (int16_t)329, (int16_t)-156, (int16_t)-75, |
5852 | | (int16_t)817, (int16_t)1097, (int16_t)603, (int16_t)610, |
5853 | | (int16_t)1322, (int16_t)-1285, (int16_t)-1465, (int16_t)384, |
5854 | | (int16_t)-1215, (int16_t)-136, (int16_t)1218, (int16_t)-1335, |
5855 | | (int16_t)-874, (int16_t)220, (int16_t)-1187, (int16_t)-1659, |
5856 | | (int16_t)-1185, (int16_t)-1530, (int16_t)-1278, (int16_t)794, |
5857 | | (int16_t)-1510, (int16_t)-854, (int16_t)-870, (int16_t)478, |
5858 | | (int16_t)-108, (int16_t)-308, (int16_t)996, (int16_t)991, |
5859 | | (int16_t)958, (int16_t)-1460, (int16_t)1522, (int16_t)1628}; |
5860 | | |
5861 | 0 | #define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U) |
5862 | | |
5863 | | #define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT \ |
5864 | 0 | (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \ |
5865 | 0 | LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR) |
5866 | | |
5867 | 0 | #define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329) |
5868 | | |
5869 | | #define LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS \ |
5870 | 0 | ((int16_t)1353) |
5871 | | |
5872 | | #define LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R \ |
5873 | 0 | (62209U) |
5874 | | |
5875 | | typedef struct libcrux_ml_kem_vector_portable_vector_type_PortableVector_s { |
5876 | | int16_t elements[16U]; |
5877 | | } libcrux_ml_kem_vector_portable_vector_type_PortableVector; |
5878 | | |
5879 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
5880 | | libcrux_ml_kem_vector_portable_vector_type_from_i16_array( |
5881 | 0 | Eurydice_slice array) { |
5882 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector lit; |
5883 | 0 | int16_t ret[16U]; |
5884 | 0 | Result_c0 dst; |
5885 | 0 | Eurydice_slice_to_array2( |
5886 | 0 | &dst, Eurydice_slice_subslice2(array, (size_t)0U, (size_t)16U, int16_t), |
5887 | 0 | Eurydice_slice, int16_t[16U]); |
5888 | 0 | unwrap_41_f9(dst, ret); |
5889 | 0 | memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t)); |
5890 | 0 | return lit; |
5891 | 0 | } |
5892 | | |
5893 | | /** |
5894 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
5895 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
5896 | | */ |
5897 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
5898 | 0 | libcrux_ml_kem_vector_portable_from_i16_array_0d(Eurydice_slice array) { |
5899 | 0 | return libcrux_ml_kem_vector_portable_vector_type_from_i16_array(array); |
5900 | 0 | } |
5901 | | |
5902 | | typedef struct uint8_t_x11_s { |
5903 | | uint8_t fst; |
5904 | | uint8_t snd; |
5905 | | uint8_t thd; |
5906 | | uint8_t f3; |
5907 | | uint8_t f4; |
5908 | | uint8_t f5; |
5909 | | uint8_t f6; |
5910 | | uint8_t f7; |
5911 | | uint8_t f8; |
5912 | | uint8_t f9; |
5913 | | uint8_t f10; |
5914 | | } uint8_t_x11; |
5915 | | |
5916 | | static KRML_MUSTINLINE uint8_t_x11 |
5917 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_11_int(Eurydice_slice v) { |
5918 | 0 | uint8_t r0 = (uint8_t)Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *); |
5919 | 0 | uint8_t r1 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, |
5920 | 0 | int16_t *) & |
5921 | 0 | (int16_t)31) |
5922 | 0 | << 3U | |
5923 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, |
5924 | 0 | int16_t *) >> |
5925 | 0 | 8U); |
5926 | 0 | uint8_t r2 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t, |
5927 | 0 | int16_t *) & |
5928 | 0 | (int16_t)3) |
5929 | 0 | << 6U | |
5930 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, |
5931 | 0 | int16_t *) >> |
5932 | 0 | 5U); |
5933 | 0 | uint8_t r3 = |
5934 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t, int16_t *) >> 2U & |
5935 | 0 | (int16_t)255); |
5936 | 0 | uint8_t r4 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, |
5937 | 0 | int16_t *) & |
5938 | 0 | (int16_t)127) |
5939 | 0 | << 1U | |
5940 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t, |
5941 | 0 | int16_t *) >> |
5942 | 0 | 10U); |
5943 | 0 | uint8_t r5 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)4U, int16_t, |
5944 | 0 | int16_t *) & |
5945 | 0 | (int16_t)15) |
5946 | 0 | << 4U | |
5947 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, |
5948 | 0 | int16_t *) >> |
5949 | 0 | 7U); |
5950 | 0 | uint8_t r6 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)5U, int16_t, |
5951 | 0 | int16_t *) & |
5952 | 0 | (int16_t)1) |
5953 | 0 | << 7U | |
5954 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)4U, int16_t, |
5955 | 0 | int16_t *) >> |
5956 | 0 | 4U); |
5957 | 0 | uint8_t r7 = |
5958 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *) >> 1U & |
5959 | 0 | (int16_t)255); |
5960 | 0 | uint8_t r8 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)6U, int16_t, |
5961 | 0 | int16_t *) & |
5962 | 0 | (int16_t)63) |
5963 | 0 | << 2U | |
5964 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)5U, int16_t, |
5965 | 0 | int16_t *) >> |
5966 | 0 | 9U); |
5967 | 0 | uint8_t r9 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)7U, int16_t, |
5968 | 0 | int16_t *) & |
5969 | 0 | (int16_t)7) |
5970 | 0 | << 5U | |
5971 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)6U, int16_t, |
5972 | 0 | int16_t *) >> |
5973 | 0 | 6U); |
5974 | 0 | uint8_t r10 = |
5975 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *) >> 3U); |
5976 | 0 | return (CLITERAL(uint8_t_x11){.fst = r0, |
5977 | 0 | .snd = r1, |
5978 | 0 | .thd = r2, |
5979 | 0 | .f3 = r3, |
5980 | 0 | .f4 = r4, |
5981 | 0 | .f5 = r5, |
5982 | 0 | .f6 = r6, |
5983 | 0 | .f7 = r7, |
5984 | 0 | .f8 = r8, |
5985 | 0 | .f9 = r9, |
5986 | 0 | .f10 = r10}); |
5987 | 0 | } |
5988 | | |
5989 | | static KRML_MUSTINLINE void |
5990 | | libcrux_ml_kem_vector_portable_serialize_serialize_11( |
5991 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, |
5992 | 0 | uint8_t ret[22U]) { |
5993 | 0 | uint8_t_x11 r0_10 = libcrux_ml_kem_vector_portable_serialize_serialize_11_int( |
5994 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)8U, int16_t)); |
5995 | 0 | uint8_t_x11 r11_21 = |
5996 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_11_int( |
5997 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)16U, |
5998 | 0 | int16_t)); |
5999 | 0 | uint8_t result[22U] = {0U}; |
6000 | 0 | result[0U] = r0_10.fst; |
6001 | 0 | result[1U] = r0_10.snd; |
6002 | 0 | result[2U] = r0_10.thd; |
6003 | 0 | result[3U] = r0_10.f3; |
6004 | 0 | result[4U] = r0_10.f4; |
6005 | 0 | result[5U] = r0_10.f5; |
6006 | 0 | result[6U] = r0_10.f6; |
6007 | 0 | result[7U] = r0_10.f7; |
6008 | 0 | result[8U] = r0_10.f8; |
6009 | 0 | result[9U] = r0_10.f9; |
6010 | 0 | result[10U] = r0_10.f10; |
6011 | 0 | result[11U] = r11_21.fst; |
6012 | 0 | result[12U] = r11_21.snd; |
6013 | 0 | result[13U] = r11_21.thd; |
6014 | 0 | result[14U] = r11_21.f3; |
6015 | 0 | result[15U] = r11_21.f4; |
6016 | 0 | result[16U] = r11_21.f5; |
6017 | 0 | result[17U] = r11_21.f6; |
6018 | 0 | result[18U] = r11_21.f7; |
6019 | 0 | result[19U] = r11_21.f8; |
6020 | 0 | result[20U] = r11_21.f9; |
6021 | 0 | result[21U] = r11_21.f10; |
6022 | 0 | memcpy(ret, result, (size_t)22U * sizeof(uint8_t)); |
6023 | 0 | } |
6024 | | |
6025 | | /** |
6026 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6027 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6028 | | */ |
6029 | | static inline void libcrux_ml_kem_vector_portable_serialize_11_0d( |
6030 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
6031 | 0 | uint8_t ret[22U]) { |
6032 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_11(a, ret); |
6033 | 0 | } |
6034 | | |
6035 | | typedef struct int16_t_x8_s { |
6036 | | int16_t fst; |
6037 | | int16_t snd; |
6038 | | int16_t thd; |
6039 | | int16_t f3; |
6040 | | int16_t f4; |
6041 | | int16_t f5; |
6042 | | int16_t f6; |
6043 | | int16_t f7; |
6044 | | } int16_t_x8; |
6045 | | |
6046 | | static KRML_MUSTINLINE int16_t_x8 |
6047 | | libcrux_ml_kem_vector_portable_serialize_deserialize_11_int( |
6048 | 0 | Eurydice_slice bytes) { |
6049 | 0 | int16_t r0 = |
6050 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) & |
6051 | 0 | (int16_t)7) |
6052 | 0 | << 8U | |
6053 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *); |
6054 | 0 | int16_t r1 = |
6055 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) & |
6056 | 0 | (int16_t)63) |
6057 | 0 | << 5U | |
6058 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) >> |
6059 | 0 | 3U; |
6060 | 0 | int16_t r2 = |
6061 | 0 | (((int16_t)Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *) & |
6062 | 0 | (int16_t)1) |
6063 | 0 | << 10U | |
6064 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) |
6065 | 0 | << 2U) | |
6066 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) >> |
6067 | 0 | 6U; |
6068 | 0 | int16_t r3 = |
6069 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *) & |
6070 | 0 | (int16_t)15) |
6071 | 0 | << 7U | |
6072 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *) >> |
6073 | 0 | 1U; |
6074 | 0 | int16_t r4 = |
6075 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) & |
6076 | 0 | (int16_t)127) |
6077 | 0 | << 4U | |
6078 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *) >> |
6079 | 0 | 4U; |
6080 | 0 | int16_t r5 = |
6081 | 0 | (((int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) & |
6082 | 0 | (int16_t)3) |
6083 | 0 | << 9U | |
6084 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *) |
6085 | 0 | << 1U) | |
6086 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) >> |
6087 | 0 | 7U; |
6088 | 0 | int16_t r6 = |
6089 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *) & |
6090 | 0 | (int16_t)31) |
6091 | 0 | << 6U | |
6092 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) >> |
6093 | 0 | 2U; |
6094 | 0 | int16_t r7 = |
6095 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)10U, uint8_t, uint8_t *) |
6096 | 0 | << 3U | |
6097 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *) >> |
6098 | 0 | 5U; |
6099 | 0 | return (CLITERAL(int16_t_x8){.fst = r0, |
6100 | 0 | .snd = r1, |
6101 | 0 | .thd = r2, |
6102 | 0 | .f3 = r3, |
6103 | 0 | .f4 = r4, |
6104 | 0 | .f5 = r5, |
6105 | 0 | .f6 = r6, |
6106 | 0 | .f7 = r7}); |
6107 | 0 | } |
6108 | | |
6109 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6110 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(void) { |
6111 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector lit; |
6112 | 0 | lit.elements[0U] = (int16_t)0; |
6113 | 0 | lit.elements[1U] = (int16_t)0; |
6114 | 0 | lit.elements[2U] = (int16_t)0; |
6115 | 0 | lit.elements[3U] = (int16_t)0; |
6116 | 0 | lit.elements[4U] = (int16_t)0; |
6117 | 0 | lit.elements[5U] = (int16_t)0; |
6118 | 0 | lit.elements[6U] = (int16_t)0; |
6119 | 0 | lit.elements[7U] = (int16_t)0; |
6120 | 0 | lit.elements[8U] = (int16_t)0; |
6121 | 0 | lit.elements[9U] = (int16_t)0; |
6122 | 0 | lit.elements[10U] = (int16_t)0; |
6123 | 0 | lit.elements[11U] = (int16_t)0; |
6124 | 0 | lit.elements[12U] = (int16_t)0; |
6125 | 0 | lit.elements[13U] = (int16_t)0; |
6126 | 0 | lit.elements[14U] = (int16_t)0; |
6127 | 0 | lit.elements[15U] = (int16_t)0; |
6128 | 0 | return lit; |
6129 | 0 | } |
6130 | | |
6131 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6132 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_11(Eurydice_slice bytes) { |
6133 | 0 | int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_11_int( |
6134 | 0 | Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)11U, uint8_t)); |
6135 | 0 | int16_t_x8 v8_15 = |
6136 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_11_int( |
6137 | 0 | Eurydice_slice_subslice2(bytes, (size_t)11U, (size_t)22U, uint8_t)); |
6138 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v = |
6139 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
6140 | 0 | v.elements[0U] = v0_7.fst; |
6141 | 0 | v.elements[1U] = v0_7.snd; |
6142 | 0 | v.elements[2U] = v0_7.thd; |
6143 | 0 | v.elements[3U] = v0_7.f3; |
6144 | 0 | v.elements[4U] = v0_7.f4; |
6145 | 0 | v.elements[5U] = v0_7.f5; |
6146 | 0 | v.elements[6U] = v0_7.f6; |
6147 | 0 | v.elements[7U] = v0_7.f7; |
6148 | 0 | v.elements[8U] = v8_15.fst; |
6149 | 0 | v.elements[9U] = v8_15.snd; |
6150 | 0 | v.elements[10U] = v8_15.thd; |
6151 | 0 | v.elements[11U] = v8_15.f3; |
6152 | 0 | v.elements[12U] = v8_15.f4; |
6153 | 0 | v.elements[13U] = v8_15.f5; |
6154 | 0 | v.elements[14U] = v8_15.f6; |
6155 | 0 | v.elements[15U] = v8_15.f7; |
6156 | 0 | return v; |
6157 | 0 | } |
6158 | | |
6159 | | /** |
6160 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6161 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6162 | | */ |
6163 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6164 | 0 | libcrux_ml_kem_vector_portable_deserialize_11_0d(Eurydice_slice a) { |
6165 | 0 | return libcrux_ml_kem_vector_portable_serialize_deserialize_11(a); |
6166 | 0 | } |
6167 | | |
6168 | | static KRML_MUSTINLINE void |
6169 | | libcrux_ml_kem_vector_portable_vector_type_to_i16_array( |
6170 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector x, |
6171 | 0 | int16_t ret[16U]) { |
6172 | 0 | memcpy(ret, x.elements, (size_t)16U * sizeof(int16_t)); |
6173 | 0 | } |
6174 | | |
6175 | | /** |
6176 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6177 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6178 | | */ |
6179 | | static inline void libcrux_ml_kem_vector_portable_to_i16_array_0d( |
6180 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector x, |
6181 | 0 | int16_t ret[16U]) { |
6182 | 0 | libcrux_ml_kem_vector_portable_vector_type_to_i16_array(x, ret); |
6183 | 0 | } |
6184 | | |
6185 | | static const uint8_t |
6186 | | libcrux_ml_kem_vector_rej_sample_table_REJECTION_SAMPLE_SHUFFLE_TABLE |
6187 | | [256U][16U] = {{255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6188 | | 255U, 255U, 255U, 255U, 255U, 255U, 255U}, |
6189 | | {0U, 1U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6190 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6191 | | {2U, 3U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6192 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6193 | | {0U, 1U, 2U, 3U, 255U, 255U, 255U, 255U, 255U, 255U, |
6194 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6195 | | {4U, 5U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6196 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6197 | | {0U, 1U, 4U, 5U, 255U, 255U, 255U, 255U, 255U, 255U, |
6198 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6199 | | {2U, 3U, 4U, 5U, 255U, 255U, 255U, 255U, 255U, 255U, |
6200 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6201 | | {0U, 1U, 2U, 3U, 4U, 5U, 255U, 255U, 255U, 255U, 255U, |
6202 | | 255U, 255U, 255U, 255U, 255U}, |
6203 | | {6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6204 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6205 | | {0U, 1U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U, |
6206 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6207 | | {2U, 3U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U, |
6208 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6209 | | {0U, 1U, 2U, 3U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, |
6210 | | 255U, 255U, 255U, 255U, 255U}, |
6211 | | {4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, 255U, |
6212 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6213 | | {0U, 1U, 4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, |
6214 | | 255U, 255U, 255U, 255U, 255U}, |
6215 | | {2U, 3U, 4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, 255U, |
6216 | | 255U, 255U, 255U, 255U, 255U}, |
6217 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 255U, 255U, 255U, 255U, |
6218 | | 255U, 255U, 255U, 255U}, |
6219 | | {8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6220 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6221 | | {0U, 1U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U, |
6222 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6223 | | {2U, 3U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U, |
6224 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6225 | | {0U, 1U, 2U, 3U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, |
6226 | | 255U, 255U, 255U, 255U, 255U}, |
6227 | | {4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U, |
6228 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6229 | | {0U, 1U, 4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, |
6230 | | 255U, 255U, 255U, 255U, 255U}, |
6231 | | {2U, 3U, 4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, |
6232 | | 255U, 255U, 255U, 255U, 255U}, |
6233 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 255U, 255U, 255U, 255U, |
6234 | | 255U, 255U, 255U, 255U}, |
6235 | | {6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, 255U, |
6236 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6237 | | {0U, 1U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, |
6238 | | 255U, 255U, 255U, 255U, 255U}, |
6239 | | {2U, 3U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, |
6240 | | 255U, 255U, 255U, 255U, 255U}, |
6241 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, |
6242 | | 255U, 255U, 255U, 255U}, |
6243 | | {4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, 255U, |
6244 | | 255U, 255U, 255U, 255U, 255U}, |
6245 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, |
6246 | | 255U, 255U, 255U, 255U}, |
6247 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, 255U, 255U, |
6248 | | 255U, 255U, 255U, 255U}, |
6249 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 255U, 255U, |
6250 | | 255U, 255U, 255U, 255U}, |
6251 | | {10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6252 | | 255U, 255U, 255U, 255U, 255U, 255U, 255U}, |
6253 | | {0U, 1U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, |
6254 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6255 | | {2U, 3U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, |
6256 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6257 | | {0U, 1U, 2U, 3U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6258 | | 255U, 255U, 255U, 255U, 255U}, |
6259 | | {4U, 5U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, |
6260 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6261 | | {0U, 1U, 4U, 5U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6262 | | 255U, 255U, 255U, 255U, 255U}, |
6263 | | {2U, 3U, 4U, 5U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6264 | | 255U, 255U, 255U, 255U, 255U}, |
6265 | | {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 255U, 255U, 255U, |
6266 | | 255U, 255U, 255U, 255U, 255U}, |
6267 | | {6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, |
6268 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6269 | | {0U, 1U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6270 | | 255U, 255U, 255U, 255U, 255U}, |
6271 | | {2U, 3U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6272 | | 255U, 255U, 255U, 255U, 255U}, |
6273 | | {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, |
6274 | | 255U, 255U, 255U, 255U, 255U}, |
6275 | | {4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6276 | | 255U, 255U, 255U, 255U, 255U}, |
6277 | | {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, |
6278 | | 255U, 255U, 255U, 255U, 255U}, |
6279 | | {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, 255U, |
6280 | | 255U, 255U, 255U, 255U, 255U}, |
6281 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 255U, 255U, |
6282 | | 255U, 255U, 255U, 255U}, |
6283 | | {8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, 255U, |
6284 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6285 | | {0U, 1U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6286 | | 255U, 255U, 255U, 255U, 255U}, |
6287 | | {2U, 3U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6288 | | 255U, 255U, 255U, 255U, 255U}, |
6289 | | {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, |
6290 | | 255U, 255U, 255U, 255U, 255U}, |
6291 | | {4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6292 | | 255U, 255U, 255U, 255U, 255U}, |
6293 | | {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, |
6294 | | 255U, 255U, 255U, 255U, 255U}, |
6295 | | {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, |
6296 | | 255U, 255U, 255U, 255U, 255U}, |
6297 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 255U, 255U, |
6298 | | 255U, 255U, 255U, 255U}, |
6299 | | {6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, 255U, 255U, |
6300 | | 255U, 255U, 255U, 255U, 255U}, |
6301 | | {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, |
6302 | | 255U, 255U, 255U, 255U, 255U}, |
6303 | | {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, |
6304 | | 255U, 255U, 255U, 255U, 255U}, |
6305 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, |
6306 | | 255U, 255U, 255U, 255U}, |
6307 | | {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, 255U, |
6308 | | 255U, 255U, 255U, 255U, 255U}, |
6309 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, |
6310 | | 255U, 255U, 255U, 255U}, |
6311 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, 255U, |
6312 | | 255U, 255U, 255U, 255U}, |
6313 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 255U, |
6314 | | 255U, 255U, 255U}, |
6315 | | {12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6316 | | 255U, 255U, 255U, 255U, 255U, 255U, 255U}, |
6317 | | {0U, 1U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, |
6318 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6319 | | {2U, 3U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, |
6320 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6321 | | {0U, 1U, 2U, 3U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6322 | | 255U, 255U, 255U, 255U, 255U}, |
6323 | | {4U, 5U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, |
6324 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6325 | | {0U, 1U, 4U, 5U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6326 | | 255U, 255U, 255U, 255U, 255U}, |
6327 | | {2U, 3U, 4U, 5U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6328 | | 255U, 255U, 255U, 255U, 255U}, |
6329 | | {0U, 1U, 2U, 3U, 4U, 5U, 12U, 13U, 255U, 255U, 255U, |
6330 | | 255U, 255U, 255U, 255U, 255U}, |
6331 | | {6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, |
6332 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6333 | | {0U, 1U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6334 | | 255U, 255U, 255U, 255U, 255U}, |
6335 | | {2U, 3U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6336 | | 255U, 255U, 255U, 255U, 255U}, |
6337 | | {0U, 1U, 2U, 3U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, |
6338 | | 255U, 255U, 255U, 255U, 255U}, |
6339 | | {4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6340 | | 255U, 255U, 255U, 255U, 255U}, |
6341 | | {0U, 1U, 4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, |
6342 | | 255U, 255U, 255U, 255U, 255U}, |
6343 | | {2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, 255U, |
6344 | | 255U, 255U, 255U, 255U, 255U}, |
6345 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 255U, 255U, |
6346 | | 255U, 255U, 255U, 255U}, |
6347 | | {8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, |
6348 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6349 | | {0U, 1U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6350 | | 255U, 255U, 255U, 255U, 255U}, |
6351 | | {2U, 3U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6352 | | 255U, 255U, 255U, 255U, 255U}, |
6353 | | {0U, 1U, 2U, 3U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, |
6354 | | 255U, 255U, 255U, 255U, 255U}, |
6355 | | {4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6356 | | 255U, 255U, 255U, 255U, 255U}, |
6357 | | {0U, 1U, 4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, |
6358 | | 255U, 255U, 255U, 255U, 255U}, |
6359 | | {2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, |
6360 | | 255U, 255U, 255U, 255U, 255U}, |
6361 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 255U, 255U, |
6362 | | 255U, 255U, 255U, 255U}, |
6363 | | {6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, |
6364 | | 255U, 255U, 255U, 255U, 255U}, |
6365 | | {0U, 1U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, |
6366 | | 255U, 255U, 255U, 255U, 255U}, |
6367 | | {2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, |
6368 | | 255U, 255U, 255U, 255U, 255U}, |
6369 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, |
6370 | | 255U, 255U, 255U, 255U}, |
6371 | | {4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, 255U, |
6372 | | 255U, 255U, 255U, 255U, 255U}, |
6373 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, |
6374 | | 255U, 255U, 255U, 255U}, |
6375 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, 255U, |
6376 | | 255U, 255U, 255U, 255U}, |
6377 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 255U, |
6378 | | 255U, 255U, 255U}, |
6379 | | {10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, 255U, 255U, |
6380 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6381 | | {0U, 1U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, |
6382 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6383 | | {2U, 3U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, |
6384 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6385 | | {0U, 1U, 2U, 3U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6386 | | 255U, 255U, 255U, 255U, 255U}, |
6387 | | {4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, |
6388 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6389 | | {0U, 1U, 4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6390 | | 255U, 255U, 255U, 255U, 255U}, |
6391 | | {2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6392 | | 255U, 255U, 255U, 255U, 255U}, |
6393 | | {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 255U, 255U, |
6394 | | 255U, 255U, 255U, 255U}, |
6395 | | {6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, |
6396 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6397 | | {0U, 1U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6398 | | 255U, 255U, 255U, 255U, 255U}, |
6399 | | {2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6400 | | 255U, 255U, 255U, 255U, 255U}, |
6401 | | {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, |
6402 | | 255U, 255U, 255U, 255U}, |
6403 | | {4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6404 | | 255U, 255U, 255U, 255U, 255U}, |
6405 | | {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, |
6406 | | 255U, 255U, 255U, 255U}, |
6407 | | {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 255U, 255U, |
6408 | | 255U, 255U, 255U, 255U}, |
6409 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, |
6410 | | 255U, 255U, 255U, 255U}, |
6411 | | {8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, 255U, |
6412 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6413 | | {0U, 1U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6414 | | 255U, 255U, 255U, 255U, 255U}, |
6415 | | {2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6416 | | 255U, 255U, 255U, 255U, 255U}, |
6417 | | {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, |
6418 | | 255U, 255U, 255U, 255U}, |
6419 | | {4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6420 | | 255U, 255U, 255U, 255U, 255U}, |
6421 | | {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, |
6422 | | 255U, 255U, 255U, 255U}, |
6423 | | {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, |
6424 | | 255U, 255U, 255U, 255U}, |
6425 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, |
6426 | | 255U, 255U, 255U, 255U}, |
6427 | | {6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, 255U, |
6428 | | 255U, 255U, 255U, 255U, 255U}, |
6429 | | {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, |
6430 | | 255U, 255U, 255U, 255U}, |
6431 | | {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, |
6432 | | 255U, 255U, 255U, 255U}, |
6433 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, |
6434 | | 255U, 255U, 255U, 255U}, |
6435 | | {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 255U, 255U, |
6436 | | 255U, 255U, 255U, 255U}, |
6437 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, |
6438 | | 255U, 255U, 255U, 255U}, |
6439 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, |
6440 | | 255U, 255U, 255U, 255U}, |
6441 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, |
6442 | | 13U, 255U, 255U}, |
6443 | | {14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, 255U, |
6444 | | 255U, 255U, 255U, 255U, 255U, 255U, 255U}, |
6445 | | {0U, 1U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6446 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6447 | | {2U, 3U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6448 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6449 | | {0U, 1U, 2U, 3U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6450 | | 255U, 255U, 255U, 255U, 255U}, |
6451 | | {4U, 5U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6452 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6453 | | {0U, 1U, 4U, 5U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6454 | | 255U, 255U, 255U, 255U, 255U}, |
6455 | | {2U, 3U, 4U, 5U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6456 | | 255U, 255U, 255U, 255U, 255U}, |
6457 | | {0U, 1U, 2U, 3U, 4U, 5U, 14U, 15U, 255U, 255U, 255U, |
6458 | | 255U, 255U, 255U, 255U, 255U}, |
6459 | | {6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6460 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6461 | | {0U, 1U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6462 | | 255U, 255U, 255U, 255U, 255U}, |
6463 | | {2U, 3U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6464 | | 255U, 255U, 255U, 255U, 255U}, |
6465 | | {0U, 1U, 2U, 3U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, |
6466 | | 255U, 255U, 255U, 255U, 255U}, |
6467 | | {4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6468 | | 255U, 255U, 255U, 255U, 255U}, |
6469 | | {0U, 1U, 4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, |
6470 | | 255U, 255U, 255U, 255U, 255U}, |
6471 | | {2U, 3U, 4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, 255U, |
6472 | | 255U, 255U, 255U, 255U, 255U}, |
6473 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 14U, 15U, 255U, 255U, |
6474 | | 255U, 255U, 255U, 255U}, |
6475 | | {8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6476 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6477 | | {0U, 1U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6478 | | 255U, 255U, 255U, 255U, 255U}, |
6479 | | {2U, 3U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6480 | | 255U, 255U, 255U, 255U, 255U}, |
6481 | | {0U, 1U, 2U, 3U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, |
6482 | | 255U, 255U, 255U, 255U, 255U}, |
6483 | | {4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6484 | | 255U, 255U, 255U, 255U, 255U}, |
6485 | | {0U, 1U, 4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, |
6486 | | 255U, 255U, 255U, 255U, 255U}, |
6487 | | {2U, 3U, 4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, |
6488 | | 255U, 255U, 255U, 255U, 255U}, |
6489 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 14U, 15U, 255U, 255U, |
6490 | | 255U, 255U, 255U, 255U}, |
6491 | | {6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, |
6492 | | 255U, 255U, 255U, 255U, 255U}, |
6493 | | {0U, 1U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, |
6494 | | 255U, 255U, 255U, 255U, 255U}, |
6495 | | {2U, 3U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, |
6496 | | 255U, 255U, 255U, 255U, 255U}, |
6497 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, |
6498 | | 255U, 255U, 255U, 255U}, |
6499 | | {4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, 255U, |
6500 | | 255U, 255U, 255U, 255U, 255U}, |
6501 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, |
6502 | | 255U, 255U, 255U, 255U}, |
6503 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, 255U, |
6504 | | 255U, 255U, 255U, 255U}, |
6505 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 14U, 15U, 255U, |
6506 | | 255U, 255U, 255U}, |
6507 | | {10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6508 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6509 | | {0U, 1U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, |
6510 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6511 | | {2U, 3U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, |
6512 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6513 | | {0U, 1U, 2U, 3U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6514 | | 255U, 255U, 255U, 255U, 255U}, |
6515 | | {4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, |
6516 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6517 | | {0U, 1U, 4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6518 | | 255U, 255U, 255U, 255U, 255U}, |
6519 | | {2U, 3U, 4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6520 | | 255U, 255U, 255U, 255U, 255U}, |
6521 | | {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 14U, 15U, 255U, 255U, |
6522 | | 255U, 255U, 255U, 255U}, |
6523 | | {6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, |
6524 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6525 | | {0U, 1U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6526 | | 255U, 255U, 255U, 255U, 255U}, |
6527 | | {2U, 3U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6528 | | 255U, 255U, 255U, 255U, 255U}, |
6529 | | {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, |
6530 | | 255U, 255U, 255U, 255U}, |
6531 | | {4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6532 | | 255U, 255U, 255U, 255U, 255U}, |
6533 | | {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, |
6534 | | 255U, 255U, 255U, 255U}, |
6535 | | {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, 255U, 255U, |
6536 | | 255U, 255U, 255U, 255U}, |
6537 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 14U, 15U, |
6538 | | 255U, 255U, 255U, 255U}, |
6539 | | {8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, 255U, |
6540 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6541 | | {0U, 1U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6542 | | 255U, 255U, 255U, 255U, 255U}, |
6543 | | {2U, 3U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6544 | | 255U, 255U, 255U, 255U, 255U}, |
6545 | | {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, |
6546 | | 255U, 255U, 255U, 255U}, |
6547 | | {4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6548 | | 255U, 255U, 255U, 255U, 255U}, |
6549 | | {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, |
6550 | | 255U, 255U, 255U, 255U}, |
6551 | | {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, |
6552 | | 255U, 255U, 255U, 255U}, |
6553 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 14U, 15U, |
6554 | | 255U, 255U, 255U, 255U}, |
6555 | | {6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, 255U, |
6556 | | 255U, 255U, 255U, 255U, 255U}, |
6557 | | {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, |
6558 | | 255U, 255U, 255U, 255U}, |
6559 | | {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, |
6560 | | 255U, 255U, 255U, 255U}, |
6561 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, |
6562 | | 255U, 255U, 255U, 255U}, |
6563 | | {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, 255U, 255U, |
6564 | | 255U, 255U, 255U, 255U}, |
6565 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, |
6566 | | 255U, 255U, 255U, 255U}, |
6567 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, 15U, |
6568 | | 255U, 255U, 255U, 255U}, |
6569 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 14U, |
6570 | | 15U, 255U, 255U}, |
6571 | | {12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, 255U, 255U, |
6572 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6573 | | {0U, 1U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, |
6574 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6575 | | {2U, 3U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, |
6576 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6577 | | {0U, 1U, 2U, 3U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6578 | | 255U, 255U, 255U, 255U, 255U}, |
6579 | | {4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, |
6580 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6581 | | {0U, 1U, 4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6582 | | 255U, 255U, 255U, 255U, 255U}, |
6583 | | {2U, 3U, 4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6584 | | 255U, 255U, 255U, 255U, 255U}, |
6585 | | {0U, 1U, 2U, 3U, 4U, 5U, 12U, 13U, 14U, 15U, 255U, 255U, |
6586 | | 255U, 255U, 255U, 255U}, |
6587 | | {6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, |
6588 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6589 | | {0U, 1U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6590 | | 255U, 255U, 255U, 255U, 255U}, |
6591 | | {2U, 3U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6592 | | 255U, 255U, 255U, 255U, 255U}, |
6593 | | {0U, 1U, 2U, 3U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, |
6594 | | 255U, 255U, 255U, 255U}, |
6595 | | {4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6596 | | 255U, 255U, 255U, 255U, 255U}, |
6597 | | {0U, 1U, 4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, |
6598 | | 255U, 255U, 255U, 255U}, |
6599 | | {2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, 255U, 255U, |
6600 | | 255U, 255U, 255U, 255U}, |
6601 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 12U, 13U, 14U, 15U, |
6602 | | 255U, 255U, 255U, 255U}, |
6603 | | {8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, |
6604 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6605 | | {0U, 1U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6606 | | 255U, 255U, 255U, 255U, 255U}, |
6607 | | {2U, 3U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6608 | | 255U, 255U, 255U, 255U, 255U}, |
6609 | | {0U, 1U, 2U, 3U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, |
6610 | | 255U, 255U, 255U, 255U}, |
6611 | | {4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6612 | | 255U, 255U, 255U, 255U, 255U}, |
6613 | | {0U, 1U, 4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, |
6614 | | 255U, 255U, 255U, 255U}, |
6615 | | {2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, |
6616 | | 255U, 255U, 255U, 255U}, |
6617 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 12U, 13U, 14U, 15U, |
6618 | | 255U, 255U, 255U, 255U}, |
6619 | | {6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6620 | | 255U, 255U, 255U, 255U, 255U}, |
6621 | | {0U, 1U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, |
6622 | | 255U, 255U, 255U, 255U}, |
6623 | | {2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, |
6624 | | 255U, 255U, 255U, 255U}, |
6625 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, |
6626 | | 255U, 255U, 255U, 255U}, |
6627 | | {4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, 255U, 255U, |
6628 | | 255U, 255U, 255U, 255U}, |
6629 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, |
6630 | | 255U, 255U, 255U, 255U}, |
6631 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, 15U, |
6632 | | 255U, 255U, 255U, 255U}, |
6633 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 12U, 13U, 14U, |
6634 | | 15U, 255U, 255U}, |
6635 | | {10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, 255U, |
6636 | | 255U, 255U, 255U, 255U, 255U, 255U}, |
6637 | | {0U, 1U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6638 | | 255U, 255U, 255U, 255U, 255U}, |
6639 | | {2U, 3U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6640 | | 255U, 255U, 255U, 255U, 255U}, |
6641 | | {0U, 1U, 2U, 3U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6642 | | 255U, 255U, 255U, 255U, 255U}, |
6643 | | {4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6644 | | 255U, 255U, 255U, 255U, 255U}, |
6645 | | {0U, 1U, 4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6646 | | 255U, 255U, 255U, 255U, 255U}, |
6647 | | {2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6648 | | 255U, 255U, 255U, 255U, 255U}, |
6649 | | {0U, 1U, 2U, 3U, 4U, 5U, 10U, 11U, 12U, 13U, 14U, 15U, |
6650 | | 255U, 255U, 255U, 255U}, |
6651 | | {6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6652 | | 255U, 255U, 255U, 255U, 255U}, |
6653 | | {0U, 1U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6654 | | 255U, 255U, 255U, 255U, 255U}, |
6655 | | {2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6656 | | 255U, 255U, 255U, 255U, 255U}, |
6657 | | {0U, 1U, 2U, 3U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, |
6658 | | 255U, 255U, 255U, 255U}, |
6659 | | {4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6660 | | 255U, 255U, 255U, 255U, 255U}, |
6661 | | {0U, 1U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, |
6662 | | 255U, 255U, 255U, 255U}, |
6663 | | {2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, 15U, |
6664 | | 255U, 255U, 255U, 255U}, |
6665 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 10U, 11U, 12U, 13U, 14U, |
6666 | | 15U, 255U, 255U}, |
6667 | | {8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, 255U, 255U, |
6668 | | 255U, 255U, 255U, 255U, 255U}, |
6669 | | {0U, 1U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6670 | | 255U, 255U, 255U, 255U, 255U}, |
6671 | | {2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6672 | | 255U, 255U, 255U, 255U, 255U}, |
6673 | | {0U, 1U, 2U, 3U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, |
6674 | | 255U, 255U, 255U, 255U}, |
6675 | | {4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6676 | | 255U, 255U, 255U, 255U, 255U}, |
6677 | | {0U, 1U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, |
6678 | | 255U, 255U, 255U, 255U}, |
6679 | | {2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, |
6680 | | 255U, 255U, 255U, 255U}, |
6681 | | {0U, 1U, 2U, 3U, 4U, 5U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, |
6682 | | 15U, 255U, 255U}, |
6683 | | {6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, 255U, |
6684 | | 255U, 255U, 255U, 255U, 255U}, |
6685 | | {0U, 1U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, |
6686 | | 255U, 255U, 255U, 255U}, |
6687 | | {2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, |
6688 | | 255U, 255U, 255U, 255U}, |
6689 | | {0U, 1U, 2U, 3U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, |
6690 | | 15U, 255U, 255U}, |
6691 | | {4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U, |
6692 | | 255U, 255U, 255U, 255U}, |
6693 | | {0U, 1U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, |
6694 | | 15U, 255U, 255U}, |
6695 | | {2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, 13U, 14U, |
6696 | | 15U, 255U, 255U}, |
6697 | | {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 9U, 10U, 11U, 12U, |
6698 | | 13U, 14U, 15U}}; |
6699 | | |
6700 | | /** |
6701 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6702 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6703 | | */ |
6704 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6705 | 0 | libcrux_ml_kem_vector_portable_ZERO_0d(void) { |
6706 | 0 | return libcrux_ml_kem_vector_portable_vector_type_zero(); |
6707 | 0 | } |
6708 | | |
6709 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6710 | | libcrux_ml_kem_vector_portable_arithmetic_add( |
6711 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs, |
6712 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) { |
6713 | 0 | for (size_t i = (size_t)0U; |
6714 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
6715 | 0 | size_t i0 = i; |
6716 | 0 | size_t uu____0 = i0; |
6717 | 0 | lhs.elements[uu____0] = lhs.elements[uu____0] + rhs->elements[i0]; |
6718 | 0 | } |
6719 | 0 | return lhs; |
6720 | 0 | } |
6721 | | |
6722 | | /** |
6723 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6724 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6725 | | */ |
6726 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6727 | | libcrux_ml_kem_vector_portable_add_0d( |
6728 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs, |
6729 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) { |
6730 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_add(lhs, rhs); |
6731 | 0 | } |
6732 | | |
6733 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6734 | | libcrux_ml_kem_vector_portable_arithmetic_sub( |
6735 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs, |
6736 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) { |
6737 | 0 | for (size_t i = (size_t)0U; |
6738 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
6739 | 0 | size_t i0 = i; |
6740 | 0 | size_t uu____0 = i0; |
6741 | 0 | lhs.elements[uu____0] = lhs.elements[uu____0] - rhs->elements[i0]; |
6742 | 0 | } |
6743 | 0 | return lhs; |
6744 | 0 | } |
6745 | | |
6746 | | /** |
6747 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6748 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6749 | | */ |
6750 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6751 | | libcrux_ml_kem_vector_portable_sub_0d( |
6752 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector lhs, |
6753 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) { |
6754 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_sub(lhs, rhs); |
6755 | 0 | } |
6756 | | |
6757 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6758 | | libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant( |
6759 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) { |
6760 | 0 | for (size_t i = (size_t)0U; |
6761 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
6762 | 0 | size_t i0 = i; |
6763 | 0 | size_t uu____0 = i0; |
6764 | 0 | v.elements[uu____0] = v.elements[uu____0] * c; |
6765 | 0 | } |
6766 | 0 | return v; |
6767 | 0 | } |
6768 | | |
6769 | | /** |
6770 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6771 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6772 | | */ |
6773 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6774 | | libcrux_ml_kem_vector_portable_multiply_by_constant_0d( |
6775 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) { |
6776 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(v, c); |
6777 | 0 | } |
6778 | | |
6779 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6780 | | libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant( |
6781 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) { |
6782 | 0 | for (size_t i = (size_t)0U; |
6783 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
6784 | 0 | size_t i0 = i; |
6785 | 0 | size_t uu____0 = i0; |
6786 | 0 | v.elements[uu____0] = v.elements[uu____0] & c; |
6787 | 0 | } |
6788 | 0 | return v; |
6789 | 0 | } |
6790 | | |
6791 | | /** |
6792 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6793 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6794 | | */ |
6795 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6796 | | libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d( |
6797 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) { |
6798 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(v, |
6799 | 0 | c); |
6800 | 0 | } |
6801 | | |
6802 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6803 | | libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329( |
6804 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
6805 | 0 | core_ops_range_Range_b3 iter = |
6806 | 0 | core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter( |
6807 | 0 | (CLITERAL(core_ops_range_Range_b3){ |
6808 | 0 | .start = (size_t)0U, |
6809 | 0 | .end = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR}), |
6810 | 0 | core_ops_range_Range_b3, core_ops_range_Range_b3); |
6811 | 0 | while (true) { |
6812 | 0 | Option_b3 uu____0 = |
6813 | 0 | core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next( |
6814 | 0 | &iter, size_t, Option_b3); |
6815 | 0 | if (!(uu____0.tag == None)) { |
6816 | 0 | size_t i = uu____0.f0; |
6817 | 0 | if (v.elements[i] >= (int16_t)3329) { |
6818 | 0 | size_t uu____1 = i; |
6819 | 0 | v.elements[uu____1] = v.elements[uu____1] - (int16_t)3329; |
6820 | 0 | } |
6821 | 0 | continue; |
6822 | 0 | } |
6823 | 0 | return v; |
6824 | 0 | } |
6825 | 0 | } |
6826 | | |
6827 | | /** |
6828 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6829 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6830 | | */ |
6831 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6832 | | libcrux_ml_kem_vector_portable_cond_subtract_3329_0d( |
6833 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
6834 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329(v); |
6835 | 0 | } |
6836 | | |
6837 | | #define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER \ |
6838 | 0 | ((int32_t)20159) |
6839 | | |
6840 | 0 | #define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT ((int32_t)26) |
6841 | | |
6842 | | #define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_R \ |
6843 | 0 | ((int32_t)1 << (uint32_t) \ |
6844 | 0 | LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT) |
6845 | | |
6846 | | /** |
6847 | | Signed Barrett Reduction |
6848 | | |
6849 | | Given an input `value`, `barrett_reduce` outputs a representative `result` |
6850 | | such that: |
6851 | | |
6852 | | - result ≡ value (mod FIELD_MODULUS) |
6853 | | - the absolute value of `result` is bound as follows: |
6854 | | |
6855 | | `|result| ≤ FIELD_MODULUS / 2 · (|value|/BARRETT_R + 1) |
6856 | | |
6857 | | In particular, if `|value| < BARRETT_R`, then `|result| < FIELD_MODULUS`. |
6858 | | */ |
6859 | | static inline int16_t |
6860 | | libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element( |
6861 | 0 | int16_t value) { |
6862 | 0 | int32_t t = (int32_t)value * |
6863 | 0 | LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER + |
6864 | 0 | (LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_R >> 1U); |
6865 | 0 | int16_t quotient = |
6866 | 0 | (int16_t)(t >> |
6867 | 0 | (uint32_t) |
6868 | 0 | LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT); |
6869 | 0 | return value - quotient * LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
6870 | 0 | } |
6871 | | |
6872 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6873 | | libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce( |
6874 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
6875 | 0 | for (size_t i = (size_t)0U; |
6876 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
6877 | 0 | size_t i0 = i; |
6878 | 0 | v.elements[i0] = |
6879 | 0 | libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element( |
6880 | 0 | v.elements[i0]); |
6881 | 0 | } |
6882 | 0 | return v; |
6883 | 0 | } |
6884 | | |
6885 | | /** |
6886 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6887 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6888 | | */ |
6889 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6890 | | libcrux_ml_kem_vector_portable_barrett_reduce_0d( |
6891 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
6892 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(v); |
6893 | 0 | } |
6894 | | |
6895 | 0 | #define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U) |
6896 | | |
6897 | | #define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_R \ |
6898 | | ((int32_t)1 << (uint32_t) \ |
6899 | | LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT) |
6900 | | |
6901 | | /** |
6902 | | Signed Montgomery Reduction |
6903 | | |
6904 | | Given an input `value`, `montgomery_reduce` outputs a representative `o` |
6905 | | such that: |
6906 | | |
6907 | | - o ≡ value · MONTGOMERY_R^(-1) (mod FIELD_MODULUS) |
6908 | | - the absolute value of `o` is bound as follows: |
6909 | | |
6910 | | `|result| ≤ (|value| / MONTGOMERY_R) + (FIELD_MODULUS / 2) |
6911 | | |
6912 | | In particular, if `|value| ≤ FIELD_MODULUS * MONTGOMERY_R`, then `|o| < (3 · |
6913 | | FIELD_MODULUS) / 2`. |
6914 | | */ |
6915 | | static inline int16_t |
6916 | | libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element( |
6917 | 0 | int32_t value) { |
6918 | 0 | int32_t k = |
6919 | 0 | (int32_t)(int16_t)value * |
6920 | 0 | (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R; |
6921 | 0 | int32_t k_times_modulus = |
6922 | 0 | (int32_t)(int16_t)k * (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
6923 | 0 | int16_t c = |
6924 | 0 | (int16_t)(k_times_modulus >> |
6925 | 0 | (uint32_t) |
6926 | 0 | LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT); |
6927 | 0 | int16_t value_high = |
6928 | 0 | (int16_t)(value >> |
6929 | 0 | (uint32_t) |
6930 | 0 | LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT); |
6931 | 0 | return value_high - c; |
6932 | 0 | } |
6933 | | |
6934 | | /** |
6935 | | If `fe` is some field element 'x' of the Kyber field and `fer` is congruent to |
6936 | | `y · MONTGOMERY_R`, this procedure outputs a value that is congruent to |
6937 | | `x · y`, as follows: |
6938 | | |
6939 | | `fe · fer ≡ x · y · MONTGOMERY_R (mod FIELD_MODULUS)` |
6940 | | |
6941 | | `montgomery_reduce` takes the value `x · y · MONTGOMERY_R` and outputs a |
6942 | | representative `x · y · MONTGOMERY_R * MONTGOMERY_R^{-1} ≡ x · y (mod |
6943 | | FIELD_MODULUS)`. |
6944 | | */ |
6945 | | static KRML_MUSTINLINE int16_t |
6946 | | libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer( |
6947 | 0 | int16_t fe, int16_t fer) { |
6948 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element( |
6949 | 0 | (int32_t)fe * (int32_t)fer); |
6950 | 0 | } |
6951 | | |
6952 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6953 | | libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant( |
6954 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) { |
6955 | 0 | for (size_t i = (size_t)0U; |
6956 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
6957 | 0 | size_t i0 = i; |
6958 | 0 | v.elements[i0] = |
6959 | 0 | libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer( |
6960 | 0 | v.elements[i0], c); |
6961 | 0 | } |
6962 | 0 | return v; |
6963 | 0 | } |
6964 | | |
6965 | | /** |
6966 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
6967 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
6968 | | */ |
6969 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
6970 | | libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d( |
6971 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t r) { |
6972 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant( |
6973 | 0 | v, r); |
6974 | 0 | } |
6975 | | |
6976 | | /** |
6977 | | The `compress_*` functions implement the `Compress` function specified in the |
6978 | | NIST FIPS 203 standard (Page 18, Expression 4.5), which is defined as: |
6979 | | |
6980 | | ```plaintext |
6981 | | Compress_d: ℤq -> ℤ_{2ᵈ} |
6982 | | Compress_d(x) = ⌈(2ᵈ/q)·x⌋ |
6983 | | ``` |
6984 | | |
6985 | | Since `⌈x⌋ = ⌊x + 1/2⌋` we have: |
6986 | | |
6987 | | ```plaintext |
6988 | | Compress_d(x) = ⌊(2ᵈ/q)·x + 1/2⌋ |
6989 | | = ⌊(2^{d+1}·x + q) / 2q⌋ |
6990 | | ``` |
6991 | | |
6992 | | For further information about the function implementations, consult the |
6993 | | `implementation_notes.pdf` document in this directory. |
6994 | | |
6995 | | The NIST FIPS 203 standard can be found at |
6996 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
6997 | | */ |
6998 | | static inline uint8_t |
6999 | | libcrux_ml_kem_vector_portable_compress_compress_message_coefficient( |
7000 | 0 | uint16_t fe) { |
7001 | 0 | int16_t shifted = (int16_t)1664 - (int16_t)fe; |
7002 | 0 | int16_t mask = shifted >> 15U; |
7003 | 0 | int16_t shifted_to_positive = mask ^ shifted; |
7004 | 0 | int16_t shifted_positive_in_range = shifted_to_positive - (int16_t)832; |
7005 | 0 | return (uint8_t)(shifted_positive_in_range >> 15U & (int16_t)1); |
7006 | 0 | } |
7007 | | |
7008 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7009 | | libcrux_ml_kem_vector_portable_compress_compress_1( |
7010 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
7011 | 0 | for (size_t i = (size_t)0U; |
7012 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
7013 | 0 | size_t i0 = i; |
7014 | 0 | v.elements[i0] = (int16_t) |
7015 | 0 | libcrux_ml_kem_vector_portable_compress_compress_message_coefficient( |
7016 | 0 | (uint16_t)v.elements[i0]); |
7017 | 0 | } |
7018 | 0 | return v; |
7019 | 0 | } |
7020 | | |
7021 | | /** |
7022 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7023 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7024 | | */ |
7025 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7026 | | libcrux_ml_kem_vector_portable_compress_1_0d( |
7027 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
7028 | 0 | return libcrux_ml_kem_vector_portable_compress_compress_1(v); |
7029 | 0 | } |
7030 | | |
7031 | | static KRML_MUSTINLINE uint32_t |
7032 | | libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits( |
7033 | 0 | uint8_t n, uint32_t value) { |
7034 | 0 | return value & ((1U << (uint32_t)n) - 1U); |
7035 | 0 | } |
7036 | | |
7037 | | static inline int16_t |
7038 | | libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient( |
7039 | 0 | uint8_t coefficient_bits, uint16_t fe) { |
7040 | 0 | uint64_t compressed = (uint64_t)fe << (uint32_t)coefficient_bits; |
7041 | 0 | compressed = compressed + 1664ULL; |
7042 | 0 | compressed = compressed * 10321340ULL; |
7043 | 0 | compressed = compressed >> 35U; |
7044 | 0 | return (int16_t) |
7045 | 0 | libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits( |
7046 | 0 | coefficient_bits, (uint32_t)compressed); |
7047 | 0 | } |
7048 | | |
7049 | | static KRML_MUSTINLINE void libcrux_ml_kem_vector_portable_ntt_ntt_step( |
7050 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *v, int16_t zeta, |
7051 | 0 | size_t i, size_t j) { |
7052 | 0 | int16_t t = |
7053 | 0 | libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer( |
7054 | 0 | v->elements[j], zeta); |
7055 | 0 | v->elements[j] = v->elements[i] - t; |
7056 | 0 | v->elements[i] = v->elements[i] + t; |
7057 | 0 | } |
7058 | | |
7059 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7060 | | libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step( |
7061 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0, |
7062 | 0 | int16_t zeta1, int16_t zeta2, int16_t zeta3) { |
7063 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)0U, |
7064 | 0 | (size_t)2U); |
7065 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)1U, |
7066 | 0 | (size_t)3U); |
7067 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)4U, |
7068 | 0 | (size_t)6U); |
7069 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)5U, |
7070 | 0 | (size_t)7U); |
7071 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta2, (size_t)8U, |
7072 | 0 | (size_t)10U); |
7073 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta2, (size_t)9U, |
7074 | 0 | (size_t)11U); |
7075 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta3, (size_t)12U, |
7076 | 0 | (size_t)14U); |
7077 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta3, (size_t)13U, |
7078 | 0 | (size_t)15U); |
7079 | 0 | return v; |
7080 | 0 | } |
7081 | | |
7082 | | /** |
7083 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7084 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7085 | | */ |
7086 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7087 | | libcrux_ml_kem_vector_portable_ntt_layer_1_step_0d( |
7088 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0, |
7089 | 0 | int16_t zeta1, int16_t zeta2, int16_t zeta3) { |
7090 | 0 | return libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(a, zeta0, zeta1, |
7091 | 0 | zeta2, zeta3); |
7092 | 0 | } |
7093 | | |
7094 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7095 | | libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step( |
7096 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0, |
7097 | 0 | int16_t zeta1) { |
7098 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)0U, |
7099 | 0 | (size_t)4U); |
7100 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)1U, |
7101 | 0 | (size_t)5U); |
7102 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)2U, |
7103 | 0 | (size_t)6U); |
7104 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)3U, |
7105 | 0 | (size_t)7U); |
7106 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)8U, |
7107 | 0 | (size_t)12U); |
7108 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)9U, |
7109 | 0 | (size_t)13U); |
7110 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)10U, |
7111 | 0 | (size_t)14U); |
7112 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)11U, |
7113 | 0 | (size_t)15U); |
7114 | 0 | return v; |
7115 | 0 | } |
7116 | | |
7117 | | /** |
7118 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7119 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7120 | | */ |
7121 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7122 | | libcrux_ml_kem_vector_portable_ntt_layer_2_step_0d( |
7123 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0, |
7124 | 0 | int16_t zeta1) { |
7125 | 0 | return libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(a, zeta0, zeta1); |
7126 | 0 | } |
7127 | | |
7128 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7129 | | libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step( |
7130 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta) { |
7131 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)0U, (size_t)8U); |
7132 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)1U, (size_t)9U); |
7133 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)2U, |
7134 | 0 | (size_t)10U); |
7135 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)3U, |
7136 | 0 | (size_t)11U); |
7137 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)4U, |
7138 | 0 | (size_t)12U); |
7139 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)5U, |
7140 | 0 | (size_t)13U); |
7141 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)6U, |
7142 | 0 | (size_t)14U); |
7143 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)7U, |
7144 | 0 | (size_t)15U); |
7145 | 0 | return v; |
7146 | 0 | } |
7147 | | |
7148 | | /** |
7149 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7150 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7151 | | */ |
7152 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7153 | | libcrux_ml_kem_vector_portable_ntt_layer_3_step_0d( |
7154 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) { |
7155 | 0 | return libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(a, zeta); |
7156 | 0 | } |
7157 | | |
7158 | | static KRML_MUSTINLINE void libcrux_ml_kem_vector_portable_ntt_inv_ntt_step( |
7159 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *v, int16_t zeta, |
7160 | 0 | size_t i, size_t j) { |
7161 | 0 | int16_t a_minus_b = v->elements[j] - v->elements[i]; |
7162 | 0 | v->elements[i] = |
7163 | 0 | libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element( |
7164 | 0 | v->elements[i] + v->elements[j]); |
7165 | 0 | v->elements[j] = |
7166 | 0 | libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer( |
7167 | 0 | a_minus_b, zeta); |
7168 | 0 | } |
7169 | | |
7170 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7171 | | libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step( |
7172 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0, |
7173 | 0 | int16_t zeta1, int16_t zeta2, int16_t zeta3) { |
7174 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)0U, |
7175 | 0 | (size_t)2U); |
7176 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)1U, |
7177 | 0 | (size_t)3U); |
7178 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)4U, |
7179 | 0 | (size_t)6U); |
7180 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)5U, |
7181 | 0 | (size_t)7U); |
7182 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta2, (size_t)8U, |
7183 | 0 | (size_t)10U); |
7184 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta2, (size_t)9U, |
7185 | 0 | (size_t)11U); |
7186 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta3, (size_t)12U, |
7187 | 0 | (size_t)14U); |
7188 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta3, (size_t)13U, |
7189 | 0 | (size_t)15U); |
7190 | 0 | return v; |
7191 | 0 | } |
7192 | | |
7193 | | /** |
7194 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7195 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7196 | | */ |
7197 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7198 | | libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_0d( |
7199 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0, |
7200 | 0 | int16_t zeta1, int16_t zeta2, int16_t zeta3) { |
7201 | 0 | return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step( |
7202 | 0 | a, zeta0, zeta1, zeta2, zeta3); |
7203 | 0 | } |
7204 | | |
7205 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7206 | | libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step( |
7207 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta0, |
7208 | 0 | int16_t zeta1) { |
7209 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)0U, |
7210 | 0 | (size_t)4U); |
7211 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)1U, |
7212 | 0 | (size_t)5U); |
7213 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)2U, |
7214 | 0 | (size_t)6U); |
7215 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta0, (size_t)3U, |
7216 | 0 | (size_t)7U); |
7217 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)8U, |
7218 | 0 | (size_t)12U); |
7219 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)9U, |
7220 | 0 | (size_t)13U); |
7221 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)10U, |
7222 | 0 | (size_t)14U); |
7223 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta1, (size_t)11U, |
7224 | 0 | (size_t)15U); |
7225 | 0 | return v; |
7226 | 0 | } |
7227 | | |
7228 | | /** |
7229 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7230 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7231 | | */ |
7232 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7233 | | libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_0d( |
7234 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta0, |
7235 | 0 | int16_t zeta1) { |
7236 | 0 | return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step(a, zeta0, |
7237 | 0 | zeta1); |
7238 | 0 | } |
7239 | | |
7240 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7241 | | libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step( |
7242 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta) { |
7243 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)0U, |
7244 | 0 | (size_t)8U); |
7245 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)1U, |
7246 | 0 | (size_t)9U); |
7247 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)2U, |
7248 | 0 | (size_t)10U); |
7249 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)3U, |
7250 | 0 | (size_t)11U); |
7251 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)4U, |
7252 | 0 | (size_t)12U); |
7253 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)5U, |
7254 | 0 | (size_t)13U); |
7255 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)6U, |
7256 | 0 | (size_t)14U); |
7257 | 0 | libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&v, zeta, (size_t)7U, |
7258 | 0 | (size_t)15U); |
7259 | 0 | return v; |
7260 | 0 | } |
7261 | | |
7262 | | /** |
7263 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7264 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7265 | | */ |
7266 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7267 | | libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_0d( |
7268 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) { |
7269 | 0 | return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step(a, zeta); |
7270 | 0 | } |
7271 | | |
7272 | | /** |
7273 | | Compute the product of two Kyber binomials with respect to the |
7274 | | modulus `X² - zeta`. |
7275 | | |
7276 | | This function almost implements <strong>Algorithm 11</strong> of the |
7277 | | NIST FIPS 203 standard, which is reproduced below: |
7278 | | |
7279 | | ```plaintext |
7280 | | Input: a₀, a₁, b₀, b₁ ∈ ℤq. |
7281 | | Input: γ ∈ ℤq. |
7282 | | Output: c₀, c₁ ∈ ℤq. |
7283 | | |
7284 | | c₀ ← a₀·b₀ + a₁·b₁·γ |
7285 | | c₁ ← a₀·b₁ + a₁·b₀ |
7286 | | return c₀, c₁ |
7287 | | ``` |
7288 | | We say "almost" because the coefficients output by this function are in |
7289 | | the Montgomery domain (unlike in the specification). |
7290 | | |
7291 | | The NIST FIPS 203 standard can be found at |
7292 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
7293 | | */ |
7294 | | static KRML_MUSTINLINE void |
7295 | | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7296 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *a, |
7297 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *b, int16_t zeta, |
7298 | | size_t i, size_t j, |
7299 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector *out) { |
7300 | 0 | int16_t o0 = libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element( |
7301 | 0 | (int32_t)a->elements[i] * (int32_t)b->elements[i] + |
7302 | 0 | (int32_t) |
7303 | 0 | libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element( |
7304 | 0 | (int32_t)a->elements[j] * (int32_t)b->elements[j]) * |
7305 | 0 | (int32_t)zeta); |
7306 | 0 | int16_t o1 = |
7307 | 0 | libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element( |
7308 | 0 | (int32_t)a->elements[i] * (int32_t)b->elements[j] + |
7309 | 0 | (int32_t)a->elements[j] * (int32_t)b->elements[i]); |
7310 | 0 | out->elements[i] = o0; |
7311 | 0 | out->elements[j] = o1; |
7312 | 0 | } |
7313 | | |
7314 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7315 | | libcrux_ml_kem_vector_portable_ntt_ntt_multiply( |
7316 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *lhs, |
7317 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs, |
7318 | 0 | int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) { |
7319 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector out = |
7320 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
7321 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7322 | 0 | lhs, rhs, zeta0, (size_t)0U, (size_t)1U, &out); |
7323 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7324 | 0 | lhs, rhs, -zeta0, (size_t)2U, (size_t)3U, &out); |
7325 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7326 | 0 | lhs, rhs, zeta1, (size_t)4U, (size_t)5U, &out); |
7327 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7328 | 0 | lhs, rhs, -zeta1, (size_t)6U, (size_t)7U, &out); |
7329 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7330 | 0 | lhs, rhs, zeta2, (size_t)8U, (size_t)9U, &out); |
7331 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7332 | 0 | lhs, rhs, -zeta2, (size_t)10U, (size_t)11U, &out); |
7333 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7334 | 0 | lhs, rhs, zeta3, (size_t)12U, (size_t)13U, &out); |
7335 | 0 | libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials( |
7336 | 0 | lhs, rhs, -zeta3, (size_t)14U, (size_t)15U, &out); |
7337 | 0 | return out; |
7338 | 0 | } |
7339 | | |
7340 | | /** |
7341 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7342 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7343 | | */ |
7344 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7345 | | libcrux_ml_kem_vector_portable_ntt_multiply_0d( |
7346 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *lhs, |
7347 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs, |
7348 | 0 | int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) { |
7349 | 0 | return libcrux_ml_kem_vector_portable_ntt_ntt_multiply(lhs, rhs, zeta0, zeta1, |
7350 | 0 | zeta2, zeta3); |
7351 | 0 | } |
7352 | | |
7353 | | static KRML_MUSTINLINE void |
7354 | | libcrux_ml_kem_vector_portable_serialize_serialize_1( |
7355 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, |
7356 | 0 | uint8_t ret[2U]) { |
7357 | 0 | uint8_t result[2U] = {0U}; |
7358 | 0 | for (size_t i = (size_t)0U; i < (size_t)8U; i++) { |
7359 | 0 | size_t i0 = i; |
7360 | 0 | size_t uu____0 = (size_t)0U; |
7361 | 0 | result[uu____0] = (uint32_t)result[uu____0] | |
7362 | 0 | (uint32_t)(uint8_t)v.elements[i0] << (uint32_t)i0; |
7363 | 0 | } |
7364 | 0 | for (size_t i = (size_t)8U; i < (size_t)16U; i++) { |
7365 | 0 | size_t i0 = i; |
7366 | 0 | size_t uu____1 = (size_t)1U; |
7367 | 0 | result[uu____1] = |
7368 | 0 | (uint32_t)result[uu____1] | (uint32_t)(uint8_t)v.elements[i0] |
7369 | 0 | << (uint32_t)(i0 - (size_t)8U); |
7370 | 0 | } |
7371 | 0 | memcpy(ret, result, (size_t)2U * sizeof(uint8_t)); |
7372 | 0 | } |
7373 | | |
7374 | | /** |
7375 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7376 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7377 | | */ |
7378 | | static inline void libcrux_ml_kem_vector_portable_serialize_1_0d( |
7379 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
7380 | 0 | uint8_t ret[2U]) { |
7381 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_1(a, ret); |
7382 | 0 | } |
7383 | | |
7384 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7385 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_1(Eurydice_slice v) { |
7386 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector result = |
7387 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
7388 | 0 | for (size_t i = (size_t)0U; i < (size_t)8U; i++) { |
7389 | 0 | size_t i0 = i; |
7390 | 0 | result.elements[i0] = (int16_t)((uint32_t)Eurydice_slice_index( |
7391 | 0 | v, (size_t)0U, uint8_t, uint8_t *) >> |
7392 | 0 | (uint32_t)i0 & |
7393 | 0 | 1U); |
7394 | 0 | } |
7395 | 0 | for (size_t i = (size_t)8U; |
7396 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
7397 | 0 | size_t i0 = i; |
7398 | 0 | result.elements[i0] = (int16_t)((uint32_t)Eurydice_slice_index( |
7399 | 0 | v, (size_t)1U, uint8_t, uint8_t *) >> |
7400 | 0 | (uint32_t)(i0 - (size_t)8U) & |
7401 | 0 | 1U); |
7402 | 0 | } |
7403 | 0 | return result; |
7404 | 0 | } |
7405 | | |
7406 | | /** |
7407 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7408 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7409 | | */ |
7410 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7411 | 0 | libcrux_ml_kem_vector_portable_deserialize_1_0d(Eurydice_slice a) { |
7412 | 0 | return libcrux_ml_kem_vector_portable_serialize_deserialize_1(a); |
7413 | 0 | } |
7414 | | |
7415 | | typedef struct uint8_t_x4_s { |
7416 | | uint8_t fst; |
7417 | | uint8_t snd; |
7418 | | uint8_t thd; |
7419 | | uint8_t f3; |
7420 | | } uint8_t_x4; |
7421 | | |
7422 | | static KRML_MUSTINLINE uint8_t_x4 |
7423 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_4_int(Eurydice_slice v) { |
7424 | 0 | uint8_t result0 = |
7425 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) |
7426 | 0 | << 4U | |
7427 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)0U, int16_t, |
7428 | 0 | int16_t *); |
7429 | 0 | uint8_t result1 = |
7430 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) |
7431 | 0 | << 4U | |
7432 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)2U, int16_t, |
7433 | 0 | int16_t *); |
7434 | 0 | uint8_t result2 = |
7435 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *) |
7436 | 0 | << 4U | |
7437 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)4U, int16_t, |
7438 | 0 | int16_t *); |
7439 | 0 | uint8_t result3 = |
7440 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *) |
7441 | 0 | << 4U | |
7442 | 0 | (uint32_t)(uint8_t)Eurydice_slice_index(v, (size_t)6U, int16_t, |
7443 | 0 | int16_t *); |
7444 | 0 | return (CLITERAL(uint8_t_x4){ |
7445 | 0 | .fst = result0, .snd = result1, .thd = result2, .f3 = result3}); |
7446 | 0 | } |
7447 | | |
7448 | | static KRML_MUSTINLINE void |
7449 | | libcrux_ml_kem_vector_portable_serialize_serialize_4( |
7450 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, |
7451 | 0 | uint8_t ret[8U]) { |
7452 | 0 | uint8_t_x4 result0_3 = |
7453 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_4_int( |
7454 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)8U, |
7455 | 0 | int16_t)); |
7456 | 0 | uint8_t_x4 result4_7 = |
7457 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_4_int( |
7458 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)16U, |
7459 | 0 | int16_t)); |
7460 | 0 | uint8_t result[8U] = {0U}; |
7461 | 0 | result[0U] = result0_3.fst; |
7462 | 0 | result[1U] = result0_3.snd; |
7463 | 0 | result[2U] = result0_3.thd; |
7464 | 0 | result[3U] = result0_3.f3; |
7465 | 0 | result[4U] = result4_7.fst; |
7466 | 0 | result[5U] = result4_7.snd; |
7467 | 0 | result[6U] = result4_7.thd; |
7468 | 0 | result[7U] = result4_7.f3; |
7469 | 0 | memcpy(ret, result, (size_t)8U * sizeof(uint8_t)); |
7470 | 0 | } |
7471 | | |
7472 | | /** |
7473 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7474 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7475 | | */ |
7476 | | static inline void libcrux_ml_kem_vector_portable_serialize_4_0d( |
7477 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
7478 | 0 | uint8_t ret[8U]) { |
7479 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_4(a, ret); |
7480 | 0 | } |
7481 | | |
7482 | | static KRML_MUSTINLINE int16_t_x8 |
7483 | | libcrux_ml_kem_vector_portable_serialize_deserialize_4_int( |
7484 | 0 | Eurydice_slice bytes) { |
7485 | 0 | int16_t v0 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)0U, |
7486 | 0 | uint8_t, uint8_t *) & |
7487 | 0 | 15U); |
7488 | 0 | int16_t v1 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)0U, |
7489 | 0 | uint8_t, uint8_t *) >> |
7490 | 0 | 4U & |
7491 | 0 | 15U); |
7492 | 0 | int16_t v2 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)1U, |
7493 | 0 | uint8_t, uint8_t *) & |
7494 | 0 | 15U); |
7495 | 0 | int16_t v3 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)1U, |
7496 | 0 | uint8_t, uint8_t *) >> |
7497 | 0 | 4U & |
7498 | 0 | 15U); |
7499 | 0 | int16_t v4 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)2U, |
7500 | 0 | uint8_t, uint8_t *) & |
7501 | 0 | 15U); |
7502 | 0 | int16_t v5 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)2U, |
7503 | 0 | uint8_t, uint8_t *) >> |
7504 | 0 | 4U & |
7505 | 0 | 15U); |
7506 | 0 | int16_t v6 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)3U, |
7507 | 0 | uint8_t, uint8_t *) & |
7508 | 0 | 15U); |
7509 | 0 | int16_t v7 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)3U, |
7510 | 0 | uint8_t, uint8_t *) >> |
7511 | 0 | 4U & |
7512 | 0 | 15U); |
7513 | 0 | return (CLITERAL(int16_t_x8){.fst = v0, |
7514 | 0 | .snd = v1, |
7515 | 0 | .thd = v2, |
7516 | 0 | .f3 = v3, |
7517 | 0 | .f4 = v4, |
7518 | 0 | .f5 = v5, |
7519 | 0 | .f6 = v6, |
7520 | 0 | .f7 = v7}); |
7521 | 0 | } |
7522 | | |
7523 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7524 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_4(Eurydice_slice bytes) { |
7525 | 0 | int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_4_int( |
7526 | 0 | Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)4U, uint8_t)); |
7527 | 0 | int16_t_x8 v8_15 = libcrux_ml_kem_vector_portable_serialize_deserialize_4_int( |
7528 | 0 | Eurydice_slice_subslice2(bytes, (size_t)4U, (size_t)8U, uint8_t)); |
7529 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v = |
7530 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
7531 | 0 | v.elements[0U] = v0_7.fst; |
7532 | 0 | v.elements[1U] = v0_7.snd; |
7533 | 0 | v.elements[2U] = v0_7.thd; |
7534 | 0 | v.elements[3U] = v0_7.f3; |
7535 | 0 | v.elements[4U] = v0_7.f4; |
7536 | 0 | v.elements[5U] = v0_7.f5; |
7537 | 0 | v.elements[6U] = v0_7.f6; |
7538 | 0 | v.elements[7U] = v0_7.f7; |
7539 | 0 | v.elements[8U] = v8_15.fst; |
7540 | 0 | v.elements[9U] = v8_15.snd; |
7541 | 0 | v.elements[10U] = v8_15.thd; |
7542 | 0 | v.elements[11U] = v8_15.f3; |
7543 | 0 | v.elements[12U] = v8_15.f4; |
7544 | 0 | v.elements[13U] = v8_15.f5; |
7545 | 0 | v.elements[14U] = v8_15.f6; |
7546 | 0 | v.elements[15U] = v8_15.f7; |
7547 | 0 | return v; |
7548 | 0 | } |
7549 | | |
7550 | | /** |
7551 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7552 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7553 | | */ |
7554 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7555 | 0 | libcrux_ml_kem_vector_portable_deserialize_4_0d(Eurydice_slice a) { |
7556 | 0 | return libcrux_ml_kem_vector_portable_serialize_deserialize_4(a); |
7557 | 0 | } |
7558 | | |
7559 | | typedef struct uint8_t_x5_s { |
7560 | | uint8_t fst; |
7561 | | uint8_t snd; |
7562 | | uint8_t thd; |
7563 | | uint8_t f3; |
7564 | | uint8_t f4; |
7565 | | } uint8_t_x5; |
7566 | | |
7567 | | static KRML_MUSTINLINE uint8_t_x5 |
7568 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_5_int(Eurydice_slice v) { |
7569 | 0 | uint8_t r0 = |
7570 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) | |
7571 | 0 | Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) << 5U); |
7572 | 0 | uint8_t r1 = |
7573 | 0 | (uint8_t)((Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 3U | |
7574 | 0 | Eurydice_slice_index(v, (size_t)2U, int16_t, int16_t *) |
7575 | 0 | << 2U) | |
7576 | 0 | Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) << 7U); |
7577 | 0 | uint8_t r2 = |
7578 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) >> 1U | |
7579 | 0 | Eurydice_slice_index(v, (size_t)4U, int16_t, int16_t *) << 4U); |
7580 | 0 | uint8_t r3 = |
7581 | 0 | (uint8_t)((Eurydice_slice_index(v, (size_t)4U, int16_t, int16_t *) >> 4U | |
7582 | 0 | Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *) |
7583 | 0 | << 1U) | |
7584 | 0 | Eurydice_slice_index(v, (size_t)6U, int16_t, int16_t *) << 6U); |
7585 | 0 | uint8_t r4 = |
7586 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)6U, int16_t, int16_t *) >> 2U | |
7587 | 0 | Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *) << 3U); |
7588 | 0 | return (CLITERAL(uint8_t_x5){ |
7589 | 0 | .fst = r0, .snd = r1, .thd = r2, .f3 = r3, .f4 = r4}); |
7590 | 0 | } |
7591 | | |
7592 | | static KRML_MUSTINLINE void |
7593 | | libcrux_ml_kem_vector_portable_serialize_serialize_5( |
7594 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, |
7595 | 0 | uint8_t ret[10U]) { |
7596 | 0 | uint8_t_x5 r0_4 = libcrux_ml_kem_vector_portable_serialize_serialize_5_int( |
7597 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)8U, int16_t)); |
7598 | 0 | uint8_t_x5 r5_9 = libcrux_ml_kem_vector_portable_serialize_serialize_5_int( |
7599 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)16U, |
7600 | 0 | int16_t)); |
7601 | 0 | uint8_t result[10U] = {0U}; |
7602 | 0 | result[0U] = r0_4.fst; |
7603 | 0 | result[1U] = r0_4.snd; |
7604 | 0 | result[2U] = r0_4.thd; |
7605 | 0 | result[3U] = r0_4.f3; |
7606 | 0 | result[4U] = r0_4.f4; |
7607 | 0 | result[5U] = r5_9.fst; |
7608 | 0 | result[6U] = r5_9.snd; |
7609 | 0 | result[7U] = r5_9.thd; |
7610 | 0 | result[8U] = r5_9.f3; |
7611 | 0 | result[9U] = r5_9.f4; |
7612 | 0 | memcpy(ret, result, (size_t)10U * sizeof(uint8_t)); |
7613 | 0 | } |
7614 | | |
7615 | | /** |
7616 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7617 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7618 | | */ |
7619 | | static inline void libcrux_ml_kem_vector_portable_serialize_5_0d( |
7620 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
7621 | 0 | uint8_t ret[10U]) { |
7622 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_5(a, ret); |
7623 | 0 | } |
7624 | | |
7625 | | static KRML_MUSTINLINE int16_t_x8 |
7626 | | libcrux_ml_kem_vector_portable_serialize_deserialize_5_int( |
7627 | 0 | Eurydice_slice bytes) { |
7628 | 0 | int16_t v0 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)0U, |
7629 | 0 | uint8_t, uint8_t *) & |
7630 | 0 | 31U); |
7631 | 0 | int16_t v1 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)1U, |
7632 | 0 | uint8_t, uint8_t *) & |
7633 | 0 | 3U) << 3U | |
7634 | 0 | (uint32_t)Eurydice_slice_index(bytes, (size_t)0U, |
7635 | 0 | uint8_t, uint8_t *) >> |
7636 | 0 | 5U); |
7637 | 0 | int16_t v2 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)1U, |
7638 | 0 | uint8_t, uint8_t *) >> |
7639 | 0 | 2U & |
7640 | 0 | 31U); |
7641 | 0 | int16_t v3 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)2U, |
7642 | 0 | uint8_t, uint8_t *) & |
7643 | 0 | 15U) |
7644 | 0 | << 1U | |
7645 | 0 | (uint32_t)Eurydice_slice_index(bytes, (size_t)1U, |
7646 | 0 | uint8_t, uint8_t *) >> |
7647 | 0 | 7U); |
7648 | 0 | int16_t v4 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)3U, |
7649 | 0 | uint8_t, uint8_t *) & |
7650 | 0 | 1U) << 4U | |
7651 | 0 | (uint32_t)Eurydice_slice_index(bytes, (size_t)2U, |
7652 | 0 | uint8_t, uint8_t *) >> |
7653 | 0 | 4U); |
7654 | 0 | int16_t v5 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)3U, |
7655 | 0 | uint8_t, uint8_t *) >> |
7656 | 0 | 1U & |
7657 | 0 | 31U); |
7658 | 0 | int16_t v6 = (int16_t)(((uint32_t)Eurydice_slice_index(bytes, (size_t)4U, |
7659 | 0 | uint8_t, uint8_t *) & |
7660 | 0 | 7U) << 2U | |
7661 | 0 | (uint32_t)Eurydice_slice_index(bytes, (size_t)3U, |
7662 | 0 | uint8_t, uint8_t *) >> |
7663 | 0 | 6U); |
7664 | 0 | int16_t v7 = (int16_t)((uint32_t)Eurydice_slice_index(bytes, (size_t)4U, |
7665 | 0 | uint8_t, uint8_t *) >> |
7666 | 0 | 3U); |
7667 | 0 | return (CLITERAL(int16_t_x8){.fst = v0, |
7668 | 0 | .snd = v1, |
7669 | 0 | .thd = v2, |
7670 | 0 | .f3 = v3, |
7671 | 0 | .f4 = v4, |
7672 | 0 | .f5 = v5, |
7673 | 0 | .f6 = v6, |
7674 | 0 | .f7 = v7}); |
7675 | 0 | } |
7676 | | |
7677 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7678 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_5(Eurydice_slice bytes) { |
7679 | 0 | int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_5_int( |
7680 | 0 | Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)5U, uint8_t)); |
7681 | 0 | int16_t_x8 v8_15 = libcrux_ml_kem_vector_portable_serialize_deserialize_5_int( |
7682 | 0 | Eurydice_slice_subslice2(bytes, (size_t)5U, (size_t)10U, uint8_t)); |
7683 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v = |
7684 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
7685 | 0 | v.elements[0U] = v0_7.fst; |
7686 | 0 | v.elements[1U] = v0_7.snd; |
7687 | 0 | v.elements[2U] = v0_7.thd; |
7688 | 0 | v.elements[3U] = v0_7.f3; |
7689 | 0 | v.elements[4U] = v0_7.f4; |
7690 | 0 | v.elements[5U] = v0_7.f5; |
7691 | 0 | v.elements[6U] = v0_7.f6; |
7692 | 0 | v.elements[7U] = v0_7.f7; |
7693 | 0 | v.elements[8U] = v8_15.fst; |
7694 | 0 | v.elements[9U] = v8_15.snd; |
7695 | 0 | v.elements[10U] = v8_15.thd; |
7696 | 0 | v.elements[11U] = v8_15.f3; |
7697 | 0 | v.elements[12U] = v8_15.f4; |
7698 | 0 | v.elements[13U] = v8_15.f5; |
7699 | 0 | v.elements[14U] = v8_15.f6; |
7700 | 0 | v.elements[15U] = v8_15.f7; |
7701 | 0 | return v; |
7702 | 0 | } |
7703 | | |
7704 | | /** |
7705 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7706 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7707 | | */ |
7708 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7709 | 0 | libcrux_ml_kem_vector_portable_deserialize_5_0d(Eurydice_slice a) { |
7710 | 0 | return libcrux_ml_kem_vector_portable_serialize_deserialize_5(a); |
7711 | 0 | } |
7712 | | |
7713 | | static KRML_MUSTINLINE uint8_t_x5 |
7714 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_slice v) { |
7715 | 0 | uint8_t r0 = |
7716 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) & |
7717 | 0 | (int16_t)255); |
7718 | 0 | uint8_t r1 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, |
7719 | 0 | int16_t *) & |
7720 | 0 | (int16_t)63) |
7721 | 0 | << 2U | |
7722 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, |
7723 | 0 | int16_t *) >> |
7724 | 0 | 8U & |
7725 | 0 | (int16_t)3); |
7726 | 0 | uint8_t r2 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t, |
7727 | 0 | int16_t *) & |
7728 | 0 | (int16_t)15) |
7729 | 0 | << 4U | |
7730 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, |
7731 | 0 | int16_t *) >> |
7732 | 0 | 6U & |
7733 | 0 | (int16_t)15); |
7734 | 0 | uint8_t r3 = (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, |
7735 | 0 | int16_t *) & |
7736 | 0 | (int16_t)3) |
7737 | 0 | << 6U | |
7738 | 0 | (uint32_t)(uint8_t)(Eurydice_slice_index(v, (size_t)2U, int16_t, |
7739 | 0 | int16_t *) >> |
7740 | 0 | 4U & |
7741 | 0 | (int16_t)63); |
7742 | 0 | uint8_t r4 = |
7743 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) >> 2U & |
7744 | 0 | (int16_t)255); |
7745 | 0 | return (CLITERAL(uint8_t_x5){ |
7746 | 0 | .fst = r0, .snd = r1, .thd = r2, .f3 = r3, .f4 = r4}); |
7747 | 0 | } |
7748 | | |
7749 | | static KRML_MUSTINLINE void |
7750 | | libcrux_ml_kem_vector_portable_serialize_serialize_10( |
7751 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, |
7752 | 0 | uint8_t ret[20U]) { |
7753 | 0 | uint8_t_x5 r0_4 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int( |
7754 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)4U, int16_t)); |
7755 | 0 | uint8_t_x5 r5_9 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int( |
7756 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)4U, (size_t)8U, int16_t)); |
7757 | 0 | uint8_t_x5 r10_14 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int( |
7758 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)12U, |
7759 | 0 | int16_t)); |
7760 | 0 | uint8_t_x5 r15_19 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int( |
7761 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)12U, (size_t)16U, |
7762 | 0 | int16_t)); |
7763 | 0 | uint8_t result[20U] = {0U}; |
7764 | 0 | result[0U] = r0_4.fst; |
7765 | 0 | result[1U] = r0_4.snd; |
7766 | 0 | result[2U] = r0_4.thd; |
7767 | 0 | result[3U] = r0_4.f3; |
7768 | 0 | result[4U] = r0_4.f4; |
7769 | 0 | result[5U] = r5_9.fst; |
7770 | 0 | result[6U] = r5_9.snd; |
7771 | 0 | result[7U] = r5_9.thd; |
7772 | 0 | result[8U] = r5_9.f3; |
7773 | 0 | result[9U] = r5_9.f4; |
7774 | 0 | result[10U] = r10_14.fst; |
7775 | 0 | result[11U] = r10_14.snd; |
7776 | 0 | result[12U] = r10_14.thd; |
7777 | 0 | result[13U] = r10_14.f3; |
7778 | 0 | result[14U] = r10_14.f4; |
7779 | 0 | result[15U] = r15_19.fst; |
7780 | 0 | result[16U] = r15_19.snd; |
7781 | 0 | result[17U] = r15_19.thd; |
7782 | 0 | result[18U] = r15_19.f3; |
7783 | 0 | result[19U] = r15_19.f4; |
7784 | 0 | memcpy(ret, result, (size_t)20U * sizeof(uint8_t)); |
7785 | 0 | } |
7786 | | |
7787 | | /** |
7788 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7789 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7790 | | */ |
7791 | | static inline void libcrux_ml_kem_vector_portable_serialize_10_0d( |
7792 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
7793 | 0 | uint8_t ret[20U]) { |
7794 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_10(a, ret); |
7795 | 0 | } |
7796 | | |
7797 | | static KRML_MUSTINLINE int16_t_x8 |
7798 | | libcrux_ml_kem_vector_portable_serialize_deserialize_10_int( |
7799 | 0 | Eurydice_slice bytes) { |
7800 | 0 | int16_t r0 = |
7801 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) & |
7802 | 0 | (int16_t)3) |
7803 | 0 | << 8U | |
7804 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *) & |
7805 | 0 | (int16_t)255); |
7806 | 0 | int16_t r1 = |
7807 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) & |
7808 | 0 | (int16_t)15) |
7809 | 0 | << 6U | |
7810 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) >> |
7811 | 0 | 2U; |
7812 | 0 | int16_t r2 = |
7813 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) & |
7814 | 0 | (int16_t)63) |
7815 | 0 | << 4U | |
7816 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) >> |
7817 | 0 | 4U; |
7818 | 0 | int16_t r3 = |
7819 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *) |
7820 | 0 | << 2U | |
7821 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) >> |
7822 | 0 | 6U; |
7823 | 0 | int16_t r4 = |
7824 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) & |
7825 | 0 | (int16_t)3) |
7826 | 0 | << 8U | |
7827 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *) & |
7828 | 0 | (int16_t)255); |
7829 | 0 | int16_t r5 = |
7830 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *) & |
7831 | 0 | (int16_t)15) |
7832 | 0 | << 6U | |
7833 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *) >> |
7834 | 0 | 2U; |
7835 | 0 | int16_t r6 = |
7836 | 0 | ((int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) & |
7837 | 0 | (int16_t)63) |
7838 | 0 | << 4U | |
7839 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *) >> |
7840 | 0 | 4U; |
7841 | 0 | int16_t r7 = |
7842 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *) |
7843 | 0 | << 2U | |
7844 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *) >> |
7845 | 0 | 6U; |
7846 | 0 | return (CLITERAL(int16_t_x8){.fst = r0, |
7847 | 0 | .snd = r1, |
7848 | 0 | .thd = r2, |
7849 | 0 | .f3 = r3, |
7850 | 0 | .f4 = r4, |
7851 | 0 | .f5 = r5, |
7852 | 0 | .f6 = r6, |
7853 | 0 | .f7 = r7}); |
7854 | 0 | } |
7855 | | |
7856 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7857 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_10(Eurydice_slice bytes) { |
7858 | 0 | int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_10_int( |
7859 | 0 | Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)10U, uint8_t)); |
7860 | 0 | int16_t_x8 v8_15 = |
7861 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_10_int( |
7862 | 0 | Eurydice_slice_subslice2(bytes, (size_t)10U, (size_t)20U, uint8_t)); |
7863 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v = |
7864 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
7865 | 0 | v.elements[0U] = v0_7.fst; |
7866 | 0 | v.elements[1U] = v0_7.snd; |
7867 | 0 | v.elements[2U] = v0_7.thd; |
7868 | 0 | v.elements[3U] = v0_7.f3; |
7869 | 0 | v.elements[4U] = v0_7.f4; |
7870 | 0 | v.elements[5U] = v0_7.f5; |
7871 | 0 | v.elements[6U] = v0_7.f6; |
7872 | 0 | v.elements[7U] = v0_7.f7; |
7873 | 0 | v.elements[8U] = v8_15.fst; |
7874 | 0 | v.elements[9U] = v8_15.snd; |
7875 | 0 | v.elements[10U] = v8_15.thd; |
7876 | 0 | v.elements[11U] = v8_15.f3; |
7877 | 0 | v.elements[12U] = v8_15.f4; |
7878 | 0 | v.elements[13U] = v8_15.f5; |
7879 | 0 | v.elements[14U] = v8_15.f6; |
7880 | 0 | v.elements[15U] = v8_15.f7; |
7881 | 0 | return v; |
7882 | 0 | } |
7883 | | |
7884 | | /** |
7885 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7886 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7887 | | */ |
7888 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7889 | 0 | libcrux_ml_kem_vector_portable_deserialize_10_0d(Eurydice_slice a) { |
7890 | 0 | return libcrux_ml_kem_vector_portable_serialize_deserialize_10(a); |
7891 | 0 | } |
7892 | | |
7893 | | typedef struct uint8_t_x3_s { |
7894 | | uint8_t fst; |
7895 | | uint8_t snd; |
7896 | | uint8_t thd; |
7897 | | } uint8_t_x3; |
7898 | | |
7899 | | static KRML_MUSTINLINE uint8_t_x3 |
7900 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_slice v) { |
7901 | 0 | uint8_t r0 = |
7902 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) & |
7903 | 0 | (int16_t)255); |
7904 | 0 | uint8_t r1 = |
7905 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) >> 8U | |
7906 | 0 | (Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) & |
7907 | 0 | (int16_t)15) |
7908 | 0 | << 4U); |
7909 | 0 | uint8_t r2 = |
7910 | 0 | (uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 4U & |
7911 | 0 | (int16_t)255); |
7912 | 0 | return (CLITERAL(uint8_t_x3){.fst = r0, .snd = r1, .thd = r2}); |
7913 | 0 | } |
7914 | | |
7915 | | static KRML_MUSTINLINE void |
7916 | | libcrux_ml_kem_vector_portable_serialize_serialize_12( |
7917 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, |
7918 | 0 | uint8_t ret[24U]) { |
7919 | 0 | uint8_t_x3 r0_2 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7920 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)2U, int16_t)); |
7921 | 0 | uint8_t_x3 r3_5 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7922 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)2U, (size_t)4U, int16_t)); |
7923 | 0 | uint8_t_x3 r6_8 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7924 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)4U, (size_t)6U, int16_t)); |
7925 | 0 | uint8_t_x3 r9_11 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7926 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)6U, (size_t)8U, int16_t)); |
7927 | 0 | uint8_t_x3 r12_14 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7928 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)10U, |
7929 | 0 | int16_t)); |
7930 | 0 | uint8_t_x3 r15_17 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7931 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)10U, (size_t)12U, |
7932 | 0 | int16_t)); |
7933 | 0 | uint8_t_x3 r18_20 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7934 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)12U, (size_t)14U, |
7935 | 0 | int16_t)); |
7936 | 0 | uint8_t_x3 r21_23 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int( |
7937 | 0 | Eurydice_array_to_subslice2(v.elements, (size_t)14U, (size_t)16U, |
7938 | 0 | int16_t)); |
7939 | 0 | uint8_t result[24U] = {0U}; |
7940 | 0 | result[0U] = r0_2.fst; |
7941 | 0 | result[1U] = r0_2.snd; |
7942 | 0 | result[2U] = r0_2.thd; |
7943 | 0 | result[3U] = r3_5.fst; |
7944 | 0 | result[4U] = r3_5.snd; |
7945 | 0 | result[5U] = r3_5.thd; |
7946 | 0 | result[6U] = r6_8.fst; |
7947 | 0 | result[7U] = r6_8.snd; |
7948 | 0 | result[8U] = r6_8.thd; |
7949 | 0 | result[9U] = r9_11.fst; |
7950 | 0 | result[10U] = r9_11.snd; |
7951 | 0 | result[11U] = r9_11.thd; |
7952 | 0 | result[12U] = r12_14.fst; |
7953 | 0 | result[13U] = r12_14.snd; |
7954 | 0 | result[14U] = r12_14.thd; |
7955 | 0 | result[15U] = r15_17.fst; |
7956 | 0 | result[16U] = r15_17.snd; |
7957 | 0 | result[17U] = r15_17.thd; |
7958 | 0 | result[18U] = r18_20.fst; |
7959 | 0 | result[19U] = r18_20.snd; |
7960 | 0 | result[20U] = r18_20.thd; |
7961 | 0 | result[21U] = r21_23.fst; |
7962 | 0 | result[22U] = r21_23.snd; |
7963 | 0 | result[23U] = r21_23.thd; |
7964 | 0 | memcpy(ret, result, (size_t)24U * sizeof(uint8_t)); |
7965 | 0 | } |
7966 | | |
7967 | | /** |
7968 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
7969 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
7970 | | */ |
7971 | | static inline void libcrux_ml_kem_vector_portable_serialize_12_0d( |
7972 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
7973 | 0 | uint8_t ret[24U]) { |
7974 | 0 | libcrux_ml_kem_vector_portable_serialize_serialize_12(a, ret); |
7975 | 0 | } |
7976 | | |
7977 | | typedef struct int16_t_x2_s { |
7978 | | int16_t fst; |
7979 | | int16_t snd; |
7980 | | } int16_t_x2; |
7981 | | |
7982 | | static KRML_MUSTINLINE int16_t_x2 |
7983 | | libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
7984 | 0 | Eurydice_slice bytes) { |
7985 | 0 | int16_t byte0 = |
7986 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *); |
7987 | 0 | int16_t byte1 = |
7988 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *); |
7989 | 0 | int16_t byte2 = |
7990 | 0 | (int16_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *); |
7991 | 0 | int16_t r0 = (byte1 & (int16_t)15) << 8U | (byte0 & (int16_t)255); |
7992 | 0 | int16_t r1 = byte2 << 4U | (byte1 >> 4U & (int16_t)15); |
7993 | 0 | return (CLITERAL(int16_t_x2){.fst = r0, .snd = r1}); |
7994 | 0 | } |
7995 | | |
7996 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
7997 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_12(Eurydice_slice bytes) { |
7998 | 0 | int16_t_x2 v0_1 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
7999 | 0 | Eurydice_slice_subslice2(bytes, (size_t)0U, (size_t)3U, uint8_t)); |
8000 | 0 | int16_t_x2 v2_3 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8001 | 0 | Eurydice_slice_subslice2(bytes, (size_t)3U, (size_t)6U, uint8_t)); |
8002 | 0 | int16_t_x2 v4_5 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8003 | 0 | Eurydice_slice_subslice2(bytes, (size_t)6U, (size_t)9U, uint8_t)); |
8004 | 0 | int16_t_x2 v6_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8005 | 0 | Eurydice_slice_subslice2(bytes, (size_t)9U, (size_t)12U, uint8_t)); |
8006 | 0 | int16_t_x2 v8_9 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8007 | 0 | Eurydice_slice_subslice2(bytes, (size_t)12U, (size_t)15U, uint8_t)); |
8008 | 0 | int16_t_x2 v10_11 = |
8009 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8010 | 0 | Eurydice_slice_subslice2(bytes, (size_t)15U, (size_t)18U, uint8_t)); |
8011 | 0 | int16_t_x2 v12_13 = |
8012 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8013 | 0 | Eurydice_slice_subslice2(bytes, (size_t)18U, (size_t)21U, uint8_t)); |
8014 | 0 | int16_t_x2 v14_15 = |
8015 | 0 | libcrux_ml_kem_vector_portable_serialize_deserialize_12_int( |
8016 | 0 | Eurydice_slice_subslice2(bytes, (size_t)21U, (size_t)24U, uint8_t)); |
8017 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector re = |
8018 | 0 | libcrux_ml_kem_vector_portable_vector_type_zero(); |
8019 | 0 | re.elements[0U] = v0_1.fst; |
8020 | 0 | re.elements[1U] = v0_1.snd; |
8021 | 0 | re.elements[2U] = v2_3.fst; |
8022 | 0 | re.elements[3U] = v2_3.snd; |
8023 | 0 | re.elements[4U] = v4_5.fst; |
8024 | 0 | re.elements[5U] = v4_5.snd; |
8025 | 0 | re.elements[6U] = v6_7.fst; |
8026 | 0 | re.elements[7U] = v6_7.snd; |
8027 | 0 | re.elements[8U] = v8_9.fst; |
8028 | 0 | re.elements[9U] = v8_9.snd; |
8029 | 0 | re.elements[10U] = v10_11.fst; |
8030 | 0 | re.elements[11U] = v10_11.snd; |
8031 | 0 | re.elements[12U] = v12_13.fst; |
8032 | 0 | re.elements[13U] = v12_13.snd; |
8033 | 0 | re.elements[14U] = v14_15.fst; |
8034 | 0 | re.elements[15U] = v14_15.snd; |
8035 | 0 | return re; |
8036 | 0 | } |
8037 | | |
8038 | | /** |
8039 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
8040 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
8041 | | */ |
8042 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8043 | 0 | libcrux_ml_kem_vector_portable_deserialize_12_0d(Eurydice_slice a) { |
8044 | 0 | return libcrux_ml_kem_vector_portable_serialize_deserialize_12(a); |
8045 | 0 | } |
8046 | | |
8047 | | static KRML_MUSTINLINE size_t |
8048 | | libcrux_ml_kem_vector_portable_sampling_rej_sample(Eurydice_slice a, |
8049 | 0 | Eurydice_slice result) { |
8050 | 0 | size_t sampled = (size_t)0U; |
8051 | 0 | for (size_t i = (size_t)0U; i < Eurydice_slice_len(a, uint8_t) / (size_t)3U; |
8052 | 0 | i++) { |
8053 | 0 | size_t i0 = i; |
8054 | 0 | int16_t b1 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)0U, |
8055 | 0 | uint8_t, uint8_t *); |
8056 | 0 | int16_t b2 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)1U, |
8057 | 0 | uint8_t, uint8_t *); |
8058 | 0 | int16_t b3 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)2U, |
8059 | 0 | uint8_t, uint8_t *); |
8060 | 0 | int16_t d1 = (b2 & (int16_t)15) << 8U | b1; |
8061 | 0 | int16_t d2 = b3 << 4U | b2 >> 4U; |
8062 | 0 | bool uu____0; |
8063 | 0 | int16_t uu____1; |
8064 | 0 | bool uu____2; |
8065 | 0 | size_t uu____3; |
8066 | 0 | int16_t uu____4; |
8067 | 0 | size_t uu____5; |
8068 | 0 | int16_t uu____6; |
8069 | 0 | if (d1 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) { |
8070 | 0 | if (sampled < (size_t)16U) { |
8071 | 0 | Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d1; |
8072 | 0 | sampled++; |
8073 | 0 | uu____1 = d2; |
8074 | 0 | uu____6 = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
8075 | 0 | uu____0 = uu____1 < uu____6; |
8076 | 0 | if (uu____0) { |
8077 | 0 | uu____3 = sampled; |
8078 | 0 | uu____2 = uu____3 < (size_t)16U; |
8079 | 0 | if (uu____2) { |
8080 | 0 | uu____4 = d2; |
8081 | 0 | uu____5 = sampled; |
8082 | 0 | Eurydice_slice_index(result, uu____5, int16_t, int16_t *) = uu____4; |
8083 | 0 | sampled++; |
8084 | 0 | continue; |
8085 | 0 | } |
8086 | 0 | } |
8087 | 0 | continue; |
8088 | 0 | } |
8089 | 0 | } |
8090 | 0 | uu____1 = d2; |
8091 | 0 | uu____6 = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
8092 | 0 | uu____0 = uu____1 < uu____6; |
8093 | 0 | if (uu____0) { |
8094 | 0 | uu____3 = sampled; |
8095 | 0 | uu____2 = uu____3 < (size_t)16U; |
8096 | 0 | if (uu____2) { |
8097 | 0 | uu____4 = d2; |
8098 | 0 | uu____5 = sampled; |
8099 | 0 | Eurydice_slice_index(result, uu____5, int16_t, int16_t *) = uu____4; |
8100 | 0 | sampled++; |
8101 | 0 | continue; |
8102 | 0 | } |
8103 | 0 | } |
8104 | 0 | } |
8105 | 0 | return sampled; |
8106 | 0 | } |
8107 | | |
8108 | | /** |
8109 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
8110 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
8111 | | */ |
8112 | | static inline size_t libcrux_ml_kem_vector_portable_rej_sample_0d( |
8113 | 0 | Eurydice_slice a, Eurydice_slice out) { |
8114 | 0 | return libcrux_ml_kem_vector_portable_sampling_rej_sample(a, out); |
8115 | 0 | } |
8116 | | |
8117 | | #define LIBCRUX_ML_KEM_MLKEM768_VECTOR_U_COMPRESSION_FACTOR_768 ((size_t)10U) |
8118 | | |
8119 | | #define LIBCRUX_ML_KEM_MLKEM768_C1_BLOCK_SIZE_768 \ |
8120 | | (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \ |
8121 | | LIBCRUX_ML_KEM_MLKEM768_VECTOR_U_COMPRESSION_FACTOR_768 / (size_t)8U) |
8122 | | |
8123 | | #define LIBCRUX_ML_KEM_MLKEM768_RANK_768 ((size_t)3U) |
8124 | | |
8125 | | #define LIBCRUX_ML_KEM_MLKEM768_C1_SIZE_768 \ |
8126 | | (LIBCRUX_ML_KEM_MLKEM768_C1_BLOCK_SIZE_768 * LIBCRUX_ML_KEM_MLKEM768_RANK_768) |
8127 | | |
8128 | | #define LIBCRUX_ML_KEM_MLKEM768_VECTOR_V_COMPRESSION_FACTOR_768 ((size_t)4U) |
8129 | | |
8130 | | #define LIBCRUX_ML_KEM_MLKEM768_C2_SIZE_768 \ |
8131 | | (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \ |
8132 | | LIBCRUX_ML_KEM_MLKEM768_VECTOR_V_COMPRESSION_FACTOR_768 / (size_t)8U) |
8133 | | |
8134 | | #define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_CIPHERTEXT_SIZE_768 \ |
8135 | | (LIBCRUX_ML_KEM_MLKEM768_C1_SIZE_768 + LIBCRUX_ML_KEM_MLKEM768_C2_SIZE_768) |
8136 | | |
8137 | | #define LIBCRUX_ML_KEM_MLKEM768_T_AS_NTT_ENCODED_SIZE_768 \ |
8138 | | (LIBCRUX_ML_KEM_MLKEM768_RANK_768 * \ |
8139 | | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \ |
8140 | | LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT / (size_t)8U) |
8141 | | |
8142 | | #define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_PUBLIC_KEY_SIZE_768 \ |
8143 | | (LIBCRUX_ML_KEM_MLKEM768_T_AS_NTT_ENCODED_SIZE_768 + (size_t)32U) |
8144 | | |
8145 | | #define LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_SECRET_KEY_SIZE_768 \ |
8146 | | (LIBCRUX_ML_KEM_MLKEM768_RANK_768 * \ |
8147 | | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * \ |
8148 | | LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_COEFFICIENT / (size_t)8U) |
8149 | | |
8150 | | #define LIBCRUX_ML_KEM_MLKEM768_ETA1 ((size_t)2U) |
8151 | | |
8152 | | #define LIBCRUX_ML_KEM_MLKEM768_ETA1_RANDOMNESS_SIZE \ |
8153 | | (LIBCRUX_ML_KEM_MLKEM768_ETA1 * (size_t)64U) |
8154 | | |
8155 | | #define LIBCRUX_ML_KEM_MLKEM768_ETA2 ((size_t)2U) |
8156 | | |
8157 | | #define LIBCRUX_ML_KEM_MLKEM768_ETA2_RANDOMNESS_SIZE \ |
8158 | | (LIBCRUX_ML_KEM_MLKEM768_ETA2 * (size_t)64U) |
8159 | | |
8160 | | #define LIBCRUX_ML_KEM_MLKEM768_IMPLICIT_REJECTION_HASH_INPUT_SIZE \ |
8161 | | (LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE + \ |
8162 | | LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_CIPHERTEXT_SIZE_768) |
8163 | | |
8164 | | typedef libcrux_ml_kem_types_MlKemPrivateKey_55 |
8165 | | libcrux_ml_kem_mlkem768_MlKem768PrivateKey; |
8166 | | |
8167 | | typedef libcrux_ml_kem_types_MlKemPublicKey_15 |
8168 | | libcrux_ml_kem_mlkem768_MlKem768PublicKey; |
8169 | | |
8170 | | #define LIBCRUX_ML_KEM_MLKEM768_RANKED_BYTES_PER_RING_ELEMENT_768 \ |
8171 | | (LIBCRUX_ML_KEM_MLKEM768_RANK_768 * \ |
8172 | | LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U) |
8173 | | |
8174 | | #define LIBCRUX_ML_KEM_MLKEM768_SECRET_KEY_SIZE_768 \ |
8175 | | (LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_SECRET_KEY_SIZE_768 + \ |
8176 | | LIBCRUX_ML_KEM_MLKEM768_CPA_PKE_PUBLIC_KEY_SIZE_768 + \ |
8177 | | LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE + \ |
8178 | | LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE) |
8179 | | |
8180 | | /** |
8181 | | A monomorphic instance of libcrux_ml_kem.polynomial.PolynomialRingElement |
8182 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8183 | | |
8184 | | */ |
8185 | | typedef struct libcrux_ml_kem_polynomial_PolynomialRingElement_f0_s { |
8186 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficients[16U]; |
8187 | | } libcrux_ml_kem_polynomial_PolynomialRingElement_f0; |
8188 | | |
8189 | | /** |
8190 | | This function found in impl |
8191 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
8192 | | */ |
8193 | | /** |
8194 | | A monomorphic instance of libcrux_ml_kem.polynomial.ZERO_89 |
8195 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8196 | | with const generics |
8197 | | |
8198 | | */ |
8199 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8200 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(void) { |
8201 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 lit; |
8202 | 0 | lit.coefficients[0U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8203 | 0 | lit.coefficients[1U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8204 | 0 | lit.coefficients[2U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8205 | 0 | lit.coefficients[3U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8206 | 0 | lit.coefficients[4U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8207 | 0 | lit.coefficients[5U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8208 | 0 | lit.coefficients[6U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8209 | 0 | lit.coefficients[7U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8210 | 0 | lit.coefficients[8U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8211 | 0 | lit.coefficients[9U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8212 | 0 | lit.coefficients[10U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8213 | 0 | lit.coefficients[11U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8214 | 0 | lit.coefficients[12U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8215 | 0 | lit.coefficients[13U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8216 | 0 | lit.coefficients[14U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8217 | 0 | lit.coefficients[15U] = libcrux_ml_kem_vector_portable_ZERO_0d(); |
8218 | 0 | return lit; |
8219 | 0 | } |
8220 | | |
8221 | | /** |
8222 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_secret_key.closure |
8223 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8224 | | with const generics |
8225 | | - K= 3 |
8226 | | */ |
8227 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8228 | 0 | libcrux_ml_kem_ind_cpa_deserialize_secret_key_closure_6b(size_t _) { |
8229 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8230 | 0 | } |
8231 | | |
8232 | | /** |
8233 | | A monomorphic instance of |
8234 | | libcrux_ml_kem.serialize.deserialize_to_uncompressed_ring_element with types |
8235 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8236 | | |
8237 | | */ |
8238 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8239 | | libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_af( |
8240 | 0 | Eurydice_slice serialized) { |
8241 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
8242 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8243 | 0 | for (size_t i = (size_t)0U; |
8244 | 0 | i < Eurydice_slice_len(serialized, uint8_t) / (size_t)24U; i++) { |
8245 | 0 | size_t i0 = i; |
8246 | 0 | Eurydice_slice bytes = Eurydice_slice_subslice2( |
8247 | 0 | serialized, i0 * (size_t)24U, i0 * (size_t)24U + (size_t)24U, uint8_t); |
8248 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8249 | 0 | libcrux_ml_kem_vector_portable_deserialize_12_0d(bytes); |
8250 | 0 | re.coefficients[i0] = uu____0; |
8251 | 0 | } |
8252 | 0 | return re; |
8253 | 0 | } |
8254 | | |
8255 | | /** |
8256 | | Call [`deserialize_to_uncompressed_ring_element`] for each ring element. |
8257 | | */ |
8258 | | /** |
8259 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_secret_key |
8260 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8261 | | with const generics |
8262 | | - K= 3 |
8263 | | */ |
8264 | | static KRML_MUSTINLINE void libcrux_ml_kem_ind_cpa_deserialize_secret_key_24( |
8265 | | Eurydice_slice secret_key, |
8266 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
8267 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U]; |
8268 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
8269 | 0 | secret_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8270 | 0 | } |
8271 | 0 | for (size_t i = (size_t)0U; |
8272 | 0 | i < Eurydice_slice_len(secret_key, uint8_t) / |
8273 | 0 | LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT; |
8274 | 0 | i++) { |
8275 | 0 | size_t i0 = i; |
8276 | 0 | Eurydice_slice secret_bytes = Eurydice_slice_subslice2( |
8277 | 0 | secret_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
8278 | 0 | i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT + |
8279 | 0 | LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
8280 | 0 | uint8_t); |
8281 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____0 = |
8282 | 0 | libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_af( |
8283 | 0 | secret_bytes); |
8284 | 0 | secret_as_ntt[i0] = uu____0; |
8285 | 0 | } |
8286 | 0 | memcpy( |
8287 | 0 | ret, secret_as_ntt, |
8288 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
8289 | 0 | } |
8290 | | |
8291 | | /** |
8292 | | A monomorphic instance of |
8293 | | libcrux_ml_kem.ind_cpa.unpacked.IndCpaPrivateKeyUnpacked with types |
8294 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8295 | | - $3size_t |
8296 | | */ |
8297 | | typedef struct libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8_s { |
8298 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U]; |
8299 | | } libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8; |
8300 | | |
8301 | | /** |
8302 | | A monomorphic instance of |
8303 | | libcrux_ml_kem.ind_cpa.deserialize_then_decompress_u.closure with types |
8304 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8305 | | - K= 3 |
8306 | | - CIPHERTEXT_SIZE= 1088 |
8307 | | - U_COMPRESSION_FACTOR= 10 |
8308 | | */ |
8309 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8310 | 0 | libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_closure_7c(size_t _) { |
8311 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8312 | 0 | } |
8313 | | |
8314 | | /** |
8315 | | A monomorphic instance of |
8316 | | libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with |
8317 | | const generics |
8318 | | - COEFFICIENT_BITS= 10 |
8319 | | */ |
8320 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8321 | | libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b( |
8322 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8323 | 0 | for (size_t i = (size_t)0U; |
8324 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
8325 | 0 | size_t i0 = i; |
8326 | 0 | int32_t decompressed = (int32_t)v.elements[i0] * |
8327 | 0 | (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
8328 | 0 | decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)10); |
8329 | 0 | decompressed = decompressed >> (uint32_t)((int32_t)10 + (int32_t)1); |
8330 | 0 | v.elements[i0] = (int16_t)decompressed; |
8331 | 0 | } |
8332 | 0 | return v; |
8333 | 0 | } |
8334 | | |
8335 | | /** |
8336 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
8337 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
8338 | | */ |
8339 | | /** |
8340 | | A monomorphic instance of |
8341 | | libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const |
8342 | | generics |
8343 | | - COEFFICIENT_BITS= 10 |
8344 | | */ |
8345 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8346 | | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a( |
8347 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8348 | 0 | return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b( |
8349 | 0 | v); |
8350 | 0 | } |
8351 | | |
8352 | | /** |
8353 | | A monomorphic instance of |
8354 | | libcrux_ml_kem.serialize.deserialize_then_decompress_10 with types |
8355 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8356 | | |
8357 | | */ |
8358 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8359 | | libcrux_ml_kem_serialize_deserialize_then_decompress_10_2c( |
8360 | 0 | Eurydice_slice serialized) { |
8361 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
8362 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8363 | 0 | for (size_t i = (size_t)0U; |
8364 | 0 | i < Eurydice_slice_len(serialized, uint8_t) / (size_t)20U; i++) { |
8365 | 0 | size_t i0 = i; |
8366 | 0 | Eurydice_slice bytes = Eurydice_slice_subslice2( |
8367 | 0 | serialized, i0 * (size_t)20U, i0 * (size_t)20U + (size_t)20U, uint8_t); |
8368 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
8369 | 0 | libcrux_ml_kem_vector_portable_deserialize_10_0d(bytes); |
8370 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8371 | 0 | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a( |
8372 | 0 | coefficient); |
8373 | 0 | re.coefficients[i0] = uu____0; |
8374 | 0 | } |
8375 | 0 | return re; |
8376 | 0 | } |
8377 | | |
8378 | | /** |
8379 | | A monomorphic instance of |
8380 | | libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with |
8381 | | const generics |
8382 | | - COEFFICIENT_BITS= 11 |
8383 | | */ |
8384 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8385 | | libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b0( |
8386 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8387 | 0 | for (size_t i = (size_t)0U; |
8388 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
8389 | 0 | size_t i0 = i; |
8390 | 0 | int32_t decompressed = (int32_t)v.elements[i0] * |
8391 | 0 | (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
8392 | 0 | decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)11); |
8393 | 0 | decompressed = decompressed >> (uint32_t)((int32_t)11 + (int32_t)1); |
8394 | 0 | v.elements[i0] = (int16_t)decompressed; |
8395 | 0 | } |
8396 | 0 | return v; |
8397 | 0 | } |
8398 | | |
8399 | | /** |
8400 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
8401 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
8402 | | */ |
8403 | | /** |
8404 | | A monomorphic instance of |
8405 | | libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const |
8406 | | generics |
8407 | | - COEFFICIENT_BITS= 11 |
8408 | | */ |
8409 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8410 | | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a0( |
8411 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8412 | 0 | return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b0( |
8413 | 0 | v); |
8414 | 0 | } |
8415 | | |
8416 | | /** |
8417 | | A monomorphic instance of |
8418 | | libcrux_ml_kem.serialize.deserialize_then_decompress_11 with types |
8419 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8420 | | |
8421 | | */ |
8422 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8423 | | libcrux_ml_kem_serialize_deserialize_then_decompress_11_8d( |
8424 | 0 | Eurydice_slice serialized) { |
8425 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
8426 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8427 | 0 | for (size_t i = (size_t)0U; |
8428 | 0 | i < Eurydice_slice_len(serialized, uint8_t) / (size_t)22U; i++) { |
8429 | 0 | size_t i0 = i; |
8430 | 0 | Eurydice_slice bytes = Eurydice_slice_subslice2( |
8431 | 0 | serialized, i0 * (size_t)22U, i0 * (size_t)22U + (size_t)22U, uint8_t); |
8432 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
8433 | 0 | libcrux_ml_kem_vector_portable_deserialize_11_0d(bytes); |
8434 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8435 | 0 | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a0( |
8436 | 0 | coefficient); |
8437 | 0 | re.coefficients[i0] = uu____0; |
8438 | 0 | } |
8439 | 0 | return re; |
8440 | 0 | } |
8441 | | |
8442 | | /** |
8443 | | A monomorphic instance of |
8444 | | libcrux_ml_kem.serialize.deserialize_then_decompress_ring_element_u with types |
8445 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8446 | | - COMPRESSION_FACTOR= 10 |
8447 | | */ |
8448 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8449 | | libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_34( |
8450 | 0 | Eurydice_slice serialized) { |
8451 | 0 | return libcrux_ml_kem_serialize_deserialize_then_decompress_10_2c(serialized); |
8452 | 0 | } |
8453 | | |
8454 | | typedef struct libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2_s { |
8455 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector fst; |
8456 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector snd; |
8457 | | } libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2; |
8458 | | |
8459 | | /** |
8460 | | A monomorphic instance of libcrux_ml_kem.vector.traits.montgomery_multiply_fe |
8461 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8462 | | with const generics |
8463 | | |
8464 | | */ |
8465 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8466 | | libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67( |
8467 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t fer) { |
8468 | 0 | return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(v, |
8469 | 0 | fer); |
8470 | 0 | } |
8471 | | |
8472 | | /** |
8473 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_layer_int_vec_step |
8474 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8475 | | with const generics |
8476 | | |
8477 | | */ |
8478 | | static KRML_MUSTINLINE |
8479 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 |
8480 | | libcrux_ml_kem_ntt_ntt_layer_int_vec_step_0c( |
8481 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
8482 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector b, |
8483 | 0 | int16_t zeta_r) { |
8484 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector t = |
8485 | 0 | libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67(b, zeta_r); |
8486 | 0 | b = libcrux_ml_kem_vector_portable_sub_0d(a, &t); |
8487 | 0 | a = libcrux_ml_kem_vector_portable_add_0d(a, &t); |
8488 | 0 | return ( |
8489 | 0 | CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){ |
8490 | 0 | .fst = a, .snd = b}); |
8491 | 0 | } |
8492 | | |
8493 | | /** |
8494 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_4_plus |
8495 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8496 | | with const generics |
8497 | | |
8498 | | */ |
8499 | | static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51( |
8500 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8501 | 0 | size_t layer, size_t _initial_coefficient_bound) { |
8502 | 0 | size_t step = (size_t)1U << (uint32_t)layer; |
8503 | 0 | for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) { |
8504 | 0 | size_t round = i0; |
8505 | 0 | zeta_i[0U] = zeta_i[0U] + (size_t)1U; |
8506 | 0 | size_t offset = round * step * (size_t)2U; |
8507 | 0 | size_t offset_vec = offset / (size_t)16U; |
8508 | 0 | size_t step_vec = step / (size_t)16U; |
8509 | 0 | for (size_t i = offset_vec; i < offset_vec + step_vec; i++) { |
8510 | 0 | size_t j = i; |
8511 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 = |
8512 | 0 | libcrux_ml_kem_ntt_ntt_layer_int_vec_step_0c( |
8513 | 0 | re->coefficients[j], re->coefficients[j + step_vec], |
8514 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]); |
8515 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst; |
8516 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd; |
8517 | 0 | re->coefficients[j] = x; |
8518 | 0 | re->coefficients[j + step_vec] = y; |
8519 | 0 | } |
8520 | 0 | } |
8521 | 0 | } |
8522 | | |
8523 | | /** |
8524 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_3 |
8525 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8526 | | with const generics |
8527 | | |
8528 | | */ |
8529 | | static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_3_fd( |
8530 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8531 | 0 | size_t _layer, size_t _initial_coefficient_bound) { |
8532 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
8533 | 0 | size_t round = i; |
8534 | 0 | zeta_i[0U] = zeta_i[0U] + (size_t)1U; |
8535 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8536 | 0 | libcrux_ml_kem_vector_portable_ntt_layer_3_step_0d( |
8537 | 0 | re->coefficients[round], |
8538 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]); |
8539 | 0 | re->coefficients[round] = uu____0; |
8540 | 0 | } |
8541 | 0 | } |
8542 | | |
8543 | | /** |
8544 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_2 |
8545 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8546 | | with const generics |
8547 | | |
8548 | | */ |
8549 | | static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_2_ad( |
8550 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8551 | 0 | size_t _layer, size_t _initial_coefficient_bound) { |
8552 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
8553 | 0 | size_t round = i; |
8554 | 0 | zeta_i[0U] = zeta_i[0U] + (size_t)1U; |
8555 | 0 | re->coefficients[round] = |
8556 | 0 | libcrux_ml_kem_vector_portable_ntt_layer_2_step_0d( |
8557 | 0 | re->coefficients[round], |
8558 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]], |
8559 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] + |
8560 | 0 | (size_t)1U]); |
8561 | 0 | zeta_i[0U] = zeta_i[0U] + (size_t)1U; |
8562 | 0 | } |
8563 | 0 | } |
8564 | | |
8565 | | /** |
8566 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_1 |
8567 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8568 | | with const generics |
8569 | | |
8570 | | */ |
8571 | | static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_1_a2( |
8572 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8573 | 0 | size_t _layer, size_t _initial_coefficient_bound) { |
8574 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
8575 | 0 | size_t round = i; |
8576 | 0 | zeta_i[0U] = zeta_i[0U] + (size_t)1U; |
8577 | 0 | re->coefficients[round] = |
8578 | 0 | libcrux_ml_kem_vector_portable_ntt_layer_1_step_0d( |
8579 | 0 | re->coefficients[round], |
8580 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]], |
8581 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] + |
8582 | 0 | (size_t)1U], |
8583 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] + |
8584 | 0 | (size_t)2U], |
8585 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] + |
8586 | 0 | (size_t)3U]); |
8587 | 0 | zeta_i[0U] = zeta_i[0U] + (size_t)3U; |
8588 | 0 | } |
8589 | 0 | } |
8590 | | |
8591 | | /** |
8592 | | This function found in impl |
8593 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
8594 | | */ |
8595 | | /** |
8596 | | A monomorphic instance of libcrux_ml_kem.polynomial.poly_barrett_reduce_89 |
8597 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8598 | | with const generics |
8599 | | |
8600 | | */ |
8601 | | static KRML_MUSTINLINE void libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b( |
8602 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self) { |
8603 | 0 | for (size_t i = (size_t)0U; |
8604 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
8605 | 0 | size_t i0 = i; |
8606 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8607 | 0 | libcrux_ml_kem_vector_portable_barrett_reduce_0d( |
8608 | 0 | self->coefficients[i0]); |
8609 | 0 | self->coefficients[i0] = uu____0; |
8610 | 0 | } |
8611 | 0 | } |
8612 | | |
8613 | | /** |
8614 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_vector_u |
8615 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8616 | | with const generics |
8617 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
8618 | | */ |
8619 | | static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_vector_u_9f( |
8620 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) { |
8621 | 0 | size_t zeta_i = (size_t)0U; |
8622 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)7U, |
8623 | 0 | (size_t)3328U); |
8624 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)6U, |
8625 | 0 | (size_t)3328U); |
8626 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)5U, |
8627 | 0 | (size_t)3328U); |
8628 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)4U, |
8629 | 0 | (size_t)3328U); |
8630 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_3_fd(&zeta_i, re, (size_t)3U, (size_t)3328U); |
8631 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_2_ad(&zeta_i, re, (size_t)2U, (size_t)3328U); |
8632 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_1_a2(&zeta_i, re, (size_t)1U, (size_t)3328U); |
8633 | 0 | libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re); |
8634 | 0 | } |
8635 | | |
8636 | | /** |
8637 | | Call [`deserialize_then_decompress_ring_element_u`] on each ring element |
8638 | | in the `ciphertext`. |
8639 | | */ |
8640 | | /** |
8641 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.deserialize_then_decompress_u |
8642 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8643 | | with const generics |
8644 | | - K= 3 |
8645 | | - CIPHERTEXT_SIZE= 1088 |
8646 | | - U_COMPRESSION_FACTOR= 10 |
8647 | | */ |
8648 | | static KRML_MUSTINLINE void |
8649 | | libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_f4( |
8650 | | uint8_t *ciphertext, |
8651 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
8652 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 u_as_ntt[3U]; |
8653 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
8654 | 0 | u_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8655 | 0 | } |
8656 | 0 | for (size_t i = (size_t)0U; |
8657 | 0 | i < Eurydice_slice_len( |
8658 | 0 | Eurydice_array_to_slice((size_t)1088U, ciphertext, uint8_t), |
8659 | 0 | uint8_t) / |
8660 | 0 | (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * |
8661 | 0 | (size_t)10U / (size_t)8U); |
8662 | 0 | i++) { |
8663 | 0 | size_t i0 = i; |
8664 | 0 | Eurydice_slice u_bytes = Eurydice_array_to_subslice2( |
8665 | 0 | ciphertext, |
8666 | 0 | i0 * (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * |
8667 | 0 | (size_t)10U / (size_t)8U), |
8668 | 0 | i0 * (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * |
8669 | 0 | (size_t)10U / (size_t)8U) + |
8670 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * |
8671 | 0 | (size_t)10U / (size_t)8U, |
8672 | 0 | uint8_t); |
8673 | 0 | u_as_ntt[i0] = |
8674 | 0 | libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_34( |
8675 | 0 | u_bytes); |
8676 | 0 | libcrux_ml_kem_ntt_ntt_vector_u_9f(&u_as_ntt[i0]); |
8677 | 0 | } |
8678 | 0 | memcpy( |
8679 | 0 | ret, u_as_ntt, |
8680 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
8681 | 0 | } |
8682 | | |
8683 | | /** |
8684 | | A monomorphic instance of |
8685 | | libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with |
8686 | | const generics |
8687 | | - COEFFICIENT_BITS= 4 |
8688 | | */ |
8689 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8690 | | libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b1( |
8691 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8692 | 0 | for (size_t i = (size_t)0U; |
8693 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
8694 | 0 | size_t i0 = i; |
8695 | 0 | int32_t decompressed = (int32_t)v.elements[i0] * |
8696 | 0 | (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
8697 | 0 | decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)4); |
8698 | 0 | decompressed = decompressed >> (uint32_t)((int32_t)4 + (int32_t)1); |
8699 | 0 | v.elements[i0] = (int16_t)decompressed; |
8700 | 0 | } |
8701 | 0 | return v; |
8702 | 0 | } |
8703 | | |
8704 | | /** |
8705 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
8706 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
8707 | | */ |
8708 | | /** |
8709 | | A monomorphic instance of |
8710 | | libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const |
8711 | | generics |
8712 | | - COEFFICIENT_BITS= 4 |
8713 | | */ |
8714 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8715 | | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a1( |
8716 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8717 | 0 | return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b1( |
8718 | 0 | v); |
8719 | 0 | } |
8720 | | |
8721 | | /** |
8722 | | A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_4 |
8723 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8724 | | with const generics |
8725 | | |
8726 | | */ |
8727 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8728 | | libcrux_ml_kem_serialize_deserialize_then_decompress_4_41( |
8729 | 0 | Eurydice_slice serialized) { |
8730 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
8731 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8732 | 0 | for (size_t i = (size_t)0U; |
8733 | 0 | i < Eurydice_slice_len(serialized, uint8_t) / (size_t)8U; i++) { |
8734 | 0 | size_t i0 = i; |
8735 | 0 | Eurydice_slice bytes = Eurydice_slice_subslice2( |
8736 | 0 | serialized, i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t); |
8737 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
8738 | 0 | libcrux_ml_kem_vector_portable_deserialize_4_0d(bytes); |
8739 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8740 | 0 | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a1( |
8741 | 0 | coefficient); |
8742 | 0 | re.coefficients[i0] = uu____0; |
8743 | 0 | } |
8744 | 0 | return re; |
8745 | 0 | } |
8746 | | |
8747 | | /** |
8748 | | A monomorphic instance of |
8749 | | libcrux_ml_kem.vector.portable.compress.decompress_ciphertext_coefficient with |
8750 | | const generics |
8751 | | - COEFFICIENT_BITS= 5 |
8752 | | */ |
8753 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8754 | | libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b2( |
8755 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8756 | 0 | for (size_t i = (size_t)0U; |
8757 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
8758 | 0 | size_t i0 = i; |
8759 | 0 | int32_t decompressed = (int32_t)v.elements[i0] * |
8760 | 0 | (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS; |
8761 | 0 | decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)5); |
8762 | 0 | decompressed = decompressed >> (uint32_t)((int32_t)5 + (int32_t)1); |
8763 | 0 | v.elements[i0] = (int16_t)decompressed; |
8764 | 0 | } |
8765 | 0 | return v; |
8766 | 0 | } |
8767 | | |
8768 | | /** |
8769 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
8770 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
8771 | | */ |
8772 | | /** |
8773 | | A monomorphic instance of |
8774 | | libcrux_ml_kem.vector.portable.decompress_ciphertext_coefficient_0d with const |
8775 | | generics |
8776 | | - COEFFICIENT_BITS= 5 |
8777 | | */ |
8778 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8779 | | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a2( |
8780 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
8781 | 0 | return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_6b2( |
8782 | 0 | v); |
8783 | 0 | } |
8784 | | |
8785 | | /** |
8786 | | A monomorphic instance of libcrux_ml_kem.serialize.deserialize_then_decompress_5 |
8787 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8788 | | with const generics |
8789 | | |
8790 | | */ |
8791 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8792 | | libcrux_ml_kem_serialize_deserialize_then_decompress_5_4e( |
8793 | 0 | Eurydice_slice serialized) { |
8794 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
8795 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8796 | 0 | for (size_t i = (size_t)0U; |
8797 | 0 | i < Eurydice_slice_len(serialized, uint8_t) / (size_t)10U; i++) { |
8798 | 0 | size_t i0 = i; |
8799 | 0 | Eurydice_slice bytes = Eurydice_slice_subslice2( |
8800 | 0 | serialized, i0 * (size_t)10U, i0 * (size_t)10U + (size_t)10U, uint8_t); |
8801 | 0 | re.coefficients[i0] = |
8802 | 0 | libcrux_ml_kem_vector_portable_deserialize_5_0d(bytes); |
8803 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 = |
8804 | 0 | libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_0d_5a2( |
8805 | 0 | re.coefficients[i0]); |
8806 | 0 | re.coefficients[i0] = uu____1; |
8807 | 0 | } |
8808 | 0 | return re; |
8809 | 0 | } |
8810 | | |
8811 | | /** |
8812 | | A monomorphic instance of |
8813 | | libcrux_ml_kem.serialize.deserialize_then_decompress_ring_element_v with types |
8814 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8815 | | - COMPRESSION_FACTOR= 4 |
8816 | | */ |
8817 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8818 | | libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_56( |
8819 | 0 | Eurydice_slice serialized) { |
8820 | 0 | return libcrux_ml_kem_serialize_deserialize_then_decompress_4_41(serialized); |
8821 | 0 | } |
8822 | | |
8823 | | /** |
8824 | | Given two `KyberPolynomialRingElement`s in their NTT representations, |
8825 | | compute their product. Given two polynomials in the NTT domain `f^` and `ĵ`, |
8826 | | the `iᵗʰ` coefficient of the product `k̂` is determined by the calculation: |
8827 | | |
8828 | | ```plaintext |
8829 | | ĥ[2·i] + ĥ[2·i + 1]X = (f^[2·i] + f^[2·i + 1]X)·(ĝ[2·i] + ĝ[2·i + 1]X) mod (X² |
8830 | | - ζ^(2·BitRev₇(i) + 1)) |
8831 | | ``` |
8832 | | |
8833 | | This function almost implements <strong>Algorithm 10</strong> of the |
8834 | | NIST FIPS 203 standard, which is reproduced below: |
8835 | | |
8836 | | ```plaintext |
8837 | | Input: Two arrays fˆ ∈ ℤ₂₅₆ and ĝ ∈ ℤ₂₅₆. |
8838 | | Output: An array ĥ ∈ ℤq. |
8839 | | |
8840 | | for(i ← 0; i < 128; i++) |
8841 | | (ĥ[2i], ĥ[2i+1]) ← BaseCaseMultiply(fˆ[2i], fˆ[2i+1], ĝ[2i], ĝ[2i+1], |
8842 | | ζ^(2·BitRev₇(i) + 1)) end for return ĥ |
8843 | | ``` |
8844 | | We say "almost" because the coefficients of the ring element output by |
8845 | | this function are in the Montgomery domain. |
8846 | | |
8847 | | The NIST FIPS 203 standard can be found at |
8848 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
8849 | | */ |
8850 | | /** |
8851 | | This function found in impl |
8852 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
8853 | | */ |
8854 | | /** |
8855 | | A monomorphic instance of libcrux_ml_kem.polynomial.ntt_multiply_89 |
8856 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8857 | | with const generics |
8858 | | |
8859 | | */ |
8860 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
8861 | | libcrux_ml_kem_polynomial_ntt_multiply_89_2a( |
8862 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self, |
8863 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *rhs) { |
8864 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 out = |
8865 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
8866 | 0 | for (size_t i = (size_t)0U; |
8867 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
8868 | 0 | size_t i0 = i; |
8869 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8870 | 0 | libcrux_ml_kem_vector_portable_ntt_multiply_0d( |
8871 | 0 | &self->coefficients[i0], &rhs->coefficients[i0], |
8872 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U + |
8873 | 0 | (size_t)4U * i0], |
8874 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U + |
8875 | 0 | (size_t)4U * i0 + |
8876 | 0 | (size_t)1U], |
8877 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U + |
8878 | 0 | (size_t)4U * i0 + |
8879 | 0 | (size_t)2U], |
8880 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U + |
8881 | 0 | (size_t)4U * i0 + |
8882 | 0 | (size_t)3U]); |
8883 | 0 | out.coefficients[i0] = uu____0; |
8884 | 0 | } |
8885 | 0 | return out; |
8886 | 0 | } |
8887 | | |
8888 | | /** |
8889 | | Given two polynomial ring elements `lhs` and `rhs`, compute the pointwise |
8890 | | sum of their constituent coefficients. |
8891 | | */ |
8892 | | /** |
8893 | | This function found in impl |
8894 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
8895 | | */ |
8896 | | /** |
8897 | | A monomorphic instance of libcrux_ml_kem.polynomial.add_to_ring_element_89 |
8898 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8899 | | with const generics |
8900 | | - K= 3 |
8901 | | */ |
8902 | | static KRML_MUSTINLINE void libcrux_ml_kem_polynomial_add_to_ring_element_89_84( |
8903 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self, |
8904 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *rhs) { |
8905 | 0 | for (size_t i = (size_t)0U; |
8906 | 0 | i < Eurydice_slice_len( |
8907 | 0 | Eurydice_array_to_slice( |
8908 | 0 | (size_t)16U, self->coefficients, |
8909 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector), |
8910 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector); |
8911 | 0 | i++) { |
8912 | 0 | size_t i0 = i; |
8913 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8914 | 0 | libcrux_ml_kem_vector_portable_add_0d(self->coefficients[i0], |
8915 | 0 | &rhs->coefficients[i0]); |
8916 | 0 | self->coefficients[i0] = uu____0; |
8917 | 0 | } |
8918 | 0 | } |
8919 | | |
8920 | | /** |
8921 | | A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_1 |
8922 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8923 | | with const generics |
8924 | | |
8925 | | */ |
8926 | | static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_83( |
8927 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8928 | 0 | size_t _layer) { |
8929 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
8930 | 0 | size_t round = i; |
8931 | 0 | zeta_i[0U] = zeta_i[0U] - (size_t)1U; |
8932 | 0 | re->coefficients[round] = |
8933 | 0 | libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_0d( |
8934 | 0 | re->coefficients[round], |
8935 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]], |
8936 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] - |
8937 | 0 | (size_t)1U], |
8938 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] - |
8939 | 0 | (size_t)2U], |
8940 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] - |
8941 | 0 | (size_t)3U]); |
8942 | 0 | zeta_i[0U] = zeta_i[0U] - (size_t)3U; |
8943 | 0 | } |
8944 | 0 | } |
8945 | | |
8946 | | /** |
8947 | | A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_2 |
8948 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8949 | | with const generics |
8950 | | |
8951 | | */ |
8952 | | static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_c3( |
8953 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8954 | 0 | size_t _layer) { |
8955 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
8956 | 0 | size_t round = i; |
8957 | 0 | zeta_i[0U] = zeta_i[0U] - (size_t)1U; |
8958 | 0 | re->coefficients[round] = |
8959 | 0 | libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_0d( |
8960 | 0 | re->coefficients[round], |
8961 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]], |
8962 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] - |
8963 | 0 | (size_t)1U]); |
8964 | 0 | zeta_i[0U] = zeta_i[0U] - (size_t)1U; |
8965 | 0 | } |
8966 | 0 | } |
8967 | | |
8968 | | /** |
8969 | | A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_3 |
8970 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
8971 | | with const generics |
8972 | | |
8973 | | */ |
8974 | | static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_68( |
8975 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
8976 | 0 | size_t _layer) { |
8977 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
8978 | 0 | size_t round = i; |
8979 | 0 | zeta_i[0U] = zeta_i[0U] - (size_t)1U; |
8980 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
8981 | 0 | libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_0d( |
8982 | 0 | re->coefficients[round], |
8983 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]); |
8984 | 0 | re->coefficients[round] = uu____0; |
8985 | 0 | } |
8986 | 0 | } |
8987 | | |
8988 | | /** |
8989 | | A monomorphic instance of |
8990 | | libcrux_ml_kem.invert_ntt.inv_ntt_layer_int_vec_step_reduce with types |
8991 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
8992 | | |
8993 | | */ |
8994 | | static KRML_MUSTINLINE |
8995 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 |
8996 | | libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_65( |
8997 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector a, |
8998 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector b, |
8999 | 0 | int16_t zeta_r) { |
9000 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector a_minus_b = |
9001 | 0 | libcrux_ml_kem_vector_portable_sub_0d(b, &a); |
9002 | 0 | a = libcrux_ml_kem_vector_portable_barrett_reduce_0d( |
9003 | 0 | libcrux_ml_kem_vector_portable_add_0d(a, &b)); |
9004 | 0 | b = libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67(a_minus_b, zeta_r); |
9005 | 0 | return ( |
9006 | 0 | CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){ |
9007 | 0 | .fst = a, .snd = b}); |
9008 | 0 | } |
9009 | | |
9010 | | /** |
9011 | | A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_at_layer_4_plus |
9012 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9013 | | with const generics |
9014 | | |
9015 | | */ |
9016 | | static KRML_MUSTINLINE void |
9017 | | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e( |
9018 | | size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, |
9019 | 0 | size_t layer) { |
9020 | 0 | size_t step = (size_t)1U << (uint32_t)layer; |
9021 | 0 | for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) { |
9022 | 0 | size_t round = i0; |
9023 | 0 | zeta_i[0U] = zeta_i[0U] - (size_t)1U; |
9024 | 0 | size_t offset = round * step * (size_t)2U; |
9025 | 0 | size_t offset_vec = |
9026 | 0 | offset / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; |
9027 | 0 | size_t step_vec = |
9028 | 0 | step / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; |
9029 | 0 | for (size_t i = offset_vec; i < offset_vec + step_vec; i++) { |
9030 | 0 | size_t j = i; |
9031 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 = |
9032 | 0 | libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_65( |
9033 | 0 | re->coefficients[j], re->coefficients[j + step_vec], |
9034 | 0 | libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]); |
9035 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst; |
9036 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd; |
9037 | 0 | re->coefficients[j] = x; |
9038 | 0 | re->coefficients[j + step_vec] = y; |
9039 | 0 | } |
9040 | 0 | } |
9041 | 0 | } |
9042 | | |
9043 | | /** |
9044 | | A monomorphic instance of libcrux_ml_kem.invert_ntt.invert_ntt_montgomery |
9045 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9046 | | with const generics |
9047 | | - K= 3 |
9048 | | */ |
9049 | | static KRML_MUSTINLINE void libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6( |
9050 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) { |
9051 | 0 | size_t zeta_i = |
9052 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)2U; |
9053 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_83(&zeta_i, re, (size_t)1U); |
9054 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_c3(&zeta_i, re, (size_t)2U); |
9055 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_68(&zeta_i, re, (size_t)3U); |
9056 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re, |
9057 | 0 | (size_t)4U); |
9058 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re, |
9059 | 0 | (size_t)5U); |
9060 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re, |
9061 | 0 | (size_t)6U); |
9062 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_6e(&zeta_i, re, |
9063 | 0 | (size_t)7U); |
9064 | 0 | libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re); |
9065 | 0 | } |
9066 | | |
9067 | | /** |
9068 | | This function found in impl |
9069 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
9070 | | */ |
9071 | | /** |
9072 | | A monomorphic instance of libcrux_ml_kem.polynomial.subtract_reduce_89 |
9073 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9074 | | with const generics |
9075 | | |
9076 | | */ |
9077 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9078 | | libcrux_ml_kem_polynomial_subtract_reduce_89_d4( |
9079 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self, |
9080 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 b) { |
9081 | 0 | for (size_t i = (size_t)0U; |
9082 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
9083 | 0 | size_t i0 = i; |
9084 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9085 | 0 | coefficient_normal_form = |
9086 | 0 | libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d( |
9087 | 0 | b.coefficients[i0], (int16_t)1441); |
9088 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
9089 | 0 | libcrux_ml_kem_vector_portable_barrett_reduce_0d( |
9090 | 0 | libcrux_ml_kem_vector_portable_sub_0d(self->coefficients[i0], |
9091 | 0 | &coefficient_normal_form)); |
9092 | 0 | b.coefficients[i0] = uu____0; |
9093 | 0 | } |
9094 | 0 | return b; |
9095 | 0 | } |
9096 | | |
9097 | | /** |
9098 | | The following functions compute various expressions involving |
9099 | | vectors and matrices. The computation of these expressions has been |
9100 | | abstracted away into these functions in order to save on loop iterations. |
9101 | | Compute v − InverseNTT(sᵀ ◦ NTT(u)) |
9102 | | */ |
9103 | | /** |
9104 | | A monomorphic instance of libcrux_ml_kem.matrix.compute_message |
9105 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9106 | | with const generics |
9107 | | - K= 3 |
9108 | | */ |
9109 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9110 | | libcrux_ml_kem_matrix_compute_message_b3( |
9111 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *v, |
9112 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *secret_as_ntt, |
9113 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *u_as_ntt) { |
9114 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result = |
9115 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9116 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9117 | 0 | size_t i0 = i; |
9118 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product = |
9119 | 0 | libcrux_ml_kem_polynomial_ntt_multiply_89_2a(&secret_as_ntt[i0], |
9120 | 0 | &u_as_ntt[i0]); |
9121 | 0 | libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result, &product); |
9122 | 0 | } |
9123 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(&result); |
9124 | 0 | result = libcrux_ml_kem_polynomial_subtract_reduce_89_d4(v, result); |
9125 | 0 | return result; |
9126 | 0 | } |
9127 | | |
9128 | | /** |
9129 | | A monomorphic instance of libcrux_ml_kem.vector.portable.arithmetic.shift_right |
9130 | | with const generics |
9131 | | - SHIFT_BY= 15 |
9132 | | */ |
9133 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9134 | | libcrux_ml_kem_vector_portable_arithmetic_shift_right_94( |
9135 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
9136 | 0 | for (size_t i = (size_t)0U; |
9137 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
9138 | 0 | size_t i0 = i; |
9139 | 0 | v.elements[i0] = v.elements[i0] >> (uint32_t)(int32_t)15; |
9140 | 0 | } |
9141 | 0 | return v; |
9142 | 0 | } |
9143 | | |
9144 | | /** |
9145 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
9146 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
9147 | | */ |
9148 | | /** |
9149 | | A monomorphic instance of libcrux_ml_kem.vector.portable.shift_right_0d |
9150 | | with const generics |
9151 | | - SHIFT_BY= 15 |
9152 | | */ |
9153 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9154 | | libcrux_ml_kem_vector_portable_shift_right_0d_19( |
9155 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
9156 | 0 | return libcrux_ml_kem_vector_portable_arithmetic_shift_right_94(v); |
9157 | 0 | } |
9158 | | |
9159 | | /** |
9160 | | A monomorphic instance of |
9161 | | libcrux_ml_kem.vector.traits.to_unsigned_representative with types |
9162 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9163 | | |
9164 | | */ |
9165 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9166 | | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
9167 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector a) { |
9168 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector t = |
9169 | 0 | libcrux_ml_kem_vector_portable_shift_right_0d_19(a); |
9170 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector fm = |
9171 | 0 | libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d( |
9172 | 0 | t, LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS); |
9173 | 0 | return libcrux_ml_kem_vector_portable_add_0d(a, &fm); |
9174 | 0 | } |
9175 | | |
9176 | | /** |
9177 | | A monomorphic instance of |
9178 | | libcrux_ml_kem.serialize.compress_then_serialize_message with types |
9179 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9180 | | |
9181 | | */ |
9182 | | static KRML_MUSTINLINE void |
9183 | | libcrux_ml_kem_serialize_compress_then_serialize_message_aa( |
9184 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re, uint8_t ret[32U]) { |
9185 | 0 | uint8_t serialized[32U] = {0U}; |
9186 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
9187 | 0 | size_t i0 = i; |
9188 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
9189 | 0 | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
9190 | 0 | re.coefficients[i0]); |
9191 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9192 | 0 | coefficient_compressed = |
9193 | 0 | libcrux_ml_kem_vector_portable_compress_1_0d(coefficient); |
9194 | 0 | uint8_t bytes[2U]; |
9195 | 0 | libcrux_ml_kem_vector_portable_serialize_1_0d(coefficient_compressed, |
9196 | 0 | bytes); |
9197 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
9198 | 0 | serialized, (size_t)2U * i0, (size_t)2U * i0 + (size_t)2U, uint8_t); |
9199 | 0 | Eurydice_slice_copy( |
9200 | 0 | uu____0, Eurydice_array_to_slice((size_t)2U, bytes, uint8_t), uint8_t); |
9201 | 0 | } |
9202 | 0 | memcpy(ret, serialized, (size_t)32U * sizeof(uint8_t)); |
9203 | 0 | } |
9204 | | |
9205 | | /** |
9206 | | This function implements <strong>Algorithm 14</strong> of the |
9207 | | NIST FIPS 203 specification; this is the Kyber CPA-PKE decryption algorithm. |
9208 | | |
9209 | | Algorithm 14 is reproduced below: |
9210 | | |
9211 | | ```plaintext |
9212 | | Input: decryption key dkₚₖₑ ∈ 𝔹^{384k}. |
9213 | | Input: ciphertext c ∈ 𝔹^{32(dᵤk + dᵥ)}. |
9214 | | Output: message m ∈ 𝔹^{32}. |
9215 | | |
9216 | | c₁ ← c[0 : 32dᵤk] |
9217 | | c₂ ← c[32dᵤk : 32(dᵤk + dᵥ)] |
9218 | | u ← Decompress_{dᵤ}(ByteDecode_{dᵤ}(c₁)) |
9219 | | v ← Decompress_{dᵥ}(ByteDecode_{dᵥ}(c₂)) |
9220 | | ŝ ← ByteDecode₁₂(dkₚₖₑ) |
9221 | | w ← v - NTT-¹(ŝᵀ ◦ NTT(u)) |
9222 | | m ← ByteEncode₁(Compress₁(w)) |
9223 | | return m |
9224 | | ``` |
9225 | | |
9226 | | The NIST FIPS 203 standard can be found at |
9227 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
9228 | | */ |
9229 | | /** |
9230 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt_unpacked |
9231 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9232 | | with const generics |
9233 | | - K= 3 |
9234 | | - CIPHERTEXT_SIZE= 1088 |
9235 | | - VECTOR_U_ENCODED_SIZE= 960 |
9236 | | - U_COMPRESSION_FACTOR= 10 |
9237 | | - V_COMPRESSION_FACTOR= 4 |
9238 | | */ |
9239 | | static inline void libcrux_ml_kem_ind_cpa_decrypt_unpacked_6d( |
9240 | | libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8 *secret_key, |
9241 | 0 | uint8_t *ciphertext, uint8_t ret[32U]) { |
9242 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 u_as_ntt[3U]; |
9243 | 0 | libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_f4(ciphertext, u_as_ntt); |
9244 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 v = |
9245 | 0 | libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_56( |
9246 | 0 | Eurydice_array_to_subslice_from((size_t)1088U, ciphertext, |
9247 | 0 | (size_t)960U, uint8_t, size_t)); |
9248 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 message = |
9249 | 0 | libcrux_ml_kem_matrix_compute_message_b3(&v, secret_key->secret_as_ntt, |
9250 | 0 | u_as_ntt); |
9251 | 0 | uint8_t ret0[32U]; |
9252 | 0 | libcrux_ml_kem_serialize_compress_then_serialize_message_aa(message, ret0); |
9253 | 0 | memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t)); |
9254 | 0 | } |
9255 | | |
9256 | | /** |
9257 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.decrypt |
9258 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9259 | | with const generics |
9260 | | - K= 3 |
9261 | | - CIPHERTEXT_SIZE= 1088 |
9262 | | - VECTOR_U_ENCODED_SIZE= 960 |
9263 | | - U_COMPRESSION_FACTOR= 10 |
9264 | | - V_COMPRESSION_FACTOR= 4 |
9265 | | */ |
9266 | | static inline void libcrux_ml_kem_ind_cpa_decrypt_43(Eurydice_slice secret_key, |
9267 | | uint8_t *ciphertext, |
9268 | 0 | uint8_t ret[32U]) { |
9269 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U]; |
9270 | 0 | libcrux_ml_kem_ind_cpa_deserialize_secret_key_24(secret_key, secret_as_ntt); |
9271 | | /* Passing arrays by value in Rust generates a copy in C */ |
9272 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_secret_as_ntt[3U]; |
9273 | 0 | memcpy( |
9274 | 0 | copy_of_secret_as_ntt, secret_as_ntt, |
9275 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
9276 | 0 | libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_f8 |
9277 | 0 | secret_key_unpacked; |
9278 | 0 | memcpy( |
9279 | 0 | secret_key_unpacked.secret_as_ntt, copy_of_secret_as_ntt, |
9280 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
9281 | 0 | uint8_t ret0[32U]; |
9282 | 0 | libcrux_ml_kem_ind_cpa_decrypt_unpacked_6d(&secret_key_unpacked, ciphertext, |
9283 | 0 | ret0); |
9284 | 0 | memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t)); |
9285 | 0 | } |
9286 | | |
9287 | | /** |
9288 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
9289 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
9290 | | */ |
9291 | | /** |
9292 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.G_f1 |
9293 | | with const generics |
9294 | | - K= 3 |
9295 | | */ |
9296 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_G_f1_e4( |
9297 | 0 | Eurydice_slice input, uint8_t ret[64U]) { |
9298 | 0 | libcrux_ml_kem_hash_functions_portable_G(input, ret); |
9299 | 0 | } |
9300 | | |
9301 | | /** |
9302 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF |
9303 | | with const generics |
9304 | | - LEN= 32 |
9305 | | */ |
9306 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_2b( |
9307 | 0 | Eurydice_slice input, uint8_t ret[32U]) { |
9308 | 0 | uint8_t digest[32U] = {0U}; |
9309 | 0 | libcrux_sha3_portable_shake256( |
9310 | 0 | Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input); |
9311 | 0 | memcpy(ret, digest, (size_t)32U * sizeof(uint8_t)); |
9312 | 0 | } |
9313 | | |
9314 | | /** |
9315 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
9316 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
9317 | | */ |
9318 | | /** |
9319 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF_f1 |
9320 | | with const generics |
9321 | | - K= 3 |
9322 | | - LEN= 32 |
9323 | | */ |
9324 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_f1_ee( |
9325 | 0 | Eurydice_slice input, uint8_t ret[32U]) { |
9326 | 0 | libcrux_ml_kem_hash_functions_portable_PRF_2b(input, ret); |
9327 | 0 | } |
9328 | | |
9329 | | /** |
9330 | | A monomorphic instance of |
9331 | | libcrux_ml_kem.serialize.deserialize_ring_elements_reduced.closure with types |
9332 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9333 | | - PUBLIC_KEY_SIZE= 1152 |
9334 | | - K= 3 |
9335 | | */ |
9336 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9337 | | libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_closure_cd( |
9338 | 0 | size_t _i) { |
9339 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9340 | 0 | } |
9341 | | |
9342 | | /** |
9343 | | Only use with public values. |
9344 | | |
9345 | | This MUST NOT be used with secret inputs, like its caller |
9346 | | `deserialize_ring_elements_reduced`. |
9347 | | */ |
9348 | | /** |
9349 | | A monomorphic instance of |
9350 | | libcrux_ml_kem.serialize.deserialize_to_reduced_ring_element with types |
9351 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9352 | | |
9353 | | */ |
9354 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9355 | | libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_4c( |
9356 | 0 | Eurydice_slice serialized) { |
9357 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
9358 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9359 | 0 | for (size_t i = (size_t)0U; |
9360 | 0 | i < Eurydice_slice_len(serialized, uint8_t) / (size_t)24U; i++) { |
9361 | 0 | size_t i0 = i; |
9362 | 0 | Eurydice_slice bytes = Eurydice_slice_subslice2( |
9363 | 0 | serialized, i0 * (size_t)24U, i0 * (size_t)24U + (size_t)24U, uint8_t); |
9364 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
9365 | 0 | libcrux_ml_kem_vector_portable_deserialize_12_0d(bytes); |
9366 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
9367 | 0 | libcrux_ml_kem_vector_portable_cond_subtract_3329_0d(coefficient); |
9368 | 0 | re.coefficients[i0] = uu____0; |
9369 | 0 | } |
9370 | 0 | return re; |
9371 | 0 | } |
9372 | | |
9373 | | /** |
9374 | | This function deserializes ring elements and reduces the result by the field |
9375 | | modulus. |
9376 | | |
9377 | | This function MUST NOT be used on secret inputs. |
9378 | | */ |
9379 | | /** |
9380 | | A monomorphic instance of |
9381 | | libcrux_ml_kem.serialize.deserialize_ring_elements_reduced with types |
9382 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9383 | | - PUBLIC_KEY_SIZE= 1152 |
9384 | | - K= 3 |
9385 | | */ |
9386 | | static KRML_MUSTINLINE void |
9387 | | libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_33( |
9388 | | Eurydice_slice public_key, |
9389 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
9390 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 deserialized_pk[3U]; |
9391 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9392 | 0 | deserialized_pk[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9393 | 0 | } |
9394 | 0 | for (size_t i = (size_t)0U; |
9395 | 0 | i < Eurydice_slice_len(public_key, uint8_t) / |
9396 | 0 | LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT; |
9397 | 0 | i++) { |
9398 | 0 | size_t i0 = i; |
9399 | 0 | Eurydice_slice ring_element = Eurydice_slice_subslice2( |
9400 | 0 | public_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
9401 | 0 | i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT + |
9402 | 0 | LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
9403 | 0 | uint8_t); |
9404 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____0 = |
9405 | 0 | libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_4c( |
9406 | 0 | ring_element); |
9407 | 0 | deserialized_pk[i0] = uu____0; |
9408 | 0 | } |
9409 | 0 | memcpy( |
9410 | 0 | ret, deserialized_pk, |
9411 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
9412 | 0 | } |
9413 | | |
9414 | | /** |
9415 | | A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A.closure.closure |
9416 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
9417 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
9418 | | generics |
9419 | | - K= 3 |
9420 | | */ |
9421 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9422 | 0 | libcrux_ml_kem_matrix_sample_matrix_A_closure_closure_78(size_t _j) { |
9423 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9424 | 0 | } |
9425 | | |
9426 | | /** |
9427 | | A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A.closure |
9428 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
9429 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
9430 | | generics |
9431 | | - K= 3 |
9432 | | */ |
9433 | | static inline void libcrux_ml_kem_matrix_sample_matrix_A_closure_4b( |
9434 | 0 | size_t _i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
9435 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9436 | 0 | ret[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9437 | 0 | } |
9438 | 0 | } |
9439 | | |
9440 | | /** |
9441 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PortableHash |
9442 | | with const generics |
9443 | | - $3size_t |
9444 | | */ |
9445 | | typedef struct libcrux_ml_kem_hash_functions_portable_PortableHash_58_s { |
9446 | | libcrux_sha3_generic_keccak_KeccakState_48 shake128_state[3U]; |
9447 | | } libcrux_ml_kem_hash_functions_portable_PortableHash_58; |
9448 | | |
9449 | | /** |
9450 | | A monomorphic instance of |
9451 | | libcrux_ml_kem.hash_functions.portable.shake128_init_absorb with const generics |
9452 | | - K= 3 |
9453 | | */ |
9454 | | static KRML_MUSTINLINE libcrux_ml_kem_hash_functions_portable_PortableHash_58 |
9455 | | libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_b7( |
9456 | 0 | uint8_t input[3U][34U]) { |
9457 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 shake128_state[3U]; |
9458 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9459 | 0 | shake128_state[i] = libcrux_sha3_portable_incremental_shake128_init(); |
9460 | 0 | } |
9461 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9462 | 0 | size_t i0 = i; |
9463 | 0 | libcrux_sha3_portable_incremental_shake128_absorb_final( |
9464 | 0 | &shake128_state[i0], |
9465 | 0 | Eurydice_array_to_slice((size_t)34U, input[i0], uint8_t)); |
9466 | 0 | } |
9467 | | /* Passing arrays by value in Rust generates a copy in C */ |
9468 | 0 | libcrux_sha3_generic_keccak_KeccakState_48 copy_of_shake128_state[3U]; |
9469 | 0 | memcpy(copy_of_shake128_state, shake128_state, |
9470 | 0 | (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_48)); |
9471 | 0 | libcrux_ml_kem_hash_functions_portable_PortableHash_58 lit; |
9472 | 0 | memcpy(lit.shake128_state, copy_of_shake128_state, |
9473 | 0 | (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_48)); |
9474 | 0 | return lit; |
9475 | 0 | } |
9476 | | |
9477 | | /** |
9478 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
9479 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
9480 | | */ |
9481 | | /** |
9482 | | A monomorphic instance of |
9483 | | libcrux_ml_kem.hash_functions.portable.shake128_init_absorb_f1 with const |
9484 | | generics |
9485 | | - K= 3 |
9486 | | */ |
9487 | | static KRML_MUSTINLINE libcrux_ml_kem_hash_functions_portable_PortableHash_58 |
9488 | | libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_f1_8c( |
9489 | 0 | uint8_t input[3U][34U]) { |
9490 | | /* Passing arrays by value in Rust generates a copy in C */ |
9491 | 0 | uint8_t copy_of_input[3U][34U]; |
9492 | 0 | memcpy(copy_of_input, input, (size_t)3U * sizeof(uint8_t[34U])); |
9493 | 0 | return libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_b7( |
9494 | 0 | copy_of_input); |
9495 | 0 | } |
9496 | | |
9497 | | /** |
9498 | | A monomorphic instance of |
9499 | | libcrux_ml_kem.hash_functions.portable.shake128_squeeze_three_blocks with const |
9500 | | generics |
9501 | | - K= 3 |
9502 | | */ |
9503 | | static KRML_MUSTINLINE void |
9504 | | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_ca( |
9505 | | libcrux_ml_kem_hash_functions_portable_PortableHash_58 *st, |
9506 | 0 | uint8_t ret[3U][504U]) { |
9507 | 0 | uint8_t out[3U][504U] = {{0U}}; |
9508 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9509 | 0 | size_t i0 = i; |
9510 | 0 | libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks( |
9511 | 0 | &st->shake128_state[i0], |
9512 | 0 | Eurydice_array_to_slice((size_t)504U, out[i0], uint8_t)); |
9513 | 0 | } |
9514 | 0 | memcpy(ret, out, (size_t)3U * sizeof(uint8_t[504U])); |
9515 | 0 | } |
9516 | | |
9517 | | /** |
9518 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
9519 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
9520 | | */ |
9521 | | /** |
9522 | | A monomorphic instance of |
9523 | | libcrux_ml_kem.hash_functions.portable.shake128_squeeze_three_blocks_f1 with |
9524 | | const generics |
9525 | | - K= 3 |
9526 | | */ |
9527 | | static KRML_MUSTINLINE void |
9528 | | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_f1_69( |
9529 | | libcrux_ml_kem_hash_functions_portable_PortableHash_58 *self, |
9530 | 0 | uint8_t ret[3U][504U]) { |
9531 | 0 | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_ca(self, |
9532 | 0 | ret); |
9533 | 0 | } |
9534 | | |
9535 | | /** |
9536 | | If `bytes` contains a set of uniformly random bytes, this function |
9537 | | uniformly samples a ring element `â` that is treated as being the NTT |
9538 | | representation of the corresponding polynomial `a`. |
9539 | | |
9540 | | Since rejection sampling is used, it is possible the supplied bytes are |
9541 | | not enough to sample the element, in which case an `Err` is returned and the |
9542 | | caller must try again with a fresh set of bytes. |
9543 | | |
9544 | | This function <strong>partially</strong> implements <strong>Algorithm |
9545 | | 6</strong> of the NIST FIPS 203 standard, We say "partially" because this |
9546 | | implementation only accepts a finite set of bytes as input and returns an error |
9547 | | if the set is not enough; Algorithm 6 of the FIPS 203 standard on the other |
9548 | | hand samples from an infinite stream of bytes until the ring element is filled. |
9549 | | Algorithm 6 is reproduced below: |
9550 | | |
9551 | | ```plaintext |
9552 | | Input: byte stream B ∈ 𝔹*. |
9553 | | Output: array â ∈ ℤ₂₅₆. |
9554 | | |
9555 | | i ← 0 |
9556 | | j ← 0 |
9557 | | while j < 256 do |
9558 | | d₁ ← B[i] + 256·(B[i+1] mod 16) |
9559 | | d₂ ← ⌊B[i+1]/16⌋ + 16·B[i+2] |
9560 | | if d₁ < q then |
9561 | | â[j] ← d₁ |
9562 | | j ← j + 1 |
9563 | | end if |
9564 | | if d₂ < q and j < 256 then |
9565 | | â[j] ← d₂ |
9566 | | j ← j + 1 |
9567 | | end if |
9568 | | i ← i + 3 |
9569 | | end while |
9570 | | return â |
9571 | | ``` |
9572 | | |
9573 | | The NIST FIPS 203 standard can be found at |
9574 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
9575 | | */ |
9576 | | /** |
9577 | | A monomorphic instance of |
9578 | | libcrux_ml_kem.sampling.sample_from_uniform_distribution_next with types |
9579 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9580 | | - K= 3 |
9581 | | - N= 504 |
9582 | | */ |
9583 | | static KRML_MUSTINLINE bool |
9584 | | libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db( |
9585 | | uint8_t randomness[3U][504U], size_t *sampled_coefficients, |
9586 | 0 | int16_t (*out)[272U]) { |
9587 | 0 | for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) { |
9588 | 0 | size_t i1 = i0; |
9589 | 0 | for (size_t i = (size_t)0U; i < (size_t)504U / (size_t)24U; i++) { |
9590 | 0 | size_t r = i; |
9591 | 0 | if (sampled_coefficients[i1] < |
9592 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) { |
9593 | 0 | Eurydice_slice uu____0 = |
9594 | 0 | Eurydice_array_to_subslice2(randomness[i1], r * (size_t)24U, |
9595 | 0 | r * (size_t)24U + (size_t)24U, uint8_t); |
9596 | 0 | size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_0d( |
9597 | 0 | uu____0, Eurydice_array_to_subslice2( |
9598 | 0 | out[i1], sampled_coefficients[i1], |
9599 | 0 | sampled_coefficients[i1] + (size_t)16U, int16_t)); |
9600 | 0 | size_t uu____1 = i1; |
9601 | 0 | sampled_coefficients[uu____1] = sampled_coefficients[uu____1] + sampled; |
9602 | 0 | } |
9603 | 0 | } |
9604 | 0 | } |
9605 | 0 | bool done = true; |
9606 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9607 | 0 | size_t i0 = i; |
9608 | 0 | if (sampled_coefficients[i0] >= |
9609 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) { |
9610 | 0 | sampled_coefficients[i0] = |
9611 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT; |
9612 | 0 | } else { |
9613 | 0 | done = false; |
9614 | 0 | } |
9615 | 0 | } |
9616 | 0 | return done; |
9617 | 0 | } |
9618 | | |
9619 | | /** |
9620 | | A monomorphic instance of |
9621 | | libcrux_ml_kem.hash_functions.portable.shake128_squeeze_block with const |
9622 | | generics |
9623 | | - K= 3 |
9624 | | */ |
9625 | | static KRML_MUSTINLINE void |
9626 | | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_dd( |
9627 | | libcrux_ml_kem_hash_functions_portable_PortableHash_58 *st, |
9628 | 0 | uint8_t ret[3U][168U]) { |
9629 | 0 | uint8_t out[3U][168U] = {{0U}}; |
9630 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9631 | 0 | size_t i0 = i; |
9632 | 0 | libcrux_sha3_portable_incremental_shake128_squeeze_next_block( |
9633 | 0 | &st->shake128_state[i0], |
9634 | 0 | Eurydice_array_to_slice((size_t)168U, out[i0], uint8_t)); |
9635 | 0 | } |
9636 | 0 | memcpy(ret, out, (size_t)3U * sizeof(uint8_t[168U])); |
9637 | 0 | } |
9638 | | |
9639 | | /** |
9640 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
9641 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
9642 | | */ |
9643 | | /** |
9644 | | A monomorphic instance of |
9645 | | libcrux_ml_kem.hash_functions.portable.shake128_squeeze_block_f1 with const |
9646 | | generics |
9647 | | - K= 3 |
9648 | | */ |
9649 | | static KRML_MUSTINLINE void |
9650 | | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_f1_60( |
9651 | | libcrux_ml_kem_hash_functions_portable_PortableHash_58 *self, |
9652 | 0 | uint8_t ret[3U][168U]) { |
9653 | 0 | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_dd(self, ret); |
9654 | 0 | } |
9655 | | |
9656 | | /** |
9657 | | If `bytes` contains a set of uniformly random bytes, this function |
9658 | | uniformly samples a ring element `â` that is treated as being the NTT |
9659 | | representation of the corresponding polynomial `a`. |
9660 | | |
9661 | | Since rejection sampling is used, it is possible the supplied bytes are |
9662 | | not enough to sample the element, in which case an `Err` is returned and the |
9663 | | caller must try again with a fresh set of bytes. |
9664 | | |
9665 | | This function <strong>partially</strong> implements <strong>Algorithm |
9666 | | 6</strong> of the NIST FIPS 203 standard, We say "partially" because this |
9667 | | implementation only accepts a finite set of bytes as input and returns an error |
9668 | | if the set is not enough; Algorithm 6 of the FIPS 203 standard on the other |
9669 | | hand samples from an infinite stream of bytes until the ring element is filled. |
9670 | | Algorithm 6 is reproduced below: |
9671 | | |
9672 | | ```plaintext |
9673 | | Input: byte stream B ∈ 𝔹*. |
9674 | | Output: array â ∈ ℤ₂₅₆. |
9675 | | |
9676 | | i ← 0 |
9677 | | j ← 0 |
9678 | | while j < 256 do |
9679 | | d₁ ← B[i] + 256·(B[i+1] mod 16) |
9680 | | d₂ ← ⌊B[i+1]/16⌋ + 16·B[i+2] |
9681 | | if d₁ < q then |
9682 | | â[j] ← d₁ |
9683 | | j ← j + 1 |
9684 | | end if |
9685 | | if d₂ < q and j < 256 then |
9686 | | â[j] ← d₂ |
9687 | | j ← j + 1 |
9688 | | end if |
9689 | | i ← i + 3 |
9690 | | end while |
9691 | | return â |
9692 | | ``` |
9693 | | |
9694 | | The NIST FIPS 203 standard can be found at |
9695 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
9696 | | */ |
9697 | | /** |
9698 | | A monomorphic instance of |
9699 | | libcrux_ml_kem.sampling.sample_from_uniform_distribution_next with types |
9700 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9701 | | - K= 3 |
9702 | | - N= 168 |
9703 | | */ |
9704 | | static KRML_MUSTINLINE bool |
9705 | | libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db0( |
9706 | | uint8_t randomness[3U][168U], size_t *sampled_coefficients, |
9707 | 0 | int16_t (*out)[272U]) { |
9708 | 0 | for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) { |
9709 | 0 | size_t i1 = i0; |
9710 | 0 | for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)24U; i++) { |
9711 | 0 | size_t r = i; |
9712 | 0 | if (sampled_coefficients[i1] < |
9713 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) { |
9714 | 0 | Eurydice_slice uu____0 = |
9715 | 0 | Eurydice_array_to_subslice2(randomness[i1], r * (size_t)24U, |
9716 | 0 | r * (size_t)24U + (size_t)24U, uint8_t); |
9717 | 0 | size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_0d( |
9718 | 0 | uu____0, Eurydice_array_to_subslice2( |
9719 | 0 | out[i1], sampled_coefficients[i1], |
9720 | 0 | sampled_coefficients[i1] + (size_t)16U, int16_t)); |
9721 | 0 | size_t uu____1 = i1; |
9722 | 0 | sampled_coefficients[uu____1] = sampled_coefficients[uu____1] + sampled; |
9723 | 0 | } |
9724 | 0 | } |
9725 | 0 | } |
9726 | 0 | bool done = true; |
9727 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9728 | 0 | size_t i0 = i; |
9729 | 0 | if (sampled_coefficients[i0] >= |
9730 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) { |
9731 | 0 | sampled_coefficients[i0] = |
9732 | 0 | LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT; |
9733 | 0 | } else { |
9734 | 0 | done = false; |
9735 | 0 | } |
9736 | 0 | } |
9737 | 0 | return done; |
9738 | 0 | } |
9739 | | |
9740 | | /** |
9741 | | This function found in impl |
9742 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
9743 | | */ |
9744 | | /** |
9745 | | A monomorphic instance of libcrux_ml_kem.polynomial.from_i16_array_89 |
9746 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
9747 | | with const generics |
9748 | | |
9749 | | */ |
9750 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9751 | 0 | libcrux_ml_kem_polynomial_from_i16_array_89_c1(Eurydice_slice a) { |
9752 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result = |
9753 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9754 | 0 | for (size_t i = (size_t)0U; |
9755 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
9756 | 0 | size_t i0 = i; |
9757 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
9758 | 0 | libcrux_ml_kem_vector_portable_from_i16_array_0d( |
9759 | 0 | Eurydice_slice_subslice2(a, i0 * (size_t)16U, |
9760 | 0 | (i0 + (size_t)1U) * (size_t)16U, int16_t)); |
9761 | 0 | result.coefficients[i0] = uu____0; |
9762 | 0 | } |
9763 | 0 | return result; |
9764 | 0 | } |
9765 | | |
9766 | | /** |
9767 | | A monomorphic instance of libcrux_ml_kem.sampling.sample_from_xof.closure |
9768 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
9769 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
9770 | | generics |
9771 | | - K= 3 |
9772 | | */ |
9773 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9774 | 0 | libcrux_ml_kem_sampling_sample_from_xof_closure_04(int16_t s[272U]) { |
9775 | 0 | return libcrux_ml_kem_polynomial_from_i16_array_89_c1( |
9776 | 0 | Eurydice_array_to_subslice2(s, (size_t)0U, (size_t)256U, int16_t)); |
9777 | 0 | } |
9778 | | |
9779 | | /** |
9780 | | A monomorphic instance of libcrux_ml_kem.sampling.sample_from_xof |
9781 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
9782 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
9783 | | generics |
9784 | | - K= 3 |
9785 | | */ |
9786 | | static KRML_MUSTINLINE void libcrux_ml_kem_sampling_sample_from_xof_3f( |
9787 | | uint8_t seeds[3U][34U], |
9788 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
9789 | 0 | size_t sampled_coefficients[3U] = {0U}; |
9790 | 0 | int16_t out[3U][272U] = {{0U}}; |
9791 | | /* Passing arrays by value in Rust generates a copy in C */ |
9792 | 0 | uint8_t copy_of_seeds[3U][34U]; |
9793 | 0 | memcpy(copy_of_seeds, seeds, (size_t)3U * sizeof(uint8_t[34U])); |
9794 | 0 | libcrux_ml_kem_hash_functions_portable_PortableHash_58 xof_state = |
9795 | 0 | libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_f1_8c( |
9796 | 0 | copy_of_seeds); |
9797 | 0 | uint8_t randomness0[3U][504U]; |
9798 | 0 | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_f1_69( |
9799 | 0 | &xof_state, randomness0); |
9800 | | /* Passing arrays by value in Rust generates a copy in C */ |
9801 | 0 | uint8_t copy_of_randomness0[3U][504U]; |
9802 | 0 | memcpy(copy_of_randomness0, randomness0, (size_t)3U * sizeof(uint8_t[504U])); |
9803 | 0 | bool done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db( |
9804 | 0 | copy_of_randomness0, sampled_coefficients, out); |
9805 | 0 | while (true) { |
9806 | 0 | if (done) { |
9807 | 0 | break; |
9808 | 0 | } else { |
9809 | 0 | uint8_t randomness[3U][168U]; |
9810 | 0 | libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_f1_60( |
9811 | 0 | &xof_state, randomness); |
9812 | | /* Passing arrays by value in Rust generates a copy in C */ |
9813 | 0 | uint8_t copy_of_randomness[3U][168U]; |
9814 | 0 | memcpy(copy_of_randomness, randomness, |
9815 | 0 | (size_t)3U * sizeof(uint8_t[168U])); |
9816 | 0 | done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db0( |
9817 | 0 | copy_of_randomness, sampled_coefficients, out); |
9818 | 0 | } |
9819 | 0 | } |
9820 | | /* Passing arrays by value in Rust generates a copy in C */ |
9821 | 0 | int16_t copy_of_out[3U][272U]; |
9822 | 0 | memcpy(copy_of_out, out, (size_t)3U * sizeof(int16_t[272U])); |
9823 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret0[3U]; |
9824 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9825 | 0 | ret0[i] = |
9826 | 0 | libcrux_ml_kem_sampling_sample_from_xof_closure_04(copy_of_out[i]); |
9827 | 0 | } |
9828 | 0 | memcpy( |
9829 | 0 | ret, ret0, |
9830 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
9831 | 0 | } |
9832 | | |
9833 | | /** |
9834 | | A monomorphic instance of libcrux_ml_kem.matrix.sample_matrix_A |
9835 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
9836 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
9837 | | generics |
9838 | | - K= 3 |
9839 | | */ |
9840 | | static KRML_MUSTINLINE void libcrux_ml_kem_matrix_sample_matrix_A_38( |
9841 | | uint8_t seed[34U], bool transpose, |
9842 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U][3U]) { |
9843 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U]; |
9844 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9845 | 0 | libcrux_ml_kem_matrix_sample_matrix_A_closure_4b(i, A_transpose[i]); |
9846 | 0 | } |
9847 | 0 | for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) { |
9848 | 0 | size_t i1 = i0; |
9849 | | /* Passing arrays by value in Rust generates a copy in C */ |
9850 | 0 | uint8_t copy_of_seed[34U]; |
9851 | 0 | memcpy(copy_of_seed, seed, (size_t)34U * sizeof(uint8_t)); |
9852 | 0 | uint8_t seeds[3U][34U]; |
9853 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9854 | 0 | memcpy(seeds[i], copy_of_seed, (size_t)34U * sizeof(uint8_t)); |
9855 | 0 | } |
9856 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9857 | 0 | size_t j = i; |
9858 | 0 | seeds[j][32U] = (uint8_t)i1; |
9859 | 0 | seeds[j][33U] = (uint8_t)j; |
9860 | 0 | } |
9861 | | /* Passing arrays by value in Rust generates a copy in C */ |
9862 | 0 | uint8_t copy_of_seeds[3U][34U]; |
9863 | 0 | memcpy(copy_of_seeds, seeds, (size_t)3U * sizeof(uint8_t[34U])); |
9864 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 sampled[3U]; |
9865 | 0 | libcrux_ml_kem_sampling_sample_from_xof_3f(copy_of_seeds, sampled); |
9866 | 0 | for (size_t i = (size_t)0U; |
9867 | 0 | i < Eurydice_slice_len( |
9868 | 0 | Eurydice_array_to_slice( |
9869 | 0 | (size_t)3U, sampled, |
9870 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0), |
9871 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0); |
9872 | 0 | i++) { |
9873 | 0 | size_t j = i; |
9874 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 sample = sampled[j]; |
9875 | 0 | if (transpose) { |
9876 | 0 | A_transpose[j][i1] = sample; |
9877 | 0 | } else { |
9878 | 0 | A_transpose[i1][j] = sample; |
9879 | 0 | } |
9880 | 0 | } |
9881 | 0 | } |
9882 | 0 | memcpy(ret, A_transpose, |
9883 | 0 | (size_t)3U * |
9884 | 0 | sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U])); |
9885 | 0 | } |
9886 | | |
9887 | | /** |
9888 | | A monomorphic instance of K. |
9889 | | with types libcrux_ml_kem_polynomial_PolynomialRingElement |
9890 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector[3size_t], uint8_t |
9891 | | |
9892 | | */ |
9893 | | typedef struct tuple_b0_s { |
9894 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 fst[3U]; |
9895 | | uint8_t snd; |
9896 | | } tuple_b0; |
9897 | | |
9898 | | /** |
9899 | | A monomorphic instance of |
9900 | | libcrux_ml_kem.ind_cpa.sample_vector_cbd_then_ntt.closure with types |
9901 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
9902 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
9903 | | generics |
9904 | | - K= 3 |
9905 | | - ETA= 2 |
9906 | | - ETA_RANDOMNESS_SIZE= 128 |
9907 | | */ |
9908 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
9909 | 0 | libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_closure_f7(size_t _i) { |
9910 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
9911 | 0 | } |
9912 | | |
9913 | | /** |
9914 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRFxN |
9915 | | with const generics |
9916 | | - K= 3 |
9917 | | - LEN= 128 |
9918 | | */ |
9919 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRFxN_c5( |
9920 | 0 | uint8_t (*input)[33U], uint8_t ret[3U][128U]) { |
9921 | 0 | uint8_t out[3U][128U] = {{0U}}; |
9922 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
9923 | 0 | size_t i0 = i; |
9924 | 0 | libcrux_sha3_portable_shake256( |
9925 | 0 | Eurydice_array_to_slice((size_t)128U, out[i0], uint8_t), |
9926 | 0 | Eurydice_array_to_slice((size_t)33U, input[i0], uint8_t)); |
9927 | 0 | } |
9928 | 0 | memcpy(ret, out, (size_t)3U * sizeof(uint8_t[128U])); |
9929 | 0 | } |
9930 | | |
9931 | | /** |
9932 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
9933 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
9934 | | */ |
9935 | | /** |
9936 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRFxN_f1 |
9937 | | with const generics |
9938 | | - K= 3 |
9939 | | - LEN= 128 |
9940 | | */ |
9941 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93( |
9942 | 0 | uint8_t (*input)[33U], uint8_t ret[3U][128U]) { |
9943 | 0 | libcrux_ml_kem_hash_functions_portable_PRFxN_c5(input, ret); |
9944 | 0 | } |
9945 | | |
9946 | | /** |
9947 | | Given a series of uniformly random bytes in `randomness`, for some number |
9948 | | `eta`, the `sample_from_binomial_distribution_{eta}` functions sample a ring |
9949 | | element from a binomial distribution centered at 0 that uses two sets of `eta` |
9950 | | coin flips. If, for example, `eta = ETA`, each ring coefficient is a value `v` |
9951 | | such such that `v ∈ {-ETA, -ETA + 1, ..., 0, ..., ETA + 1, ETA}` and: |
9952 | | |
9953 | | ```plaintext |
9954 | | - If v < 0, Pr[v] = Pr[-v] |
9955 | | - If v >= 0, Pr[v] = BINOMIAL_COEFFICIENT(2 * ETA; ETA - v) / 2 ^ (2 * ETA) |
9956 | | ``` |
9957 | | |
9958 | | The values `v < 0` are mapped to the appropriate `KyberFieldElement`. |
9959 | | |
9960 | | The expected value is: |
9961 | | |
9962 | | ```plaintext |
9963 | | E[X] = (-ETA)Pr[-ETA] + (-(ETA - 1))Pr[-(ETA - 1)] + ... + (ETA - 1)Pr[ETA - 1] |
9964 | | + (ETA)Pr[ETA] = 0 since Pr[-v] = Pr[v] when v < 0. |
9965 | | ``` |
9966 | | |
9967 | | And the variance is: |
9968 | | |
9969 | | ```plaintext |
9970 | | Var(X) = E[(X - E[X])^2] |
9971 | | = E[X^2] |
9972 | | = sum_(v=-ETA to ETA)v^2 * (BINOMIAL_COEFFICIENT(2 * ETA; ETA - v) / |
9973 | | 2^(2 * ETA)) = ETA / 2 |
9974 | | ``` |
9975 | | |
9976 | | This function implements <strong>Algorithm 7</strong> of the NIST FIPS 203 |
9977 | | standard, which is reproduced below: |
9978 | | |
9979 | | ```plaintext |
9980 | | Input: byte array B ∈ 𝔹^{64η}. |
9981 | | Output: array f ∈ ℤ₂₅₆. |
9982 | | |
9983 | | b ← BytesToBits(B) |
9984 | | for (i ← 0; i < 256; i++) |
9985 | | x ← ∑(j=0 to η - 1) b[2iη + j] |
9986 | | y ← ∑(j=0 to η - 1) b[2iη + η + j] |
9987 | | f[i] ← x−y mod q |
9988 | | end for |
9989 | | return f |
9990 | | ``` |
9991 | | |
9992 | | The NIST FIPS 203 standard can be found at |
9993 | | <https://csrc.nist.gov/pubs/fips/203/ipd>. |
9994 | | */ |
9995 | | /** |
9996 | | A monomorphic instance of |
9997 | | libcrux_ml_kem.sampling.sample_from_binomial_distribution_2 with types |
9998 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
9999 | | |
10000 | | */ |
10001 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10002 | | libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_85( |
10003 | 0 | Eurydice_slice randomness) { |
10004 | 0 | int16_t sampled_i16s[256U] = {0U}; |
10005 | 0 | for (size_t i0 = (size_t)0U; |
10006 | 0 | i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)4U; i0++) { |
10007 | 0 | size_t chunk_number = i0; |
10008 | 0 | Eurydice_slice byte_chunk = Eurydice_slice_subslice2( |
10009 | 0 | randomness, chunk_number * (size_t)4U, |
10010 | 0 | chunk_number * (size_t)4U + (size_t)4U, uint8_t); |
10011 | 0 | uint32_t random_bits_as_u32 = |
10012 | 0 | (((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t, |
10013 | 0 | uint8_t *) | |
10014 | 0 | (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t, |
10015 | 0 | uint8_t *) |
10016 | 0 | << 8U) | |
10017 | 0 | (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t, |
10018 | 0 | uint8_t *) |
10019 | 0 | << 16U) | |
10020 | 0 | (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)3U, uint8_t, |
10021 | 0 | uint8_t *) |
10022 | 0 | << 24U; |
10023 | 0 | uint32_t even_bits = random_bits_as_u32 & 1431655765U; |
10024 | 0 | uint32_t odd_bits = random_bits_as_u32 >> 1U & 1431655765U; |
10025 | 0 | uint32_t coin_toss_outcomes = even_bits + odd_bits; |
10026 | 0 | for (uint32_t i = 0U; i < CORE_NUM__U32_8__BITS / 4U; i++) { |
10027 | 0 | uint32_t outcome_set = i; |
10028 | 0 | uint32_t outcome_set0 = outcome_set * 4U; |
10029 | 0 | int16_t outcome_1 = |
10030 | 0 | (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 3U); |
10031 | 0 | int16_t outcome_2 = |
10032 | 0 | (int16_t)(coin_toss_outcomes >> (uint32_t)(outcome_set0 + 2U) & 3U); |
10033 | 0 | size_t offset = (size_t)(outcome_set0 >> 2U); |
10034 | 0 | sampled_i16s[(size_t)8U * chunk_number + offset] = outcome_1 - outcome_2; |
10035 | 0 | } |
10036 | 0 | } |
10037 | 0 | return libcrux_ml_kem_polynomial_from_i16_array_89_c1( |
10038 | 0 | Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t)); |
10039 | 0 | } |
10040 | | |
10041 | | /** |
10042 | | A monomorphic instance of |
10043 | | libcrux_ml_kem.sampling.sample_from_binomial_distribution_3 with types |
10044 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
10045 | | |
10046 | | */ |
10047 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10048 | | libcrux_ml_kem_sampling_sample_from_binomial_distribution_3_eb( |
10049 | 0 | Eurydice_slice randomness) { |
10050 | 0 | int16_t sampled_i16s[256U] = {0U}; |
10051 | 0 | for (size_t i0 = (size_t)0U; |
10052 | 0 | i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)3U; i0++) { |
10053 | 0 | size_t chunk_number = i0; |
10054 | 0 | Eurydice_slice byte_chunk = Eurydice_slice_subslice2( |
10055 | 0 | randomness, chunk_number * (size_t)3U, |
10056 | 0 | chunk_number * (size_t)3U + (size_t)3U, uint8_t); |
10057 | 0 | uint32_t random_bits_as_u24 = |
10058 | 0 | ((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t, |
10059 | 0 | uint8_t *) | |
10060 | 0 | (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t, |
10061 | 0 | uint8_t *) |
10062 | 0 | << 8U) | |
10063 | 0 | (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t, |
10064 | 0 | uint8_t *) |
10065 | 0 | << 16U; |
10066 | 0 | uint32_t first_bits = random_bits_as_u24 & 2396745U; |
10067 | 0 | uint32_t second_bits = random_bits_as_u24 >> 1U & 2396745U; |
10068 | 0 | uint32_t third_bits = random_bits_as_u24 >> 2U & 2396745U; |
10069 | 0 | uint32_t coin_toss_outcomes = first_bits + second_bits + third_bits; |
10070 | 0 | for (int32_t i = (int32_t)0; i < (int32_t)24 / (int32_t)6; i++) { |
10071 | 0 | int32_t outcome_set = i; |
10072 | 0 | int32_t outcome_set0 = outcome_set * (int32_t)6; |
10073 | 0 | int16_t outcome_1 = |
10074 | 0 | (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 7U); |
10075 | 0 | int16_t outcome_2 = (int16_t)(coin_toss_outcomes >> |
10076 | 0 | (uint32_t)(outcome_set0 + (int32_t)3) & |
10077 | 0 | 7U); |
10078 | 0 | size_t offset = (size_t)(outcome_set0 / (int32_t)6); |
10079 | 0 | sampled_i16s[(size_t)4U * chunk_number + offset] = outcome_1 - outcome_2; |
10080 | 0 | } |
10081 | 0 | } |
10082 | 0 | return libcrux_ml_kem_polynomial_from_i16_array_89_c1( |
10083 | 0 | Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t)); |
10084 | 0 | } |
10085 | | |
10086 | | /** |
10087 | | A monomorphic instance of |
10088 | | libcrux_ml_kem.sampling.sample_from_binomial_distribution with types |
10089 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
10090 | | - ETA= 2 |
10091 | | */ |
10092 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10093 | | libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6( |
10094 | 0 | Eurydice_slice randomness) { |
10095 | 0 | return libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_85( |
10096 | 0 | randomness); |
10097 | 0 | } |
10098 | | |
10099 | | /** |
10100 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_at_layer_7 |
10101 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10102 | | with const generics |
10103 | | |
10104 | | */ |
10105 | | static KRML_MUSTINLINE void libcrux_ml_kem_ntt_ntt_at_layer_7_f4( |
10106 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) { |
10107 | 0 | size_t step = LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT / (size_t)2U; |
10108 | 0 | for (size_t i = (size_t)0U; i < step; i++) { |
10109 | 0 | size_t j = i; |
10110 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector t = |
10111 | 0 | libcrux_ml_kem_vector_portable_multiply_by_constant_0d( |
10112 | 0 | re->coefficients[j + step], (int16_t)-1600); |
10113 | 0 | re->coefficients[j + step] = |
10114 | 0 | libcrux_ml_kem_vector_portable_sub_0d(re->coefficients[j], &t); |
10115 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 = |
10116 | 0 | libcrux_ml_kem_vector_portable_add_0d(re->coefficients[j], &t); |
10117 | 0 | re->coefficients[j] = uu____1; |
10118 | 0 | } |
10119 | 0 | } |
10120 | | |
10121 | | /** |
10122 | | A monomorphic instance of libcrux_ml_kem.ntt.ntt_binomially_sampled_ring_element |
10123 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10124 | | with const generics |
10125 | | |
10126 | | */ |
10127 | | static KRML_MUSTINLINE void |
10128 | | libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_0f( |
10129 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) { |
10130 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_7_f4(re); |
10131 | 0 | size_t zeta_i = (size_t)1U; |
10132 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)6U, |
10133 | 0 | (size_t)3U); |
10134 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)5U, |
10135 | 0 | (size_t)3U); |
10136 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)4U, |
10137 | 0 | (size_t)3U); |
10138 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_3_fd(&zeta_i, re, (size_t)3U, (size_t)3U); |
10139 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_2_ad(&zeta_i, re, (size_t)2U, (size_t)3U); |
10140 | 0 | libcrux_ml_kem_ntt_ntt_at_layer_1_a2(&zeta_i, re, (size_t)1U, (size_t)3U); |
10141 | 0 | libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re); |
10142 | 0 | } |
10143 | | |
10144 | | /** |
10145 | | Sample a vector of ring elements from a centered binomial distribution and |
10146 | | convert them into their NTT representations. |
10147 | | */ |
10148 | | /** |
10149 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_vector_cbd_then_ntt |
10150 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
10151 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
10152 | | generics |
10153 | | - K= 3 |
10154 | | - ETA= 2 |
10155 | | - ETA_RANDOMNESS_SIZE= 128 |
10156 | | */ |
10157 | | static KRML_MUSTINLINE tuple_b0 |
10158 | | libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(uint8_t prf_input[33U], |
10159 | 0 | uint8_t domain_separator) { |
10160 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re_as_ntt[3U]; |
10161 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10162 | 0 | re_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10163 | 0 | } |
10164 | | /* Passing arrays by value in Rust generates a copy in C */ |
10165 | 0 | uint8_t copy_of_prf_input[33U]; |
10166 | 0 | memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t)); |
10167 | 0 | uint8_t prf_inputs[3U][33U]; |
10168 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10169 | 0 | memcpy(prf_inputs[i], copy_of_prf_input, (size_t)33U * sizeof(uint8_t)); |
10170 | 0 | } |
10171 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10172 | 0 | size_t i0 = i; |
10173 | 0 | prf_inputs[i0][32U] = domain_separator; |
10174 | 0 | domain_separator = (uint32_t)domain_separator + 1U; |
10175 | 0 | } |
10176 | 0 | uint8_t prf_outputs[3U][128U]; |
10177 | 0 | libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93(prf_inputs, prf_outputs); |
10178 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10179 | 0 | size_t i0 = i; |
10180 | 0 | re_as_ntt[i0] = |
10181 | 0 | libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6( |
10182 | 0 | Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t)); |
10183 | 0 | libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_0f(&re_as_ntt[i0]); |
10184 | 0 | } |
10185 | | /* Passing arrays by value in Rust generates a copy in C */ |
10186 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_re_as_ntt[3U]; |
10187 | 0 | memcpy( |
10188 | 0 | copy_of_re_as_ntt, re_as_ntt, |
10189 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10190 | 0 | tuple_b0 lit; |
10191 | 0 | memcpy( |
10192 | 0 | lit.fst, copy_of_re_as_ntt, |
10193 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10194 | 0 | lit.snd = domain_separator; |
10195 | 0 | return lit; |
10196 | 0 | } |
10197 | | |
10198 | | /** |
10199 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_ring_element_cbd.closure |
10200 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
10201 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
10202 | | generics |
10203 | | - K= 3 |
10204 | | - ETA2_RANDOMNESS_SIZE= 128 |
10205 | | - ETA2= 2 |
10206 | | */ |
10207 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10208 | 0 | libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_closure_77(size_t _i) { |
10209 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10210 | 0 | } |
10211 | | |
10212 | | /** |
10213 | | Sample a vector of ring elements from a centered binomial distribution. |
10214 | | */ |
10215 | | /** |
10216 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.sample_ring_element_cbd |
10217 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
10218 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
10219 | | generics |
10220 | | - K= 3 |
10221 | | - ETA2_RANDOMNESS_SIZE= 128 |
10222 | | - ETA2= 2 |
10223 | | */ |
10224 | | static KRML_MUSTINLINE tuple_b0 |
10225 | | libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_ac(uint8_t prf_input[33U], |
10226 | 0 | uint8_t domain_separator) { |
10227 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_1[3U]; |
10228 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10229 | 0 | error_1[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10230 | 0 | } |
10231 | | /* Passing arrays by value in Rust generates a copy in C */ |
10232 | 0 | uint8_t copy_of_prf_input[33U]; |
10233 | 0 | memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t)); |
10234 | 0 | uint8_t prf_inputs[3U][33U]; |
10235 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10236 | 0 | memcpy(prf_inputs[i], copy_of_prf_input, (size_t)33U * sizeof(uint8_t)); |
10237 | 0 | } |
10238 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10239 | 0 | size_t i0 = i; |
10240 | 0 | prf_inputs[i0][32U] = domain_separator; |
10241 | 0 | domain_separator = (uint32_t)domain_separator + 1U; |
10242 | 0 | } |
10243 | 0 | uint8_t prf_outputs[3U][128U]; |
10244 | 0 | libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93(prf_inputs, prf_outputs); |
10245 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10246 | 0 | size_t i0 = i; |
10247 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____1 = |
10248 | 0 | libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6( |
10249 | 0 | Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t)); |
10250 | 0 | error_1[i0] = uu____1; |
10251 | 0 | } |
10252 | | /* Passing arrays by value in Rust generates a copy in C */ |
10253 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_error_1[3U]; |
10254 | 0 | memcpy( |
10255 | 0 | copy_of_error_1, error_1, |
10256 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10257 | 0 | tuple_b0 lit; |
10258 | 0 | memcpy( |
10259 | 0 | lit.fst, copy_of_error_1, |
10260 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10261 | 0 | lit.snd = domain_separator; |
10262 | 0 | return lit; |
10263 | 0 | } |
10264 | | |
10265 | | /** |
10266 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF |
10267 | | with const generics |
10268 | | - LEN= 128 |
10269 | | */ |
10270 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_2b0( |
10271 | 0 | Eurydice_slice input, uint8_t ret[128U]) { |
10272 | 0 | uint8_t digest[128U] = {0U}; |
10273 | 0 | libcrux_sha3_portable_shake256( |
10274 | 0 | Eurydice_array_to_slice((size_t)128U, digest, uint8_t), input); |
10275 | 0 | memcpy(ret, digest, (size_t)128U * sizeof(uint8_t)); |
10276 | 0 | } |
10277 | | |
10278 | | /** |
10279 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
10280 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
10281 | | */ |
10282 | | /** |
10283 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.PRF_f1 |
10284 | | with const generics |
10285 | | - K= 3 |
10286 | | - LEN= 128 |
10287 | | */ |
10288 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_PRF_f1_ee0( |
10289 | 0 | Eurydice_slice input, uint8_t ret[128U]) { |
10290 | 0 | libcrux_ml_kem_hash_functions_portable_PRF_2b0(input, ret); |
10291 | 0 | } |
10292 | | |
10293 | | /** |
10294 | | A monomorphic instance of libcrux_ml_kem.matrix.compute_vector_u.closure |
10295 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10296 | | with const generics |
10297 | | - K= 3 |
10298 | | */ |
10299 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10300 | 0 | libcrux_ml_kem_matrix_compute_vector_u_closure_d6(size_t _i) { |
10301 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10302 | 0 | } |
10303 | | |
10304 | | /** |
10305 | | This function found in impl |
10306 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
10307 | | */ |
10308 | | /** |
10309 | | A monomorphic instance of libcrux_ml_kem.polynomial.add_error_reduce_89 |
10310 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10311 | | with const generics |
10312 | | |
10313 | | */ |
10314 | | static KRML_MUSTINLINE void libcrux_ml_kem_polynomial_add_error_reduce_89_38( |
10315 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self, |
10316 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error) { |
10317 | 0 | for (size_t i = (size_t)0U; |
10318 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
10319 | 0 | size_t j = i; |
10320 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10321 | 0 | coefficient_normal_form = |
10322 | 0 | libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d( |
10323 | 0 | self->coefficients[j], (int16_t)1441); |
10324 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
10325 | 0 | libcrux_ml_kem_vector_portable_barrett_reduce_0d( |
10326 | 0 | libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form, |
10327 | 0 | &error->coefficients[j])); |
10328 | 0 | self->coefficients[j] = uu____0; |
10329 | 0 | } |
10330 | 0 | } |
10331 | | |
10332 | | /** |
10333 | | Compute u := InvertNTT(Aᵀ ◦ r̂) + e₁ |
10334 | | */ |
10335 | | /** |
10336 | | A monomorphic instance of libcrux_ml_kem.matrix.compute_vector_u |
10337 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10338 | | with const generics |
10339 | | - K= 3 |
10340 | | */ |
10341 | | static KRML_MUSTINLINE void libcrux_ml_kem_matrix_compute_vector_u_59( |
10342 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 (*a_as_ntt)[3U], |
10343 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *r_as_ntt, |
10344 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error_1, |
10345 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
10346 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result[3U]; |
10347 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10348 | 0 | result[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10349 | 0 | } |
10350 | 0 | for (size_t i0 = (size_t)0U; |
10351 | 0 | i0 < Eurydice_slice_len( |
10352 | 0 | Eurydice_array_to_slice( |
10353 | 0 | (size_t)3U, a_as_ntt, |
10354 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]), |
10355 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]); |
10356 | 0 | i0++) { |
10357 | 0 | size_t i1 = i0; |
10358 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *row = a_as_ntt[i1]; |
10359 | 0 | for (size_t i = (size_t)0U; |
10360 | 0 | i < Eurydice_slice_len( |
10361 | 0 | Eurydice_array_to_slice( |
10362 | 0 | (size_t)3U, row, |
10363 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0), |
10364 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0); |
10365 | 0 | i++) { |
10366 | 0 | size_t j = i; |
10367 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *a_element = &row[j]; |
10368 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product = |
10369 | 0 | libcrux_ml_kem_polynomial_ntt_multiply_89_2a(a_element, &r_as_ntt[j]); |
10370 | 0 | libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result[i1], |
10371 | 0 | &product); |
10372 | 0 | } |
10373 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(&result[i1]); |
10374 | 0 | libcrux_ml_kem_polynomial_add_error_reduce_89_38(&result[i1], &error_1[i1]); |
10375 | 0 | } |
10376 | 0 | memcpy( |
10377 | 0 | ret, result, |
10378 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10379 | 0 | } |
10380 | | |
10381 | | /** |
10382 | | A monomorphic instance of libcrux_ml_kem.vector.traits.decompress_1 |
10383 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10384 | | with const generics |
10385 | | |
10386 | | */ |
10387 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10388 | | libcrux_ml_kem_vector_traits_decompress_1_63( |
10389 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10390 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
10391 | 0 | libcrux_ml_kem_vector_portable_ZERO_0d(); |
10392 | 0 | return libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d( |
10393 | 0 | libcrux_ml_kem_vector_portable_sub_0d(uu____0, &v), (int16_t)1665); |
10394 | 0 | } |
10395 | | |
10396 | | /** |
10397 | | A monomorphic instance of |
10398 | | libcrux_ml_kem.serialize.deserialize_then_decompress_message with types |
10399 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
10400 | | |
10401 | | */ |
10402 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10403 | | libcrux_ml_kem_serialize_deserialize_then_decompress_message_0d( |
10404 | 0 | uint8_t serialized[32U]) { |
10405 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = |
10406 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10407 | 0 | for (size_t i = (size_t)0U; i < (size_t)16U; i++) { |
10408 | 0 | size_t i0 = i; |
10409 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10410 | 0 | coefficient_compressed = |
10411 | 0 | libcrux_ml_kem_vector_portable_deserialize_1_0d( |
10412 | 0 | Eurydice_array_to_subslice2(serialized, (size_t)2U * i0, |
10413 | 0 | (size_t)2U * i0 + (size_t)2U, |
10414 | 0 | uint8_t)); |
10415 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
10416 | 0 | libcrux_ml_kem_vector_traits_decompress_1_63(coefficient_compressed); |
10417 | 0 | re.coefficients[i0] = uu____0; |
10418 | 0 | } |
10419 | 0 | return re; |
10420 | 0 | } |
10421 | | |
10422 | | /** |
10423 | | This function found in impl |
10424 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
10425 | | */ |
10426 | | /** |
10427 | | A monomorphic instance of libcrux_ml_kem.polynomial.add_message_error_reduce_89 |
10428 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10429 | | with const generics |
10430 | | |
10431 | | */ |
10432 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10433 | | libcrux_ml_kem_polynomial_add_message_error_reduce_89_ea( |
10434 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self, |
10435 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *message, |
10436 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result) { |
10437 | 0 | for (size_t i = (size_t)0U; |
10438 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
10439 | 0 | size_t i0 = i; |
10440 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10441 | 0 | coefficient_normal_form = |
10442 | 0 | libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d( |
10443 | 0 | result.coefficients[i0], (int16_t)1441); |
10444 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector tmp = |
10445 | 0 | libcrux_ml_kem_vector_portable_add_0d(self->coefficients[i0], |
10446 | 0 | &message->coefficients[i0]); |
10447 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector tmp0 = |
10448 | 0 | libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form, &tmp); |
10449 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
10450 | 0 | libcrux_ml_kem_vector_portable_barrett_reduce_0d(tmp0); |
10451 | 0 | result.coefficients[i0] = uu____0; |
10452 | 0 | } |
10453 | 0 | return result; |
10454 | 0 | } |
10455 | | |
10456 | | /** |
10457 | | Compute InverseNTT(tᵀ ◦ r̂) + e₂ + message |
10458 | | */ |
10459 | | /** |
10460 | | A monomorphic instance of libcrux_ml_kem.matrix.compute_ring_element_v |
10461 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10462 | | with const generics |
10463 | | - K= 3 |
10464 | | */ |
10465 | | static KRML_MUSTINLINE libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
10466 | | libcrux_ml_kem_matrix_compute_ring_element_v_54( |
10467 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *t_as_ntt, |
10468 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *r_as_ntt, |
10469 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error_2, |
10470 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *message) { |
10471 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result = |
10472 | 0 | libcrux_ml_kem_polynomial_ZERO_89_ea(); |
10473 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
10474 | 0 | size_t i0 = i; |
10475 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product = |
10476 | 0 | libcrux_ml_kem_polynomial_ntt_multiply_89_2a(&t_as_ntt[i0], |
10477 | 0 | &r_as_ntt[i0]); |
10478 | 0 | libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result, &product); |
10479 | 0 | } |
10480 | 0 | libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_f6(&result); |
10481 | 0 | result = libcrux_ml_kem_polynomial_add_message_error_reduce_89_ea( |
10482 | 0 | error_2, message, result); |
10483 | 0 | return result; |
10484 | 0 | } |
10485 | | |
10486 | | /** |
10487 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress |
10488 | | with const generics |
10489 | | - COEFFICIENT_BITS= 10 |
10490 | | */ |
10491 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10492 | | libcrux_ml_kem_vector_portable_compress_compress_02( |
10493 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10494 | 0 | for (size_t i = (size_t)0U; |
10495 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
10496 | 0 | size_t i0 = i; |
10497 | 0 | int16_t uu____0 = |
10498 | 0 | libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient( |
10499 | 0 | (uint8_t)(int32_t)10, (uint16_t)v.elements[i0]); |
10500 | 0 | v.elements[i0] = uu____0; |
10501 | 0 | } |
10502 | 0 | return v; |
10503 | 0 | } |
10504 | | |
10505 | | /** |
10506 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
10507 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
10508 | | */ |
10509 | | /** |
10510 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d |
10511 | | with const generics |
10512 | | - COEFFICIENT_BITS= 10 |
10513 | | */ |
10514 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10515 | | libcrux_ml_kem_vector_portable_compress_0d_28( |
10516 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10517 | 0 | return libcrux_ml_kem_vector_portable_compress_compress_02(v); |
10518 | 0 | } |
10519 | | |
10520 | | /** |
10521 | | A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_10 |
10522 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10523 | | with const generics |
10524 | | - OUT_LEN= 320 |
10525 | | */ |
10526 | | static KRML_MUSTINLINE void |
10527 | | libcrux_ml_kem_serialize_compress_then_serialize_10_fc( |
10528 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[320U]) { |
10529 | 0 | uint8_t serialized[320U] = {0U}; |
10530 | 0 | for (size_t i = (size_t)0U; |
10531 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
10532 | 0 | size_t i0 = i; |
10533 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
10534 | 0 | libcrux_ml_kem_vector_portable_compress_0d_28( |
10535 | 0 | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
10536 | 0 | re->coefficients[i0])); |
10537 | 0 | uint8_t bytes[20U]; |
10538 | 0 | libcrux_ml_kem_vector_portable_serialize_10_0d(coefficient, bytes); |
10539 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
10540 | 0 | serialized, (size_t)20U * i0, (size_t)20U * i0 + (size_t)20U, uint8_t); |
10541 | 0 | Eurydice_slice_copy( |
10542 | 0 | uu____0, Eurydice_array_to_slice((size_t)20U, bytes, uint8_t), uint8_t); |
10543 | 0 | } |
10544 | 0 | memcpy(ret, serialized, (size_t)320U * sizeof(uint8_t)); |
10545 | 0 | } |
10546 | | |
10547 | | /** |
10548 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress |
10549 | | with const generics |
10550 | | - COEFFICIENT_BITS= 11 |
10551 | | */ |
10552 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10553 | | libcrux_ml_kem_vector_portable_compress_compress_020( |
10554 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10555 | 0 | for (size_t i = (size_t)0U; |
10556 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
10557 | 0 | size_t i0 = i; |
10558 | 0 | int16_t uu____0 = |
10559 | 0 | libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient( |
10560 | 0 | (uint8_t)(int32_t)11, (uint16_t)v.elements[i0]); |
10561 | 0 | v.elements[i0] = uu____0; |
10562 | 0 | } |
10563 | 0 | return v; |
10564 | 0 | } |
10565 | | |
10566 | | /** |
10567 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
10568 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
10569 | | */ |
10570 | | /** |
10571 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d |
10572 | | with const generics |
10573 | | - COEFFICIENT_BITS= 11 |
10574 | | */ |
10575 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10576 | | libcrux_ml_kem_vector_portable_compress_0d_280( |
10577 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10578 | 0 | return libcrux_ml_kem_vector_portable_compress_compress_020(v); |
10579 | 0 | } |
10580 | | |
10581 | | /** |
10582 | | A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_11 |
10583 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10584 | | with const generics |
10585 | | - OUT_LEN= 320 |
10586 | | */ |
10587 | | static KRML_MUSTINLINE void |
10588 | | libcrux_ml_kem_serialize_compress_then_serialize_11_e1( |
10589 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[320U]) { |
10590 | 0 | uint8_t serialized[320U] = {0U}; |
10591 | 0 | for (size_t i = (size_t)0U; |
10592 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
10593 | 0 | size_t i0 = i; |
10594 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
10595 | 0 | libcrux_ml_kem_vector_portable_compress_0d_280( |
10596 | 0 | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
10597 | 0 | re->coefficients[i0])); |
10598 | 0 | uint8_t bytes[22U]; |
10599 | 0 | libcrux_ml_kem_vector_portable_serialize_11_0d(coefficient, bytes); |
10600 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
10601 | 0 | serialized, (size_t)22U * i0, (size_t)22U * i0 + (size_t)22U, uint8_t); |
10602 | 0 | Eurydice_slice_copy( |
10603 | 0 | uu____0, Eurydice_array_to_slice((size_t)22U, bytes, uint8_t), uint8_t); |
10604 | 0 | } |
10605 | 0 | memcpy(ret, serialized, (size_t)320U * sizeof(uint8_t)); |
10606 | 0 | } |
10607 | | |
10608 | | /** |
10609 | | A monomorphic instance of |
10610 | | libcrux_ml_kem.serialize.compress_then_serialize_ring_element_u with types |
10611 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
10612 | | - COMPRESSION_FACTOR= 10 |
10613 | | - OUT_LEN= 320 |
10614 | | */ |
10615 | | static KRML_MUSTINLINE void |
10616 | | libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_5f( |
10617 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[320U]) { |
10618 | 0 | uint8_t uu____0[320U]; |
10619 | 0 | libcrux_ml_kem_serialize_compress_then_serialize_10_fc(re, uu____0); |
10620 | 0 | memcpy(ret, uu____0, (size_t)320U * sizeof(uint8_t)); |
10621 | 0 | } |
10622 | | |
10623 | | /** |
10624 | | Call [`compress_then_serialize_ring_element_u`] on each ring element. |
10625 | | */ |
10626 | | /** |
10627 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.compress_then_serialize_u |
10628 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10629 | | with const generics |
10630 | | - K= 3 |
10631 | | - OUT_LEN= 960 |
10632 | | - COMPRESSION_FACTOR= 10 |
10633 | | - BLOCK_LEN= 320 |
10634 | | */ |
10635 | | static inline void libcrux_ml_kem_ind_cpa_compress_then_serialize_u_a7( |
10636 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 input[3U], |
10637 | 0 | Eurydice_slice out) { |
10638 | 0 | for (size_t i = (size_t)0U; |
10639 | 0 | i < Eurydice_slice_len( |
10640 | 0 | Eurydice_array_to_slice( |
10641 | 0 | (size_t)3U, input, |
10642 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0), |
10643 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0); |
10644 | 0 | i++) { |
10645 | 0 | size_t i0 = i; |
10646 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = input[i0]; |
10647 | 0 | Eurydice_slice uu____0 = Eurydice_slice_subslice2( |
10648 | 0 | out, i0 * ((size_t)960U / (size_t)3U), |
10649 | 0 | (i0 + (size_t)1U) * ((size_t)960U / (size_t)3U), uint8_t); |
10650 | 0 | uint8_t ret[320U]; |
10651 | 0 | libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_5f(&re, |
10652 | 0 | ret); |
10653 | 0 | Eurydice_slice_copy( |
10654 | 0 | uu____0, Eurydice_array_to_slice((size_t)320U, ret, uint8_t), uint8_t); |
10655 | 0 | } |
10656 | 0 | } |
10657 | | |
10658 | | /** |
10659 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress |
10660 | | with const generics |
10661 | | - COEFFICIENT_BITS= 4 |
10662 | | */ |
10663 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10664 | | libcrux_ml_kem_vector_portable_compress_compress_021( |
10665 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10666 | 0 | for (size_t i = (size_t)0U; |
10667 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
10668 | 0 | size_t i0 = i; |
10669 | 0 | int16_t uu____0 = |
10670 | 0 | libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient( |
10671 | 0 | (uint8_t)(int32_t)4, (uint16_t)v.elements[i0]); |
10672 | 0 | v.elements[i0] = uu____0; |
10673 | 0 | } |
10674 | 0 | return v; |
10675 | 0 | } |
10676 | | |
10677 | | /** |
10678 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
10679 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
10680 | | */ |
10681 | | /** |
10682 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d |
10683 | | with const generics |
10684 | | - COEFFICIENT_BITS= 4 |
10685 | | */ |
10686 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10687 | | libcrux_ml_kem_vector_portable_compress_0d_281( |
10688 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10689 | 0 | return libcrux_ml_kem_vector_portable_compress_compress_021(v); |
10690 | 0 | } |
10691 | | |
10692 | | /** |
10693 | | A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_4 |
10694 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10695 | | with const generics |
10696 | | |
10697 | | */ |
10698 | | static KRML_MUSTINLINE void |
10699 | | libcrux_ml_kem_serialize_compress_then_serialize_4_9a( |
10700 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re, |
10701 | 0 | Eurydice_slice serialized) { |
10702 | 0 | for (size_t i = (size_t)0U; |
10703 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
10704 | 0 | size_t i0 = i; |
10705 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
10706 | 0 | libcrux_ml_kem_vector_portable_compress_0d_281( |
10707 | 0 | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
10708 | 0 | re.coefficients[i0])); |
10709 | 0 | uint8_t bytes[8U]; |
10710 | 0 | libcrux_ml_kem_vector_portable_serialize_4_0d(coefficient, bytes); |
10711 | 0 | Eurydice_slice_copy( |
10712 | 0 | Eurydice_slice_subslice2(serialized, (size_t)8U * i0, |
10713 | 0 | (size_t)8U * i0 + (size_t)8U, uint8_t), |
10714 | 0 | Eurydice_array_to_slice((size_t)8U, bytes, uint8_t), uint8_t); |
10715 | 0 | } |
10716 | 0 | } |
10717 | | |
10718 | | /** |
10719 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress.compress |
10720 | | with const generics |
10721 | | - COEFFICIENT_BITS= 5 |
10722 | | */ |
10723 | | static KRML_MUSTINLINE libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10724 | | libcrux_ml_kem_vector_portable_compress_compress_022( |
10725 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10726 | 0 | for (size_t i = (size_t)0U; |
10727 | 0 | i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) { |
10728 | 0 | size_t i0 = i; |
10729 | 0 | int16_t uu____0 = |
10730 | 0 | libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient( |
10731 | 0 | (uint8_t)(int32_t)5, (uint16_t)v.elements[i0]); |
10732 | 0 | v.elements[i0] = uu____0; |
10733 | 0 | } |
10734 | 0 | return v; |
10735 | 0 | } |
10736 | | |
10737 | | /** |
10738 | | This function found in impl {(libcrux_ml_kem::vector::traits::Operations for |
10739 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
10740 | | */ |
10741 | | /** |
10742 | | A monomorphic instance of libcrux_ml_kem.vector.portable.compress_0d |
10743 | | with const generics |
10744 | | - COEFFICIENT_BITS= 5 |
10745 | | */ |
10746 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10747 | | libcrux_ml_kem_vector_portable_compress_0d_282( |
10748 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
10749 | 0 | return libcrux_ml_kem_vector_portable_compress_compress_022(v); |
10750 | 0 | } |
10751 | | |
10752 | | /** |
10753 | | A monomorphic instance of libcrux_ml_kem.serialize.compress_then_serialize_5 |
10754 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
10755 | | with const generics |
10756 | | |
10757 | | */ |
10758 | | static KRML_MUSTINLINE void |
10759 | | libcrux_ml_kem_serialize_compress_then_serialize_5_1f( |
10760 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re, |
10761 | 0 | Eurydice_slice serialized) { |
10762 | 0 | for (size_t i = (size_t)0U; |
10763 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
10764 | 0 | size_t i0 = i; |
10765 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficients = |
10766 | 0 | libcrux_ml_kem_vector_portable_compress_0d_282( |
10767 | 0 | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
10768 | 0 | re.coefficients[i0])); |
10769 | 0 | uint8_t bytes[10U]; |
10770 | 0 | libcrux_ml_kem_vector_portable_serialize_5_0d(coefficients, bytes); |
10771 | 0 | Eurydice_slice_copy( |
10772 | 0 | Eurydice_slice_subslice2(serialized, (size_t)10U * i0, |
10773 | 0 | (size_t)10U * i0 + (size_t)10U, uint8_t), |
10774 | 0 | Eurydice_array_to_slice((size_t)10U, bytes, uint8_t), uint8_t); |
10775 | 0 | } |
10776 | 0 | } |
10777 | | |
10778 | | /** |
10779 | | A monomorphic instance of |
10780 | | libcrux_ml_kem.serialize.compress_then_serialize_ring_element_v with types |
10781 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
10782 | | - COMPRESSION_FACTOR= 4 |
10783 | | - OUT_LEN= 128 |
10784 | | */ |
10785 | | static KRML_MUSTINLINE void |
10786 | | libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_4e( |
10787 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re, Eurydice_slice out) { |
10788 | 0 | libcrux_ml_kem_serialize_compress_then_serialize_4_9a(re, out); |
10789 | 0 | } |
10790 | | |
10791 | | /** |
10792 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.encrypt |
10793 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
10794 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] with const |
10795 | | generics |
10796 | | - K= 3 |
10797 | | - CIPHERTEXT_SIZE= 1088 |
10798 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
10799 | | - C1_LEN= 960 |
10800 | | - C2_LEN= 128 |
10801 | | - U_COMPRESSION_FACTOR= 10 |
10802 | | - V_COMPRESSION_FACTOR= 4 |
10803 | | - BLOCK_LEN= 320 |
10804 | | - ETA1= 2 |
10805 | | - ETA1_RANDOMNESS_SIZE= 128 |
10806 | | - ETA2= 2 |
10807 | | - ETA2_RANDOMNESS_SIZE= 128 |
10808 | | */ |
10809 | | static inline void libcrux_ml_kem_ind_cpa_encrypt_60(Eurydice_slice public_key, |
10810 | | uint8_t message[32U], |
10811 | | Eurydice_slice randomness, |
10812 | 0 | uint8_t ret[1088U]) { |
10813 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U]; |
10814 | 0 | libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_33( |
10815 | 0 | Eurydice_slice_subslice_to(public_key, (size_t)1152U, uint8_t, size_t), |
10816 | 0 | t_as_ntt); |
10817 | 0 | Eurydice_slice seed = |
10818 | 0 | Eurydice_slice_subslice_from(public_key, (size_t)1152U, uint8_t, size_t); |
10819 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A[3U][3U]; |
10820 | 0 | uint8_t ret0[34U]; |
10821 | 0 | libcrux_ml_kem_utils_into_padded_array_ea1(seed, ret0); |
10822 | 0 | libcrux_ml_kem_matrix_sample_matrix_A_38(ret0, false, A); |
10823 | 0 | uint8_t prf_input[33U]; |
10824 | 0 | libcrux_ml_kem_utils_into_padded_array_ea2(randomness, prf_input); |
10825 | | /* Passing arrays by value in Rust generates a copy in C */ |
10826 | 0 | uint8_t copy_of_prf_input0[33U]; |
10827 | 0 | memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t)); |
10828 | 0 | tuple_b0 uu____1 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc( |
10829 | 0 | copy_of_prf_input0, 0U); |
10830 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 r_as_ntt[3U]; |
10831 | 0 | memcpy( |
10832 | 0 | r_as_ntt, uu____1.fst, |
10833 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10834 | 0 | uint8_t domain_separator0 = uu____1.snd; |
10835 | | /* Passing arrays by value in Rust generates a copy in C */ |
10836 | 0 | uint8_t copy_of_prf_input[33U]; |
10837 | 0 | memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t)); |
10838 | 0 | tuple_b0 uu____3 = libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_ac( |
10839 | 0 | copy_of_prf_input, domain_separator0); |
10840 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_1[3U]; |
10841 | 0 | memcpy( |
10842 | 0 | error_1, uu____3.fst, |
10843 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10844 | 0 | uint8_t domain_separator = uu____3.snd; |
10845 | 0 | prf_input[32U] = domain_separator; |
10846 | 0 | uint8_t prf_output[128U]; |
10847 | 0 | libcrux_ml_kem_hash_functions_portable_PRF_f1_ee0( |
10848 | 0 | Eurydice_array_to_slice((size_t)33U, prf_input, uint8_t), prf_output); |
10849 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_2 = |
10850 | 0 | libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6( |
10851 | 0 | Eurydice_array_to_slice((size_t)128U, prf_output, uint8_t)); |
10852 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 u[3U]; |
10853 | 0 | libcrux_ml_kem_matrix_compute_vector_u_59(A, r_as_ntt, error_1, u); |
10854 | | /* Passing arrays by value in Rust generates a copy in C */ |
10855 | 0 | uint8_t copy_of_message[32U]; |
10856 | 0 | memcpy(copy_of_message, message, (size_t)32U * sizeof(uint8_t)); |
10857 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 message_as_ring_element = |
10858 | 0 | libcrux_ml_kem_serialize_deserialize_then_decompress_message_0d( |
10859 | 0 | copy_of_message); |
10860 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 v = |
10861 | 0 | libcrux_ml_kem_matrix_compute_ring_element_v_54( |
10862 | 0 | t_as_ntt, r_as_ntt, &error_2, &message_as_ring_element); |
10863 | 0 | uint8_t ciphertext[1088U] = {0U}; |
10864 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____5[3U]; |
10865 | 0 | memcpy( |
10866 | 0 | uu____5, u, |
10867 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
10868 | 0 | libcrux_ml_kem_ind_cpa_compress_then_serialize_u_a7( |
10869 | 0 | uu____5, Eurydice_array_to_subslice2(ciphertext, (size_t)0U, (size_t)960U, |
10870 | 0 | uint8_t)); |
10871 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____6 = v; |
10872 | 0 | libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_4e( |
10873 | 0 | uu____6, Eurydice_array_to_subslice_from((size_t)1088U, ciphertext, |
10874 | 0 | (size_t)960U, uint8_t, size_t)); |
10875 | 0 | memcpy(ret, ciphertext, (size_t)1088U * sizeof(uint8_t)); |
10876 | 0 | } |
10877 | | |
10878 | | /** |
10879 | | This function found in impl {(libcrux_ml_kem::variant::Variant for |
10880 | | libcrux_ml_kem::variant::MlKem)#1} |
10881 | | */ |
10882 | | /** |
10883 | | A monomorphic instance of libcrux_ml_kem.variant.kdf_d8 |
10884 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
10885 | | with const generics |
10886 | | - K= 3 |
10887 | | - CIPHERTEXT_SIZE= 1088 |
10888 | | */ |
10889 | | static KRML_MUSTINLINE void libcrux_ml_kem_variant_kdf_d8_41( |
10890 | | Eurydice_slice shared_secret, libcrux_ml_kem_mlkem768_MlKem768Ciphertext *_, |
10891 | 0 | uint8_t ret[32U]) { |
10892 | 0 | uint8_t out[32U] = {0U}; |
10893 | 0 | Eurydice_slice_copy(Eurydice_array_to_slice((size_t)32U, out, uint8_t), |
10894 | 0 | shared_secret, uint8_t); |
10895 | 0 | memcpy(ret, out, (size_t)32U * sizeof(uint8_t)); |
10896 | 0 | } |
10897 | | |
10898 | | /** |
10899 | | A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate |
10900 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
10901 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
10902 | | libcrux_ml_kem_variant_MlKem with const generics |
10903 | | - K= 3 |
10904 | | - SECRET_KEY_SIZE= 2400 |
10905 | | - CPA_SECRET_KEY_SIZE= 1152 |
10906 | | - PUBLIC_KEY_SIZE= 1184 |
10907 | | - CIPHERTEXT_SIZE= 1088 |
10908 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
10909 | | - C1_SIZE= 960 |
10910 | | - C2_SIZE= 128 |
10911 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
10912 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
10913 | | - C1_BLOCK_SIZE= 320 |
10914 | | - ETA1= 2 |
10915 | | - ETA1_RANDOMNESS_SIZE= 128 |
10916 | | - ETA2= 2 |
10917 | | - ETA2_RANDOMNESS_SIZE= 128 |
10918 | | - IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120 |
10919 | | */ |
10920 | | static inline void libcrux_ml_kem_ind_cca_decapsulate_70( |
10921 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
10922 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
10923 | 0 | Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at( |
10924 | 0 | Eurydice_array_to_slice((size_t)2400U, private_key->value, uint8_t), |
10925 | 0 | (size_t)1152U, uint8_t, Eurydice_slice_uint8_t_x2); |
10926 | 0 | Eurydice_slice ind_cpa_secret_key = uu____0.fst; |
10927 | 0 | Eurydice_slice secret_key0 = uu____0.snd; |
10928 | 0 | Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at( |
10929 | 0 | secret_key0, (size_t)1184U, uint8_t, Eurydice_slice_uint8_t_x2); |
10930 | 0 | Eurydice_slice ind_cpa_public_key = uu____1.fst; |
10931 | 0 | Eurydice_slice secret_key = uu____1.snd; |
10932 | 0 | Eurydice_slice_uint8_t_x2 uu____2 = Eurydice_slice_split_at( |
10933 | 0 | secret_key, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t, |
10934 | 0 | Eurydice_slice_uint8_t_x2); |
10935 | 0 | Eurydice_slice ind_cpa_public_key_hash = uu____2.fst; |
10936 | 0 | Eurydice_slice implicit_rejection_value = uu____2.snd; |
10937 | 0 | uint8_t decrypted[32U]; |
10938 | 0 | libcrux_ml_kem_ind_cpa_decrypt_43(ind_cpa_secret_key, ciphertext->value, |
10939 | 0 | decrypted); |
10940 | 0 | uint8_t to_hash0[64U]; |
10941 | 0 | libcrux_ml_kem_utils_into_padded_array_ea( |
10942 | 0 | Eurydice_array_to_slice((size_t)32U, decrypted, uint8_t), to_hash0); |
10943 | 0 | Eurydice_slice_copy( |
10944 | 0 | Eurydice_array_to_subslice_from( |
10945 | 0 | (size_t)64U, to_hash0, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, |
10946 | 0 | uint8_t, size_t), |
10947 | 0 | ind_cpa_public_key_hash, uint8_t); |
10948 | 0 | uint8_t hashed[64U]; |
10949 | 0 | libcrux_ml_kem_hash_functions_portable_G_f1_e4( |
10950 | 0 | Eurydice_array_to_slice((size_t)64U, to_hash0, uint8_t), hashed); |
10951 | 0 | Eurydice_slice_uint8_t_x2 uu____3 = Eurydice_slice_split_at( |
10952 | 0 | Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), |
10953 | 0 | LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t, |
10954 | 0 | Eurydice_slice_uint8_t_x2); |
10955 | 0 | Eurydice_slice shared_secret0 = uu____3.fst; |
10956 | 0 | Eurydice_slice pseudorandomness = uu____3.snd; |
10957 | 0 | uint8_t to_hash[1120U]; |
10958 | 0 | libcrux_ml_kem_utils_into_padded_array_ea0(implicit_rejection_value, to_hash); |
10959 | 0 | Eurydice_slice uu____4 = Eurydice_array_to_subslice_from( |
10960 | 0 | (size_t)1120U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, |
10961 | 0 | uint8_t, size_t); |
10962 | 0 | Eurydice_slice_copy(uu____4, libcrux_ml_kem_types_as_ref_00_24(ciphertext), |
10963 | 0 | uint8_t); |
10964 | 0 | uint8_t implicit_rejection_shared_secret0[32U]; |
10965 | 0 | libcrux_ml_kem_hash_functions_portable_PRF_f1_ee( |
10966 | 0 | Eurydice_array_to_slice((size_t)1120U, to_hash, uint8_t), |
10967 | 0 | implicit_rejection_shared_secret0); |
10968 | 0 | Eurydice_slice uu____5 = ind_cpa_public_key; |
10969 | | /* Passing arrays by value in Rust generates a copy in C */ |
10970 | 0 | uint8_t copy_of_decrypted[32U]; |
10971 | 0 | memcpy(copy_of_decrypted, decrypted, (size_t)32U * sizeof(uint8_t)); |
10972 | 0 | uint8_t expected_ciphertext[1088U]; |
10973 | 0 | libcrux_ml_kem_ind_cpa_encrypt_60(uu____5, copy_of_decrypted, |
10974 | 0 | pseudorandomness, expected_ciphertext); |
10975 | 0 | uint8_t implicit_rejection_shared_secret[32U]; |
10976 | 0 | libcrux_ml_kem_variant_kdf_d8_41( |
10977 | 0 | Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret0, |
10978 | 0 | uint8_t), |
10979 | 0 | ciphertext, implicit_rejection_shared_secret); |
10980 | 0 | uint8_t shared_secret[32U]; |
10981 | 0 | libcrux_ml_kem_variant_kdf_d8_41(shared_secret0, ciphertext, shared_secret); |
10982 | 0 | uint8_t ret0[32U]; |
10983 | 0 | libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time( |
10984 | 0 | libcrux_ml_kem_types_as_ref_00_24(ciphertext), |
10985 | 0 | Eurydice_array_to_slice((size_t)1088U, expected_ciphertext, uint8_t), |
10986 | 0 | Eurydice_array_to_slice((size_t)32U, shared_secret, uint8_t), |
10987 | 0 | Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret, |
10988 | 0 | uint8_t), |
10989 | 0 | ret0); |
10990 | 0 | memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t)); |
10991 | 0 | } |
10992 | | |
10993 | | /** |
10994 | | Portable decapsulate |
10995 | | */ |
10996 | | /** |
10997 | | A monomorphic instance of |
10998 | | libcrux_ml_kem.ind_cca.instantiations.portable.decapsulate with const generics |
10999 | | - K= 3 |
11000 | | - SECRET_KEY_SIZE= 2400 |
11001 | | - CPA_SECRET_KEY_SIZE= 1152 |
11002 | | - PUBLIC_KEY_SIZE= 1184 |
11003 | | - CIPHERTEXT_SIZE= 1088 |
11004 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11005 | | - C1_SIZE= 960 |
11006 | | - C2_SIZE= 128 |
11007 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11008 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11009 | | - C1_BLOCK_SIZE= 320 |
11010 | | - ETA1= 2 |
11011 | | - ETA1_RANDOMNESS_SIZE= 128 |
11012 | | - ETA2= 2 |
11013 | | - ETA2_RANDOMNESS_SIZE= 128 |
11014 | | - IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120 |
11015 | | */ |
11016 | | static inline void |
11017 | | libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_2e( |
11018 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
11019 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
11020 | 0 | libcrux_ml_kem_ind_cca_decapsulate_70(private_key, ciphertext, ret); |
11021 | 0 | } |
11022 | | |
11023 | | /** |
11024 | | Decapsulate ML-KEM 768 |
11025 | | |
11026 | | Generates an [`MlKemSharedSecret`]. |
11027 | | The input is a reference to an [`MlKem768PrivateKey`] and an |
11028 | | [`MlKem768Ciphertext`]. |
11029 | | */ |
11030 | | static inline void libcrux_ml_kem_mlkem768_portable_decapsulate( |
11031 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
11032 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
11033 | 0 | libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_2e( |
11034 | 0 | private_key, ciphertext, ret); |
11035 | 0 | } |
11036 | | |
11037 | | /** |
11038 | | This function found in impl {(libcrux_ml_kem::variant::Variant for |
11039 | | libcrux_ml_kem::variant::MlKem)#1} |
11040 | | */ |
11041 | | /** |
11042 | | A monomorphic instance of libcrux_ml_kem.variant.entropy_preprocess_d8 |
11043 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
11044 | | with const generics |
11045 | | - K= 3 |
11046 | | */ |
11047 | | static KRML_MUSTINLINE void libcrux_ml_kem_variant_entropy_preprocess_d8_63( |
11048 | 0 | Eurydice_slice randomness, uint8_t ret[32U]) { |
11049 | 0 | uint8_t out[32U] = {0U}; |
11050 | 0 | Eurydice_slice_copy(Eurydice_array_to_slice((size_t)32U, out, uint8_t), |
11051 | 0 | randomness, uint8_t); |
11052 | 0 | memcpy(ret, out, (size_t)32U * sizeof(uint8_t)); |
11053 | 0 | } |
11054 | | |
11055 | | /** |
11056 | | This function found in impl {(libcrux_ml_kem::hash_functions::Hash<K> for |
11057 | | libcrux_ml_kem::hash_functions::portable::PortableHash<K>)} |
11058 | | */ |
11059 | | /** |
11060 | | A monomorphic instance of libcrux_ml_kem.hash_functions.portable.H_f1 |
11061 | | with const generics |
11062 | | - K= 3 |
11063 | | */ |
11064 | | static KRML_MUSTINLINE void libcrux_ml_kem_hash_functions_portable_H_f1_1a( |
11065 | 0 | Eurydice_slice input, uint8_t ret[32U]) { |
11066 | 0 | libcrux_ml_kem_hash_functions_portable_H(input, ret); |
11067 | 0 | } |
11068 | | |
11069 | | /** |
11070 | | A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate |
11071 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
11072 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
11073 | | libcrux_ml_kem_variant_MlKem with const generics |
11074 | | - K= 3 |
11075 | | - CIPHERTEXT_SIZE= 1088 |
11076 | | - PUBLIC_KEY_SIZE= 1184 |
11077 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11078 | | - C1_SIZE= 960 |
11079 | | - C2_SIZE= 128 |
11080 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11081 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11082 | | - VECTOR_U_BLOCK_LEN= 320 |
11083 | | - ETA1= 2 |
11084 | | - ETA1_RANDOMNESS_SIZE= 128 |
11085 | | - ETA2= 2 |
11086 | | - ETA2_RANDOMNESS_SIZE= 128 |
11087 | | */ |
11088 | | static inline tuple_3c libcrux_ml_kem_ind_cca_encapsulate_cd( |
11089 | | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key, |
11090 | 0 | uint8_t randomness[32U]) { |
11091 | 0 | uint8_t randomness0[32U]; |
11092 | 0 | libcrux_ml_kem_variant_entropy_preprocess_d8_63( |
11093 | 0 | Eurydice_array_to_slice((size_t)32U, randomness, uint8_t), randomness0); |
11094 | 0 | uint8_t to_hash[64U]; |
11095 | 0 | libcrux_ml_kem_utils_into_padded_array_ea( |
11096 | 0 | Eurydice_array_to_slice((size_t)32U, randomness0, uint8_t), to_hash); |
11097 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice_from( |
11098 | 0 | (size_t)64U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t, |
11099 | 0 | size_t); |
11100 | 0 | uint8_t ret[32U]; |
11101 | 0 | libcrux_ml_kem_hash_functions_portable_H_f1_1a( |
11102 | 0 | Eurydice_array_to_slice((size_t)1184U, |
11103 | 0 | libcrux_ml_kem_types_as_slice_cb_50(public_key), |
11104 | 0 | uint8_t), |
11105 | 0 | ret); |
11106 | 0 | Eurydice_slice_copy( |
11107 | 0 | uu____0, Eurydice_array_to_slice((size_t)32U, ret, uint8_t), uint8_t); |
11108 | 0 | uint8_t hashed[64U]; |
11109 | 0 | libcrux_ml_kem_hash_functions_portable_G_f1_e4( |
11110 | 0 | Eurydice_array_to_slice((size_t)64U, to_hash, uint8_t), hashed); |
11111 | 0 | Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at( |
11112 | 0 | Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), |
11113 | 0 | LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t, |
11114 | 0 | Eurydice_slice_uint8_t_x2); |
11115 | 0 | Eurydice_slice shared_secret = uu____1.fst; |
11116 | 0 | Eurydice_slice pseudorandomness = uu____1.snd; |
11117 | 0 | Eurydice_slice uu____2 = Eurydice_array_to_slice( |
11118 | 0 | (size_t)1184U, libcrux_ml_kem_types_as_slice_cb_50(public_key), uint8_t); |
11119 | | /* Passing arrays by value in Rust generates a copy in C */ |
11120 | 0 | uint8_t copy_of_randomness[32U]; |
11121 | 0 | memcpy(copy_of_randomness, randomness0, (size_t)32U * sizeof(uint8_t)); |
11122 | 0 | uint8_t ciphertext[1088U]; |
11123 | 0 | libcrux_ml_kem_ind_cpa_encrypt_60(uu____2, copy_of_randomness, |
11124 | 0 | pseudorandomness, ciphertext); |
11125 | | /* Passing arrays by value in Rust generates a copy in C */ |
11126 | 0 | uint8_t copy_of_ciphertext[1088U]; |
11127 | 0 | memcpy(copy_of_ciphertext, ciphertext, (size_t)1088U * sizeof(uint8_t)); |
11128 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext ciphertext0 = |
11129 | 0 | libcrux_ml_kem_types_from_01_9f(copy_of_ciphertext); |
11130 | 0 | uint8_t shared_secret_array[32U]; |
11131 | 0 | libcrux_ml_kem_variant_kdf_d8_41(shared_secret, &ciphertext0, |
11132 | 0 | shared_secret_array); |
11133 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext uu____5 = ciphertext0; |
11134 | | /* Passing arrays by value in Rust generates a copy in C */ |
11135 | 0 | uint8_t copy_of_shared_secret_array[32U]; |
11136 | 0 | memcpy(copy_of_shared_secret_array, shared_secret_array, |
11137 | 0 | (size_t)32U * sizeof(uint8_t)); |
11138 | 0 | tuple_3c lit; |
11139 | 0 | lit.fst = uu____5; |
11140 | 0 | memcpy(lit.snd, copy_of_shared_secret_array, (size_t)32U * sizeof(uint8_t)); |
11141 | 0 | return lit; |
11142 | 0 | } |
11143 | | |
11144 | | /** |
11145 | | A monomorphic instance of |
11146 | | libcrux_ml_kem.ind_cca.instantiations.portable.encapsulate with const generics |
11147 | | - K= 3 |
11148 | | - CIPHERTEXT_SIZE= 1088 |
11149 | | - PUBLIC_KEY_SIZE= 1184 |
11150 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11151 | | - C1_SIZE= 960 |
11152 | | - C2_SIZE= 128 |
11153 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11154 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11155 | | - VECTOR_U_BLOCK_LEN= 320 |
11156 | | - ETA1= 2 |
11157 | | - ETA1_RANDOMNESS_SIZE= 128 |
11158 | | - ETA2= 2 |
11159 | | - ETA2_RANDOMNESS_SIZE= 128 |
11160 | | */ |
11161 | | static inline tuple_3c |
11162 | | libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_c6( |
11163 | | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key, |
11164 | 0 | uint8_t randomness[32U]) { |
11165 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key; |
11166 | | /* Passing arrays by value in Rust generates a copy in C */ |
11167 | 0 | uint8_t copy_of_randomness[32U]; |
11168 | 0 | memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t)); |
11169 | 0 | return libcrux_ml_kem_ind_cca_encapsulate_cd(uu____0, copy_of_randomness); |
11170 | 0 | } |
11171 | | |
11172 | | /** |
11173 | | Encapsulate ML-KEM 768 |
11174 | | |
11175 | | Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple. |
11176 | | The input is a reference to an [`MlKem768PublicKey`] and [`SHARED_SECRET_SIZE`] |
11177 | | bytes of `randomness`. |
11178 | | */ |
11179 | | static inline tuple_3c libcrux_ml_kem_mlkem768_portable_encapsulate( |
11180 | | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key, |
11181 | 0 | uint8_t randomness[32U]) { |
11182 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key; |
11183 | | /* Passing arrays by value in Rust generates a copy in C */ |
11184 | 0 | uint8_t copy_of_randomness[32U]; |
11185 | 0 | memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t)); |
11186 | 0 | return libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_c6( |
11187 | 0 | uu____0, copy_of_randomness); |
11188 | 0 | } |
11189 | | |
11190 | | /** |
11191 | | This function found in impl {(libcrux_ml_kem::variant::Variant for |
11192 | | libcrux_ml_kem::variant::MlKem)#1} |
11193 | | */ |
11194 | | /** |
11195 | | A monomorphic instance of libcrux_ml_kem.variant.cpa_keygen_seed_d8 |
11196 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
11197 | | with const generics |
11198 | | - K= 3 |
11199 | | */ |
11200 | | static KRML_MUSTINLINE void libcrux_ml_kem_variant_cpa_keygen_seed_d8_0e( |
11201 | 0 | Eurydice_slice key_generation_seed, uint8_t ret[64U]) { |
11202 | 0 | uint8_t seed[33U] = {0U}; |
11203 | 0 | Eurydice_slice_copy( |
11204 | 0 | Eurydice_array_to_subslice2( |
11205 | 0 | seed, (size_t)0U, |
11206 | 0 | LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t), |
11207 | 0 | key_generation_seed, uint8_t); |
11208 | 0 | seed[LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE] = |
11209 | 0 | (uint8_t)(size_t)3U; |
11210 | 0 | uint8_t ret0[64U]; |
11211 | 0 | libcrux_ml_kem_hash_functions_portable_G_f1_e4( |
11212 | 0 | Eurydice_array_to_slice((size_t)33U, seed, uint8_t), ret0); |
11213 | 0 | memcpy(ret, ret0, (size_t)64U * sizeof(uint8_t)); |
11214 | 0 | } |
11215 | | |
11216 | | /** |
11217 | | A monomorphic instance of libcrux_ml_kem.matrix.compute_As_plus_e.closure |
11218 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11219 | | with const generics |
11220 | | - K= 3 |
11221 | | */ |
11222 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
11223 | 0 | libcrux_ml_kem_matrix_compute_As_plus_e_closure_87(size_t _i) { |
11224 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
11225 | 0 | } |
11226 | | |
11227 | | /** |
11228 | | A monomorphic instance of libcrux_ml_kem.vector.traits.to_standard_domain |
11229 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11230 | | with const generics |
11231 | | |
11232 | | */ |
11233 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11234 | | libcrux_ml_kem_vector_traits_to_standard_domain_59( |
11235 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector v) { |
11236 | 0 | return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d( |
11237 | 0 | v, LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS); |
11238 | 0 | } |
11239 | | |
11240 | | /** |
11241 | | This function found in impl |
11242 | | {libcrux_ml_kem::polynomial::PolynomialRingElement<Vector>[TraitClause@0]} |
11243 | | */ |
11244 | | /** |
11245 | | A monomorphic instance of libcrux_ml_kem.polynomial.add_standard_error_reduce_89 |
11246 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11247 | | with const generics |
11248 | | |
11249 | | */ |
11250 | | static KRML_MUSTINLINE void |
11251 | | libcrux_ml_kem_polynomial_add_standard_error_reduce_89_03( |
11252 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self, |
11253 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error) { |
11254 | 0 | for (size_t i = (size_t)0U; |
11255 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
11256 | 0 | size_t j = i; |
11257 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11258 | 0 | coefficient_normal_form = |
11259 | 0 | libcrux_ml_kem_vector_traits_to_standard_domain_59( |
11260 | 0 | self->coefficients[j]); |
11261 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 = |
11262 | 0 | libcrux_ml_kem_vector_portable_barrett_reduce_0d( |
11263 | 0 | libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form, |
11264 | 0 | &error->coefficients[j])); |
11265 | 0 | self->coefficients[j] = uu____0; |
11266 | 0 | } |
11267 | 0 | } |
11268 | | |
11269 | | /** |
11270 | | Compute  ◦ ŝ + ê |
11271 | | */ |
11272 | | /** |
11273 | | A monomorphic instance of libcrux_ml_kem.matrix.compute_As_plus_e |
11274 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11275 | | with const generics |
11276 | | - K= 3 |
11277 | | */ |
11278 | | static KRML_MUSTINLINE void libcrux_ml_kem_matrix_compute_As_plus_e_60( |
11279 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 (*matrix_A)[3U], |
11280 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *s_as_ntt, |
11281 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error_as_ntt, |
11282 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
11283 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result[3U]; |
11284 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
11285 | 0 | result[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
11286 | 0 | } |
11287 | 0 | for (size_t i0 = (size_t)0U; |
11288 | 0 | i0 < Eurydice_slice_len( |
11289 | 0 | Eurydice_array_to_slice( |
11290 | 0 | (size_t)3U, matrix_A, |
11291 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]), |
11292 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]); |
11293 | 0 | i0++) { |
11294 | 0 | size_t i1 = i0; |
11295 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *row = matrix_A[i1]; |
11296 | 0 | for (size_t i = (size_t)0U; |
11297 | 0 | i < Eurydice_slice_len( |
11298 | 0 | Eurydice_array_to_slice( |
11299 | 0 | (size_t)3U, row, |
11300 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0), |
11301 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0); |
11302 | 0 | i++) { |
11303 | 0 | size_t j = i; |
11304 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *matrix_element = |
11305 | 0 | &row[j]; |
11306 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product = |
11307 | 0 | libcrux_ml_kem_polynomial_ntt_multiply_89_2a(matrix_element, |
11308 | 0 | &s_as_ntt[j]); |
11309 | 0 | libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result[i1], |
11310 | 0 | &product); |
11311 | 0 | } |
11312 | 0 | libcrux_ml_kem_polynomial_add_standard_error_reduce_89_03( |
11313 | 0 | &result[i1], &error_as_ntt[i1]); |
11314 | 0 | } |
11315 | 0 | memcpy( |
11316 | 0 | ret, result, |
11317 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
11318 | 0 | } |
11319 | | |
11320 | | /** |
11321 | | A monomorphic instance of |
11322 | | libcrux_ml_kem.serialize.serialize_uncompressed_ring_element with types |
11323 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
11324 | | |
11325 | | */ |
11326 | | static KRML_MUSTINLINE void |
11327 | | libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_5b( |
11328 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[384U]) { |
11329 | 0 | uint8_t serialized[384U] = {0U}; |
11330 | 0 | for (size_t i = (size_t)0U; |
11331 | 0 | i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) { |
11332 | 0 | size_t i0 = i; |
11333 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient = |
11334 | 0 | libcrux_ml_kem_vector_traits_to_unsigned_representative_db( |
11335 | 0 | re->coefficients[i0]); |
11336 | 0 | uint8_t bytes[24U]; |
11337 | 0 | libcrux_ml_kem_vector_portable_serialize_12_0d(coefficient, bytes); |
11338 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
11339 | 0 | serialized, (size_t)24U * i0, (size_t)24U * i0 + (size_t)24U, uint8_t); |
11340 | 0 | Eurydice_slice_copy( |
11341 | 0 | uu____0, Eurydice_array_to_slice((size_t)24U, bytes, uint8_t), uint8_t); |
11342 | 0 | } |
11343 | 0 | memcpy(ret, serialized, (size_t)384U * sizeof(uint8_t)); |
11344 | 0 | } |
11345 | | |
11346 | | /** |
11347 | | Call [`serialize_uncompressed_ring_element`] for each ring element. |
11348 | | */ |
11349 | | /** |
11350 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_secret_key |
11351 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11352 | | with const generics |
11353 | | - K= 3 |
11354 | | - OUT_LEN= 1152 |
11355 | | */ |
11356 | | static KRML_MUSTINLINE void libcrux_ml_kem_ind_cpa_serialize_secret_key_b5( |
11357 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *key, |
11358 | 0 | uint8_t ret[1152U]) { |
11359 | 0 | uint8_t out[1152U] = {0U}; |
11360 | 0 | for (size_t i = (size_t)0U; |
11361 | 0 | i < Eurydice_slice_len( |
11362 | 0 | Eurydice_array_to_slice( |
11363 | 0 | (size_t)3U, key, |
11364 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0), |
11365 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0); |
11366 | 0 | i++) { |
11367 | 0 | size_t i0 = i; |
11368 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = key[i0]; |
11369 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
11370 | 0 | out, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
11371 | 0 | (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
11372 | 0 | uint8_t); |
11373 | 0 | uint8_t ret0[384U]; |
11374 | 0 | libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_5b(&re, ret0); |
11375 | 0 | Eurydice_slice_copy( |
11376 | 0 | uu____0, Eurydice_array_to_slice((size_t)384U, ret0, uint8_t), uint8_t); |
11377 | 0 | } |
11378 | 0 | memcpy(ret, out, (size_t)1152U * sizeof(uint8_t)); |
11379 | 0 | } |
11380 | | |
11381 | | /** |
11382 | | Concatenate `t` and `ρ` into the public key. |
11383 | | */ |
11384 | | /** |
11385 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.serialize_public_key |
11386 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
11387 | | with const generics |
11388 | | - K= 3 |
11389 | | - RANKED_BYTES_PER_RING_ELEMENT= 1152 |
11390 | | - PUBLIC_KEY_SIZE= 1184 |
11391 | | */ |
11392 | | static KRML_MUSTINLINE void libcrux_ml_kem_ind_cpa_serialize_public_key_79( |
11393 | | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *t_as_ntt, |
11394 | 0 | Eurydice_slice seed_for_a, uint8_t ret[1184U]) { |
11395 | 0 | uint8_t public_key_serialized[1184U] = {0U}; |
11396 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice2( |
11397 | 0 | public_key_serialized, (size_t)0U, (size_t)1152U, uint8_t); |
11398 | 0 | uint8_t ret0[1152U]; |
11399 | 0 | libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(t_as_ntt, ret0); |
11400 | 0 | Eurydice_slice_copy( |
11401 | 0 | uu____0, Eurydice_array_to_slice((size_t)1152U, ret0, uint8_t), uint8_t); |
11402 | 0 | Eurydice_slice_copy( |
11403 | 0 | Eurydice_array_to_subslice_from((size_t)1184U, public_key_serialized, |
11404 | 0 | (size_t)1152U, uint8_t, size_t), |
11405 | 0 | seed_for_a, uint8_t); |
11406 | 0 | memcpy(ret, public_key_serialized, (size_t)1184U * sizeof(uint8_t)); |
11407 | 0 | } |
11408 | | |
11409 | | /** |
11410 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair |
11411 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
11412 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
11413 | | libcrux_ml_kem_variant_MlKem with const generics |
11414 | | - K= 3 |
11415 | | - PRIVATE_KEY_SIZE= 1152 |
11416 | | - PUBLIC_KEY_SIZE= 1184 |
11417 | | - RANKED_BYTES_PER_RING_ELEMENT= 1152 |
11418 | | - ETA1= 2 |
11419 | | - ETA1_RANDOMNESS_SIZE= 128 |
11420 | | */ |
11421 | | static inline libcrux_ml_kem_utils_extraction_helper_Keypair768 |
11422 | 0 | libcrux_ml_kem_ind_cpa_generate_keypair_fc(Eurydice_slice key_generation_seed) { |
11423 | 0 | uint8_t hashed[64U]; |
11424 | 0 | libcrux_ml_kem_variant_cpa_keygen_seed_d8_0e(key_generation_seed, hashed); |
11425 | 0 | Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at( |
11426 | 0 | Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U, |
11427 | 0 | uint8_t, Eurydice_slice_uint8_t_x2); |
11428 | 0 | Eurydice_slice seed_for_A0 = uu____0.fst; |
11429 | 0 | Eurydice_slice seed_for_secret_and_error = uu____0.snd; |
11430 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U]; |
11431 | 0 | uint8_t ret[34U]; |
11432 | 0 | libcrux_ml_kem_utils_into_padded_array_ea1(seed_for_A0, ret); |
11433 | 0 | libcrux_ml_kem_matrix_sample_matrix_A_38(ret, true, A_transpose); |
11434 | 0 | uint8_t prf_input[33U]; |
11435 | 0 | libcrux_ml_kem_utils_into_padded_array_ea2(seed_for_secret_and_error, |
11436 | 0 | prf_input); |
11437 | | /* Passing arrays by value in Rust generates a copy in C */ |
11438 | 0 | uint8_t copy_of_prf_input0[33U]; |
11439 | 0 | memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t)); |
11440 | 0 | tuple_b0 uu____2 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc( |
11441 | 0 | copy_of_prf_input0, 0U); |
11442 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U]; |
11443 | 0 | memcpy( |
11444 | 0 | secret_as_ntt, uu____2.fst, |
11445 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
11446 | 0 | uint8_t domain_separator = uu____2.snd; |
11447 | | /* Passing arrays by value in Rust generates a copy in C */ |
11448 | 0 | uint8_t copy_of_prf_input[33U]; |
11449 | 0 | memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t)); |
11450 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_as_ntt[3U]; |
11451 | 0 | memcpy( |
11452 | 0 | error_as_ntt, |
11453 | 0 | libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(copy_of_prf_input, |
11454 | 0 | domain_separator) |
11455 | 0 | .fst, |
11456 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
11457 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U]; |
11458 | 0 | libcrux_ml_kem_matrix_compute_As_plus_e_60(A_transpose, secret_as_ntt, |
11459 | 0 | error_as_ntt, t_as_ntt); |
11460 | 0 | uint8_t seed_for_A[32U]; |
11461 | 0 | Result_00 dst; |
11462 | 0 | Eurydice_slice_to_array2(&dst, seed_for_A0, Eurydice_slice, uint8_t[32U]); |
11463 | 0 | unwrap_41_83(dst, seed_for_A); |
11464 | 0 | uint8_t public_key_serialized[1184U]; |
11465 | 0 | libcrux_ml_kem_ind_cpa_serialize_public_key_79( |
11466 | 0 | t_as_ntt, Eurydice_array_to_slice((size_t)32U, seed_for_A, uint8_t), |
11467 | 0 | public_key_serialized); |
11468 | 0 | uint8_t secret_key_serialized[1152U]; |
11469 | 0 | libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(secret_as_ntt, |
11470 | 0 | secret_key_serialized); |
11471 | | /* Passing arrays by value in Rust generates a copy in C */ |
11472 | 0 | uint8_t copy_of_secret_key_serialized[1152U]; |
11473 | 0 | memcpy(copy_of_secret_key_serialized, secret_key_serialized, |
11474 | 0 | (size_t)1152U * sizeof(uint8_t)); |
11475 | | /* Passing arrays by value in Rust generates a copy in C */ |
11476 | 0 | uint8_t copy_of_public_key_serialized[1184U]; |
11477 | 0 | memcpy(copy_of_public_key_serialized, public_key_serialized, |
11478 | 0 | (size_t)1184U * sizeof(uint8_t)); |
11479 | 0 | libcrux_ml_kem_utils_extraction_helper_Keypair768 lit; |
11480 | 0 | memcpy(lit.fst, copy_of_secret_key_serialized, |
11481 | 0 | (size_t)1152U * sizeof(uint8_t)); |
11482 | 0 | memcpy(lit.snd, copy_of_public_key_serialized, |
11483 | 0 | (size_t)1184U * sizeof(uint8_t)); |
11484 | 0 | return lit; |
11485 | 0 | } |
11486 | | |
11487 | | /** |
11488 | | Serialize the secret key. |
11489 | | */ |
11490 | | /** |
11491 | | A monomorphic instance of libcrux_ml_kem.ind_cca.serialize_kem_secret_key |
11492 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
11493 | | with const generics |
11494 | | - K= 3 |
11495 | | - SERIALIZED_KEY_LEN= 2400 |
11496 | | */ |
11497 | | static KRML_MUSTINLINE void libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48( |
11498 | | Eurydice_slice private_key, Eurydice_slice public_key, |
11499 | 0 | Eurydice_slice implicit_rejection_value, uint8_t ret[2400U]) { |
11500 | 0 | uint8_t out[2400U] = {0U}; |
11501 | 0 | size_t pointer = (size_t)0U; |
11502 | 0 | uint8_t *uu____0 = out; |
11503 | 0 | size_t uu____1 = pointer; |
11504 | 0 | size_t uu____2 = pointer; |
11505 | 0 | Eurydice_slice_copy( |
11506 | 0 | Eurydice_array_to_subslice2( |
11507 | 0 | uu____0, uu____1, uu____2 + Eurydice_slice_len(private_key, uint8_t), |
11508 | 0 | uint8_t), |
11509 | 0 | private_key, uint8_t); |
11510 | 0 | pointer = pointer + Eurydice_slice_len(private_key, uint8_t); |
11511 | 0 | uint8_t *uu____3 = out; |
11512 | 0 | size_t uu____4 = pointer; |
11513 | 0 | size_t uu____5 = pointer; |
11514 | 0 | Eurydice_slice_copy( |
11515 | 0 | Eurydice_array_to_subslice2( |
11516 | 0 | uu____3, uu____4, uu____5 + Eurydice_slice_len(public_key, uint8_t), |
11517 | 0 | uint8_t), |
11518 | 0 | public_key, uint8_t); |
11519 | 0 | pointer = pointer + Eurydice_slice_len(public_key, uint8_t); |
11520 | 0 | Eurydice_slice uu____6 = Eurydice_array_to_subslice2( |
11521 | 0 | out, pointer, pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t); |
11522 | 0 | uint8_t ret0[32U]; |
11523 | 0 | libcrux_ml_kem_hash_functions_portable_H_f1_1a(public_key, ret0); |
11524 | 0 | Eurydice_slice_copy( |
11525 | 0 | uu____6, Eurydice_array_to_slice((size_t)32U, ret0, uint8_t), uint8_t); |
11526 | 0 | pointer = pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE; |
11527 | 0 | uint8_t *uu____7 = out; |
11528 | 0 | size_t uu____8 = pointer; |
11529 | 0 | size_t uu____9 = pointer; |
11530 | 0 | Eurydice_slice_copy( |
11531 | 0 | Eurydice_array_to_subslice2( |
11532 | 0 | uu____7, uu____8, |
11533 | 0 | uu____9 + Eurydice_slice_len(implicit_rejection_value, uint8_t), |
11534 | 0 | uint8_t), |
11535 | 0 | implicit_rejection_value, uint8_t); |
11536 | 0 | memcpy(ret, out, (size_t)2400U * sizeof(uint8_t)); |
11537 | 0 | } |
11538 | | |
11539 | | /** |
11540 | | Packed API |
11541 | | |
11542 | | Generate a key pair. |
11543 | | |
11544 | | Depending on the `Vector` and `Hasher` used, this requires different hardware |
11545 | | features |
11546 | | */ |
11547 | | /** |
11548 | | A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair |
11549 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
11550 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
11551 | | libcrux_ml_kem_variant_MlKem with const generics |
11552 | | - K= 3 |
11553 | | - CPA_PRIVATE_KEY_SIZE= 1152 |
11554 | | - PRIVATE_KEY_SIZE= 2400 |
11555 | | - PUBLIC_KEY_SIZE= 1184 |
11556 | | - BYTES_PER_RING_ELEMENT= 1152 |
11557 | | - ETA1= 2 |
11558 | | - ETA1_RANDOMNESS_SIZE= 128 |
11559 | | */ |
11560 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
11561 | 0 | libcrux_ml_kem_ind_cca_generate_keypair_8c(uint8_t randomness[64U]) { |
11562 | 0 | Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice2( |
11563 | 0 | randomness, (size_t)0U, |
11564 | 0 | LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t); |
11565 | 0 | Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from( |
11566 | 0 | (size_t)64U, randomness, |
11567 | 0 | LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t, |
11568 | 0 | size_t); |
11569 | 0 | libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 = |
11570 | 0 | libcrux_ml_kem_ind_cpa_generate_keypair_fc(ind_cpa_keypair_randomness); |
11571 | 0 | uint8_t ind_cpa_private_key[1152U]; |
11572 | 0 | memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t)); |
11573 | 0 | uint8_t public_key[1184U]; |
11574 | 0 | memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t)); |
11575 | 0 | uint8_t secret_key_serialized[2400U]; |
11576 | 0 | libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48( |
11577 | 0 | Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t), |
11578 | 0 | Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t), |
11579 | 0 | implicit_rejection_value, secret_key_serialized); |
11580 | | /* Passing arrays by value in Rust generates a copy in C */ |
11581 | 0 | uint8_t copy_of_secret_key_serialized[2400U]; |
11582 | 0 | memcpy(copy_of_secret_key_serialized, secret_key_serialized, |
11583 | 0 | (size_t)2400U * sizeof(uint8_t)); |
11584 | 0 | libcrux_ml_kem_types_MlKemPrivateKey_55 private_key = |
11585 | 0 | libcrux_ml_kem_types_from_05_f2(copy_of_secret_key_serialized); |
11586 | 0 | libcrux_ml_kem_types_MlKemPrivateKey_55 uu____2 = private_key; |
11587 | | /* Passing arrays by value in Rust generates a copy in C */ |
11588 | 0 | uint8_t copy_of_public_key[1184U]; |
11589 | 0 | memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t)); |
11590 | 0 | return libcrux_ml_kem_types_from_17_35( |
11591 | 0 | uu____2, libcrux_ml_kem_types_from_b6_da(copy_of_public_key)); |
11592 | 0 | } |
11593 | | |
11594 | | /** |
11595 | | Portable generate key pair. |
11596 | | */ |
11597 | | /** |
11598 | | A monomorphic instance of |
11599 | | libcrux_ml_kem.ind_cca.instantiations.portable.generate_keypair with const |
11600 | | generics |
11601 | | - K= 3 |
11602 | | - CPA_PRIVATE_KEY_SIZE= 1152 |
11603 | | - PRIVATE_KEY_SIZE= 2400 |
11604 | | - PUBLIC_KEY_SIZE= 1184 |
11605 | | - BYTES_PER_RING_ELEMENT= 1152 |
11606 | | - ETA1= 2 |
11607 | | - ETA1_RANDOMNESS_SIZE= 128 |
11608 | | */ |
11609 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
11610 | | libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_d5( |
11611 | 0 | uint8_t randomness[64U]) { |
11612 | | /* Passing arrays by value in Rust generates a copy in C */ |
11613 | 0 | uint8_t copy_of_randomness[64U]; |
11614 | 0 | memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t)); |
11615 | 0 | return libcrux_ml_kem_ind_cca_generate_keypair_8c(copy_of_randomness); |
11616 | 0 | } |
11617 | | |
11618 | | /** |
11619 | | Generate ML-KEM 768 Key Pair |
11620 | | */ |
11621 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
11622 | 0 | libcrux_ml_kem_mlkem768_portable_generate_key_pair(uint8_t randomness[64U]) { |
11623 | | /* Passing arrays by value in Rust generates a copy in C */ |
11624 | 0 | uint8_t copy_of_randomness[64U]; |
11625 | 0 | memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t)); |
11626 | 0 | return libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_d5( |
11627 | 0 | copy_of_randomness); |
11628 | 0 | } |
11629 | | |
11630 | | /** |
11631 | | This function found in impl {(libcrux_ml_kem::variant::Variant for |
11632 | | libcrux_ml_kem::variant::Kyber)} |
11633 | | */ |
11634 | | /** |
11635 | | A monomorphic instance of libcrux_ml_kem.variant.kdf_33 |
11636 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
11637 | | with const generics |
11638 | | - K= 3 |
11639 | | - CIPHERTEXT_SIZE= 1088 |
11640 | | */ |
11641 | | static KRML_MUSTINLINE void libcrux_ml_kem_variant_kdf_33_f0( |
11642 | | Eurydice_slice shared_secret, |
11643 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
11644 | 0 | uint8_t kdf_input[64U]; |
11645 | 0 | libcrux_ml_kem_utils_into_padded_array_ea(shared_secret, kdf_input); |
11646 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice_from( |
11647 | 0 | (size_t)64U, kdf_input, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t, |
11648 | 0 | size_t); |
11649 | 0 | uint8_t ret0[32U]; |
11650 | 0 | libcrux_ml_kem_hash_functions_portable_H_f1_1a( |
11651 | 0 | Eurydice_array_to_slice((size_t)1088U, |
11652 | 0 | libcrux_ml_kem_types_as_slice_d4_1d(ciphertext), |
11653 | 0 | uint8_t), |
11654 | 0 | ret0); |
11655 | 0 | Eurydice_slice_copy( |
11656 | 0 | uu____0, Eurydice_array_to_slice((size_t)32U, ret0, uint8_t), uint8_t); |
11657 | 0 | uint8_t ret1[32U]; |
11658 | 0 | libcrux_ml_kem_hash_functions_portable_PRF_f1_ee( |
11659 | 0 | Eurydice_array_to_slice((size_t)64U, kdf_input, uint8_t), ret1); |
11660 | 0 | memcpy(ret, ret1, (size_t)32U * sizeof(uint8_t)); |
11661 | 0 | } |
11662 | | |
11663 | | /** |
11664 | | A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate |
11665 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
11666 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
11667 | | libcrux_ml_kem_variant_Kyber with const generics |
11668 | | - K= 3 |
11669 | | - SECRET_KEY_SIZE= 2400 |
11670 | | - CPA_SECRET_KEY_SIZE= 1152 |
11671 | | - PUBLIC_KEY_SIZE= 1184 |
11672 | | - CIPHERTEXT_SIZE= 1088 |
11673 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11674 | | - C1_SIZE= 960 |
11675 | | - C2_SIZE= 128 |
11676 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11677 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11678 | | - C1_BLOCK_SIZE= 320 |
11679 | | - ETA1= 2 |
11680 | | - ETA1_RANDOMNESS_SIZE= 128 |
11681 | | - ETA2= 2 |
11682 | | - ETA2_RANDOMNESS_SIZE= 128 |
11683 | | - IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120 |
11684 | | */ |
11685 | | static inline void libcrux_ml_kem_ind_cca_decapsulate_700( |
11686 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
11687 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
11688 | 0 | Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at( |
11689 | 0 | Eurydice_array_to_slice((size_t)2400U, private_key->value, uint8_t), |
11690 | 0 | (size_t)1152U, uint8_t, Eurydice_slice_uint8_t_x2); |
11691 | 0 | Eurydice_slice ind_cpa_secret_key = uu____0.fst; |
11692 | 0 | Eurydice_slice secret_key0 = uu____0.snd; |
11693 | 0 | Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at( |
11694 | 0 | secret_key0, (size_t)1184U, uint8_t, Eurydice_slice_uint8_t_x2); |
11695 | 0 | Eurydice_slice ind_cpa_public_key = uu____1.fst; |
11696 | 0 | Eurydice_slice secret_key = uu____1.snd; |
11697 | 0 | Eurydice_slice_uint8_t_x2 uu____2 = Eurydice_slice_split_at( |
11698 | 0 | secret_key, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t, |
11699 | 0 | Eurydice_slice_uint8_t_x2); |
11700 | 0 | Eurydice_slice ind_cpa_public_key_hash = uu____2.fst; |
11701 | 0 | Eurydice_slice implicit_rejection_value = uu____2.snd; |
11702 | 0 | uint8_t decrypted[32U]; |
11703 | 0 | libcrux_ml_kem_ind_cpa_decrypt_43(ind_cpa_secret_key, ciphertext->value, |
11704 | 0 | decrypted); |
11705 | 0 | uint8_t to_hash0[64U]; |
11706 | 0 | libcrux_ml_kem_utils_into_padded_array_ea( |
11707 | 0 | Eurydice_array_to_slice((size_t)32U, decrypted, uint8_t), to_hash0); |
11708 | 0 | Eurydice_slice_copy( |
11709 | 0 | Eurydice_array_to_subslice_from( |
11710 | 0 | (size_t)64U, to_hash0, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, |
11711 | 0 | uint8_t, size_t), |
11712 | 0 | ind_cpa_public_key_hash, uint8_t); |
11713 | 0 | uint8_t hashed[64U]; |
11714 | 0 | libcrux_ml_kem_hash_functions_portable_G_f1_e4( |
11715 | 0 | Eurydice_array_to_slice((size_t)64U, to_hash0, uint8_t), hashed); |
11716 | 0 | Eurydice_slice_uint8_t_x2 uu____3 = Eurydice_slice_split_at( |
11717 | 0 | Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), |
11718 | 0 | LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t, |
11719 | 0 | Eurydice_slice_uint8_t_x2); |
11720 | 0 | Eurydice_slice shared_secret0 = uu____3.fst; |
11721 | 0 | Eurydice_slice pseudorandomness = uu____3.snd; |
11722 | 0 | uint8_t to_hash[1120U]; |
11723 | 0 | libcrux_ml_kem_utils_into_padded_array_ea0(implicit_rejection_value, to_hash); |
11724 | 0 | Eurydice_slice uu____4 = Eurydice_array_to_subslice_from( |
11725 | 0 | (size_t)1120U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, |
11726 | 0 | uint8_t, size_t); |
11727 | 0 | Eurydice_slice_copy(uu____4, libcrux_ml_kem_types_as_ref_00_24(ciphertext), |
11728 | 0 | uint8_t); |
11729 | 0 | uint8_t implicit_rejection_shared_secret0[32U]; |
11730 | 0 | libcrux_ml_kem_hash_functions_portable_PRF_f1_ee( |
11731 | 0 | Eurydice_array_to_slice((size_t)1120U, to_hash, uint8_t), |
11732 | 0 | implicit_rejection_shared_secret0); |
11733 | 0 | Eurydice_slice uu____5 = ind_cpa_public_key; |
11734 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11735 | 0 | uint8_t copy_of_decrypted[32U]; |
11736 | 0 | memcpy(copy_of_decrypted, decrypted, (size_t)32U * sizeof(uint8_t)); |
11737 | 0 | uint8_t expected_ciphertext[1088U]; |
11738 | 0 | libcrux_ml_kem_ind_cpa_encrypt_60(uu____5, copy_of_decrypted, |
11739 | 0 | pseudorandomness, expected_ciphertext); |
11740 | 0 | uint8_t implicit_rejection_shared_secret[32U]; |
11741 | 0 | libcrux_ml_kem_variant_kdf_33_f0( |
11742 | 0 | Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret0, |
11743 | 0 | uint8_t), |
11744 | 0 | ciphertext, implicit_rejection_shared_secret); |
11745 | 0 | uint8_t shared_secret[32U]; |
11746 | 0 | libcrux_ml_kem_variant_kdf_33_f0(shared_secret0, ciphertext, shared_secret); |
11747 | 0 | uint8_t ret0[32U]; |
11748 | 0 | libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time( |
11749 | 0 | libcrux_ml_kem_types_as_ref_00_24(ciphertext), |
11750 | 0 | Eurydice_array_to_slice((size_t)1088U, expected_ciphertext, uint8_t), |
11751 | 0 | Eurydice_array_to_slice((size_t)32U, shared_secret, uint8_t), |
11752 | 0 | Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret, |
11753 | 0 | uint8_t), |
11754 | 0 | ret0); |
11755 | 0 | memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t)); |
11756 | 0 | } |
11757 | | |
11758 | | /** |
11759 | | Portable decapsulate |
11760 | | */ |
11761 | | /** |
11762 | | A monomorphic instance of |
11763 | | libcrux_ml_kem.ind_cca.instantiations.portable.kyber_decapsulate with const |
11764 | | generics |
11765 | | - K= 3 |
11766 | | - SECRET_KEY_SIZE= 2400 |
11767 | | - CPA_SECRET_KEY_SIZE= 1152 |
11768 | | - PUBLIC_KEY_SIZE= 1184 |
11769 | | - CIPHERTEXT_SIZE= 1088 |
11770 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11771 | | - C1_SIZE= 960 |
11772 | | - C2_SIZE= 128 |
11773 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11774 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11775 | | - C1_BLOCK_SIZE= 320 |
11776 | | - ETA1= 2 |
11777 | | - ETA1_RANDOMNESS_SIZE= 128 |
11778 | | - ETA2= 2 |
11779 | | - ETA2_RANDOMNESS_SIZE= 128 |
11780 | | - IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120 |
11781 | | */ |
11782 | | static inline void |
11783 | | libcrux_ml_kem_ind_cca_instantiations_portable_kyber_decapsulate_fc( |
11784 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
11785 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
11786 | 0 | libcrux_ml_kem_ind_cca_decapsulate_700(private_key, ciphertext, ret); |
11787 | 0 | } |
11788 | | |
11789 | | /** |
11790 | | Decapsulate Kyber 768 |
11791 | | |
11792 | | Generates an [`MlKemSharedSecret`]. |
11793 | | The input is a reference to an [`MlKem768PrivateKey`] and an |
11794 | | [`MlKem768Ciphertext`]. |
11795 | | */ |
11796 | | static inline void libcrux_ml_kem_mlkem768_portable_kyber_decapsulate( |
11797 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
11798 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) { |
11799 | 0 | libcrux_ml_kem_ind_cca_instantiations_portable_kyber_decapsulate_fc( |
11800 | 0 | private_key, ciphertext, ret); |
11801 | 0 | } |
11802 | | |
11803 | | /** |
11804 | | This function found in impl {(libcrux_ml_kem::variant::Variant for |
11805 | | libcrux_ml_kem::variant::Kyber)} |
11806 | | */ |
11807 | | /** |
11808 | | A monomorphic instance of libcrux_ml_kem.variant.entropy_preprocess_33 |
11809 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
11810 | | with const generics |
11811 | | - K= 3 |
11812 | | */ |
11813 | | static KRML_MUSTINLINE void libcrux_ml_kem_variant_entropy_preprocess_33_8a( |
11814 | 0 | Eurydice_slice randomness, uint8_t ret[32U]) { |
11815 | 0 | libcrux_ml_kem_hash_functions_portable_H_f1_1a(randomness, ret); |
11816 | 0 | } |
11817 | | |
11818 | | /** |
11819 | | A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate |
11820 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
11821 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
11822 | | libcrux_ml_kem_variant_Kyber with const generics |
11823 | | - K= 3 |
11824 | | - CIPHERTEXT_SIZE= 1088 |
11825 | | - PUBLIC_KEY_SIZE= 1184 |
11826 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11827 | | - C1_SIZE= 960 |
11828 | | - C2_SIZE= 128 |
11829 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11830 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11831 | | - VECTOR_U_BLOCK_LEN= 320 |
11832 | | - ETA1= 2 |
11833 | | - ETA1_RANDOMNESS_SIZE= 128 |
11834 | | - ETA2= 2 |
11835 | | - ETA2_RANDOMNESS_SIZE= 128 |
11836 | | */ |
11837 | | static inline tuple_3c libcrux_ml_kem_ind_cca_encapsulate_cd0( |
11838 | | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key, |
11839 | 0 | uint8_t randomness[32U]) { |
11840 | 0 | uint8_t randomness0[32U]; |
11841 | 0 | libcrux_ml_kem_variant_entropy_preprocess_33_8a( |
11842 | 0 | Eurydice_array_to_slice((size_t)32U, randomness, uint8_t), randomness0); |
11843 | 0 | uint8_t to_hash[64U]; |
11844 | 0 | libcrux_ml_kem_utils_into_padded_array_ea( |
11845 | 0 | Eurydice_array_to_slice((size_t)32U, randomness0, uint8_t), to_hash); |
11846 | 0 | Eurydice_slice uu____0 = Eurydice_array_to_subslice_from( |
11847 | 0 | (size_t)64U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t, |
11848 | 0 | size_t); |
11849 | 0 | uint8_t ret[32U]; |
11850 | 0 | libcrux_ml_kem_hash_functions_portable_H_f1_1a( |
11851 | 0 | Eurydice_array_to_slice((size_t)1184U, |
11852 | 0 | libcrux_ml_kem_types_as_slice_cb_50(public_key), |
11853 | 0 | uint8_t), |
11854 | 0 | ret); |
11855 | 0 | Eurydice_slice_copy( |
11856 | 0 | uu____0, Eurydice_array_to_slice((size_t)32U, ret, uint8_t), uint8_t); |
11857 | 0 | uint8_t hashed[64U]; |
11858 | 0 | libcrux_ml_kem_hash_functions_portable_G_f1_e4( |
11859 | 0 | Eurydice_array_to_slice((size_t)64U, to_hash, uint8_t), hashed); |
11860 | 0 | Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at( |
11861 | 0 | Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), |
11862 | 0 | LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t, |
11863 | 0 | Eurydice_slice_uint8_t_x2); |
11864 | 0 | Eurydice_slice shared_secret = uu____1.fst; |
11865 | 0 | Eurydice_slice pseudorandomness = uu____1.snd; |
11866 | 0 | Eurydice_slice uu____2 = Eurydice_array_to_slice( |
11867 | 0 | (size_t)1184U, libcrux_ml_kem_types_as_slice_cb_50(public_key), uint8_t); |
11868 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11869 | 0 | uint8_t copy_of_randomness[32U]; |
11870 | 0 | memcpy(copy_of_randomness, randomness0, (size_t)32U * sizeof(uint8_t)); |
11871 | 0 | uint8_t ciphertext[1088U]; |
11872 | 0 | libcrux_ml_kem_ind_cpa_encrypt_60(uu____2, copy_of_randomness, |
11873 | 0 | pseudorandomness, ciphertext); |
11874 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11875 | 0 | uint8_t copy_of_ciphertext[1088U]; |
11876 | 0 | memcpy(copy_of_ciphertext, ciphertext, (size_t)1088U * sizeof(uint8_t)); |
11877 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext ciphertext0 = |
11878 | 0 | libcrux_ml_kem_types_from_01_9f(copy_of_ciphertext); |
11879 | 0 | uint8_t shared_secret_array[32U]; |
11880 | 0 | libcrux_ml_kem_variant_kdf_33_f0(shared_secret, &ciphertext0, |
11881 | 0 | shared_secret_array); |
11882 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext uu____5 = ciphertext0; |
11883 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11884 | 0 | uint8_t copy_of_shared_secret_array[32U]; |
11885 | 0 | memcpy(copy_of_shared_secret_array, shared_secret_array, |
11886 | 0 | (size_t)32U * sizeof(uint8_t)); |
11887 | 0 | tuple_3c lit; |
11888 | 0 | lit.fst = uu____5; |
11889 | 0 | memcpy(lit.snd, copy_of_shared_secret_array, (size_t)32U * sizeof(uint8_t)); |
11890 | 0 | return lit; |
11891 | 0 | } |
11892 | | |
11893 | | /** |
11894 | | Portable encapsulate |
11895 | | */ |
11896 | | /** |
11897 | | A monomorphic instance of |
11898 | | libcrux_ml_kem.ind_cca.instantiations.portable.kyber_encapsulate with const |
11899 | | generics |
11900 | | - K= 3 |
11901 | | - CIPHERTEXT_SIZE= 1088 |
11902 | | - PUBLIC_KEY_SIZE= 1184 |
11903 | | - T_AS_NTT_ENCODED_SIZE= 1152 |
11904 | | - C1_SIZE= 960 |
11905 | | - C2_SIZE= 128 |
11906 | | - VECTOR_U_COMPRESSION_FACTOR= 10 |
11907 | | - VECTOR_V_COMPRESSION_FACTOR= 4 |
11908 | | - VECTOR_U_BLOCK_LEN= 320 |
11909 | | - ETA1= 2 |
11910 | | - ETA1_RANDOMNESS_SIZE= 128 |
11911 | | - ETA2= 2 |
11912 | | - ETA2_RANDOMNESS_SIZE= 128 |
11913 | | */ |
11914 | | static inline tuple_3c |
11915 | | libcrux_ml_kem_ind_cca_instantiations_portable_kyber_encapsulate_7a( |
11916 | | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key, |
11917 | 0 | uint8_t randomness[32U]) { |
11918 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key; |
11919 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11920 | 0 | uint8_t copy_of_randomness[32U]; |
11921 | 0 | memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t)); |
11922 | 0 | return libcrux_ml_kem_ind_cca_encapsulate_cd0(uu____0, copy_of_randomness); |
11923 | 0 | } |
11924 | | |
11925 | | /** |
11926 | | Encapsulate Kyber 768 |
11927 | | |
11928 | | Generates an ([`MlKem768Ciphertext`], [`MlKemSharedSecret`]) tuple. |
11929 | | The input is a reference to an [`MlKem768PublicKey`] and [`SHARED_SECRET_SIZE`] |
11930 | | bytes of `randomness`. |
11931 | | */ |
11932 | | static inline tuple_3c libcrux_ml_kem_mlkem768_portable_kyber_encapsulate( |
11933 | | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key, |
11934 | 0 | uint8_t randomness[32U]) { |
11935 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 *uu____0 = public_key; |
11936 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11937 | 0 | uint8_t copy_of_randomness[32U]; |
11938 | 0 | memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t)); |
11939 | 0 | return libcrux_ml_kem_ind_cca_instantiations_portable_kyber_encapsulate_7a( |
11940 | 0 | uu____0, copy_of_randomness); |
11941 | 0 | } |
11942 | | |
11943 | | /** |
11944 | | This function found in impl {(libcrux_ml_kem::variant::Variant for |
11945 | | libcrux_ml_kem::variant::Kyber)} |
11946 | | */ |
11947 | | /** |
11948 | | A monomorphic instance of libcrux_ml_kem.variant.cpa_keygen_seed_33 |
11949 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
11950 | | with const generics |
11951 | | - K= 3 |
11952 | | */ |
11953 | | static KRML_MUSTINLINE void libcrux_ml_kem_variant_cpa_keygen_seed_33_b6( |
11954 | 0 | Eurydice_slice key_generation_seed, uint8_t ret[64U]) { |
11955 | 0 | libcrux_ml_kem_hash_functions_portable_G_f1_e4(key_generation_seed, ret); |
11956 | 0 | } |
11957 | | |
11958 | | /** |
11959 | | A monomorphic instance of libcrux_ml_kem.ind_cpa.generate_keypair |
11960 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
11961 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
11962 | | libcrux_ml_kem_variant_Kyber with const generics |
11963 | | - K= 3 |
11964 | | - PRIVATE_KEY_SIZE= 1152 |
11965 | | - PUBLIC_KEY_SIZE= 1184 |
11966 | | - RANKED_BYTES_PER_RING_ELEMENT= 1152 |
11967 | | - ETA1= 2 |
11968 | | - ETA1_RANDOMNESS_SIZE= 128 |
11969 | | */ |
11970 | | static inline libcrux_ml_kem_utils_extraction_helper_Keypair768 |
11971 | | libcrux_ml_kem_ind_cpa_generate_keypair_fc0( |
11972 | 0 | Eurydice_slice key_generation_seed) { |
11973 | 0 | uint8_t hashed[64U]; |
11974 | 0 | libcrux_ml_kem_variant_cpa_keygen_seed_33_b6(key_generation_seed, hashed); |
11975 | 0 | Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at( |
11976 | 0 | Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U, |
11977 | 0 | uint8_t, Eurydice_slice_uint8_t_x2); |
11978 | 0 | Eurydice_slice seed_for_A0 = uu____0.fst; |
11979 | 0 | Eurydice_slice seed_for_secret_and_error = uu____0.snd; |
11980 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U]; |
11981 | 0 | uint8_t ret[34U]; |
11982 | 0 | libcrux_ml_kem_utils_into_padded_array_ea1(seed_for_A0, ret); |
11983 | 0 | libcrux_ml_kem_matrix_sample_matrix_A_38(ret, true, A_transpose); |
11984 | 0 | uint8_t prf_input[33U]; |
11985 | 0 | libcrux_ml_kem_utils_into_padded_array_ea2(seed_for_secret_and_error, |
11986 | 0 | prf_input); |
11987 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11988 | 0 | uint8_t copy_of_prf_input0[33U]; |
11989 | 0 | memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t)); |
11990 | 0 | tuple_b0 uu____2 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc( |
11991 | 0 | copy_of_prf_input0, 0U); |
11992 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U]; |
11993 | 0 | memcpy( |
11994 | 0 | secret_as_ntt, uu____2.fst, |
11995 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
11996 | 0 | uint8_t domain_separator = uu____2.snd; |
11997 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
11998 | 0 | uint8_t copy_of_prf_input[33U]; |
11999 | 0 | memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t)); |
12000 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_as_ntt[3U]; |
12001 | 0 | memcpy( |
12002 | 0 | error_as_ntt, |
12003 | 0 | libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(copy_of_prf_input, |
12004 | 0 | domain_separator) |
12005 | 0 | .fst, |
12006 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
12007 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U]; |
12008 | 0 | libcrux_ml_kem_matrix_compute_As_plus_e_60(A_transpose, secret_as_ntt, |
12009 | 0 | error_as_ntt, t_as_ntt); |
12010 | 0 | uint8_t seed_for_A[32U]; |
12011 | 0 | Result_00 dst; |
12012 | 0 | Eurydice_slice_to_array2(&dst, seed_for_A0, Eurydice_slice, uint8_t[32U]); |
12013 | 0 | unwrap_41_83(dst, seed_for_A); |
12014 | 0 | uint8_t public_key_serialized[1184U]; |
12015 | 0 | libcrux_ml_kem_ind_cpa_serialize_public_key_79( |
12016 | 0 | t_as_ntt, Eurydice_array_to_slice((size_t)32U, seed_for_A, uint8_t), |
12017 | 0 | public_key_serialized); |
12018 | 0 | uint8_t secret_key_serialized[1152U]; |
12019 | 0 | libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(secret_as_ntt, |
12020 | 0 | secret_key_serialized); |
12021 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
12022 | 0 | uint8_t copy_of_secret_key_serialized[1152U]; |
12023 | 0 | memcpy(copy_of_secret_key_serialized, secret_key_serialized, |
12024 | 0 | (size_t)1152U * sizeof(uint8_t)); |
12025 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
12026 | 0 | uint8_t copy_of_public_key_serialized[1184U]; |
12027 | 0 | memcpy(copy_of_public_key_serialized, public_key_serialized, |
12028 | 0 | (size_t)1184U * sizeof(uint8_t)); |
12029 | 0 | libcrux_ml_kem_utils_extraction_helper_Keypair768 lit; |
12030 | 0 | memcpy(lit.fst, copy_of_secret_key_serialized, |
12031 | 0 | (size_t)1152U * sizeof(uint8_t)); |
12032 | 0 | memcpy(lit.snd, copy_of_public_key_serialized, |
12033 | 0 | (size_t)1184U * sizeof(uint8_t)); |
12034 | 0 | return lit; |
12035 | 0 | } |
12036 | | |
12037 | | /** |
12038 | | Packed API |
12039 | | |
12040 | | Generate a key pair. |
12041 | | |
12042 | | Depending on the `Vector` and `Hasher` used, this requires different hardware |
12043 | | features |
12044 | | */ |
12045 | | /** |
12046 | | A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair |
12047 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector, |
12048 | | libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]], |
12049 | | libcrux_ml_kem_variant_Kyber with const generics |
12050 | | - K= 3 |
12051 | | - CPA_PRIVATE_KEY_SIZE= 1152 |
12052 | | - PRIVATE_KEY_SIZE= 2400 |
12053 | | - PUBLIC_KEY_SIZE= 1184 |
12054 | | - BYTES_PER_RING_ELEMENT= 1152 |
12055 | | - ETA1= 2 |
12056 | | - ETA1_RANDOMNESS_SIZE= 128 |
12057 | | */ |
12058 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
12059 | 0 | libcrux_ml_kem_ind_cca_generate_keypair_8c0(uint8_t randomness[64U]) { |
12060 | 0 | Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice2( |
12061 | 0 | randomness, (size_t)0U, |
12062 | 0 | LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t); |
12063 | 0 | Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from( |
12064 | 0 | (size_t)64U, randomness, |
12065 | 0 | LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t, |
12066 | 0 | size_t); |
12067 | 0 | libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 = |
12068 | 0 | libcrux_ml_kem_ind_cpa_generate_keypair_fc0(ind_cpa_keypair_randomness); |
12069 | 0 | uint8_t ind_cpa_private_key[1152U]; |
12070 | 0 | memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t)); |
12071 | 0 | uint8_t public_key[1184U]; |
12072 | 0 | memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t)); |
12073 | 0 | uint8_t secret_key_serialized[2400U]; |
12074 | 0 | libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48( |
12075 | 0 | Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t), |
12076 | 0 | Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t), |
12077 | 0 | implicit_rejection_value, secret_key_serialized); |
12078 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
12079 | 0 | uint8_t copy_of_secret_key_serialized[2400U]; |
12080 | 0 | memcpy(copy_of_secret_key_serialized, secret_key_serialized, |
12081 | 0 | (size_t)2400U * sizeof(uint8_t)); |
12082 | 0 | libcrux_ml_kem_types_MlKemPrivateKey_55 private_key = |
12083 | 0 | libcrux_ml_kem_types_from_05_f2(copy_of_secret_key_serialized); |
12084 | 0 | libcrux_ml_kem_types_MlKemPrivateKey_55 uu____2 = private_key; |
12085 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
12086 | 0 | uint8_t copy_of_public_key[1184U]; |
12087 | 0 | memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t)); |
12088 | 0 | return libcrux_ml_kem_types_from_17_35( |
12089 | 0 | uu____2, libcrux_ml_kem_types_from_b6_da(copy_of_public_key)); |
12090 | 0 | } |
12091 | | |
12092 | | /** |
12093 | | A monomorphic instance of |
12094 | | libcrux_ml_kem.ind_cca.instantiations.portable.kyber_generate_keypair with const |
12095 | | generics |
12096 | | - K= 3 |
12097 | | - CPA_PRIVATE_KEY_SIZE= 1152 |
12098 | | - PRIVATE_KEY_SIZE= 2400 |
12099 | | - PUBLIC_KEY_SIZE= 1184 |
12100 | | - BYTES_PER_RING_ELEMENT= 1152 |
12101 | | - ETA1= 2 |
12102 | | - ETA1_RANDOMNESS_SIZE= 128 |
12103 | | */ |
12104 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
12105 | | libcrux_ml_kem_ind_cca_instantiations_portable_kyber_generate_keypair_9b( |
12106 | 0 | uint8_t randomness[64U]) { |
12107 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
12108 | 0 | uint8_t copy_of_randomness[64U]; |
12109 | 0 | memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t)); |
12110 | 0 | return libcrux_ml_kem_ind_cca_generate_keypair_8c0(copy_of_randomness); |
12111 | 0 | } |
12112 | | |
12113 | | /** |
12114 | | Generate Kyber 768 Key Pair |
12115 | | */ |
12116 | | static inline libcrux_ml_kem_mlkem768_MlKem768KeyPair |
12117 | | libcrux_ml_kem_mlkem768_portable_kyber_generate_key_pair( |
12118 | 0 | uint8_t randomness[64U]) { |
12119 | 0 | /* Passing arrays by value in Rust generates a copy in C */ |
12120 | 0 | uint8_t copy_of_randomness[64U]; |
12121 | 0 | memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t)); |
12122 | 0 | return libcrux_ml_kem_ind_cca_instantiations_portable_kyber_generate_keypair_9b( |
12123 | 0 | copy_of_randomness); |
12124 | 0 | } |
12125 | | |
12126 | | /** |
12127 | | Validate an ML-KEM private key. |
12128 | | |
12129 | | This implements the Hash check in 7.3 3. |
12130 | | Note that the size checks in 7.2 1 and 2 are covered by the `SECRET_KEY_SIZE` |
12131 | | and `CIPHERTEXT_SIZE` in the `private_key` and `ciphertext` types. |
12132 | | */ |
12133 | | /** |
12134 | | A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key |
12135 | | with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]] |
12136 | | with const generics |
12137 | | - K= 3 |
12138 | | - SECRET_KEY_SIZE= 2400 |
12139 | | - CIPHERTEXT_SIZE= 1088 |
12140 | | */ |
12141 | | static KRML_MUSTINLINE bool libcrux_ml_kem_ind_cca_validate_private_key_e7( |
12142 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
12143 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *_ciphertext) { |
12144 | 0 | uint8_t t[32U]; |
12145 | 0 | libcrux_ml_kem_hash_functions_portable_H_f1_1a( |
12146 | 0 | Eurydice_array_to_subslice2(private_key->value, (size_t)384U * (size_t)3U, |
12147 | 0 | (size_t)768U * (size_t)3U + (size_t)32U, |
12148 | 0 | uint8_t), |
12149 | 0 | t); |
12150 | 0 | Eurydice_slice expected = Eurydice_array_to_subslice2( |
12151 | 0 | private_key->value, (size_t)768U * (size_t)3U + (size_t)32U, |
12152 | 0 | (size_t)768U * (size_t)3U + (size_t)64U, uint8_t); |
12153 | 0 | return core_array_equality___core__cmp__PartialEq__0___Slice_U____for__Array_T__N___3__eq( |
12154 | 0 | (size_t)32U, t, &expected, uint8_t, uint8_t, bool); |
12155 | 0 | } |
12156 | | |
12157 | | /** |
12158 | | Portable private key validation |
12159 | | */ |
12160 | | /** |
12161 | | A monomorphic instance of |
12162 | | libcrux_ml_kem.ind_cca.instantiations.portable.validate_private_key with const |
12163 | | generics |
12164 | | - K= 3 |
12165 | | - SECRET_KEY_SIZE= 2400 |
12166 | | - CIPHERTEXT_SIZE= 1088 |
12167 | | */ |
12168 | | static KRML_MUSTINLINE bool |
12169 | | libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_9c( |
12170 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
12171 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext) { |
12172 | 0 | return libcrux_ml_kem_ind_cca_validate_private_key_e7(private_key, |
12173 | 0 | ciphertext); |
12174 | 0 | } |
12175 | | |
12176 | | /** |
12177 | | Validate a private key. |
12178 | | |
12179 | | Returns `true` if valid, and `false` otherwise. |
12180 | | */ |
12181 | | static inline bool libcrux_ml_kem_mlkem768_portable_validate_private_key( |
12182 | | libcrux_ml_kem_types_MlKemPrivateKey_55 *private_key, |
12183 | 0 | libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext) { |
12184 | 0 | return libcrux_ml_kem_ind_cca_instantiations_portable_validate_private_key_9c( |
12185 | 0 | private_key, ciphertext); |
12186 | 0 | } |
12187 | | |
12188 | | /** |
12189 | | A monomorphic instance of |
12190 | | libcrux_ml_kem.serialize.deserialize_ring_elements_reduced.closure with types |
12191 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
12192 | | - PUBLIC_KEY_SIZE= 1184 |
12193 | | - K= 3 |
12194 | | */ |
12195 | | static inline libcrux_ml_kem_polynomial_PolynomialRingElement_f0 |
12196 | | libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_closure_cd0( |
12197 | 0 | size_t _i) { |
12198 | 0 | return libcrux_ml_kem_polynomial_ZERO_89_ea(); |
12199 | 0 | } |
12200 | | |
12201 | | /** |
12202 | | This function deserializes ring elements and reduces the result by the field |
12203 | | modulus. |
12204 | | |
12205 | | This function MUST NOT be used on secret inputs. |
12206 | | */ |
12207 | | /** |
12208 | | A monomorphic instance of |
12209 | | libcrux_ml_kem.serialize.deserialize_ring_elements_reduced with types |
12210 | | libcrux_ml_kem_vector_portable_vector_type_PortableVector with const generics |
12211 | | - PUBLIC_KEY_SIZE= 1184 |
12212 | | - K= 3 |
12213 | | */ |
12214 | | static KRML_MUSTINLINE void |
12215 | | libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_330( |
12216 | | Eurydice_slice public_key, |
12217 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) { |
12218 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 deserialized_pk[3U]; |
12219 | 0 | for (size_t i = (size_t)0U; i < (size_t)3U; i++) { |
12220 | 0 | deserialized_pk[i] = libcrux_ml_kem_polynomial_ZERO_89_ea(); |
12221 | 0 | } |
12222 | 0 | for (size_t i = (size_t)0U; |
12223 | 0 | i < Eurydice_slice_len(public_key, uint8_t) / |
12224 | 0 | LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT; |
12225 | 0 | i++) { |
12226 | 0 | size_t i0 = i; |
12227 | 0 | Eurydice_slice ring_element = Eurydice_slice_subslice2( |
12228 | 0 | public_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
12229 | 0 | i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT + |
12230 | 0 | LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT, |
12231 | 0 | uint8_t); |
12232 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 uu____0 = |
12233 | 0 | libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_4c( |
12234 | 0 | ring_element); |
12235 | 0 | deserialized_pk[i0] = uu____0; |
12236 | 0 | } |
12237 | 0 | memcpy( |
12238 | 0 | ret, deserialized_pk, |
12239 | 0 | (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0)); |
12240 | 0 | } |
12241 | | |
12242 | | /** |
12243 | | Validate an ML-KEM public key. |
12244 | | |
12245 | | This implements the Modulus check in 7.2 2. |
12246 | | Note that the size check in 7.2 1 is covered by the `PUBLIC_KEY_SIZE` in the |
12247 | | `public_key` type. |
12248 | | */ |
12249 | | /** |
12250 | | A monomorphic instance of libcrux_ml_kem.ind_cca.validate_public_key |
12251 | | with types libcrux_ml_kem_vector_portable_vector_type_PortableVector |
12252 | | with const generics |
12253 | | - K= 3 |
12254 | | - RANKED_BYTES_PER_RING_ELEMENT= 1152 |
12255 | | - PUBLIC_KEY_SIZE= 1184 |
12256 | | */ |
12257 | | static KRML_MUSTINLINE bool libcrux_ml_kem_ind_cca_validate_public_key_19( |
12258 | 0 | uint8_t *public_key) { |
12259 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 deserialized_pk[3U]; |
12260 | 0 | libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_330( |
12261 | 0 | Eurydice_array_to_subslice_to((size_t)1184U, public_key, (size_t)1152U, |
12262 | 0 | uint8_t, size_t), |
12263 | 0 | deserialized_pk); |
12264 | 0 | libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *uu____0 = deserialized_pk; |
12265 | 0 | uint8_t public_key_serialized[1184U]; |
12266 | 0 | libcrux_ml_kem_ind_cpa_serialize_public_key_79( |
12267 | 0 | uu____0, |
12268 | 0 | Eurydice_array_to_subslice_from((size_t)1184U, public_key, (size_t)1152U, |
12269 | 0 | uint8_t, size_t), |
12270 | 0 | public_key_serialized); |
12271 | 0 | return core_array_equality___core__cmp__PartialEq__Array_U__N___for__Array_T__N____eq( |
12272 | 0 | (size_t)1184U, public_key, public_key_serialized, uint8_t, uint8_t, bool); |
12273 | 0 | } |
12274 | | |
12275 | | /** |
12276 | | Portable public key validation |
12277 | | */ |
12278 | | /** |
12279 | | A monomorphic instance of |
12280 | | libcrux_ml_kem.ind_cca.instantiations.portable.validate_public_key with const |
12281 | | generics |
12282 | | - K= 3 |
12283 | | - RANKED_BYTES_PER_RING_ELEMENT= 1152 |
12284 | | - PUBLIC_KEY_SIZE= 1184 |
12285 | | */ |
12286 | | static KRML_MUSTINLINE bool |
12287 | | libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_4b( |
12288 | 0 | uint8_t *public_key) { |
12289 | 0 | return libcrux_ml_kem_ind_cca_validate_public_key_19(public_key); |
12290 | 0 | } |
12291 | | |
12292 | | /** |
12293 | | Validate a public key. |
12294 | | |
12295 | | Returns `true` if valid, and `false` otherwise. |
12296 | | */ |
12297 | | static inline bool libcrux_ml_kem_mlkem768_portable_validate_public_key( |
12298 | 0 | libcrux_ml_kem_types_MlKemPublicKey_15 *public_key) { |
12299 | 0 | return libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_4b( |
12300 | 0 | public_key->value); |
12301 | 0 | } |
12302 | | |
12303 | | /** |
12304 | | This function found in impl {(core::clone::Clone for |
12305 | | libcrux_ml_kem::vector::portable::vector_type::PortableVector)} |
12306 | | */ |
12307 | | static inline libcrux_ml_kem_vector_portable_vector_type_PortableVector |
12308 | | libcrux_ml_kem_vector_portable_vector_type_clone_3b( |
12309 | 0 | libcrux_ml_kem_vector_portable_vector_type_PortableVector *self) { |
12310 | 0 | return self[0U]; |
12311 | 0 | } |
12312 | | |
12313 | | typedef int16_t libcrux_ml_kem_vector_portable_vector_type_FieldElement; |
12314 | | |
12315 | | typedef int16_t |
12316 | | libcrux_ml_kem_vector_portable_arithmetic_MontgomeryFieldElement; |
12317 | | |
12318 | | typedef int16_t |
12319 | | libcrux_ml_kem_vector_portable_arithmetic_FieldElementTimesMontgomeryR; |
12320 | | |
12321 | | #if defined(__cplusplus) |
12322 | | } |
12323 | | #endif |
12324 | | |
12325 | | #define __libcrux_mlkem768_portable_H_DEFINED |
12326 | | #endif |
12327 | | |
12328 | | |
12329 | | /* rename some types to be a bit more ergonomic */ |
12330 | | #define libcrux_mlkem768_keypair libcrux_ml_kem_mlkem768_MlKem768KeyPair_s |
12331 | | #define libcrux_mlkem768_pk_valid_result Option_92_s |
12332 | | #define libcrux_mlkem768_pk libcrux_ml_kem_types_MlKemPublicKey_15_s |
12333 | | #define libcrux_mlkem768_sk libcrux_ml_kem_types_MlKemPrivateKey_55_s |
12334 | | #define libcrux_mlkem768_ciphertext libcrux_ml_kem_mlkem768_MlKem768Ciphertext_s |
12335 | | #define libcrux_mlkem768_enc_result tuple_3c_s |
12336 | | /* defines for PRNG inputs */ |
12337 | | #define LIBCRUX_ML_KEM_KEY_PAIR_PRNG_LEN 64 |
12338 | | #define LIBCRUX_ML_KEM_ENC_PRNG_LEN 32 |