Skip to content

Commit bc54e43

Browse files
Merge pull request #1237 from cryspen/franziskus/single-eurydice
Update Eurydice
2 parents f63bb67 + e48938f commit bc54e43

File tree

111 files changed

+35144
-28990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+35144
-28990
lines changed

.docker/c/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ COPY --chown=$USER:$USER . $HOME/$USER
2222

2323
ENV FSTAR_HOME=$HOME/fstar
2424
ENV HACL_HOME=$HOME/hacl-star
25-
ENV KRML_HOME=$HOME/karamel
2625
ENV EURYDICE_HOME=$HOME/eurydice
27-
ENV CHARON_HOME=$HOME/charon
28-
ENV KRML_REV=80f5435f2fc505973c469a4afcc8d875cddd0d8b
29-
ENV EURYDICE_REV=2381cbc416ef2ad0b561c362c500bc84f36b6785
30-
ENV CHARON_REV=667d2fc98984ff7f3df989c2367e6c1fa4a000e7
26+
ENV KRML_HOME=$HOME/eurydice/karamel
27+
ENV CHARON_HOME=$HOME/eurydice/charon
28+
ENV EURYDICE_REV=cdf02f9d8ed0d73f88c0a495c5b79359a51398fc
3129
ENV PATH="${PATH}:$HOME/fstar/bin:$HOME/z3/bin"
30+
ENV CC=clang
31+
ENV CXX=clang++
3232

3333
# Setup & install.
3434
ADD install.sh /tmp/install.sh

.docker/c/ext-tools.sh

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,31 @@ set -v -e -x
44

55
source $HOME/.profile
66

7-
curl -L https://github.com/AeneasVerif/charon/archive/$CHARON_REV.zip \
8-
--output charon.zip
9-
unzip charon.zip
10-
rm -rf charon.zip
11-
mv charon-$CHARON_REV/ charon
12-
13-
curl -L https://github.com/FStarLang/karamel/archive/$KRML_REV.zip \
14-
--output karamel.zip
15-
unzip karamel.zip
16-
rm -rf karamel.zip
17-
mv karamel-$KRML_REV/ karamel
18-
19-
curl -L https://github.com/AeneasVerif/eurydice/archive/$EURYDICE_REV.zip \
20-
--output eurydice.zip
21-
unzip eurydice.zip
22-
rm -rf eurydice.zip
23-
mv eurydice-$EURYDICE_REV/ eurydice
24-
25-
echo "export KRML_HOME=$HOME/karamel" >>$HOME/.profile
7+
git clone https://github.com/AeneasVerif/eurydice.git
8+
cd eurydice
9+
git checkout $EURYDICE_REV
10+
11+
make setup-karamel
12+
make setup-charon
13+
make setup-libcrux
14+
15+
make test
16+
17+
# Remove Charon build files, since the binary has been generated
18+
cd charon/charon
19+
cargo clean
20+
cd -
21+
22+
echo "export KRML_HOME=$HOME/eurydice/karamel" >>$HOME/.profile
2623
echo "export EURYDICE_HOME=$HOME/eurydice" >>$HOME/.profile
27-
echo "export CHARON_HOME=$HOME/charon" >>$HOME/.profile
24+
echo "export CHARON_HOME=$HOME/eurydice/charon" >>$HOME/.profile
25+
26+
CHARON_REV="$(jq -r ".nodes.charon.locked.rev" flake.lock)"
27+
KRML_REV="$(jq -r ".nodes.karamel.locked.rev" flake.lock)"
2828

2929
echo "export KRML_REV=$KRML_REV" >>$HOME/.profile
3030
echo "export EURYDICE_REV=$EURYDICE_REV" >>$HOME/.profile
3131
echo "export CHARON_REV=$CHARON_REV" >>$HOME/.profile
3232

3333
source $HOME/.profile
3434

35-
# Build everything
36-
cd charon
37-
make build-charon-rust -j
38-
cd -
39-
40-
cd karamel
41-
make -j
42-
cd -
43-
44-
cd eurydice/lib
45-
rm -f charon
46-
ln -s $CHARON_HOME charon
47-
rm -f krml
48-
ln -s $KRML_HOME/lib krml
49-
cd ../
50-
make -j
51-
cd ../

.docker/c/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ echo "[[ ! -r /home/$USER/.opam/opam-init/init.sh ]] || source /home/$USER/.opam
3535

3636
source $HOME/.profile
3737
opam install --yes ocamlfind visitors menhir ppx_deriving_yojson core_unix \
38-
sedlex wasm fix process pprint zarith yaml easy_logging terminal unionFind
38+
sedlex wasm fix process pprint zarith yaml easy_logging terminal unionFind ocamlformat.0.27.0
3939
eval $(opam env)

.docker/c/setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ apt-get install -y \
99
build-essential \
1010
opam \
1111
jq \
12+
git \
13+
clang \
14+
ninja-build \
1215
libgmp-dev \
1316
locales \
1417
pkg-config \
1518
clang-format\
19+
cmake \
1620
curl \
1721
time
1822
curl -fsSL https://deb.nodesource.com/setup_21.x | bash -

.github/workflows/docker-c-build-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ jobs:
136136
cmake --build build
137137
138138
- name: 🏃🏻‍♀️ Test
139-
run: ./build/Debug/ml_kem_test
139+
run: ./build/Debug/ml_kem_test768
140140
if: ${{ matrix.os == 'windows-latest' }}
141141

142142
- name: 🏃🏻‍♀️ Test
143-
run: ./build/ml_kem_test
143+
run: ./build/ml_kem_test768
144144
if: ${{ matrix.os != 'windows-latest' }}
145145

146146
- name: 🔨 Build Release
@@ -174,11 +174,11 @@ jobs:
174174
# FIXME: Benchmark build for cg on Windows CI is not working right now.
175175

176176
- name: 🏃🏻‍♀️ Test
177-
run: ./build/ml_kem_test
177+
run: ./build/ml_kem_test768
178178
if: ${{ matrix.os != 'windows-latest' }}
179179

180180
- name: 🏃🏻‍♀️ Test
181-
run: ./build/Debug/ml_kem_test
181+
run: ./build/Debug/ml_kem_test768
182182
if: ${{ matrix.os == 'windows-latest' }}
183183

184184
test-build-ml-dsa-header-only:

libcrux-ml-dsa/c.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if [[ -z "$KRML_HOME" ]]; then
1616
exit 1
1717
fi
1818

19+
mldsa_root=$(pwd)
20+
repo_root=$(realpath ../)
21+
1922
portable_only=0
2023
no_hacl=0
2124
no_charon=0
@@ -58,16 +61,26 @@ fi
5861
if [[ "$no_charon" = 0 ]]; then
5962
# Because of a Charon bug we have to clean the sha3 crate.
6063
cargo clean -p libcrux-sha3
61-
rm -rf ../libcrux_ml_dsa.llbc ../libcrux_sha3.llbc
62-
echo "Running charon (sha3) ..."
63-
(cd ../libcrux-sha3 && RUSTFLAGS="--cfg eurydice" $CHARON_HOME/bin/charon --remove-associated-types '*' --rustc-arg=-Cdebug-assertions=no)
64-
if ! [[ -f ../libcrux_sha3.llbc ]]; then
64+
rm -rf $repo_root/libcrux_ml_dsa.llbc $repo_root/libcrux_sha3.llbc
65+
66+
flags=
67+
if [[ $(uname -m) == "arm64" ]]; then
68+
flags+="-- --target=x86_64-apple-darwin"
69+
fi
70+
71+
echo "Running charon (all) ..."
72+
RUSTFLAGS="--cfg eurydice" $CHARON_HOME/bin/charon cargo \
73+
$features \
74+
--preset eurydice \
75+
--include 'libcrux_sha3' \
76+
--start-from libcrux_ml_dsa --start-from libcrux_sha3 \
77+
--include 'core::num::*::BITS' --include 'core::num::*::MAX' \
78+
--rustc-arg=-Cdebug-assertions=no $flags
79+
if ! [[ -f $repo_root/libcrux_ml_dsa.llbc ]]; then
6580
echo "😱😱😱 You are the victim of a bug."
6681
echo "Suggestion: rm -rf ../target or cargo clean"
6782
exit 1
6883
fi
69-
echo "Running charon (ml-dsa) with $features ..."
70-
RUSTFLAGS="--cfg eurydice" $CHARON_HOME/bin/charon --remove-associated-types '*' --rustc-arg=-Cdebug-assertions=no $features
7184
else
7285
echo "Skipping charon"
7386
fi
@@ -114,10 +127,10 @@ echo " */" >> header.txt
114127
# Run eurydice to extract the C code
115128
echo "Running eurydice ..."
116129
echo $EURYDICE_HOME/eurydice --config ../$config -funroll-loops $unrolling \
117-
--header header.txt $cpp17 ../../libcrux_ml_dsa.llbc ../../libcrux_sha3.llbc
130+
--header header.txt $cpp17 ../../libcrux_ml_dsa.llbc --keep-going
118131

119-
$EURYDICE_HOME/eurydice --debug "-dast" --config ../$config -funroll-loops $unrolling \
120-
--header header.txt $cpp17 ../../libcrux_ml_dsa.llbc ../../libcrux_sha3.llbc
132+
$EURYDICE_HOME/eurydice --config ../$config -funroll-loops $unrolling \
133+
--header header.txt $cpp17 ../../libcrux_ml_dsa.llbc --keep-going
121134

122135
if [[ "$eurydice_glue" = 1 ]]; then
123136
cp $EURYDICE_HOME/include/eurydice_glue.h .
@@ -130,6 +143,7 @@ if [[ "$karamel_include" = 1 ]]; then
130143
fi
131144

132145
find . -type f -name '*.c' -and -not -path '*_deps*' -exec clang-format-18 --style=Google -i "{}" \;
146+
find . -type f -name '*.cc' -and -not -path '*_deps*' -exec clang-format-18 --style=Google -i "{}" \;
133147
find . -type f -name '*.h' -and -not -path '*_deps*' -exec clang-format-18 --style=Google -i "{}" \;
134148
if [ -d "internal" ]; then
135149
clang-format-18 --style=Google -i internal/*.h

libcrux-ml-dsa/cg.yaml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,43 @@ files:
55
inline_static: true
66
api:
77
- [libcrux_intrinsics, avx2]
8+
private:
9+
monomorphizations_exact:
10+
- [ Eurydice, arr_05]
11+
- [ Eurydice, arr_c0]
812

9-
# # Constant time ops
10-
# - name: libcrux_ct_ops
11-
# inline_static: true
12-
# api:
13-
# - [libcrux_ml_kem, constant_time_ops]
13+
# MLDSA: MISC NON-ARCHITECTURE SPECIFIC HEADERS
14+
- name: libcrux_mldsa_core
15+
inline_static: true
16+
private:
17+
monomorphizations_of:
18+
- [libcrux_ml_dsa, types, "*"]
19+
patterns:
20+
- [core, "*"]
21+
- [libcrux_ml_dsa, types, "*" ]
22+
monomorphizations_exact:
23+
- [libcrux_sha3, Sha3_512Digest]
24+
- [ Eurydice_dst_ref_shared uint8_t size_t_x4]
25+
- [ Eurydice_dst_ref_shared uint8_t size_t_x2]
26+
- [ Eurydice_dst_ref uint8_t size_t_x4]
27+
- [ Eurydice_dst_ref uint8_t size_t_x2]
28+
- [ "Eurydice_slice uint8_t_x4" ]
29+
- [ "Eurydice_slice uint8_t_x2" ]
30+
- [ Eurydice, arr_88]
31+
- [ Eurydice, arr_910]
32+
- [ Eurydice, arr_6d]
33+
- [ core, result, unwrap_26_ab ]
34+
- [ core, result, Result_a4 ]
1435

36+
api:
37+
- [Eurydice, "*"]
38+
1539
# SHA3 (no mention of libcrux_mlkem in this section, please)
16-
1740
- name: libcrux_sha3_avx2
1841
inline_static: true
1942
target: "avx2"
43+
include_in_h:
44+
- '"intrinsics/libcrux_intrinsics_avx2.h"'
2045
api:
2146
patterns:
2247
- [libcrux_sha3, avx2, "*"]
@@ -32,8 +57,7 @@ files:
3257
- [libcrux_sha3, avx2, "*"]
3358
- [libcrux_sha3, simd, avx2, "*"]
3459
- [libcrux_sha3, generic_keccak, simd256, "*"]
35-
include_in_h:
36-
- '"intrinsics/libcrux_intrinsics_avx2.h"'
60+
3761

3862
# Portable SHA3
3963
- name: libcrux_sha3_portable
@@ -63,7 +87,6 @@ files:
6387
- [libcrux_sha3, generic_keccak, xof, "*"]
6488

6589
# MLDSA-65
66-
6790
- name: libcrux_mldsa65_avx2
6891
inline_static: true
6992
target: "avx2"
@@ -76,8 +99,6 @@ files:
7699
- [libcrux_ml_dsa, hash_functions, simd256, "*"]
77100
- [libcrux_ml_dsa, ml_dsa_65, avx2, "*"]
78101
- [libcrux_ml_dsa, ml_dsa_generic, instantiations, avx2, "*"]
79-
# - [core, option, Option_c4]
80-
# - [libcrux_ml_dsa, polynomial, "*" ]
81102
monomorphizations_of:
82103
- [libcrux_ml_dsa, simd, avx2, "*"]
83104
- [libcrux_ml_dsa, hash_functions, simd256, "*"]
@@ -86,8 +107,9 @@ files:
86107
monomorphizations_using:
87108
- [libcrux_ml_dsa, simd, avx2, "*"]
88109
- [libcrux_ml_dsa, hash_functions, simd256, "*"]
89-
# monomorphizations_exact:
90-
# - [core, option, Option_c4]
110+
monomorphizations_exact:
111+
- [core, option, Option_e70]
112+
- [ Eurydice, arr_f8]
91113

92114
- name: libcrux_mldsa65_portable
93115
inline_static: true
@@ -99,48 +121,30 @@ files:
99121
- [libcrux_ml_dsa, hash_functions, portable, "*"]
100122
- [libcrux_ml_dsa, ml_dsa_65, portable, "*"]
101123
- [libcrux_ml_dsa, ml_dsa_generic, instantiations, portable, "*"]
102-
# - [libcrux_ml_dsa, pre_hash, PreHashResult]
103-
# - [core, option, Option_84]
104124
monomorphizations_of:
105125
- [libcrux_ml_dsa, polynomial, "*" ]
106126
- [libcrux_ml_dsa, simd, "*"]
107127
- [libcrux_ml_dsa, hash_functions, portable, "*"]
108128
- [libcrux_ml_dsa, ml_dsa_65, portable]
109129
- [libcrux_ml_dsa, ml_dsa_generic, instantiations, portable, "*"]
110-
# - [libcrux_ml_dsa, pre_hash, PreHashResult]
111-
# - [core, option, Option_84]
112130
monomorphizations_using:
113131
- [libcrux_ml_dsa, polynomial, "*" ]
114132
- [libcrux_ml_dsa, simd, "*"]
115133
- [libcrux_ml_dsa, hash_functions, portable, "*"]
116134
- [libcrux_ml_dsa, ml_dsa_generic, instantiations, portable, "*"]
117-
# - [libcrux_ml_dsa, pre_hash, PreHashResult]
118135
monomorphizations_exact:
119136
- [libcrux_ml_dsa, pre_hash, PreHashResult]
120137
- [core, result, Result_a8]
121138
- [core, option, Option_84]
122139

123-
124-
# MLKEM: MISC NON-ARCHITECTURE SPECIFIC HEADERS
125-
- name: libcrux_core
140+
# MLDSA: catch-all for things that have not matched earlier
141+
- name: libcrux_mldsa_core
126142
inline_static: true
127143
private:
128144
monomorphizations_of:
129-
- [core, "*"]
130-
- [libcrux_ml_dsa, types, "*"]
131-
- [libcrux_ml_dsa, utils, "*" ]
132-
monomorphizations_using:
133145
- [Eurydice, "*" ]
134-
- [libcrux_ml_dsa, types, "*"]
135146
patterns:
136-
- [core, "*"]
137-
- [libcrux_ml_dsa, types ]
138-
- [libcrux_ml_dsa, constants ]
139-
- [libcrux_ml_dsa, utils, "*" ]
140-
# - [libcrux_ml_dsa, simd, traits ]
141-
api:
142-
- [Eurydice, "*"]
143-
147+
- [Eurydice, "*" ]
144148
naming:
145149
skip_prefix:
146150
- [ core, core_arch, arm_shared, neon ]

libcrux-ml-dsa/cg/code_gen.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This code was generated with the following revisions:
2-
Charon: 667d2fc98984ff7f3df989c2367e6c1fa4a000e7
3-
Eurydice: 2381cbc416ef2ad0b561c362c500bc84f36b6785
4-
Karamel: 80f5435f2fc505973c469a4afcc8d875cddd0d8b
5-
F*: 71d8221589d4d438af3706d89cb653cf53e18aab
6-
Libcrux: 4433a17f91aab0789f083de6c7fe08493e5998c8
2+
Charon: 146b7dce58cb11ca8010b1c947c3437a959dcd88
3+
Eurydice: cdf02f9d8ed0d73f88c0a495c5b79359a51398fc
4+
Karamel: 8e7262955105599e91f3a99c9ab3d3387f7046f2
5+
F*: unset
6+
Libcrux: 927ad3614c662733d7c77b6cd4304177fbd390a8

0 commit comments

Comments
 (0)