Skip to content

Commit

Permalink
boring C not working
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikbhargavan committed Sep 22, 2024
1 parent 37d35d8 commit 2cc5d08
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 334 deletions.
12 changes: 0 additions & 12 deletions libcrux-ml-kem/c/benches/sha3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ shake128_34_504(benchmark::State &state)

Eurydice_slice last[4] = {EURYDICE_SLICE(input, 0, 34), EURYDICE_SLICE(input, 0, 34), EURYDICE_SLICE(input, 0, 34), EURYDICE_SLICE(input, 0, 34)};
Eurydice_slice out[4] = {EURYDICE_SLICE(digest0, 0, 504), EURYDICE_SLICE(digest1, 0, 504), EURYDICE_SLICE(digest2, 0, 504), EURYDICE_SLICE(digest3, 0, 504)};
<<<<<<< HEAD
libcrux_sha3_avx2_x4_incremental_KeccakState st = libcrux_sha3_avx2_x4_incremental_init();
libcrux_sha3_generic_keccak_absorb_final_80(&st, last);
libcrux_sha3_generic_keccak_squeeze_first_three_blocks_6d(&st, out);

for (auto _ : state)
{
libcrux_sha3_avx2_x4_incremental_KeccakState st = libcrux_sha3_avx2_x4_incremental_init();
libcrux_sha3_generic_keccak_absorb_final_80(&st, last);
libcrux_sha3_generic_keccak_squeeze_first_three_blocks_6d(&st, out);
=======
auto st = libcrux_sha3_avx2_x4_incremental_init();
libcrux_sha3_generic_keccak_absorb_final_7f(&st, last);
libcrux_sha3_generic_keccak_squeeze_first_three_blocks_ed(&st, out);
Expand All @@ -90,7 +79,6 @@ shake128_34_504(benchmark::State &state)
auto st = libcrux_sha3_avx2_x4_incremental_init();
libcrux_sha3_generic_keccak_absorb_final_7f(&st, last);
libcrux_sha3_generic_keccak_squeeze_first_three_blocks_ed(&st, out);
>>>>>>> main
}
}

Expand Down
8 changes: 0 additions & 8 deletions libcrux-ml-kem/c/internal/libcrux_mlkem_neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
<<<<<<< HEAD
* Charon: 3f6d1c304e0e5bef1e9e2ea65aec703661b05f39
* Eurydice: 392674166bac86e60f5fffa861181a398fdc3896
* Karamel: fc56fce6a58754766809845f88fc62063b2c6b92
* F*: 04413e808445c4f78fe89cd15b85ff549ed3be62
* Libcrux: 1ecfc745f64e318b06fd59a787d07818640c56cc
=======
* Charon: 53530427db2941ce784201e64086766504bc5642
* Eurydice: 7834acbb41b06c34f198a1cb6b88241cc10b9aeb
* Karamel: bdf06956e6ee025d4819bf2f8cc92651e572ad85
* F*: e5cef6f266ece8a8b55ef4cd9b61cdf103520d38
* Libcrux: d5574e8f6c62bf622ab6b61c291abeb66c1b7221
>>>>>>> main
*/

#ifndef __internal_libcrux_mlkem_neon_H
Expand Down
87 changes: 14 additions & 73 deletions libcrux-ml-kem/c/libcrux_mlkem1024_neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
<<<<<<< HEAD
* Charon: 3f6d1c304e0e5bef1e9e2ea65aec703661b05f39
* Eurydice: 392674166bac86e60f5fffa861181a398fdc3896
* Karamel: fc56fce6a58754766809845f88fc62063b2c6b92
* F*: 04413e808445c4f78fe89cd15b85ff549ed3be62
* Libcrux: 1ecfc745f64e318b06fd59a787d07818640c56cc
=======
* Charon: 53530427db2941ce784201e64086766504bc5642
* Eurydice: 7834acbb41b06c34f198a1cb6b88241cc10b9aeb
* Karamel: bdf06956e6ee025d4819bf2f8cc92651e572ad85
* F*: e5cef6f266ece8a8b55ef4cd9b61cdf103520d38
* Libcrux: d5574e8f6c62bf622ab6b61c291abeb66c1b7221
>>>>>>> main
*/

#include "libcrux_mlkem1024_neon.h"
Expand Down Expand Up @@ -46,11 +38,11 @@ with const generics
- ETA2_RANDOMNESS_SIZE= 128
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1600
*/
static void decapsulate_fa(
static void decapsulate_f8(
libcrux_ml_kem_types_MlKemPrivateKey_95 *private_key,
libcrux_ml_kem_mlkem1024_MlKem1024Ciphertext *ciphertext,
uint8_t ret[32U]) {
libcrux_ml_kem_ind_cca_decapsulate_9c(private_key, ciphertext, ret);
libcrux_ml_kem_ind_cca_decapsulate_82(private_key, ciphertext, ret);
}

/**
Expand All @@ -64,7 +56,7 @@ void libcrux_ml_kem_mlkem1024_neon_decapsulate(
libcrux_ml_kem_types_MlKemPrivateKey_95 *private_key,
libcrux_ml_kem_mlkem1024_MlKem1024Ciphertext *ciphertext,
uint8_t ret[32U]) {
decapsulate_fa(private_key, ciphertext, ret);
decapsulate_f8(private_key, ciphertext, ret);
}

/**
Expand All @@ -91,12 +83,11 @@ generics
- ETA2_RANDOMNESS_SIZE= 128
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1600
*/
static void decapsulate_unpacked_ed(
static void decapsulate_unpacked_c2(
libcrux_ml_kem_ind_cca_unpacked_MlKemKeyPairUnpacked_2c *key_pair,
libcrux_ml_kem_mlkem1024_MlKem1024Ciphertext *ciphertext,
uint8_t ret[32U]) {
libcrux_ml_kem_ind_cca_unpacked_decapsulate_unpacked_dc(key_pair, ciphertext,
ret);
libcrux_ml_kem_ind_cca_decapsulate_unpacked_ec(key_pair, ciphertext, ret);
}

/**
Expand All @@ -110,7 +101,7 @@ void libcrux_ml_kem_mlkem1024_neon_decapsulate_unpacked(
libcrux_ml_kem_ind_cca_unpacked_MlKemKeyPairUnpacked_2c *private_key,
libcrux_ml_kem_mlkem1024_MlKem1024Ciphertext *ciphertext,
uint8_t ret[32U]) {
decapsulate_unpacked_ed(private_key, ciphertext, ret);
decapsulate_unpacked_c2(private_key, ciphertext, ret);
}

/**
Expand All @@ -124,26 +115,20 @@ with const generics
- C2_SIZE= 160
- VECTOR_U_COMPRESSION_FACTOR= 11
- VECTOR_V_COMPRESSION_FACTOR= 5
- C1_BLOCK_SIZE= 352
- VECTOR_U_BLOCK_LEN= 352
- ETA1= 2
- ETA1_RANDOMNESS_SIZE= 128
- ETA2= 2
- ETA2_RANDOMNESS_SIZE= 128
*/
static tuple_21 encapsulate_2b(
static tuple_21 encapsulate_6b(
libcrux_ml_kem_types_MlKemPublicKey_1f *public_key,
uint8_t randomness[32U]) {
libcrux_ml_kem_types_MlKemPublicKey_1f *uu____0 = public_key;
<<<<<<< HEAD
uint8_t uu____1[32U];
memcpy(uu____1, randomness, (size_t)32U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_encapsulate_ff(uu____0, uu____1);
=======
/* 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_28(uu____0, copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -157,16 +142,10 @@ tuple_21 libcrux_ml_kem_mlkem1024_neon_encapsulate(
libcrux_ml_kem_types_MlKemPublicKey_1f *public_key,
uint8_t randomness[32U]) {
libcrux_ml_kem_types_MlKemPublicKey_1f *uu____0 = public_key;
<<<<<<< HEAD
uint8_t uu____1[32U];
memcpy(uu____1, randomness, (size_t)32U * sizeof(uint8_t));
return encapsulate_2b(uu____0, uu____1);
=======
/* 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 encapsulate_6b(uu____0, copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -190,23 +169,16 @@ generics
- ETA2= 2
- ETA2_RANDOMNESS_SIZE= 128
*/
static tuple_21 encapsulate_unpacked_c6(
static tuple_21 encapsulate_unpacked_1c(
libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_2c *public_key,
uint8_t randomness[32U]) {
libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_2c *uu____0 =
public_key;
<<<<<<< HEAD
uint8_t uu____1[32U];
memcpy(uu____1, randomness, (size_t)32U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_unpacked_encapsulate_unpacked_cf(uu____0,
uu____1);
=======
/* 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_unpacked_47(uu____0,
copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -224,16 +196,10 @@ tuple_21 libcrux_ml_kem_mlkem1024_neon_encapsulate_unpacked(
uint8_t randomness[32U]) {
libcrux_ml_kem_ind_cca_unpacked_MlKemPublicKeyUnpacked_2c *uu____0 =
public_key;
<<<<<<< HEAD
uint8_t uu____1[32U];
memcpy(uu____1, randomness, (size_t)32U * sizeof(uint8_t));
return encapsulate_unpacked_c6(uu____0, uu____1);
=======
/* 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 encapsulate_unpacked_1c(uu____0, copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -246,39 +212,27 @@ libcrux_ml_kem.ind_cca.instantiations.neon.generate_keypair with const generics
- CPA_PRIVATE_KEY_SIZE= 1536
- PRIVATE_KEY_SIZE= 3168
- PUBLIC_KEY_SIZE= 1568
- RANKED_BYTES_PER_RING_ELEMENT= 1536
- BYTES_PER_RING_ELEMENT= 1536
- ETA1= 2
- ETA1_RANDOMNESS_SIZE= 128
*/
static libcrux_ml_kem_mlkem1024_MlKem1024KeyPair generate_keypair_1a(
static libcrux_ml_kem_mlkem1024_MlKem1024KeyPair generate_keypair_91(
uint8_t randomness[64U]) {
<<<<<<< HEAD
uint8_t uu____0[64U];
memcpy(uu____0, randomness, (size_t)64U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_generate_keypair_ec(uu____0);
=======
/* 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_72(copy_of_randomness);
>>>>>>> main
}

/**
Generate ML-KEM 1024 Key Pair
*/
libcrux_ml_kem_mlkem1024_MlKem1024KeyPair
libcrux_ml_kem_mlkem1024_neon_generate_key_pair(uint8_t randomness[64U]) {
<<<<<<< HEAD
uint8_t uu____0[64U];
memcpy(uu____0, randomness, (size_t)64U * sizeof(uint8_t));
return generate_keypair_1a(uu____0);
=======
/* 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 generate_keypair_91(copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -297,19 +251,12 @@ generics
- ETA1_RANDOMNESS_SIZE= 128
*/
static libcrux_ml_kem_ind_cca_unpacked_MlKemKeyPairUnpacked_2c
<<<<<<< HEAD
generate_keypair_unpacked_0f(uint8_t randomness[64U]) {
uint8_t uu____0[64U];
memcpy(uu____0, randomness, (size_t)64U * sizeof(uint8_t));
return libcrux_ml_kem_ind_cca_unpacked_generate_keypair_unpacked_a5(uu____0);
=======
generate_keypair_unpacked_87(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_unpacked_b4(
copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -318,16 +265,10 @@ generate_keypair_unpacked_87(uint8_t randomness[64U]) {
libcrux_ml_kem_ind_cca_unpacked_MlKemKeyPairUnpacked_2c
libcrux_ml_kem_mlkem1024_neon_generate_key_pair_unpacked(
uint8_t randomness[64U]) {
<<<<<<< HEAD
uint8_t uu____0[64U];
memcpy(uu____0, randomness, (size_t)64U * sizeof(uint8_t));
return generate_keypair_unpacked_0f(uu____0);
=======
/* 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 generate_keypair_unpacked_87(copy_of_randomness);
>>>>>>> main
}

/**
Expand All @@ -341,8 +282,8 @@ generics
- RANKED_BYTES_PER_RING_ELEMENT= 1536
- PUBLIC_KEY_SIZE= 1568
*/
static bool validate_public_key_2c(uint8_t *public_key) {
return libcrux_ml_kem_ind_cca_validate_public_key_99(public_key);
static bool validate_public_key_a3(uint8_t *public_key) {
return libcrux_ml_kem_ind_cca_validate_public_key_7e(public_key);
}

/**
Expand All @@ -353,7 +294,7 @@ static bool validate_public_key_2c(uint8_t *public_key) {
core_option_Option_99 libcrux_ml_kem_mlkem1024_neon_validate_public_key(
libcrux_ml_kem_types_MlKemPublicKey_1f public_key) {
core_option_Option_99 uu____0;
if (validate_public_key_2c(public_key.value)) {
if (validate_public_key_a3(public_key.value)) {
uu____0 = (CLITERAL(core_option_Option_99){.tag = core_option_Some,
.f0 = public_key});
} else {
Expand Down
8 changes: 0 additions & 8 deletions libcrux-ml-kem/c/libcrux_mlkem1024_neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
* SPDX-License-Identifier: MIT or Apache-2.0
*
* This code was generated with the following revisions:
<<<<<<< HEAD
* Charon: 3f6d1c304e0e5bef1e9e2ea65aec703661b05f39
* Eurydice: 392674166bac86e60f5fffa861181a398fdc3896
* Karamel: fc56fce6a58754766809845f88fc62063b2c6b92
* F*: 04413e808445c4f78fe89cd15b85ff549ed3be62
* Libcrux: 1ecfc745f64e318b06fd59a787d07818640c56cc
=======
* Charon: 53530427db2941ce784201e64086766504bc5642
* Eurydice: 7834acbb41b06c34f198a1cb6b88241cc10b9aeb
* Karamel: bdf06956e6ee025d4819bf2f8cc92651e572ad85
* F*: e5cef6f266ece8a8b55ef4cd9b61cdf103520d38
* Libcrux: d5574e8f6c62bf622ab6b61c291abeb66c1b7221
>>>>>>> main
*/

#ifndef __libcrux_mlkem1024_neon_H
Expand Down
Loading

0 comments on commit 2cc5d08

Please sign in to comment.