pq_crypto 0.6.1 → 0.6.3
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 +10 -0
- data/SECURITY.md +7 -0
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- 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/ext/pqcrypto/vendor/mlkem-native/README.md +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +22 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -36
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +135 -146
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +116 -72
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +351 -415
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +43 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +16 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +57 -31
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +260 -349
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +17 -24
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +35 -37
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +43 -57
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +14 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +5 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +42 -6
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +31 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x1_scalar_asm.S → keccak_f1600_x1_scalar_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x1_v84a_asm.S → keccak_f1600_x1_v84a_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x2_v84a_asm.S → keccak_f1600_x2_v84a_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x4_v8a_scalar_hybrid_asm.S → keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S → keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +10 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +55 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +58 -14
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +57 -16
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +10 -7
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/{keccak_f1600_x4_avx2.S → keccak_f1600_x4_avx2_asm.S} +13 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +12 -11
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +167 -136
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +75 -68
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +135 -157
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +15 -13
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +143 -135
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +52 -46
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt.S → intt_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt.S → ntt_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_asm.S → poly_mulcache_compute_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_asm.S → poly_reduce_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_asm.S → poly_tobytes_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_asm.S → poly_tomont_aarch64_asm.S} +10 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k2.S → polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k3.S → polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k4.S → polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +10 -10
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_asm.S → rej_uniform_aarch64_asm.S} +12 -12
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +514 -513
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +254 -253
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +6 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +6 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +77 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +24 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +299 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.h +34 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/intt_ppc_asm.S +3222 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/ntt_ppc_asm.S +1651 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/poly_tomont_ppc_asm.S +294 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/reduce_ppc_asm.S +710 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +5 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +18 -16
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +19 -24
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +53 -65
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +20 -20
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +106 -88
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +45 -35
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt.S → intt_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt.S → ntt_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes.S → nttfrombytes_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes.S → ntttobytes_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack.S → nttunpack_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10.S → poly_compress_d10_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11.S → poly_compress_d11_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4.S → poly_compress_d4_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5.S → poly_compress_d5_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10.S → poly_decompress_d10_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11.S → poly_decompress_d11_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4.S → poly_decompress_d4_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5.S → poly_decompress_d5_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{mulcache_compute.S → poly_mulcache_compute_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k2.S → polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k3.S → polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k4.S → polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce.S → reduce_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_asm.S → rej_uniform_avx2_asm.S} +9 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +514 -513
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont.S → tomont_avx2_asm.S} +8 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +61 -57
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +89 -116
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +31 -32
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +226 -301
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +21 -29
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +68 -63
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +37 -48
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +44 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +141 -159
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +86 -71
- 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
|
@@ -8,54 +8,38 @@
|
|
|
8
8
|
#include "packing.h"
|
|
9
9
|
#include "poly.h"
|
|
10
10
|
#include "polyvec.h"
|
|
11
|
+
#include "rounding.h"
|
|
11
12
|
|
|
12
13
|
/* Parameter set namespacing
|
|
13
14
|
* This is to facilitate building multiple instances
|
|
14
15
|
* of mldsa-native (e.g. with varying parameter sets)
|
|
15
16
|
* within a single compilation unit. */
|
|
16
|
-
#define mld_unpack_hints MLD_ADD_PARAM_SET(mld_unpack_hints)
|
|
17
17
|
/* End of parameter set namespacing */
|
|
18
18
|
|
|
19
|
+
#if !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
19
20
|
MLD_INTERNAL_API
|
|
20
|
-
void
|
|
21
|
-
|
|
21
|
+
void mld_unpack_pk_t1(mld_poly *t1,
|
|
22
|
+
const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
|
|
23
|
+
unsigned int i)
|
|
22
24
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
mld_memcpy(pk, rho, MLDSA_SEEDBYTES);
|
|
26
|
-
for (i = 0; i < MLDSA_K; ++i)
|
|
27
|
-
__loop__(
|
|
28
|
-
assigns(i, memory_slice(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
|
|
29
|
-
invariant(i <= MLDSA_K)
|
|
30
|
-
decreases(MLDSA_K - i)
|
|
31
|
-
)
|
|
32
|
-
{
|
|
33
|
-
mld_polyt1_pack(pk + MLDSA_SEEDBYTES + i * MLDSA_POLYT1_PACKEDBYTES,
|
|
34
|
-
&t1->vec[i]);
|
|
35
|
-
}
|
|
25
|
+
mld_polyt1_unpack(t1, pk + MLDSA_SEEDBYTES + i * MLDSA_POLYT1_PACKEDBYTES);
|
|
36
26
|
}
|
|
27
|
+
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
37
28
|
|
|
29
|
+
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
38
30
|
MLD_INTERNAL_API
|
|
39
|
-
void
|
|
40
|
-
|
|
31
|
+
void mld_pack_sk_s1(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
32
|
+
const mld_polyvecl *s1)
|
|
41
33
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
mld_memcpy(rho, pk, MLDSA_SEEDBYTES);
|
|
45
|
-
pk += MLDSA_SEEDBYTES;
|
|
46
|
-
|
|
47
|
-
for (i = 0; i < MLDSA_K; ++i)
|
|
48
|
-
{
|
|
49
|
-
mld_polyt1_unpack(&t1->vec[i], pk + i * MLDSA_POLYT1_PACKEDBYTES);
|
|
50
|
-
}
|
|
34
|
+
mld_polyvecl_pack_eta(sk + 2 * MLDSA_SEEDBYTES + MLDSA_TRBYTES, s1);
|
|
51
35
|
}
|
|
52
36
|
|
|
53
37
|
MLD_INTERNAL_API
|
|
54
|
-
void
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
38
|
+
void mld_pack_sk_rho_key_tr_s2(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
39
|
+
const uint8_t rho[MLDSA_SEEDBYTES],
|
|
40
|
+
const uint8_t tr[MLDSA_TRBYTES],
|
|
41
|
+
const uint8_t key[MLDSA_SEEDBYTES],
|
|
42
|
+
const mld_polyveck *s2)
|
|
59
43
|
{
|
|
60
44
|
mld_memcpy(sk, rho, MLDSA_SEEDBYTES);
|
|
61
45
|
sk += MLDSA_SEEDBYTES;
|
|
@@ -66,19 +50,19 @@ void mld_pack_sk(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
|
66
50
|
mld_memcpy(sk, tr, MLDSA_TRBYTES);
|
|
67
51
|
sk += MLDSA_TRBYTES;
|
|
68
52
|
|
|
69
|
-
|
|
53
|
+
/* s1 already packed via mld_pack_sk_s1 */
|
|
70
54
|
sk += MLDSA_L * MLDSA_POLYETA_PACKEDBYTES;
|
|
71
55
|
|
|
72
56
|
mld_polyveck_pack_eta(sk, s2);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
mld_polyveck_pack_t0(sk, t0);
|
|
57
|
+
/* t0 already packed via mld_compute_pack_t0_t1 */
|
|
76
58
|
}
|
|
59
|
+
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
77
60
|
|
|
61
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
78
62
|
MLD_INTERNAL_API
|
|
79
63
|
void mld_unpack_sk(uint8_t rho[MLDSA_SEEDBYTES], uint8_t tr[MLDSA_TRBYTES],
|
|
80
|
-
uint8_t key[MLDSA_SEEDBYTES],
|
|
81
|
-
|
|
64
|
+
uint8_t key[MLDSA_SEEDBYTES], mld_sk_t0hat *t0,
|
|
65
|
+
mld_sk_s1hat *s1, mld_sk_s2hat *s2,
|
|
82
66
|
const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES])
|
|
83
67
|
{
|
|
84
68
|
mld_memcpy(rho, sk, MLDSA_SEEDBYTES);
|
|
@@ -90,85 +74,83 @@ void mld_unpack_sk(uint8_t rho[MLDSA_SEEDBYTES], uint8_t tr[MLDSA_TRBYTES],
|
|
|
90
74
|
mld_memcpy(tr, sk, MLDSA_TRBYTES);
|
|
91
75
|
sk += MLDSA_TRBYTES;
|
|
92
76
|
|
|
93
|
-
|
|
77
|
+
mld_unpack_sk_s1hat(s1, sk);
|
|
94
78
|
sk += MLDSA_L * MLDSA_POLYETA_PACKEDBYTES;
|
|
95
79
|
|
|
96
|
-
|
|
80
|
+
mld_unpack_sk_s2hat(s2, sk);
|
|
97
81
|
sk += MLDSA_K * MLDSA_POLYETA_PACKEDBYTES;
|
|
98
82
|
|
|
99
|
-
|
|
83
|
+
mld_unpack_sk_t0hat(t0, sk);
|
|
100
84
|
}
|
|
101
85
|
|
|
102
86
|
MLD_INTERNAL_API
|
|
103
|
-
void
|
|
104
|
-
|
|
105
|
-
const unsigned int number_of_hints)
|
|
87
|
+
void mld_pack_sig_c(uint8_t sig[MLDSA_CRYPTO_BYTES],
|
|
88
|
+
const uint8_t c[MLDSA_CTILDEBYTES])
|
|
106
89
|
{
|
|
107
|
-
unsigned int i, j, k;
|
|
108
|
-
|
|
109
90
|
mld_memcpy(sig, c, MLDSA_CTILDEBYTES);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/* skip z component - packed via mld_pack_sig_z */
|
|
113
|
-
sig += MLDSA_L * MLDSA_POLYZ_PACKEDBYTES;
|
|
91
|
+
}
|
|
114
92
|
|
|
115
|
-
|
|
93
|
+
MLD_INTERNAL_API
|
|
94
|
+
int mld_pack_sig_h(uint8_t sig[MLDSA_CRYPTO_BYTES], const mld_polyveck *w0,
|
|
95
|
+
const mld_polyveck *w1)
|
|
96
|
+
{
|
|
97
|
+
unsigned int j, k, n;
|
|
116
98
|
|
|
117
|
-
/* The
|
|
118
|
-
* MLDSA_POLYVECH_PACKEDBYTES = MLDSA_OMEGA + MLDSA_K
|
|
99
|
+
/* The hint section of sig[] is MLDSA_POLYVECH_PACKEDBYTES long, where
|
|
100
|
+
* MLDSA_POLYVECH_PACKEDBYTES = MLDSA_OMEGA + MLDSA_K.
|
|
119
101
|
*
|
|
120
102
|
* The first OMEGA bytes record the index numbers of the coefficients
|
|
121
|
-
* that are not equal to 0
|
|
103
|
+
* that are not equal to 0.
|
|
122
104
|
*
|
|
123
105
|
* The final K bytes record a running tally of the number of hints
|
|
124
|
-
* coming from each of the K polynomials
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*/
|
|
130
|
-
mld_memset(sig, 0, MLDSA_POLYVECH_PACKEDBYTES);
|
|
106
|
+
* coming from each of the K polynomials. */
|
|
107
|
+
uint8_t *sig_h = sig + MLDSA_CTILDEBYTES + MLDSA_L * MLDSA_POLYZ_PACKEDBYTES;
|
|
108
|
+
|
|
109
|
+
mld_memset(sig_h, 0, MLDSA_POLYVECH_PACKEDBYTES);
|
|
110
|
+
n = 0;
|
|
131
111
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
/* For each coefficient of each polynomial, compute its hint bit and, if
|
|
113
|
+
* non-zero, record the index in the hint section of sig. If recording the
|
|
114
|
+
* hint would overflow the OMEGA-sized index array, abort early and return
|
|
115
|
+
* MLD_ERR_FAIL. The caller is expected to reject the signature in that case.
|
|
116
|
+
*
|
|
117
|
+
* Constant time: At this point w0/w1 are public (see comment in sign.c
|
|
118
|
+
* before the call), so a data-dependent early return is fine. */
|
|
119
|
+
for (k = 0; k < MLDSA_K; k++)
|
|
135
120
|
__loop__(
|
|
136
|
-
assigns(
|
|
137
|
-
invariant(
|
|
138
|
-
|
|
139
|
-
invariant(number_of_hints <= MLDSA_OMEGA)
|
|
140
|
-
decreases(MLDSA_K - i)
|
|
121
|
+
assigns(k, j, n, memory_slice(sig_h, MLDSA_POLYVECH_PACKEDBYTES))
|
|
122
|
+
invariant(k <= MLDSA_K && n <= MLDSA_OMEGA)
|
|
123
|
+
decreases(MLDSA_K - k)
|
|
141
124
|
)
|
|
142
125
|
{
|
|
143
|
-
|
|
144
|
-
/* if its value is not zero */
|
|
145
|
-
for (j = 0; j < MLDSA_N; ++j)
|
|
126
|
+
for (j = 0; j < MLDSA_N; j++)
|
|
146
127
|
__loop__(
|
|
147
|
-
assigns(j,
|
|
148
|
-
invariant(
|
|
149
|
-
invariant(j <= MLDSA_N)
|
|
150
|
-
invariant(k <= number_of_hints)
|
|
151
|
-
invariant(number_of_hints <= MLDSA_OMEGA)
|
|
128
|
+
assigns(j, n, memory_slice(sig_h, MLDSA_POLYVECH_PACKEDBYTES))
|
|
129
|
+
invariant(j <= MLDSA_N && n <= MLDSA_OMEGA)
|
|
152
130
|
decreases(MLDSA_N - j)
|
|
153
131
|
)
|
|
154
132
|
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/* type safety. */
|
|
159
|
-
if (h->vec[i].coeffs[j] != 0 && k < number_of_hints)
|
|
133
|
+
const unsigned int hint_bit =
|
|
134
|
+
mld_make_hint(w0->vec[k].coeffs[j], w1->vec[k].coeffs[j]);
|
|
135
|
+
if (hint_bit)
|
|
160
136
|
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
137
|
+
if (n == MLDSA_OMEGA)
|
|
138
|
+
{
|
|
139
|
+
return MLD_ERR_FAIL;
|
|
140
|
+
}
|
|
141
|
+
/* Safety: branch above ensures n < MLDSA_OMEGA so n is a valid index
|
|
142
|
+
* into the OMEGA-sized index array; j < MLDSA_N <= 256 fits in
|
|
143
|
+
* uint8_t. */
|
|
144
|
+
sig_h[n] = (uint8_t)j;
|
|
145
|
+
n++;
|
|
165
146
|
}
|
|
166
147
|
}
|
|
167
|
-
/*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
148
|
+
/* Record the running tally into the correct slot for this polynomial.
|
|
149
|
+
* Safety: k < MLDSA_K, so MLDSA_OMEGA + k is a valid index into the
|
|
150
|
+
* K-byte tally tail; n <= MLDSA_OMEGA fits in uint8_t. */
|
|
151
|
+
sig_h[MLDSA_OMEGA + k] = (uint8_t)n;
|
|
171
152
|
}
|
|
153
|
+
return 0;
|
|
172
154
|
}
|
|
173
155
|
|
|
174
156
|
MLD_INTERNAL_API
|
|
@@ -179,115 +161,62 @@ void mld_pack_sig_z(uint8_t sig[MLDSA_CRYPTO_BYTES], const mld_poly *zi,
|
|
|
179
161
|
sig += i * MLDSA_POLYZ_PACKEDBYTES;
|
|
180
162
|
mld_polyz_pack(sig, zi);
|
|
181
163
|
}
|
|
164
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API */
|
|
182
165
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*
|
|
186
|
-
|
|
187
|
-
* struct
|
|
188
|
-
*
|
|
189
|
-
* Arguments: - mld_polyveck *h: pointer to output hint vector h
|
|
190
|
-
* - const uint8_t packed_hints[MLDSA_POLYVECH_PACKEDBYTES]:
|
|
191
|
-
* raw hint bytes
|
|
192
|
-
*
|
|
193
|
-
* Returns 1 in case of malformed hints; otherwise 0.
|
|
194
|
-
**************************************************/
|
|
195
|
-
static int mld_unpack_hints(
|
|
196
|
-
mld_polyveck *h, const uint8_t packed_hints[MLDSA_POLYVECH_PACKEDBYTES])
|
|
197
|
-
__contract__(
|
|
198
|
-
requires(memory_no_alias(packed_hints, MLDSA_POLYVECH_PACKEDBYTES))
|
|
199
|
-
requires(memory_no_alias(h, sizeof(mld_polyveck)))
|
|
200
|
-
assigns(memory_slice(h, sizeof(mld_polyveck)))
|
|
201
|
-
/* All returned coefficients are either 0 or 1 */
|
|
202
|
-
ensures(forall(k1, 0, MLDSA_K,
|
|
203
|
-
array_bound(h->vec[k1].coeffs, 0, MLDSA_N, 0, 2)))
|
|
204
|
-
ensures(return_value >= 0 && return_value <= 1)
|
|
205
|
-
)
|
|
166
|
+
#if !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
167
|
+
MLD_INTERNAL_API
|
|
168
|
+
int mld_sig_unpack_hints(mld_poly *h, const uint8_t sig[MLDSA_CRYPTO_BYTES],
|
|
169
|
+
unsigned int i)
|
|
206
170
|
{
|
|
207
|
-
|
|
208
|
-
|
|
171
|
+
const uint8_t *packed_hints =
|
|
172
|
+
sig + MLDSA_CTILDEBYTES + MLDSA_L * MLDSA_POLYZ_PACKEDBYTES;
|
|
173
|
+
const unsigned int old_hint_count =
|
|
174
|
+
(i == 0) ? 0 : packed_hints[MLDSA_OMEGA + i - 1];
|
|
175
|
+
const unsigned int new_hint_count = packed_hints[MLDSA_OMEGA + i];
|
|
176
|
+
unsigned int j;
|
|
177
|
+
|
|
178
|
+
if (new_hint_count < old_hint_count || new_hint_count > MLDSA_OMEGA)
|
|
179
|
+
{
|
|
180
|
+
return MLD_ERR_FAIL;
|
|
181
|
+
}
|
|
209
182
|
|
|
210
|
-
|
|
211
|
-
/* Only those that are actually non-zero hints will */
|
|
212
|
-
/* be overwritten below. */
|
|
213
|
-
mld_memset(h, 0, sizeof(mld_polyveck));
|
|
183
|
+
mld_memset(h, 0, sizeof(mld_poly));
|
|
214
184
|
|
|
215
|
-
|
|
216
|
-
for (i = 0; i < MLDSA_K; ++i)
|
|
185
|
+
for (j = old_hint_count; j < new_hint_count; ++j)
|
|
217
186
|
__loop__(
|
|
218
|
-
invariant(
|
|
219
|
-
|
|
220
|
-
invariant(
|
|
221
|
-
decreases(
|
|
187
|
+
invariant(j >= old_hint_count && j <= new_hint_count &&
|
|
188
|
+
new_hint_count <= MLDSA_OMEGA)
|
|
189
|
+
invariant(array_bound(h->coeffs, 0, MLDSA_N, 0, 2))
|
|
190
|
+
decreases(new_hint_count - j)
|
|
222
191
|
)
|
|
223
192
|
{
|
|
224
|
-
|
|
225
|
-
const unsigned int new_hint_count = packed_hints[MLDSA_OMEGA + i];
|
|
226
|
-
|
|
227
|
-
/* new_hint_count must increase or stay the same, but also remain */
|
|
228
|
-
/* less than or equal to MLDSA_OMEGA */
|
|
229
|
-
if (new_hint_count < old_hint_count || new_hint_count > MLDSA_OMEGA)
|
|
193
|
+
if (j > old_hint_count && packed_hints[j] <= packed_hints[j - 1])
|
|
230
194
|
{
|
|
231
|
-
|
|
232
|
-
return 1;
|
|
195
|
+
return MLD_ERR_FAIL;
|
|
233
196
|
}
|
|
197
|
+
/* Safety: packed_hints[j] is uint8_t (<= 255) and MLDSA_N == 256. */
|
|
198
|
+
h->coeffs[packed_hints[j]] = 1;
|
|
199
|
+
}
|
|
234
200
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
for (j =
|
|
201
|
+
/* On the last row, also verify that the trailing index slots are zero. */
|
|
202
|
+
if (i == MLDSA_K - 1)
|
|
203
|
+
{
|
|
204
|
+
for (j = new_hint_count; j < MLDSA_OMEGA; ++j)
|
|
239
205
|
__loop__(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
invariant(forall(k1, 0, MLDSA_K, array_bound(h->vec[k1].coeffs, 0, MLDSA_N, 0, 2)))
|
|
244
|
-
decreases(new_hint_count - j)
|
|
245
|
-
)
|
|
206
|
+
invariant(j <= MLDSA_OMEGA)
|
|
207
|
+
decreases(MLDSA_OMEGA - j)
|
|
208
|
+
)
|
|
246
209
|
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
/* Coefficients must be ordered for strong unforgeability */
|
|
250
|
-
if (j > old_hint_count && this_hint_index <= packed_hints[j - 1])
|
|
210
|
+
if (packed_hints[j] != 0)
|
|
251
211
|
{
|
|
252
|
-
return
|
|
212
|
+
return MLD_ERR_FAIL;
|
|
253
213
|
}
|
|
254
|
-
h->vec[i].coeffs[this_hint_index] = 1;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
old_hint_count = new_hint_count;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/* Extra indices must be zero for strong unforgeability */
|
|
261
|
-
for (j = old_hint_count; j < MLDSA_OMEGA; ++j)
|
|
262
|
-
__loop__(
|
|
263
|
-
invariant(j <= MLDSA_OMEGA)
|
|
264
|
-
/* Maintain the post-condition */
|
|
265
|
-
invariant(forall(k1, 0, MLDSA_K, array_bound(h->vec[k1].coeffs, 0, MLDSA_N, 0, 2)))
|
|
266
|
-
decreases(MLDSA_OMEGA - j)
|
|
267
|
-
)
|
|
268
|
-
{
|
|
269
|
-
if (packed_hints[j] != 0)
|
|
270
|
-
{
|
|
271
|
-
return 1;
|
|
272
214
|
}
|
|
273
215
|
}
|
|
274
216
|
|
|
275
217
|
return 0;
|
|
276
218
|
}
|
|
277
|
-
|
|
278
|
-
MLD_INTERNAL_API
|
|
279
|
-
int mld_unpack_sig(uint8_t c[MLDSA_CTILDEBYTES], mld_polyvecl *z,
|
|
280
|
-
mld_polyveck *h, const uint8_t sig[MLDSA_CRYPTO_BYTES])
|
|
281
|
-
{
|
|
282
|
-
mld_memcpy(c, sig, MLDSA_CTILDEBYTES);
|
|
283
|
-
sig += MLDSA_CTILDEBYTES;
|
|
284
|
-
|
|
285
|
-
mld_polyvecl_unpack_z(z, sig);
|
|
286
|
-
sig += MLDSA_L * MLDSA_POLYZ_PACKEDBYTES;
|
|
287
|
-
|
|
288
|
-
return mld_unpack_hints(h, sig);
|
|
289
|
-
}
|
|
219
|
+
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
290
220
|
|
|
291
221
|
/* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
|
|
292
222
|
* Don't modify by hand -- this is auto-generated by scripts/autogen. */
|
|
293
|
-
#undef mld_unpack_hints
|