Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update C code with Kyber stateful API #457

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions libcrux/include/Eurydice.h

This file was deleted.

20 changes: 12 additions & 8 deletions libcrux/include/core.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
/*
This file was generated by KaRaMeL <https://github.com/FStarLang/karamel>
KaRaMeL invocation: /Users/franziskus/repos/eurydice//eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: a32b316e
KaRaMeL version: abb38e1d
KaRaMeL invocation: /Users/jonathan/Code/eurydice/eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: c990b3ca
KaRaMeL version: 391b72f8
*/

#ifndef __core_H
#define __core_H

#include "eurydice_glue.h"

#define core_option_None 0
#define core_option_Some 1

typedef uint8_t core_option_Option__size_t_tags;

typedef struct core_ops_range_Range__size_t_s
{
size_t start;
size_t end;
}
core_ops_range_Range__size_t;

extern uint8_t Eurydice_bitand_pv_u8(uint8_t *x, uint8_t y);

extern uint8_t Eurydice_shr_pv_u8(uint8_t *x, int32_t y);

#define core_option_None 0
#define core_option_Some 1

typedef uint8_t core_option_Option__size_t_tags;


#define __core_H_DEFINED
#endif
2 changes: 2 additions & 0 deletions libcrux/include/eurydice_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef struct
}
result_tryfromslice_flexible;

// See note in karamel/lib/Inlining.ml if you change this
#define Eurydice_slice_to_array2(dst, src, _, t_arr, _ret_t) Eurydice_slice_to_array3((result_tryfromslice_flexible *)dst, src, sizeof(t_arr))

static inline void Eurydice_slice_to_array3(result_tryfromslice_flexible *dst, Eurydice_slice src, size_t sz) {
Expand Down Expand Up @@ -103,6 +104,7 @@ static inline uint8_t Eurydice_shr_pv_u8(uint8_t *p, int32_t v) { return (*p) >>

#define core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___3__next Eurydice_range_iter_next

// See note in karamel/lib/Inlining.ml if you change this
#define Eurydice_into_iter(x, t, _ret_t) (x)
#define core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I___into_iter Eurydice_into_iter

Expand Down
6 changes: 3 additions & 3 deletions libcrux/include/internal/core.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This file was generated by KaRaMeL <https://github.com/FStarLang/karamel>
KaRaMeL invocation: /Users/franziskus/repos/eurydice//eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: a32b316e
KaRaMeL version: abb38e1d
KaRaMeL invocation: /Users/jonathan/Code/eurydice/eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: c990b3ca
KaRaMeL version: 391b72f8
*/

#ifndef __internal_core_H
Expand Down
6 changes: 3 additions & 3 deletions libcrux/include/internal/libcrux_kyber.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This file was generated by KaRaMeL <https://github.com/FStarLang/karamel>
KaRaMeL invocation: /Users/franziskus/repos/eurydice//eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: a32b316e
KaRaMeL version: abb38e1d
KaRaMeL invocation: /Users/jonathan/Code/eurydice/eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: c990b3ca
KaRaMeL version: 391b72f8
*/

#ifndef __internal_libcrux_kyber_H
Expand Down
6 changes: 3 additions & 3 deletions libcrux/include/libcrux_digest.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This file was generated by KaRaMeL <https://github.com/FStarLang/karamel>
KaRaMeL invocation: /Users/franziskus/repos/eurydice//eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: a32b316e
KaRaMeL version: abb38e1d
KaRaMeL invocation: /Users/jonathan/Code/eurydice/eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: c990b3ca
KaRaMeL version: 391b72f8
*/

#ifndef __libcrux_digest_H
Expand Down
2 changes: 1 addition & 1 deletion libcrux/include/libcrux_hacl_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#include "Eurydice.h"
#include "eurydice_glue.h"

#include <stdint.h>
#include <string.h>
Expand Down
34 changes: 29 additions & 5 deletions libcrux/include/libcrux_kyber.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*
This file was generated by KaRaMeL <https://github.com/FStarLang/karamel>
KaRaMeL invocation: /Users/franziskus/repos/eurydice//eurydice --config
../../kyber-c.yaml ../libcrux_kyber.llbc F* version: a32b316e KaRaMeL version:
abb38e1d
KaRaMeL invocation: /Users/jonathan/Code/eurydice/eurydice --config
../../kyber-c.yaml ../libcrux_kyber.llbc F* version: c990b3ca KaRaMeL version:
391b72f8
*/

#ifndef __libcrux_kyber_H
#define __libcrux_kyber_H

#include "Eurydice.h"
#include "core.h"
#include "eurydice_glue.h"
#include "libcrux_digest.h"
Expand Down Expand Up @@ -86,6 +85,25 @@ typedef struct libcrux_kyber_types_MlKemKeyPair___2400size_t_1184size_t_s
libcrux_kyber_types_MlKemKeyPair___2400size_t_1184size_t
libcrux_kyber_kyber768_generate_key_pair(uint8_t randomness[64U]);

typedef struct libcrux_kyber_MlKemState___3size_t_s
{
int32_t secret_as_ntt[3U][256U];
int32_t t_as_ntt[3U][256U];
int32_t a_transpose[3U][3U][256U];
uint8_t rej[32U];
uint8_t ind_cpa_public_key_hash[32U];
} libcrux_kyber_MlKemState___3size_t;

typedef struct
K___libcrux_kyber_MlKemState__3size_t___libcrux_kyber_types_MlKemPublicKey__1184size_t___s
{
libcrux_kyber_MlKemState___3size_t fst;
uint8_t snd[1184U];
} K___libcrux_kyber_MlKemState__3size_t___libcrux_kyber_types_MlKemPublicKey__1184size_t__;

K___libcrux_kyber_MlKemState__3size_t___libcrux_kyber_types_MlKemPublicKey__1184size_t__
libcrux_kyber_kyber768_generate_key_pair_unpacked(uint8_t randomness[64U]);

typedef struct
K___libcrux_kyber_types_MlKemCiphertext__1088size_t___uint8_t_32size_t__s
{
Expand All @@ -101,6 +119,12 @@ void libcrux_kyber_kyber768_decapsulate(uint8_t (*secret_key)[2400U],
uint8_t (*ciphertext)[1088U],
uint8_t ret[32U]);

void
libcrux_kyber_kyber768_decapsulate_unpacked(
libcrux_kyber_MlKemState___3size_t* state,
uint8_t (*ciphertext)[1088U],
uint8_t ret[32U]);

extern libcrux_digest_incremental_x4_Shake128StateX4
libcrux_digest_incremental_x4__libcrux__digest__incremental_x4__Shake128StateX4__new(
void);
Expand All @@ -114,7 +138,7 @@ extern void
libcrux_digest_incremental_x4__libcrux__digest__incremental_x4__Shake128StateX4__absorb_final_(
size_t x0,
libcrux_digest_incremental_x4_Shake128StateX4* x1,
Eurydice_slice x2[3U]);
Eurydice_slice* x2);

extern void
libcrux_digest_incremental_x4__libcrux__digest__incremental_x4__Shake128StateX4__free_memory(
Expand Down
13 changes: 0 additions & 13 deletions libcrux/src/Eurydice.c

This file was deleted.

9 changes: 5 additions & 4 deletions libcrux/src/core.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
This file was generated by KaRaMeL <https://github.com/FStarLang/karamel>
KaRaMeL invocation: /Users/franziskus/repos/eurydice//eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: a32b316e
KaRaMeL version: abb38e1d
KaRaMeL invocation: /Users/jonathan/Code/eurydice/eurydice --config ../../kyber-c.yaml ../libcrux_kyber.llbc
F* version: c990b3ca
KaRaMeL version: 391b72f8
*/

#include "internal/core.h"

typedef size_t RangeTo__size_t;

typedef size_t RangeFrom__size_t;

typedef size_t RangeTo__size_t;
Loading
Loading