tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

libcrux_mlkem_portable.h (8458B)


      1 /*
      2 * SPDX-FileCopyrightText: 2025 Cryspen Sarl <info@cryspen.com>
      3 *
      4 * SPDX-License-Identifier: MIT or Apache-2.0
      5 *
      6 * This code was generated with the following revisions:
      7 * Charon: 667d2fc98984ff7f3df989c2367e6c1fa4a000e7
      8 * Eurydice: 2381cbc416ef2ad0b561c362c500bc84f36b6785
      9 * Karamel: 80f5435f2fc505973c469a4afcc8d875cddd0d8b
     10 * F*: 71d8221589d4d438af3706d89cb653cf53e18aab
     11 * Libcrux: 68dfed5a4a9e40277f62828471c029afed1ecdcc
     12 */
     13 
     14 #ifndef internal_libcrux_mlkem_portable_H
     15 #define internal_libcrux_mlkem_portable_H
     16 
     17 #include "eurydice_glue.h"
     18 
     19 #if defined(__cplusplus)
     20 extern "C" {
     21 #endif
     22 
     23 #include "../libcrux_mlkem_portable.h"
     24 #include "libcrux_core.h"
     25 
     26 /**
     27 A monomorphic instance of libcrux_ml_kem.polynomial.PolynomialRingElement
     28 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
     29 
     30 */
     31 typedef struct libcrux_ml_kem_polynomial_PolynomialRingElement_1d_s {
     32    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficients[16U];
     33 } libcrux_ml_kem_polynomial_PolynomialRingElement_1d;
     34 
     35 /**
     36 Validate an ML-KEM public key.
     37 
     38 This implements the Modulus check in 7.2 2.
     39 Note that the size check in 7.2 1 is covered by the `PUBLIC_KEY_SIZE` in the
     40 `public_key` type.
     41 */
     42 /**
     43 A monomorphic instance of libcrux_ml_kem.ind_cca.validate_public_key
     44 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
     45 with const generics
     46 - K= 4
     47 - PUBLIC_KEY_SIZE= 1568
     48 */
     49 bool libcrux_ml_kem_ind_cca_validate_public_key_ff(uint8_t *public_key);
     50 
     51 /**
     52 Validate an ML-KEM private key.
     53 
     54 This implements the Hash check in 7.3 3.
     55 */
     56 /**
     57 A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key_only
     58 with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$4size_t]]
     59 with const generics
     60 - K= 4
     61 - SECRET_KEY_SIZE= 3168
     62 */
     63 bool libcrux_ml_kem_ind_cca_validate_private_key_only_60(
     64    libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key);
     65 
     66 /**
     67 Validate an ML-KEM private key.
     68 
     69 This implements the Hash check in 7.3 3.
     70 Note that the size checks in 7.2 1 and 2 are covered by the `SECRET_KEY_SIZE`
     71 and `CIPHERTEXT_SIZE` in the `private_key` and `ciphertext` types.
     72 */
     73 /**
     74 A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key
     75 with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$4size_t]]
     76 with const generics
     77 - K= 4
     78 - SECRET_KEY_SIZE= 3168
     79 - CIPHERTEXT_SIZE= 1568
     80 */
     81 bool libcrux_ml_kem_ind_cca_validate_private_key_b5(
     82    libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key,
     83    libcrux_ml_kem_types_MlKemCiphertext_64 *_ciphertext);
     84 
     85 /**
     86 Packed API
     87 
     88 Generate a key pair.
     89 
     90 Depending on the `Vector` and `Hasher` used, this requires different hardware
     91 features
     92 */
     93 /**
     94 A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair
     95 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
     96 libcrux_ml_kem_hash_functions_portable_PortableHash[[$4size_t]],
     97 libcrux_ml_kem_variant_MlKem with const generics
     98 - K= 4
     99 - CPA_PRIVATE_KEY_SIZE= 1536
    100 - PRIVATE_KEY_SIZE= 3168
    101 - PUBLIC_KEY_SIZE= 1568
    102 - ETA1= 2
    103 - ETA1_RANDOMNESS_SIZE= 128
    104 */
    105 libcrux_ml_kem_mlkem1024_MlKem1024KeyPair
    106 libcrux_ml_kem_ind_cca_generate_keypair_150(uint8_t *randomness);
    107 
    108 /**
    109 A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate
    110 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
    111 libcrux_ml_kem_hash_functions_portable_PortableHash[[$4size_t]],
    112 libcrux_ml_kem_variant_MlKem with const generics
    113 - K= 4
    114 - CIPHERTEXT_SIZE= 1568
    115 - PUBLIC_KEY_SIZE= 1568
    116 - T_AS_NTT_ENCODED_SIZE= 1536
    117 - C1_SIZE= 1408
    118 - C2_SIZE= 160
    119 - VECTOR_U_COMPRESSION_FACTOR= 11
    120 - VECTOR_V_COMPRESSION_FACTOR= 5
    121 - C1_BLOCK_SIZE= 352
    122 - ETA1= 2
    123 - ETA1_RANDOMNESS_SIZE= 128
    124 - ETA2= 2
    125 - ETA2_RANDOMNESS_SIZE= 128
    126 */
    127 tuple_fa libcrux_ml_kem_ind_cca_encapsulate_ca0(
    128    libcrux_ml_kem_types_MlKemPublicKey_64 *public_key, uint8_t *randomness);
    129 
    130 /**
    131 This code verifies on some machines, runs out of memory on others
    132 */
    133 /**
    134 A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate
    135 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
    136 libcrux_ml_kem_hash_functions_portable_PortableHash[[$4size_t]],
    137 libcrux_ml_kem_variant_MlKem with const generics
    138 - K= 4
    139 - SECRET_KEY_SIZE= 3168
    140 - CPA_SECRET_KEY_SIZE= 1536
    141 - PUBLIC_KEY_SIZE= 1568
    142 - CIPHERTEXT_SIZE= 1568
    143 - T_AS_NTT_ENCODED_SIZE= 1536
    144 - C1_SIZE= 1408
    145 - C2_SIZE= 160
    146 - VECTOR_U_COMPRESSION_FACTOR= 11
    147 - VECTOR_V_COMPRESSION_FACTOR= 5
    148 - C1_BLOCK_SIZE= 352
    149 - ETA1= 2
    150 - ETA1_RANDOMNESS_SIZE= 128
    151 - ETA2= 2
    152 - ETA2_RANDOMNESS_SIZE= 128
    153 - IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1600
    154 */
    155 void libcrux_ml_kem_ind_cca_decapsulate_620(
    156    libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key,
    157    libcrux_ml_kem_types_MlKemCiphertext_64 *ciphertext, uint8_t ret[32U]);
    158 
    159 /**
    160 Validate an ML-KEM public key.
    161 
    162 This implements the Modulus check in 7.2 2.
    163 Note that the size check in 7.2 1 is covered by the `PUBLIC_KEY_SIZE` in the
    164 `public_key` type.
    165 */
    166 /**
    167 A monomorphic instance of libcrux_ml_kem.ind_cca.validate_public_key
    168 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector
    169 with const generics
    170 - K= 3
    171 - PUBLIC_KEY_SIZE= 1184
    172 */
    173 bool libcrux_ml_kem_ind_cca_validate_public_key_89(uint8_t *public_key);
    174 
    175 /**
    176 Validate an ML-KEM private key.
    177 
    178 This implements the Hash check in 7.3 3.
    179 */
    180 /**
    181 A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key_only
    182 with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
    183 with const generics
    184 - K= 3
    185 - SECRET_KEY_SIZE= 2400
    186 */
    187 bool libcrux_ml_kem_ind_cca_validate_private_key_only_d6(
    188    libcrux_ml_kem_types_MlKemPrivateKey_d9 *private_key);
    189 
    190 /**
    191 Validate an ML-KEM private key.
    192 
    193 This implements the Hash check in 7.3 3.
    194 Note that the size checks in 7.2 1 and 2 are covered by the `SECRET_KEY_SIZE`
    195 and `CIPHERTEXT_SIZE` in the `private_key` and `ciphertext` types.
    196 */
    197 /**
    198 A monomorphic instance of libcrux_ml_kem.ind_cca.validate_private_key
    199 with types libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]]
    200 with const generics
    201 - K= 3
    202 - SECRET_KEY_SIZE= 2400
    203 - CIPHERTEXT_SIZE= 1088
    204 */
    205 bool libcrux_ml_kem_ind_cca_validate_private_key_37(
    206    libcrux_ml_kem_types_MlKemPrivateKey_d9 *private_key,
    207    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *_ciphertext);
    208 
    209 /**
    210 Packed API
    211 
    212 Generate a key pair.
    213 
    214 Depending on the `Vector` and `Hasher` used, this requires different hardware
    215 features
    216 */
    217 /**
    218 A monomorphic instance of libcrux_ml_kem.ind_cca.generate_keypair
    219 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
    220 libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
    221 libcrux_ml_kem_variant_MlKem with const generics
    222 - K= 3
    223 - CPA_PRIVATE_KEY_SIZE= 1152
    224 - PRIVATE_KEY_SIZE= 2400
    225 - PUBLIC_KEY_SIZE= 1184
    226 - ETA1= 2
    227 - ETA1_RANDOMNESS_SIZE= 128
    228 */
    229 libcrux_ml_kem_mlkem768_MlKem768KeyPair
    230 libcrux_ml_kem_ind_cca_generate_keypair_15(uint8_t *randomness);
    231 
    232 /**
    233 A monomorphic instance of libcrux_ml_kem.ind_cca.encapsulate
    234 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
    235 libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
    236 libcrux_ml_kem_variant_MlKem with const generics
    237 - K= 3
    238 - CIPHERTEXT_SIZE= 1088
    239 - PUBLIC_KEY_SIZE= 1184
    240 - T_AS_NTT_ENCODED_SIZE= 1152
    241 - C1_SIZE= 960
    242 - C2_SIZE= 128
    243 - VECTOR_U_COMPRESSION_FACTOR= 10
    244 - VECTOR_V_COMPRESSION_FACTOR= 4
    245 - C1_BLOCK_SIZE= 320
    246 - ETA1= 2
    247 - ETA1_RANDOMNESS_SIZE= 128
    248 - ETA2= 2
    249 - ETA2_RANDOMNESS_SIZE= 128
    250 */
    251 tuple_c2 libcrux_ml_kem_ind_cca_encapsulate_ca(
    252    libcrux_ml_kem_types_MlKemPublicKey_30 *public_key, uint8_t *randomness);
    253 
    254 /**
    255 This code verifies on some machines, runs out of memory on others
    256 */
    257 /**
    258 A monomorphic instance of libcrux_ml_kem.ind_cca.decapsulate
    259 with types libcrux_ml_kem_vector_portable_vector_type_PortableVector,
    260 libcrux_ml_kem_hash_functions_portable_PortableHash[[$3size_t]],
    261 libcrux_ml_kem_variant_MlKem with const generics
    262 - K= 3
    263 - SECRET_KEY_SIZE= 2400
    264 - CPA_SECRET_KEY_SIZE= 1152
    265 - PUBLIC_KEY_SIZE= 1184
    266 - CIPHERTEXT_SIZE= 1088
    267 - T_AS_NTT_ENCODED_SIZE= 1152
    268 - C1_SIZE= 960
    269 - C2_SIZE= 128
    270 - VECTOR_U_COMPRESSION_FACTOR= 10
    271 - VECTOR_V_COMPRESSION_FACTOR= 4
    272 - C1_BLOCK_SIZE= 320
    273 - ETA1= 2
    274 - ETA1_RANDOMNESS_SIZE= 128
    275 - ETA2= 2
    276 - ETA2_RANDOMNESS_SIZE= 128
    277 - IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1120
    278 */
    279 void libcrux_ml_kem_ind_cca_decapsulate_62(
    280    libcrux_ml_kem_types_MlKemPrivateKey_d9 *private_key,
    281    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]);
    282 
    283 #if defined(__cplusplus)
    284 }
    285 #endif
    286 
    287 #define internal_libcrux_mlkem_portable_H_DEFINED
    288 #endif /* internal_libcrux_mlkem_portable_H */