Skip to content

Commit 275c2b1

Browse files
committed
Review and revise all x86_64 backend contract
- This commit re-check all x86_64 contract follow the corrseponding HOL-Light proof - After checking, the follwoing contract need to be remove: - contract and proof for `mlk_poly_mulcache_compute_avx2` - This commit also add the symmetric note for every .ml proof: (* NOTE: This must be kept in sync with the CBMC specification * in mlkem/src/native/x86_64/src/arith_native_x86_64.h *) Signed-off-by: willieyz <[email protected]>
1 parent d0bd799 commit 275c2b1

15 files changed

+35
-94
lines changed

dev/x86_64/src/arith_native_x86_64.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,7 @@ __contract__(
8181

8282
#define mlk_poly_mulcache_compute_avx2 MLK_NAMESPACE(poly_mulcache_compute_avx2)
8383
void mlk_poly_mulcache_compute_avx2(int16_t *out, const int16_t *in,
84-
const int16_t *qdata)
85-
/* This must be kept in sync with the HOL-Light specification
86-
* in proofs/hol_light/x86/proofs/mlkem_mulcache_compute.ml */
87-
__contract__(
88-
requires(memory_no_alias(out, sizeof(int16_t) * (MLKEM_N / 2)))
89-
requires(memory_no_alias(in, sizeof(int16_t) * MLKEM_N))
90-
requires(qdata == mlk_qdata)
91-
assigns(memory_slice(out, sizeof(int16_t) * (MLKEM_N / 2)))
92-
ensures(array_abs_bound(out, 0, MLKEM_N/2, 3329))
93-
);
84+
const int16_t *qdata);
9485

9586
#define mlk_polyvec_basemul_acc_montgomery_cached_asm_k2 \
9687
MLK_NAMESPACE(polyvec_basemul_acc_montgomery_cached_asm_k2)

mlkem/src/native/x86_64/src/arith_native_x86_64.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,7 @@ __contract__(
8181

8282
#define mlk_poly_mulcache_compute_avx2 MLK_NAMESPACE(poly_mulcache_compute_avx2)
8383
void mlk_poly_mulcache_compute_avx2(int16_t *out, const int16_t *in,
84-
const int16_t *qdata)
85-
/* This must be kept in sync with the HOL-Light specification
86-
* in proofs/hol_light/x86/proofs/mlkem_mulcache_compute.ml */
87-
__contract__(
88-
requires(memory_no_alias(out, sizeof(int16_t) * (MLKEM_N / 2)))
89-
requires(memory_no_alias(in, sizeof(int16_t) * MLKEM_N))
90-
requires(qdata == mlk_qdata)
91-
assigns(memory_slice(out, sizeof(int16_t) * (MLKEM_N / 2)))
92-
ensures(array_abs_bound(out, 0, MLKEM_N/2, 3329))
93-
);
84+
const int16_t *qdata);
9485

9586
#define mlk_polyvec_basemul_acc_montgomery_cached_asm_k2 \
9687
MLK_NAMESPACE(polyvec_basemul_acc_montgomery_cached_asm_k2)

proofs/cbmc/poly_mulcache_compute_native_x86_64/Makefile

Lines changed: 0 additions & 57 deletions
This file was deleted.

proofs/cbmc/poly_mulcache_compute_native_x86_64/poly_mulcache_compute_native_x86_64_harness.c

Lines changed: 0 additions & 17 deletions
This file was deleted.

proofs/hol_light/x86/proofs/mlkem_frombytes.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ let MLKEM_FROMBYTES_NOIBT_SUBROUTINE_CORRECT = prove(
444444
MAYCHANGE [RSP] ,, MAYCHANGE [memory :> bytes(r, 512)])`,
445445
X86_PROMOTE_RETURN_NOSTACK_TAC mlkem_frombytes_tmc MLKEM_FROMBYTES_CORRECT);;
446446

447+
(* NOTE: This must be kept in sync with the CBMC specification
448+
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
449+
447450
let MLKEM_FROMBYTES_SUBROUTINE_CORRECT = prove(
448451
`!r a (l:(12 word) list) pc.
449452
aligned 32 a /\

proofs/hol_light/x86/proofs/mlkem_intt.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,9 @@ let MLKEM_INTT_NOIBT_SUBROUTINE_CORRECT = prove
11941194
CONV_TAC TWEAK_CONV THEN
11951195
X86_PROMOTE_RETURN_NOSTACK_TAC mlkem_intt_tmc (CONV_RULE TWEAK_CONV MLKEM_INTT_CORRECT));;
11961196

1197+
(* NOTE: This must be kept in sync with the CBMC specification
1198+
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
1199+
11971200
let MLKEM_INTT_SUBROUTINE_CORRECT = prove
11981201
(`!a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
11991202
aligned 32 a /\

proofs/hol_light/x86/proofs/mlkem_ntt.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,9 @@ let MLKEM_NTT_NOIBT_SUBROUTINE_CORRECT = prove
12101210
CONV_TAC TWEAK_CONV THEN
12111211
X86_PROMOTE_RETURN_NOSTACK_TAC mlkem_ntt_tmc (CONV_RULE TWEAK_CONV MLKEM_NTT_CORRECT));;
12121212

1213+
(* NOTE: This must be kept in sync with the CBMC specification
1214+
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
1215+
12131216
let MLKEM_NTT_SUBROUTINE_CORRECT = prove
12141217
(`!a zetas (zetas_list:int16 list) x pc stackpointer returnaddress.
12151218
aligned 32 a /\

proofs/hol_light/x86/proofs/mlkem_poly_basemul_acc_montgomery_cached_k2.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,9 @@ let MLKEM_BASEMUL_K2_NOIBT_SUBROUTINE_CORRECT = prove(
10801080
MAYCHANGE [memory :> bytes(dst, 512)])`,
10811081
X86_PROMOTE_RETURN_NOSTACK_TAC mlkem_basemul_k2_tmc MLKEM_BASEMUL_K2_CORRECT);;
10821082

1083+
(* NOTE: This must be kept in sync with the CBMC specification
1084+
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
1085+
10831086
let MLKEM_BASEMUL_K2_SUBROUTINE_CORRECT = prove(
10841087
`!src1 src2 src2t dst a0 b0 c0 d0 dz0 a1 b1 c1 d1 dz1 pc stackpointer returnaddress.
10851088
aligned 32 src1 /\

proofs/hol_light/x86/proofs/mlkem_poly_basemul_acc_montgomery_cached_k3.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,9 @@ let MLKEM_BASEMUL_K3_NOIBT_SUBROUTINE_CORRECT = prove(
15501550
MAYCHANGE [memory :> bytes(dst, 512)])`,
15511551
X86_PROMOTE_RETURN_NOSTACK_TAC mlkem_basemul_k3_tmc MLKEM_BASEMUL_K3_CORRECT);;
15521552

1553+
(* NOTE: This must be kept in sync with the CBMC specification
1554+
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
1555+
15531556
let MLKEM_BASEMUL_K3_SUBROUTINE_CORRECT = prove(
15541557
`!src1 src2 src2t dst a0 b0 c0 d0 dz0 a1 b1 c1 d1 dz1 a2 b2 c2 d2 dz2 pc stackpointer returnaddress.
15551558
aligned 32 src1 /\

proofs/hol_light/x86/proofs/mlkem_poly_basemul_acc_montgomery_cached_k4.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,9 @@ let MLKEM_BASEMUL_K4_NOIBT_SUBROUTINE_CORRECT = prove(
20262026
MAYCHANGE [memory :> bytes(dst, 512)])`,
20272027
X86_PROMOTE_RETURN_NOSTACK_TAC mlkem_basemul_k4_tmc MLKEM_BASEMUL_K4_CORRECT);;
20282028

2029+
(* NOTE: This must be kept in sync with the CBMC specification
2030+
* in mlkem/src/native/x86_64/src/arith_native_x86_64.h *)
2031+
20292032
let MLKEM_BASEMUL_K4_SUBROUTINE_CORRECT = prove(
20302033
`!src1 src2 src2t dst a0 b0 c0 d0 dz0 a1 b1 c1 d1 dz1 a2 b2 c2 d2 dz2 a3 b3 c3 d3 dz3 pc stackpointer returnaddress.
20312034
aligned 32 src1 /\

0 commit comments

Comments
 (0)