Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikbhargavan committed Sep 29, 2024
1 parent 098de7d commit 2ac0798
Show file tree
Hide file tree
Showing 42 changed files with 655 additions and 446 deletions.
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/code_gen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Charon: 28d543bfacc902ba9cc2a734b76baae9583892a4
Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/internal/libcrux_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __internal_libcrux_core_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/internal/libcrux_mlkem_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __internal_libcrux_mlkem_avx2_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/internal/libcrux_mlkem_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __internal_libcrux_mlkem_portable_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/internal/libcrux_sha3_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __internal_libcrux_sha3_avx2_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/internal/libcrux_sha3_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __internal_libcrux_sha3_internal_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#include "internal/libcrux_core.h"
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_core_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem1024.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem1024_H
Expand Down
22 changes: 11 additions & 11 deletions libcrux-ml-kem/c/libcrux_mlkem1024_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#include "libcrux_mlkem1024_avx2.h"
Expand All @@ -35,7 +35,7 @@ with const generics
- ETA2_RANDOMNESS_SIZE= 128
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 1600
*/
static void decapsulate_2c0(
static void decapsulate_150(
libcrux_ml_kem_types_MlKemPrivateKey_95 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_1f *ciphertext, uint8_t ret[32U]) {
libcrux_ml_kem_ind_cca_decapsulate_6f0(private_key, ciphertext, ret);
Expand All @@ -51,7 +51,7 @@ static void decapsulate_2c0(
void libcrux_ml_kem_mlkem1024_avx2_decapsulate(
libcrux_ml_kem_types_MlKemPrivateKey_95 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_1f *ciphertext, uint8_t ret[32U]) {
decapsulate_2c0(private_key, ciphertext, ret);
decapsulate_150(private_key, ciphertext, ret);
}

/**
Expand All @@ -71,7 +71,7 @@ with const generics
- ETA2= 2
- ETA2_RANDOMNESS_SIZE= 128
*/
static tuple_21 encapsulate_ad0(
static tuple_21 encapsulate_9e0(
libcrux_ml_kem_types_MlKemPublicKey_1f *public_key,
uint8_t randomness[32U]) {
libcrux_ml_kem_types_MlKemPublicKey_1f *uu____0 = public_key;
Expand All @@ -95,7 +95,7 @@ tuple_21 libcrux_ml_kem_mlkem1024_avx2_encapsulate(
/* 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_ad0(uu____0, copy_of_randomness);
return encapsulate_9e0(uu____0, copy_of_randomness);
}

/**
Expand All @@ -109,7 +109,7 @@ libcrux_ml_kem.ind_cca.instantiations.avx2.generate_keypair with const generics
- ETA1= 2
- ETA1_RANDOMNESS_SIZE= 128
*/
static libcrux_ml_kem_mlkem1024_MlKem1024KeyPair generate_keypair_c70(
static libcrux_ml_kem_mlkem1024_MlKem1024KeyPair generate_keypair_010(
uint8_t randomness[64U]) {
/* Passing arrays by value in Rust generates a copy in C */
uint8_t copy_of_randomness[64U];
Expand All @@ -125,7 +125,7 @@ libcrux_ml_kem_mlkem1024_avx2_generate_key_pair(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 generate_keypair_c70(copy_of_randomness);
return generate_keypair_010(copy_of_randomness);
}

/**
Expand All @@ -136,7 +136,7 @@ generics
- SECRET_KEY_SIZE= 3168
- CIPHERTEXT_SIZE= 1568
*/
static KRML_MUSTINLINE bool validate_private_key_d10(
static KRML_MUSTINLINE bool validate_private_key_840(
libcrux_ml_kem_types_MlKemPrivateKey_95 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_1f *ciphertext) {
return libcrux_ml_kem_ind_cca_validate_private_key_e10(private_key,
Expand All @@ -151,7 +151,7 @@ static KRML_MUSTINLINE bool validate_private_key_d10(
bool libcrux_ml_kem_mlkem1024_avx2_validate_private_key(
libcrux_ml_kem_types_MlKemPrivateKey_95 *private_key,
libcrux_ml_kem_types_MlKemCiphertext_1f *ciphertext) {
return validate_private_key_d10(private_key, ciphertext);
return validate_private_key_840(private_key, ciphertext);
}

/**
Expand All @@ -162,7 +162,7 @@ generics
- RANKED_BYTES_PER_RING_ELEMENT= 1536
- PUBLIC_KEY_SIZE= 1568
*/
static KRML_MUSTINLINE bool validate_public_key_e90(uint8_t *public_key) {
static KRML_MUSTINLINE bool validate_public_key_e30(uint8_t *public_key) {
return libcrux_ml_kem_ind_cca_validate_public_key_4a0(public_key);
}

Expand All @@ -173,5 +173,5 @@ static KRML_MUSTINLINE bool validate_public_key_e90(uint8_t *public_key) {
*/
bool libcrux_ml_kem_mlkem1024_avx2_validate_public_key(
libcrux_ml_kem_types_MlKemPublicKey_1f *public_key) {
return validate_public_key_e90(public_key->value);
return validate_public_key_e30(public_key->value);
}
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem1024_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem1024_avx2_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem1024_portable.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#include "libcrux_mlkem1024_portable.h"
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem1024_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem1024_portable_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem512.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem512_H
Expand Down
22 changes: 11 additions & 11 deletions libcrux-ml-kem/c/libcrux_mlkem512_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#include "libcrux_mlkem512_avx2.h"
Expand All @@ -35,7 +35,7 @@ with const generics
- ETA2_RANDOMNESS_SIZE= 128
- IMPLICIT_REJECTION_HASH_INPUT_SIZE= 800
*/
static void decapsulate_2c(libcrux_ml_kem_types_MlKemPrivateKey_5e *private_key,
static void decapsulate_15(libcrux_ml_kem_types_MlKemPrivateKey_5e *private_key,
libcrux_ml_kem_types_MlKemCiphertext_e8 *ciphertext,
uint8_t ret[32U]) {
libcrux_ml_kem_ind_cca_decapsulate_6f(private_key, ciphertext, ret);
Expand All @@ -51,7 +51,7 @@ static void decapsulate_2c(libcrux_ml_kem_types_MlKemPrivateKey_5e *private_key,
void libcrux_ml_kem_mlkem512_avx2_decapsulate(
libcrux_ml_kem_types_MlKemPrivateKey_5e *private_key,
libcrux_ml_kem_types_MlKemCiphertext_e8 *ciphertext, uint8_t ret[32U]) {
decapsulate_2c(private_key, ciphertext, ret);
decapsulate_15(private_key, ciphertext, ret);
}

/**
Expand All @@ -71,7 +71,7 @@ with const generics
- ETA2= 2
- ETA2_RANDOMNESS_SIZE= 128
*/
static tuple_ec encapsulate_ad(
static tuple_ec encapsulate_9e(
libcrux_ml_kem_types_MlKemPublicKey_be *public_key,
uint8_t randomness[32U]) {
libcrux_ml_kem_types_MlKemPublicKey_be *uu____0 = public_key;
Expand All @@ -95,7 +95,7 @@ tuple_ec libcrux_ml_kem_mlkem512_avx2_encapsulate(
/* 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_ad(uu____0, copy_of_randomness);
return encapsulate_9e(uu____0, copy_of_randomness);
}

/**
Expand All @@ -109,7 +109,7 @@ libcrux_ml_kem.ind_cca.instantiations.avx2.generate_keypair with const generics
- ETA1= 3
- ETA1_RANDOMNESS_SIZE= 192
*/
static libcrux_ml_kem_types_MlKemKeyPair_cb generate_keypair_c7(
static libcrux_ml_kem_types_MlKemKeyPair_cb generate_keypair_01(
uint8_t randomness[64U]) {
/* Passing arrays by value in Rust generates a copy in C */
uint8_t copy_of_randomness[64U];
Expand All @@ -125,7 +125,7 @@ libcrux_ml_kem_mlkem512_avx2_generate_key_pair(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 generate_keypair_c7(copy_of_randomness);
return generate_keypair_01(copy_of_randomness);
}

/**
Expand All @@ -136,7 +136,7 @@ generics
- SECRET_KEY_SIZE= 1632
- CIPHERTEXT_SIZE= 768
*/
static KRML_MUSTINLINE bool validate_private_key_d1(
static KRML_MUSTINLINE bool validate_private_key_84(
libcrux_ml_kem_types_MlKemPrivateKey_5e *private_key,
libcrux_ml_kem_types_MlKemCiphertext_e8 *ciphertext) {
return libcrux_ml_kem_ind_cca_validate_private_key_e1(private_key,
Expand All @@ -151,7 +151,7 @@ static KRML_MUSTINLINE bool validate_private_key_d1(
bool libcrux_ml_kem_mlkem512_avx2_validate_private_key(
libcrux_ml_kem_types_MlKemPrivateKey_5e *private_key,
libcrux_ml_kem_types_MlKemCiphertext_e8 *ciphertext) {
return validate_private_key_d1(private_key, ciphertext);
return validate_private_key_84(private_key, ciphertext);
}

/**
Expand All @@ -162,7 +162,7 @@ generics
- RANKED_BYTES_PER_RING_ELEMENT= 768
- PUBLIC_KEY_SIZE= 800
*/
static KRML_MUSTINLINE bool validate_public_key_e9(uint8_t *public_key) {
static KRML_MUSTINLINE bool validate_public_key_e3(uint8_t *public_key) {
return libcrux_ml_kem_ind_cca_validate_public_key_4a(public_key);
}

Expand All @@ -173,5 +173,5 @@ static KRML_MUSTINLINE bool validate_public_key_e9(uint8_t *public_key) {
*/
bool libcrux_ml_kem_mlkem512_avx2_validate_public_key(
libcrux_ml_kem_types_MlKemPublicKey_be *public_key) {
return validate_public_key_e9(public_key->value);
return validate_public_key_e3(public_key->value);
}
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem512_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem512_avx2_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem512_portable.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#include "libcrux_mlkem512_portable.h"
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem512_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem512_portable_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux-ml-kem/c/libcrux_mlkem768.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Eurydice: 1a65dbf3758fe310833718c645a64266294a29ac
* Karamel: 15d4bce74a2d43e34a64f48f8311b7d9bcb0e152
* F*: 3063d19312f8ec3af5945f24ed3ebbb6b6cd9678
* Libcrux: 0e1943ac02e87b0a0f08a6b0dff97932b196f845
* Libcrux: 098de7d283a7867de9c3e5672d7b3c915ef9b2f1
*/

#ifndef __libcrux_mlkem768_H
Expand Down
Loading

0 comments on commit 2ac0798

Please sign in to comment.