pq_crypto 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/SECURITY.md +7 -0
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/README.md +23 -10
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +23 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +114 -58
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +498 -461
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +145 -85
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +456 -422
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +47 -25
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +26 -14
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +56 -81
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +17 -24
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +33 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +67 -87
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +19 -14
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +13 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +84 -10
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +10 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +6 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +22 -15
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +376 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +204 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +259 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1077 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +987 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +16 -10
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +2 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +60 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +48 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +18 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +658 -582
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +5 -100
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +334 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +355 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +8 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/{xkcp.h → keccak_f1600_x4_avx2.h} +11 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +44 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +454 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +37 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +213 -196
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +248 -64
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt_aarch64_asm.S +753 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +129 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +145 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +177 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt_aarch64_asm.S +653 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery_aarch64_asm.S +84 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_aarch64_asm.S +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_aarch64_asm.S +55 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_aarch64_asm.S +86 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_aarch64_asm.S +86 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_aarch64_asm.S +103 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_aarch64_asm.S +111 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_aarch64_asm.S +75 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_aarch64_asm.S +72 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +23 -11
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_aarch64_asm.S +189 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_aarch64_asm.S +137 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_aarch64_asm.S +130 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +520 -516
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +34 -33
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +202 -242
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +25 -17
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +112 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +1 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt_avx2_asm.S +2311 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt_avx2_asm.S +2383 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack_avx2_asm.S +238 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4_avx2_asm.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5_avx2_asm.S +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7_avx2_asm.S +187 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_avx2_asm.S +130 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2_asm.S +190 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +9 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +10 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +8 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +8 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +130 -129
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +109 -180
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +169 -150
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +56 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +149 -164
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +52 -57
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +132 -167
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +57 -424
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +167 -474
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +308 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +653 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +22 -29
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +37 -43
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +511 -367
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +456 -417
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +3 -3
- metadata +41 -35
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +0 -376
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +0 -204
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +0 -259
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +0 -1077
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +0 -987
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +0 -488
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +0 -16
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +0 -753
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +0 -129
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +0 -145
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +0 -177
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +0 -653
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +0 -79
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +0 -53
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +0 -55
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +0 -85
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +0 -85
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +0 -102
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +0 -110
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +0 -72
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +0 -69
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +0 -189
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +0 -135
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +0 -128
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +0 -2311
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +0 -2383
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +0 -239
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +0 -131
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +0 -139
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +0 -155
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +0 -187
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +0 -61
|
@@ -40,7 +40,7 @@ static MLD_INLINE void mld_poly_permute_bitrev_to_custom(int32_t data[MLDSA_N])
|
|
|
40
40
|
{
|
|
41
41
|
if (mld_sys_check_capability(MLD_SYS_CAP_AVX2))
|
|
42
42
|
{
|
|
43
|
-
|
|
43
|
+
mld_nttunpack_avx2_asm(data);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ static MLD_INLINE int mld_ntt_native(int32_t data[MLDSA_N])
|
|
|
52
52
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
mld_ntt_avx2_asm(data, mld_qdata);
|
|
56
56
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -63,7 +63,7 @@ static MLD_INLINE int mld_intt_native(int32_t data[MLDSA_N])
|
|
|
63
63
|
{
|
|
64
64
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
mld_invntt_avx2_asm(data, mld_qdata);
|
|
67
67
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -83,6 +83,7 @@ static MLD_INLINE int mld_rej_uniform_native(int32_t *r, unsigned len,
|
|
|
83
83
|
return (int)mld_rej_uniform_avx2(r, buf);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
86
87
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_ETA == 2
|
|
87
88
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
88
89
|
static MLD_INLINE int mld_rej_uniform_eta2_native(int32_t *r, unsigned len,
|
|
@@ -140,7 +141,9 @@ static MLD_INLINE int mld_rej_uniform_eta4_native(int32_t *r, unsigned len,
|
|
|
140
141
|
return (int)outlen;
|
|
141
142
|
}
|
|
142
143
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 4 */
|
|
144
|
+
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
143
145
|
|
|
146
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
144
147
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
145
148
|
(MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
|
|
146
149
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
@@ -169,7 +172,7 @@ static MLD_INLINE int mld_poly_decompose_88_native(int32_t *a1, int32_t *a0)
|
|
|
169
172
|
}
|
|
170
173
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44 \
|
|
171
174
|
*/
|
|
172
|
-
|
|
175
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API */
|
|
173
176
|
|
|
174
177
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
175
178
|
static MLD_INLINE int mld_poly_caddq_native(int32_t a[MLDSA_N])
|
|
@@ -178,21 +181,21 @@ static MLD_INLINE int mld_poly_caddq_native(int32_t a[MLDSA_N])
|
|
|
178
181
|
{
|
|
179
182
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
180
183
|
}
|
|
181
|
-
|
|
184
|
+
mld_poly_caddq_avx2_asm(a);
|
|
182
185
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
183
186
|
}
|
|
184
187
|
|
|
188
|
+
#if !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
185
189
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
186
190
|
(MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
|
|
187
191
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
188
|
-
static MLD_INLINE int mld_poly_use_hint_32_native(int32_t *
|
|
189
|
-
const int32_t *h)
|
|
192
|
+
static MLD_INLINE int mld_poly_use_hint_32_native(int32_t *a, const int32_t *h)
|
|
190
193
|
{
|
|
191
194
|
if (!mld_sys_check_capability(MLD_SYS_CAP_AVX2))
|
|
192
195
|
{
|
|
193
196
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
194
197
|
}
|
|
195
|
-
mld_poly_use_hint_32_avx2(
|
|
198
|
+
mld_poly_use_hint_32_avx2(a, h);
|
|
196
199
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
197
200
|
}
|
|
198
201
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
|
|
@@ -200,19 +203,18 @@ static MLD_INLINE int mld_poly_use_hint_32_native(int32_t *b, const int32_t *a,
|
|
|
200
203
|
|
|
201
204
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
|
|
202
205
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
203
|
-
static MLD_INLINE int mld_poly_use_hint_88_native(int32_t *
|
|
204
|
-
const int32_t *h)
|
|
206
|
+
static MLD_INLINE int mld_poly_use_hint_88_native(int32_t *a, const int32_t *h)
|
|
205
207
|
{
|
|
206
208
|
if (!mld_sys_check_capability(MLD_SYS_CAP_AVX2))
|
|
207
209
|
{
|
|
208
210
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
209
211
|
}
|
|
210
|
-
mld_poly_use_hint_88_avx2(
|
|
212
|
+
mld_poly_use_hint_88_avx2(a, h);
|
|
211
213
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
212
214
|
}
|
|
213
215
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44 \
|
|
214
216
|
*/
|
|
215
|
-
|
|
217
|
+
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
216
218
|
|
|
217
219
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
218
220
|
static MLD_INLINE int mld_poly_chknorm_native(const int32_t *a, int32_t B)
|
|
@@ -224,6 +226,7 @@ static MLD_INLINE int mld_poly_chknorm_native(const int32_t *a, int32_t B)
|
|
|
224
226
|
return mld_poly_chknorm_avx2(a, B);
|
|
225
227
|
}
|
|
226
228
|
|
|
229
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
227
230
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
|
|
228
231
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
229
232
|
static MLD_INLINE int mld_polyz_unpack_17_native(int32_t *r, const uint8_t *a)
|
|
@@ -252,18 +255,23 @@ static MLD_INLINE int mld_polyz_unpack_19_native(int32_t *r, const uint8_t *a)
|
|
|
252
255
|
}
|
|
253
256
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
|
|
254
257
|
|| MLD_CONFIG_PARAMETER_SET == 87 */
|
|
258
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API */
|
|
255
259
|
|
|
260
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API) || \
|
|
261
|
+
defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)
|
|
256
262
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
257
263
|
static MLD_INLINE int mld_poly_pointwise_montgomery_native(
|
|
258
|
-
int32_t
|
|
264
|
+
int32_t a[MLDSA_N], const int32_t b[MLDSA_N])
|
|
259
265
|
{
|
|
260
266
|
if (!mld_sys_check_capability(MLD_SYS_CAP_AVX2))
|
|
261
267
|
{
|
|
262
268
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
263
269
|
}
|
|
264
|
-
|
|
270
|
+
mld_pointwise_avx2_asm(a, b, mld_qdata);
|
|
265
271
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
266
272
|
}
|
|
273
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API || \
|
|
274
|
+
MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
|
|
267
275
|
|
|
268
276
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_L == 4
|
|
269
277
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
@@ -275,7 +283,7 @@ static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l4_native(
|
|
|
275
283
|
{
|
|
276
284
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
277
285
|
}
|
|
278
|
-
|
|
286
|
+
mld_pointwise_acc_l4_avx2_asm(w, u, v, mld_qdata);
|
|
279
287
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
280
288
|
}
|
|
281
289
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 4 */
|
|
@@ -290,7 +298,7 @@ static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l5_native(
|
|
|
290
298
|
{
|
|
291
299
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
292
300
|
}
|
|
293
|
-
|
|
301
|
+
mld_pointwise_acc_l5_avx2_asm(w, u, v, mld_qdata);
|
|
294
302
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
295
303
|
}
|
|
296
304
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 5 */
|
|
@@ -305,7 +313,7 @@ static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l7_native(
|
|
|
305
313
|
{
|
|
306
314
|
return MLD_NATIVE_FUNC_FALLBACK;
|
|
307
315
|
}
|
|
308
|
-
|
|
316
|
+
mld_pointwise_acc_l7_avx2_asm(w, u, v, mld_qdata);
|
|
309
317
|
return MLD_NATIVE_FUNC_SUCCESS;
|
|
310
318
|
}
|
|
311
319
|
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_L == 7 */
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
#define MLD_AVX2_REJ_UNIFORM_ETA4_BUFLEN (2 * 136)
|
|
30
30
|
|
|
31
31
|
#define mld_rej_uniform_table MLD_NAMESPACE(mld_rej_uniform_table)
|
|
32
|
-
|
|
32
|
+
MLD_INTERNAL_DATA_DECLARATION const uint8_t mld_rej_uniform_table[256][8];
|
|
33
33
|
|
|
34
|
-
#define
|
|
35
|
-
void
|
|
34
|
+
#define mld_ntt_avx2_asm MLD_NAMESPACE(ntt_avx2_asm)
|
|
35
|
+
void mld_ntt_avx2_asm(int32_t *r, const int32_t *qdata)
|
|
36
36
|
/* This must be kept in sync with the HOL-Light specification
|
|
37
|
-
* in proofs/hol_light/x86_64/proofs/
|
|
37
|
+
* in proofs/hol_light/x86_64/proofs/ntt_avx2_asm.ml */
|
|
38
38
|
__contract__(
|
|
39
39
|
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
|
|
40
40
|
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
|
|
@@ -45,10 +45,10 @@ __contract__(
|
|
|
45
45
|
/* check-magic: on */
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
-
#define
|
|
49
|
-
void
|
|
48
|
+
#define mld_invntt_avx2_asm MLD_NAMESPACE(invntt_avx2_asm)
|
|
49
|
+
void mld_invntt_avx2_asm(int32_t *r, const int32_t *qdata)
|
|
50
50
|
/* This must be kept in sync with the HOL-Light specification
|
|
51
|
-
* in proofs/hol_light/x86_64/proofs/
|
|
51
|
+
* in proofs/hol_light/x86_64/proofs/intt_avx2_asm.ml */
|
|
52
52
|
__contract__(
|
|
53
53
|
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
|
|
54
54
|
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
|
|
@@ -59,14 +59,26 @@ __contract__(
|
|
|
59
59
|
/* check-magic: on */
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
#define
|
|
63
|
-
void
|
|
62
|
+
#define mld_nttunpack_avx2_asm MLD_NAMESPACE(nttunpack_avx2_asm)
|
|
63
|
+
void mld_nttunpack_avx2_asm(int32_t *r)
|
|
64
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
65
|
+
* in proofs/hol_light/x86_64/proofs/nttunpack_avx2_asm.ml */
|
|
66
|
+
__contract__(
|
|
67
|
+
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
|
|
68
|
+
requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
|
|
69
|
+
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
|
|
70
|
+
/* Output is a permutation of input: every output coefficient
|
|
71
|
+
* is some input coefficient */
|
|
72
|
+
ensures(forall(i, 0, MLDSA_N, exists(j, 0, MLDSA_N,
|
|
73
|
+
r[i] == old(*(int32_t (*)[MLDSA_N])r)[j])))
|
|
74
|
+
);
|
|
64
75
|
|
|
65
76
|
#define mld_rej_uniform_avx2 MLD_NAMESPACE(mld_rej_uniform_avx2)
|
|
66
77
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
67
78
|
unsigned mld_rej_uniform_avx2(int32_t *r,
|
|
68
79
|
const uint8_t buf[MLD_AVX2_REJ_UNIFORM_BUFLEN]);
|
|
69
80
|
|
|
81
|
+
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
70
82
|
#define mld_rej_uniform_eta2_avx2 MLD_NAMESPACE(mld_rej_uniform_eta2_avx2)
|
|
71
83
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
72
84
|
unsigned mld_rej_uniform_eta2_avx2(
|
|
@@ -76,49 +88,121 @@ unsigned mld_rej_uniform_eta2_avx2(
|
|
|
76
88
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
77
89
|
unsigned mld_rej_uniform_eta4_avx2(
|
|
78
90
|
int32_t *r, const uint8_t buf[MLD_AVX2_REJ_UNIFORM_ETA4_BUFLEN]);
|
|
91
|
+
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
79
92
|
|
|
93
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
80
94
|
#define mld_poly_decompose_32_avx2 MLD_NAMESPACE(mld_poly_decompose_32_avx2)
|
|
81
95
|
void mld_poly_decompose_32_avx2(int32_t *a1, int32_t *a0);
|
|
82
96
|
|
|
83
97
|
#define mld_poly_decompose_88_avx2 MLD_NAMESPACE(mld_poly_decompose_88_avx2)
|
|
84
98
|
void mld_poly_decompose_88_avx2(int32_t *a1, int32_t *a0);
|
|
99
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API */
|
|
85
100
|
|
|
86
|
-
#define
|
|
87
|
-
void
|
|
101
|
+
#define mld_poly_caddq_avx2_asm MLD_NAMESPACE(poly_caddq_avx2_asm)
|
|
102
|
+
void mld_poly_caddq_avx2_asm(int32_t *r)
|
|
103
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
104
|
+
* in proofs/hol_light/x86_64/proofs/poly_caddq_avx2_asm.ml */
|
|
105
|
+
__contract__(
|
|
106
|
+
requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
|
|
107
|
+
requires(array_abs_bound(r, 0, MLDSA_N, MLDSA_Q))
|
|
108
|
+
assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
|
|
109
|
+
ensures(array_bound(r, 0, MLDSA_N, 0, MLDSA_Q))
|
|
110
|
+
);
|
|
88
111
|
|
|
112
|
+
#if !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
89
113
|
#define mld_poly_use_hint_32_avx2 MLD_NAMESPACE(mld_poly_use_hint_32_avx2)
|
|
90
|
-
void mld_poly_use_hint_32_avx2(int32_t *
|
|
114
|
+
void mld_poly_use_hint_32_avx2(int32_t *a, const int32_t *h);
|
|
91
115
|
|
|
92
116
|
#define mld_poly_use_hint_88_avx2 MLD_NAMESPACE(mld_poly_use_hint_88_avx2)
|
|
93
|
-
void mld_poly_use_hint_88_avx2(int32_t *
|
|
117
|
+
void mld_poly_use_hint_88_avx2(int32_t *a, const int32_t *h);
|
|
118
|
+
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
94
119
|
|
|
95
120
|
#define mld_poly_chknorm_avx2 MLD_NAMESPACE(mld_poly_chknorm_avx2)
|
|
96
121
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
97
122
|
int mld_poly_chknorm_avx2(const int32_t *a, int32_t B);
|
|
98
123
|
|
|
124
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
99
125
|
#define mld_polyz_unpack_17_avx2 MLD_NAMESPACE(mld_polyz_unpack_17_avx2)
|
|
100
126
|
void mld_polyz_unpack_17_avx2(int32_t *r, const uint8_t *a);
|
|
101
127
|
|
|
102
128
|
#define mld_polyz_unpack_19_avx2 MLD_NAMESPACE(mld_polyz_unpack_19_avx2)
|
|
103
129
|
void mld_polyz_unpack_19_avx2(int32_t *r, const uint8_t *a);
|
|
130
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API */
|
|
104
131
|
|
|
105
|
-
#define
|
|
106
|
-
void
|
|
107
|
-
|
|
132
|
+
#define mld_pointwise_avx2_asm MLD_NAMESPACE(pointwise_avx2_asm)
|
|
133
|
+
void mld_pointwise_avx2_asm(int32_t *a, const int32_t *b, const int32_t *qdata)
|
|
134
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
135
|
+
* in proofs/hol_light/x86_64/proofs/pointwise_avx2_asm.ml */
|
|
136
|
+
__contract__(
|
|
137
|
+
requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
|
|
138
|
+
requires(memory_no_alias(b, sizeof(int32_t) * MLDSA_N))
|
|
139
|
+
/* check-magic: off */
|
|
140
|
+
requires(array_abs_bound(a, 0, MLDSA_N, 75423753))
|
|
141
|
+
requires(array_abs_bound(b, 0, MLDSA_N, 75423753))
|
|
142
|
+
requires(qdata == mld_qdata)
|
|
143
|
+
assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
|
|
144
|
+
ensures(array_abs_bound(a, 0, MLDSA_N, 8380417))
|
|
145
|
+
/* check-magic: on */
|
|
146
|
+
);
|
|
108
147
|
|
|
109
|
-
#define
|
|
110
|
-
void
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
#define mld_pointwise_acc_l4_avx2_asm MLD_NAMESPACE(pointwise_acc_l4_avx2_asm)
|
|
149
|
+
void mld_pointwise_acc_l4_avx2_asm(int32_t c[MLDSA_N],
|
|
150
|
+
const int32_t a[4][MLDSA_N],
|
|
151
|
+
const int32_t b[4][MLDSA_N],
|
|
152
|
+
const int32_t *qdata)
|
|
153
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
154
|
+
* in proofs/hol_light/x86_64/proofs/pointwise_acc_l4_avx2_asm.ml */
|
|
155
|
+
__contract__(
|
|
156
|
+
requires(memory_no_alias(c, sizeof(int32_t) * MLDSA_N))
|
|
157
|
+
requires(memory_no_alias(a, sizeof(int32_t) * 4 * MLDSA_N))
|
|
158
|
+
requires(memory_no_alias(b, sizeof(int32_t) * 4 * MLDSA_N))
|
|
159
|
+
/* check-magic: off */
|
|
160
|
+
requires(forall(l0, 0, 4, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
|
|
161
|
+
requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
|
|
162
|
+
requires(qdata == mld_qdata)
|
|
163
|
+
assigns(memory_slice(c, sizeof(int32_t) * MLDSA_N))
|
|
164
|
+
ensures(array_abs_bound(c, 0, MLDSA_N, 8380417))
|
|
165
|
+
/* check-magic: on */
|
|
166
|
+
);
|
|
113
167
|
|
|
114
|
-
#define
|
|
115
|
-
void
|
|
116
|
-
|
|
117
|
-
|
|
168
|
+
#define mld_pointwise_acc_l5_avx2_asm MLD_NAMESPACE(pointwise_acc_l5_avx2_asm)
|
|
169
|
+
void mld_pointwise_acc_l5_avx2_asm(int32_t c[MLDSA_N],
|
|
170
|
+
const int32_t a[5][MLDSA_N],
|
|
171
|
+
const int32_t b[5][MLDSA_N],
|
|
172
|
+
const int32_t *qdata)
|
|
173
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
174
|
+
* in proofs/hol_light/x86_64/proofs/pointwise_acc_l5_avx2_asm.ml */
|
|
175
|
+
__contract__(
|
|
176
|
+
requires(memory_no_alias(c, sizeof(int32_t) * MLDSA_N))
|
|
177
|
+
requires(memory_no_alias(a, sizeof(int32_t) * 5 * MLDSA_N))
|
|
178
|
+
requires(memory_no_alias(b, sizeof(int32_t) * 5 * MLDSA_N))
|
|
179
|
+
/* check-magic: off */
|
|
180
|
+
requires(forall(l0, 0, 5, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
|
|
181
|
+
requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
|
|
182
|
+
requires(qdata == mld_qdata)
|
|
183
|
+
assigns(memory_slice(c, sizeof(int32_t) * MLDSA_N))
|
|
184
|
+
ensures(array_abs_bound(c, 0, MLDSA_N, 8380417))
|
|
185
|
+
/* check-magic: on */
|
|
186
|
+
);
|
|
118
187
|
|
|
119
|
-
#define
|
|
120
|
-
void
|
|
121
|
-
|
|
122
|
-
|
|
188
|
+
#define mld_pointwise_acc_l7_avx2_asm MLD_NAMESPACE(pointwise_acc_l7_avx2_asm)
|
|
189
|
+
void mld_pointwise_acc_l7_avx2_asm(int32_t c[MLDSA_N],
|
|
190
|
+
const int32_t a[7][MLDSA_N],
|
|
191
|
+
const int32_t b[7][MLDSA_N],
|
|
192
|
+
const int32_t *qdata)
|
|
193
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
194
|
+
* in proofs/hol_light/x86_64/proofs/pointwise_acc_l7_avx2_asm.ml */
|
|
195
|
+
__contract__(
|
|
196
|
+
requires(memory_no_alias(c, sizeof(int32_t) * MLDSA_N))
|
|
197
|
+
requires(memory_no_alias(a, sizeof(int32_t) * 7 * MLDSA_N))
|
|
198
|
+
requires(memory_no_alias(b, sizeof(int32_t) * 7 * MLDSA_N))
|
|
199
|
+
/* check-magic: off */
|
|
200
|
+
requires(forall(l0, 0, 7, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
|
|
201
|
+
requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
|
|
202
|
+
requires(qdata == mld_qdata)
|
|
203
|
+
assigns(memory_slice(c, sizeof(int32_t) * MLDSA_N))
|
|
204
|
+
ensures(array_abs_bound(c, 0, MLDSA_N, 8380417))
|
|
205
|
+
/* check-magic: on */
|
|
206
|
+
);
|
|
123
207
|
|
|
124
208
|
#endif /* !MLD_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H */
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* Table of zeta values used in the AVX2 forward and inverse NTT
|
|
21
21
|
* See autogen for details.
|
|
22
22
|
*/
|
|
23
|
-
MLD_ALIGN const int32_t mld_qdata[624] = {
|
|
23
|
+
MLD_ALIGN MLD_INTERNAL_DATA_DEFINITION const int32_t mld_qdata[624] = {
|
|
24
24
|
8380417, 8380417, 8380417, 8380417, 8380417,
|
|
25
25
|
8380417, 8380417, 8380417, 58728449, 58728449,
|
|
26
26
|
58728449, 58728449, 58728449, 58728449, 58728449,
|