Skip to content

Commit

Permalink
Update C extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Oct 17, 2024
1 parent de5cf36 commit e86fe7c
Show file tree
Hide file tree
Showing 33 changed files with 638 additions and 340 deletions.
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/code_gen.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This code was generated with the following revisions:
Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/internal/libcrux_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __internal_libcrux_core_H
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/internal/libcrux_mlkem_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __internal_libcrux_mlkem_avx2_H
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/internal/libcrux_mlkem_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __internal_libcrux_mlkem_portable_H
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/internal/libcrux_sha3_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __internal_libcrux_sha3_avx2_H
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/internal/libcrux_sha3_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __internal_libcrux_sha3_internal_H
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/libcrux_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#include "internal/libcrux_core.h"
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/libcrux_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __libcrux_core_H
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/libcrux_mlkem1024.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __libcrux_mlkem1024_H
Expand Down
120 changes: 105 additions & 15 deletions libcrux-ml-kem/c/libcrux_mlkem1024_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,43 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#include "libcrux_mlkem1024_avx2.h"

#include "internal/libcrux_mlkem_avx2.h"

/**
Portable decapsulate
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.decapsulate_avx2 with const generics
- K= 4
- SECRET_KEY_SIZE= 3168
- CPA_SECRET_KEY_SIZE= 1536
- PUBLIC_KEY_SIZE= 1568
- CIPHERTEXT_SIZE= 1568
- T_AS_NTT_ENCODED_SIZE= 1536
- C1_SIZE= 1408
- C2_SIZE= 160
- VECTOR_U_COMPRESSION_FACTOR= 11
- VECTOR_V_COMPRESSION_FACTOR= 5
- C1_BLOCK_SIZE= 352
- ETA1= 2
- ETA1_RANDOMNESS_SIZE= 128
- ETA2= 2
- ETA2_RANDOMNESS_SIZE= 128
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1600
*/
static void decapsulate_avx2_e0(
libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_64 *ciphertext, uint8_t ret[32U]) {
libcrux_ml_kem_ind_cca_decapsulate_a10(private_key, ciphertext, ret);
}

/**
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.avx2.decapsulate
with const generics
Expand All @@ -41,7 +64,7 @@ with const generics
static void decapsulate_e0(libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_64 *ciphertext,
uint8_t ret[32U]) {
libcrux_ml_kem_ind_cca_decapsulate_a10(private_key, ciphertext, ret);
decapsulate_avx2_e0(private_key, ciphertext, ret);
}

/**
Expand All @@ -57,6 +80,33 @@ void libcrux_ml_kem_mlkem1024_avx2_decapsulate(
decapsulate_e0(private_key, ciphertext, ret);
}

/**
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.encapsulate_avx2 with const generics
- K= 4
- CIPHERTEXT_SIZE= 1568
- PUBLIC_KEY_SIZE= 1568
- T_AS_NTT_ENCODED_SIZE= 1536
- C1_SIZE= 1408
- C2_SIZE= 160
- VECTOR_U_COMPRESSION_FACTOR= 11
- VECTOR_V_COMPRESSION_FACTOR= 5
- VECTOR_U_BLOCK_LEN= 352
- ETA1= 2
- ETA1_RANDOMNESS_SIZE= 128
- ETA2= 2
- ETA2_RANDOMNESS_SIZE= 128
*/
static tuple_fa encapsulate_avx2_8f(
libcrux_ml_kem_types_MlKemPublicKey_64 *public_key,
uint8_t randomness[32U]) {
libcrux_ml_kem_types_MlKemPublicKey_64 *uu____0 = public_key;
/* Passing arrays by value in Rust generates a copy in C */
uint8_t copy_of_randomness[32U];
memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_encapsulate_700(uu____0, copy_of_randomness);
}

/**
A monomorphic instance of libcrux_ml_kem.ind_cca.instantiations.avx2.encapsulate
with const generics
Expand All @@ -81,7 +131,7 @@ static tuple_fa encapsulate_8f(
/* Passing arrays by value in Rust generates a copy in C */
uint8_t copy_of_randomness[32U];
memcpy(copy_of_randomness, randomness, (size_t)32U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_encapsulate_700(uu____0, copy_of_randomness);
return encapsulate_avx2_8f(uu____0, copy_of_randomness);
}

/**
Expand All @@ -104,6 +154,26 @@ tuple_fa libcrux_ml_kem_mlkem1024_avx2_encapsulate(
/**
Portable generate key pair.
*/
/**
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.generate_keypair_avx2 with const
generics
- K= 4
- CPA_PRIVATE_KEY_SIZE= 1536
- PRIVATE_KEY_SIZE= 3168
- PUBLIC_KEY_SIZE= 1568
- BYTES_PER_RING_ELEMENT= 1536
- ETA1= 2
- ETA1_RANDOMNESS_SIZE= 128
*/
static libcrux_ml_kem_mlkem1024_MlKem1024KeyPair generate_keypair_avx2_c9(
uint8_t randomness[64U]) {
/* Passing arrays by value in Rust generates a copy in C */
uint8_t copy_of_randomness[64U];
memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_generate_keypair_d60(copy_of_randomness);
}

/**
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.generate_keypair with const generics
Expand All @@ -120,7 +190,7 @@ static libcrux_ml_kem_mlkem1024_MlKem1024KeyPair generate_keypair_c9(
/* Passing arrays by value in Rust generates a copy in C */
uint8_t copy_of_randomness[64U];
memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_generate_keypair_d60(copy_of_randomness);
return generate_keypair_avx2_c9(copy_of_randomness);
}

/**
Expand All @@ -135,8 +205,20 @@ libcrux_ml_kem_mlkem1024_avx2_generate_key_pair(uint8_t randomness[64U]) {
}

/**
Portable private key validation
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.validate_private_key_avx2 with const
generics
- K= 4
- SECRET_KEY_SIZE= 3168
- CIPHERTEXT_SIZE= 1568
*/
static bool validate_private_key_avx2_6b(
libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_64 *ciphertext) {
return libcrux_ml_kem_ind_cca_validate_private_key_b9(private_key,
ciphertext);
}

/**
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.validate_private_key with const
Expand All @@ -145,11 +227,10 @@ generics
- SECRET_KEY_SIZE= 3168
- CIPHERTEXT_SIZE= 1568
*/
static KRML_MUSTINLINE bool validate_private_key_6b(
static bool validate_private_key_6b(
libcrux_ml_kem_types_MlKemPrivateKey_83 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_64 *ciphertext) {
return libcrux_ml_kem_ind_cca_validate_private_key_b9(private_key,
ciphertext);
return validate_private_key_avx2_6b(private_key, ciphertext);
}

/**
Expand All @@ -164,8 +245,17 @@ bool libcrux_ml_kem_mlkem1024_avx2_validate_private_key(
}

/**
Portable public key validation
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.validate_public_key_avx2 with const
generics
- K= 4
- RANKED_BYTES_PER_RING_ELEMENT= 1536
- PUBLIC_KEY_SIZE= 1568
*/
static bool validate_public_key_avx2_6b(uint8_t *public_key) {
return libcrux_ml_kem_ind_cca_validate_public_key_1e(public_key);
}

/**
A monomorphic instance of
libcrux_ml_kem.ind_cca.instantiations.avx2.validate_public_key with const
Expand All @@ -174,8 +264,8 @@ generics
- RANKED_BYTES_PER_RING_ELEMENT= 1536
- PUBLIC_KEY_SIZE= 1568
*/
static KRML_MUSTINLINE bool validate_public_key_6b(uint8_t *public_key) {
return libcrux_ml_kem_ind_cca_validate_public_key_1e(public_key);
static bool validate_public_key_6b(uint8_t *public_key) {
return validate_public_key_avx2_6b(public_key);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions libcrux-ml-kem/c/libcrux_mlkem1024_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
* Charon: 45f5a34f336e35c6cc2253bc90cbdb8d812cefa9
* Charon: 3a133fe0eee9bd3928d5bb16c24ddd2dd0f3ee7f
* Eurydice: 1fff1c51ae6e6c87eafd28ec9d5594f54bc91c0c
* Karamel: 8c3612018c25889288da6857771be3ad03b75bcd
* F*: 5643e656b989aca7629723653a2570c7df6252b9-dirty
* Libcrux: 2e8f138dbcbfbfabf4bbd994c8587ec00d197102
* Karamel: c31a22c1e07d2118c07ee5cebb640d863e31a198
* F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7
* Libcrux: de5cf36eb9ea4853d387d80f6b4385ce5275511b
*/

#ifndef __libcrux_mlkem1024_avx2_H
Expand Down
Loading

0 comments on commit e86fe7c

Please sign in to comment.