Skip to content
Open
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
26 changes: 13 additions & 13 deletions dev/aarch64_clean/src/arith_native_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void mld_ntt_aarch64_asm(int32_t *r, const int32_t *zetas_l123456,
* in proofs/hol_light/aarch64/proofs/ntt_aarch64_asm.ml */
__contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
/* check-magic: 8380417 == MLDSA_Q */
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
requires(zetas_l123456 == mld_aarch64_ntt_zetas_layer123456)
requires(zetas_l78 == mld_aarch64_ntt_zetas_layer78)
Expand Down Expand Up @@ -261,12 +262,14 @@ void mld_poly_pointwise_montgomery_aarch64_asm(int32_t *a, const int32_t *b)
__contract__(
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * MLDSA_N))
/* check-magic: off */
requires(array_abs_bound(a, 0, MLDSA_N, 75423753))
requires(array_abs_bound(b, 0, MLDSA_N, 75423753))
/* Input bound MLD_NTT_BOUND = 9 * MLD_FQMUL_BOUND, the post-condition of
* the forward NTT. Hardcoded here to keep this header free of poly.h.
* Must be kept in sync with the HOL-Light precondition. */
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(array_abs_bound(a, 0, MLDSA_N, 94279698))
requires(array_abs_bound(b, 0, MLDSA_N, 94279698))
assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(a, 0, MLDSA_N, 8380417))
/* check-magic: on */
);
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API || \
MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
Expand All @@ -283,12 +286,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 4 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 4 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 4, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm \
Expand All @@ -303,12 +305,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 5 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 5 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 5, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm \
Expand All @@ -323,12 +324,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 7 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 7 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 7, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#endif /* !MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H */
26 changes: 13 additions & 13 deletions dev/aarch64_opt/src/arith_native_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void mld_ntt_aarch64_asm(int32_t *r, const int32_t *zetas_l123456,
* in proofs/hol_light/aarch64/proofs/ntt_aarch64_asm.ml */
__contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
/* check-magic: 8380417 == MLDSA_Q */
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
requires(zetas_l123456 == mld_aarch64_ntt_zetas_layer123456)
requires(zetas_l78 == mld_aarch64_ntt_zetas_layer78)
Expand Down Expand Up @@ -261,12 +262,14 @@ void mld_poly_pointwise_montgomery_aarch64_asm(int32_t *a, const int32_t *b)
__contract__(
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * MLDSA_N))
/* check-magic: off */
requires(array_abs_bound(a, 0, MLDSA_N, 75423753))
requires(array_abs_bound(b, 0, MLDSA_N, 75423753))
/* Input bound MLD_NTT_BOUND = 9 * MLD_FQMUL_BOUND, the post-condition of
* the forward NTT. Hardcoded here to keep this header free of poly.h.
* Must be kept in sync with the HOL-Light precondition. */
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(array_abs_bound(a, 0, MLDSA_N, 94279698))
requires(array_abs_bound(b, 0, MLDSA_N, 94279698))
assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(a, 0, MLDSA_N, 8380417))
/* check-magic: on */
);
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API || \
MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
Expand All @@ -283,12 +286,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 4 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 4 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 4, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm \
Expand All @@ -303,12 +305,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 5 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 5 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 5, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm \
Expand All @@ -323,12 +324,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 7 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 7 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 7, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#endif /* !MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H */
26 changes: 13 additions & 13 deletions dev/x86_64/src/arith_native_x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void mld_ntt_avx2_asm(int32_t *r, const int32_t *qdata)
* in proofs/hol_light/x86_64/proofs/ntt_avx2_asm.ml */
__contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
/* check-magic: 8380417 == MLDSA_Q */
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
requires(qdata == mld_qdata)
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
Expand Down Expand Up @@ -136,13 +137,15 @@ void mld_pointwise_avx2_asm(int32_t *a, const int32_t *b, const int32_t *qdata)
__contract__(
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * MLDSA_N))
/* check-magic: off */
requires(array_abs_bound(a, 0, MLDSA_N, 75423753))
requires(array_abs_bound(b, 0, MLDSA_N, 75423753))
/* Input bound MLD_NTT_BOUND = 9 * MLD_FQMUL_BOUND, the post-condition of
* the forward NTT. Hardcoded here to keep this header free of poly.h.
* Must be kept in sync with the HOL-Light precondition. */
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(array_abs_bound(a, 0, MLDSA_N, 94279698))
requires(array_abs_bound(b, 0, MLDSA_N, 94279698))
requires(qdata == mld_qdata)
assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(a, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_pointwise_acc_l4_avx2_asm MLD_NAMESPACE(pointwise_acc_l4_avx2_asm)
Expand All @@ -156,13 +159,12 @@ __contract__(
requires(memory_no_alias(c, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 4 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 4 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 4, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
requires(qdata == mld_qdata)
assigns(memory_slice(c, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(c, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_pointwise_acc_l5_avx2_asm MLD_NAMESPACE(pointwise_acc_l5_avx2_asm)
Expand All @@ -176,13 +178,12 @@ __contract__(
requires(memory_no_alias(c, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 5 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 5 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 5, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
requires(qdata == mld_qdata)
assigns(memory_slice(c, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(c, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_pointwise_acc_l7_avx2_asm MLD_NAMESPACE(pointwise_acc_l7_avx2_asm)
Expand All @@ -196,13 +197,12 @@ __contract__(
requires(memory_no_alias(c, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 7 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 7 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 7, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
requires(qdata == mld_qdata)
assigns(memory_slice(c, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(c, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#endif /* !MLD_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H */
2 changes: 2 additions & 0 deletions mldsa/mldsa_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@
#undef mld_debug_check_assert
#undef mld_debug_check_bounds
/* mldsa/src/poly.h */
#undef MLD_FQMUL_BOUND
#undef MLD_INTT_BOUND
#undef MLD_NTT_BOUND
#undef MLD_POLY_H
Expand Down Expand Up @@ -652,6 +653,7 @@
#endif /* MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 */
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH)
/* mldsa/src/native/api.h */
#undef MLD_FQMUL_BOUND
#undef MLD_INTT_BOUND
#undef MLD_NATIVE_API_H
#undef MLD_NATIVE_FUNC_FALLBACK
Expand Down
2 changes: 2 additions & 0 deletions mldsa/mldsa_native_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@
#undef mld_debug_check_assert
#undef mld_debug_check_bounds
/* mldsa/src/poly.h */
#undef MLD_FQMUL_BOUND
#undef MLD_INTT_BOUND
#undef MLD_NTT_BOUND
#undef MLD_POLY_H
Expand Down Expand Up @@ -659,6 +660,7 @@
#endif /* MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 */
#if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH)
/* mldsa/src/native/api.h */
#undef MLD_FQMUL_BOUND
#undef MLD_INTT_BOUND
#undef MLD_NATIVE_API_H
#undef MLD_NATIVE_FUNC_FALLBACK
Expand Down
26 changes: 13 additions & 13 deletions mldsa/src/native/aarch64/src/arith_native_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void mld_ntt_aarch64_asm(int32_t *r, const int32_t *zetas_l123456,
* in proofs/hol_light/aarch64/proofs/ntt_aarch64_asm.ml */
__contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
/* check-magic: 8380417 == MLDSA_Q */
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
requires(zetas_l123456 == mld_aarch64_ntt_zetas_layer123456)
requires(zetas_l78 == mld_aarch64_ntt_zetas_layer78)
Expand Down Expand Up @@ -261,12 +262,14 @@ void mld_poly_pointwise_montgomery_aarch64_asm(int32_t *a, const int32_t *b)
__contract__(
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * MLDSA_N))
/* check-magic: off */
requires(array_abs_bound(a, 0, MLDSA_N, 75423753))
requires(array_abs_bound(b, 0, MLDSA_N, 75423753))
/* Input bound MLD_NTT_BOUND = 9 * MLD_FQMUL_BOUND, the post-condition of
* the forward NTT. Hardcoded here to keep this header free of poly.h.
* Must be kept in sync with the HOL-Light precondition. */
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(array_abs_bound(a, 0, MLDSA_N, 94279698))
requires(array_abs_bound(b, 0, MLDSA_N, 94279698))
assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(a, 0, MLDSA_N, 8380417))
/* check-magic: on */
);
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API || \
MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
Expand All @@ -283,12 +286,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 4 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 4 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 4, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm \
Expand All @@ -303,12 +305,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 5 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 5 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 5, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#define mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm \
Expand All @@ -323,12 +324,11 @@ __contract__(
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
requires(memory_no_alias(a, sizeof(int32_t) * 7 * MLDSA_N))
requires(memory_no_alias(b, sizeof(int32_t) * 7 * MLDSA_N))
/* check-magic: off */
requires(forall(l0, 0, 7, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
/* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
/* check-magic: on */
);

#endif /* !MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H */
8 changes: 7 additions & 1 deletion mldsa/src/native/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@
*/
#define MLD_NATIVE_FUNC_FALLBACK (-1)

/* Absolute exclusive upper bound for the output of fqmul.
*
* NOTE: This is the same bound as in poly.h and has to be kept
* in sync. */
#define MLD_FQMUL_BOUND ((5 * MLDSA_Q + 3) / 4)

/* Bound on absolute value of coefficients after NTT.
*
* NOTE: This is the same bound as in poly.h and has to be kept
* in sync. */
#define MLD_NTT_BOUND (9 * MLDSA_Q)
#define MLD_NTT_BOUND (9 * MLD_FQMUL_BOUND)

/* Absolute exclusive upper bound for the output of the inverse NTT
*
Expand Down
Loading
Loading