Skip to content

Commit 7bf2ee9

Browse files
Merge pull request #1114 from cryspen/ci-fix
Fixing proofs on CI
2 parents a90e524 + a0add98 commit 7bf2ee9

21 files changed

+275
-327
lines changed

libcrux-ml-dsa/cg/code_gen.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ This code was generated with the following revisions:
22
Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
33
Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
44
Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
5-
F*: 4b3fc11774003a6ff7c09500ecb5f0145ca6d862
6-
Libcrux: b54a2f8eacb847bfe456abe6b195dc94bf464dda
5+
F*: unset
6+
Libcrux: c9823353edf245785e103a69312b21cca741967a

libcrux-ml-dsa/cg/header.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
* Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
88
* Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
99
* Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
10-
* F*: 4b3fc11774003a6ff7c09500ecb5f0145ca6d862
11-
* Libcrux: b54a2f8eacb847bfe456abe6b195dc94bf464dda
10+
* F*: unset
11+
* Libcrux: c9823353edf245785e103a69312b21cca741967a
1212
*/

libcrux-ml-dsa/cg/libcrux_core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
88
* Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
99
* Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
10-
* F*: 4b3fc11774003a6ff7c09500ecb5f0145ca6d862
11-
* Libcrux: b54a2f8eacb847bfe456abe6b195dc94bf464dda
10+
* F*: unset
11+
* Libcrux: c9823353edf245785e103a69312b21cca741967a
1212
*/
1313

1414
#ifndef __libcrux_core_H

libcrux-ml-dsa/cg/libcrux_mldsa65_avx2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
88
* Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
99
* Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
10-
* F*: 4b3fc11774003a6ff7c09500ecb5f0145ca6d862
11-
* Libcrux: b54a2f8eacb847bfe456abe6b195dc94bf464dda
10+
* F*: unset
11+
* Libcrux: c9823353edf245785e103a69312b21cca741967a
1212
*/
1313

1414
#ifndef __libcrux_mldsa65_avx2_H

libcrux-ml-dsa/cg/libcrux_mldsa65_portable.h

Lines changed: 76 additions & 220 deletions
Large diffs are not rendered by default.

libcrux-ml-dsa/cg/libcrux_sha3_avx2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
88
* Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
99
* Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
10-
* F*: 4b3fc11774003a6ff7c09500ecb5f0145ca6d862
11-
* Libcrux: b54a2f8eacb847bfe456abe6b195dc94bf464dda
10+
* F*: unset
11+
* Libcrux: c9823353edf245785e103a69312b21cca741967a
1212
*/
1313

1414
#ifndef __libcrux_sha3_avx2_H

libcrux-ml-dsa/cg/libcrux_sha3_portable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
88
* Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
99
* Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
10-
* F*: 4b3fc11774003a6ff7c09500ecb5f0145ca6d862
11-
* Libcrux: b54a2f8eacb847bfe456abe6b195dc94bf464dda
10+
* F*: unset
11+
* Libcrux: c9823353edf245785e103a69312b21cca741967a
1212
*/
1313

1414
#ifndef __libcrux_sha3_portable_H

libcrux-ml-dsa/src/simd/portable/ntt.rs

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,6 @@ fn ntt_at_layer_2(re: &mut [Coefficients; SIMD_UNITS_IN_RING_ELEMENT]) {
323323
}
324324

325325
#[inline(always)]
326-
#[hax_lib::fstar::before(
327-
r#"
328-
let layer_bound_factor (step_by:usize) : n:nat{n <= 4} =
329-
match step_by with
330-
| MkInt 1 -> 4
331-
| MkInt 2 -> 3
332-
| MkInt 4 -> 2
333-
| MkInt 8 -> 1
334-
| MkInt 16 -> 0
335-
| _ -> 0
336-
"#
337-
)]
338326
#[hax_lib::fstar::options("--z3rlimit 600 --split_queries always")]
339327
#[hax_lib::fstar::before(r#"[@@ "opaque_to_smt"]"#)]
340328
#[hax_lib::requires(fstar!(r#"
@@ -357,6 +345,61 @@ let layer_bound_factor (step_by:usize) : n:nat{n <= 4} =
357345
fn outer_3_plus<const OFFSET: usize, const STEP_BY: usize, const ZETA: i32>(
358346
re: &mut [Coefficients; SIMD_UNITS_IN_RING_ELEMENT],
359347
) {
348+
// Refactoring the code to have the loop body separately verified is good for proof performance.
349+
// So we factor out the loop body in a `round` function similarly to the other NTT layers.
350+
#[inline(always)]
351+
#[hax_lib::fstar::before(
352+
r#"
353+
let layer_bound_factor (step_by:usize) : n:nat{n <= 4} =
354+
match step_by with
355+
| MkInt 1 -> 4
356+
| MkInt 2 -> 3
357+
| MkInt 4 -> 2
358+
| MkInt 8 -> 1
359+
| MkInt 16 -> 0
360+
| _ -> 0
361+
"#
362+
)]
363+
#[hax_lib::fstar::options("--z3rlimit 300 --split_queries always")]
364+
#[hax_lib::fstar::before(r#"[@@ "opaque_to_smt"]"#)]
365+
#[hax_lib::requires(fstar!(r#"
366+
v $step_by > 0 /\
367+
v $index + v $step_by < v $SIMD_UNITS_IN_RING_ELEMENT /\
368+
Spec.Utils.is_i32b_array_opaque
369+
(v $NTT_BASE_BOUND + ((layer_bound_factor $step_by) * v $FIELD_MAX))
370+
(Seq.index ${re} (v $index)).f_values /\
371+
Spec.Utils.is_i32b_array_opaque
372+
(v $NTT_BASE_BOUND + ((layer_bound_factor $step_by) * v $FIELD_MAX))
373+
(Seq.index ${re} (v $index + v $step_by)).f_values /\
374+
Spec.Utils.is_i32b 4190208 $zeta
375+
"#))]
376+
#[hax_lib::ensures(|_| fstar!(r#"
377+
Spec.Utils.modifies2_32 ${re} ${re}_future $index (${index + step_by}) /\
378+
Spec.Utils.is_i32b_array_opaque
379+
(v $NTT_BASE_BOUND + ((layer_bound_factor $step_by + 1) * v $FIELD_MAX))
380+
(Seq.index ${re}_future (v $index)).f_values /\
381+
Spec.Utils.is_i32b_array_opaque
382+
(v $NTT_BASE_BOUND + ((layer_bound_factor $step_by + 1) * v $FIELD_MAX))
383+
(Seq.index ${re}_future (v $index + v step_by)).f_values
384+
"#))]
385+
fn round(
386+
re: &mut [Coefficients; SIMD_UNITS_IN_RING_ELEMENT],
387+
index: usize,
388+
step_by: usize,
389+
zeta: i32,
390+
) {
391+
hax_lib::fstar!(
392+
"reveal_opaque (`%Spec.Utils.is_i32b_array_opaque) (Spec.Utils.is_i32b_array_opaque)"
393+
);
394+
let mut tmp = re[index + step_by];
395+
montgomery_multiply_by_constant(&mut tmp, zeta);
396+
397+
re[index + step_by] = re[index];
398+
399+
arithmetic::subtract(&mut re[index + step_by], &tmp);
400+
arithmetic::add(&mut re[index], &tmp);
401+
}
402+
360403
#[cfg(hax)]
361404
let orig_re = re.clone();
362405

@@ -372,20 +415,7 @@ fn outer_3_plus<const OFFSET: usize, const STEP_BY: usize, const ZETA: i32>(
372415
(Seq.index ${re} i).f_values))
373416
"#
374417
));
375-
376-
let mut tmp = re[j + STEP_BY];
377-
montgomery_multiply_by_constant(&mut tmp, ZETA);
378-
379-
re[j + STEP_BY] = re[j];
380-
381-
arithmetic::subtract(&mut re[j + STEP_BY], &tmp);
382-
arithmetic::add(&mut re[j], &tmp);
383-
384-
hax_lib::fstar!(
385-
r#"
386-
assert ((v ${NTT_BASE_BOUND} + ((layer_bound_factor v_STEP_BY) * v $FIELD_MAX)) + (v $FIELD_MAX)
387-
== (v ${NTT_BASE_BOUND} + ((layer_bound_factor v_STEP_BY + 1) * v $FIELD_MAX)))"#
388-
);
418+
round(re, j, STEP_BY, ZETA);
389419
}
390420
}
391421

libcrux-ml-kem/cg/code_gen.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ This code was generated with the following revisions:
22
Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
33
Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
44
Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
5-
F*: 71d8221589d4d438af3706d89cb653cf53e18aab
6-
Libcrux: e74ed15b655f78c0fb80c8614a94c07932712e44
5+
F*: unset
6+
Libcrux: c9823353edf245785e103a69312b21cca741967a

libcrux-ml-kem/cg/header.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
* Charon: bb62a9b39db4ea8c6d536fe61b7d26663751bf3c
88
* Eurydice: 46cef5d58a855ed049fa89bfe99c959b5d9d0d4b
99
* Karamel: 39cb85a718da8ae4a724d31b08f9134ca9311336
10-
* F*: 71d8221589d4d438af3706d89cb653cf53e18aab
11-
* Libcrux: e74ed15b655f78c0fb80c8614a94c07932712e44
10+
* F*: unset
11+
* Libcrux: c9823353edf245785e103a69312b21cca741967a
1212
*/

0 commit comments

Comments
 (0)