pq_crypto 0.6.8 → 0.6.9
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 +11 -0
- data/README.md +1 -3
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +71 -0
- data/ext/pqcrypto/vendor/mldsa-native/README.md +26 -11
- data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +77 -150
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +93 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +74 -59
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +106 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +94 -92
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/capability.h +31 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +55 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +12 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +3 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/auto.h +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +574 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +679 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +5 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +110 -120
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +109 -101
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +97 -93
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +1 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +4 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/fastmul.h +74 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/slowmul.h +77 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/arith_native_rv32im.h +124 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_asm.S +331 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_slowmul_asm.S +381 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_asm.S +304 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_slowmul_asm.S +351 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_poly_pointwise_montgomery_rv32im_asm.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/rv32im_zetas.c +118 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +6 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +2 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +12 -16
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +14 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +23 -27
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +21 -42
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +28 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +87 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +61 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +23 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +55 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +67 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +16 -24
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +27 -21
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +8 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +191 -119
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +16 -42
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +72 -0
- data/ext/pqcrypto/vendor/mlkem-native/README.md +9 -5
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +64 -312
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -34
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +41 -13
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +89 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +50 -46
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/capability.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +4 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +15 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +23 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +11 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +7 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/auto.h +47 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +573 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +678 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +1 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +29 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +156 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +137 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/compress_d5_table.c +43 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d10_table.c +50 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d11_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d4_table.c +44 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d5_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_intt_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d10_aarch64_asm.S +439 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d11_aarch64_asm.S +452 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d4_aarch64_asm.S +106 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d5_aarch64_asm.S +124 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d10_aarch64_asm.S +108 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d11_aarch64_asm.S +116 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d4_aarch64_asm.S +93 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d5_aarch64_asm.S +104 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_frombytes_aarch64_asm.S +84 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_mulcache_compute_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_reduce_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tobytes_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tomont_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_rej_uniform_aarch64_asm.S +112 -104
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +0 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +16 -21
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_intt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_ntt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_reduce_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +5 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +5 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_intt_avx2_asm.S +36 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntt_avx2_asm.S +67 -65
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttfrombytes_avx2_asm.S +8 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntttobytes_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d10_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d11_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d4_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S +118 -115
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S +174 -171
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S +230 -227
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_reduce_avx2_asm.S +17 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_rej_uniform_avx2_asm.S +7 -6
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_tomont_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +4 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +31 -44
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +1 -1
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +36 -1
|
@@ -124,30 +124,34 @@ __contract__(
|
|
|
124
124
|
);
|
|
125
125
|
#endif /* !MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
|
|
126
126
|
|
|
127
|
-
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
127
|
+
#if (!defined(MLD_CONFIG_NO_KEYPAIR_API) && \
|
|
128
|
+
!defined(MLD_CONFIG_CORE_API_ONLY)) || \
|
|
129
|
+
!defined(MLD_CONFIG_NO_VERIFY_API)
|
|
128
130
|
#define mld_polyvecl_chknorm MLD_NAMESPACE_KL(polyvecl_chknorm)
|
|
129
131
|
/**
|
|
130
132
|
* Check infinity norm of polynomials in vector of length MLDSA_L. Assumes
|
|
131
133
|
* input mld_polyvecl to be reduced by polyvecl_reduce().
|
|
132
134
|
*
|
|
133
135
|
* @param[in] v Pointer to vector.
|
|
134
|
-
* @param B Norm bound.
|
|
136
|
+
* @param B Norm bound. Must be MLDSA_GAMMA1 - MLDSA_BETA or
|
|
137
|
+
* MLDSA_ETA + 1, the only bounds used by the library.
|
|
135
138
|
*
|
|
136
139
|
* @return 0 if norm of all polynomials is strictly smaller than
|
|
137
|
-
* B
|
|
140
|
+
* B and 0xFFFFFFFF otherwise.
|
|
138
141
|
*/
|
|
139
142
|
MLD_INTERNAL_API
|
|
140
143
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
141
144
|
uint32_t mld_polyvecl_chknorm(const mld_polyvecl *v, int32_t B)
|
|
142
145
|
__contract__(
|
|
143
146
|
requires(memory_no_alias(v, sizeof(mld_polyvecl)))
|
|
144
|
-
requires(
|
|
147
|
+
requires(B == MLDSA_GAMMA1 - MLDSA_BETA || B == MLDSA_ETA + 1)
|
|
145
148
|
requires(forall(k0, 0, MLDSA_L,
|
|
146
149
|
array_bound(v->vec[k0].coeffs, 0, MLDSA_N, -MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
|
|
147
150
|
ensures(return_value == 0 || return_value == 0xFFFFFFFF)
|
|
148
151
|
ensures((return_value == 0) == forall(k1, 0, MLDSA_L, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, B)))
|
|
149
152
|
);
|
|
150
|
-
#endif /* !MLD_CONFIG_NO_KEYPAIR_API
|
|
153
|
+
#endif /* (!MLD_CONFIG_NO_KEYPAIR_API && !MLD_CONFIG_CORE_API_ONLY) || \
|
|
154
|
+
!MLD_CONFIG_NO_VERIFY_API */
|
|
151
155
|
|
|
152
156
|
/** Vector of MLDSA_K polynomials. */
|
|
153
157
|
typedef struct
|
|
@@ -238,134 +242,87 @@ __contract__(
|
|
|
238
242
|
);
|
|
239
243
|
#endif /* !MLD_CONFIG_NO_SIGN_API || MLD_UNIT_TEST */
|
|
240
244
|
|
|
241
|
-
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
242
|
-
#define
|
|
245
|
+
#if !defined(MLD_CONFIG_NO_KEYPAIR_API) && !defined(MLD_CONFIG_CORE_API_ONLY)
|
|
246
|
+
#define mld_polyveck_unpack_eta_chknorm \
|
|
247
|
+
MLD_NAMESPACE_KL(polyveck_unpack_eta_chknorm)
|
|
243
248
|
/**
|
|
244
|
-
* Check infinity norm of
|
|
245
|
-
* input mld_polyveck to be reduced by polyveck_reduce().
|
|
249
|
+
* Check the infinity norm of a bit-packed vector of MLDSA_K polynomials.
|
|
246
250
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
251
|
+
* Each polynomial is unpacked into the scratch buffer and checked in turn.
|
|
252
|
+
*
|
|
253
|
+
* @param[in] r Input byte array with bit-packed polynomial vector.
|
|
254
|
+
* @param B Norm bound.
|
|
255
|
+
* @param[out] scratch Scratch buffer for the polynomial being checked.
|
|
249
256
|
*
|
|
250
|
-
* @return 0 if norm of all polynomials
|
|
257
|
+
* @return 0 if the norm of all polynomials is strictly smaller than
|
|
251
258
|
* B <= (MLDSA_Q-1)/8 and 0xFFFFFFFF otherwise.
|
|
252
259
|
*/
|
|
253
260
|
MLD_INTERNAL_API
|
|
254
261
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
255
|
-
uint32_t
|
|
262
|
+
uint32_t mld_polyveck_unpack_eta_chknorm(
|
|
263
|
+
const uint8_t r[MLDSA_K * MLDSA_POLYETA_PACKEDBYTES], int32_t B,
|
|
264
|
+
mld_poly *scratch)
|
|
256
265
|
__contract__(
|
|
257
|
-
requires(memory_no_alias(
|
|
266
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
|
|
267
|
+
requires(memory_no_alias(scratch, sizeof(mld_poly)))
|
|
258
268
|
requires(0 <= B && B <= (MLDSA_Q - 1) / 8)
|
|
259
|
-
|
|
260
|
-
array_bound(v->vec[k0].coeffs, 0, MLDSA_N,
|
|
261
|
-
-MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
|
|
269
|
+
assigns(memory_slice(scratch, sizeof(mld_poly)))
|
|
262
270
|
ensures(return_value == 0 || return_value == 0xFFFFFFFF)
|
|
263
|
-
ensures((return_value == 0) == forall(k1, 0, MLDSA_K, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, B)))
|
|
264
271
|
);
|
|
265
272
|
|
|
266
|
-
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
273
|
+
#endif /* !MLD_CONFIG_NO_KEYPAIR_API && !MLD_CONFIG_CORE_API_ONLY */
|
|
267
274
|
|
|
268
275
|
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
269
|
-
#define
|
|
276
|
+
#define mld_polyveck_decompose_pack_w1 \
|
|
277
|
+
MLD_NAMESPACE_KL(polyveck_decompose_pack_w1)
|
|
270
278
|
/**
|
|
271
279
|
* For all coefficients a of polynomials in vector of length MLDSA_K, compute
|
|
272
280
|
* high and low bits a0, a1 such a mod^+ MLDSA_Q = a1*ALPHA + a0 with
|
|
273
281
|
* -ALPHA/2 < a0 <= ALPHA/2 except a1 = (MLDSA_Q-1)/ALPHA where we set
|
|
274
282
|
* a1 = 0 and -ALPHA/2 <= a0 = a mod MLDSA_Q - MLDSA_Q < 0. Assumes
|
|
275
|
-
* coefficients to be standard representatives.
|
|
283
|
+
* coefficients to be standard representatives. The low bits replace the input
|
|
284
|
+
* vector, the high bits are bit-packed into r.
|
|
285
|
+
*
|
|
286
|
+
* Decomposing and packing are fused so that the high bits are never held as a
|
|
287
|
+
* vector of polynomials, saving MLDSA_K * sizeof(mld_poly) bytes. During
|
|
288
|
+
* MakeHint, a single entry of w1 is instead unpacked on demand.
|
|
276
289
|
*
|
|
277
|
-
* @
|
|
278
|
-
*
|
|
279
|
-
* the aliasing eases CBMC proofs.}
|
|
290
|
+
* @spec{Combines @[FIPS204, Algorithm 36, Decompose] with
|
|
291
|
+
* @[FIPS204, Algorithm 28, w1Encode].}
|
|
280
292
|
*
|
|
281
|
-
* @
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
293
|
+
* @reference{The reference implementation has the Decompose input as a separate
|
|
294
|
+
* argument that may be aliased with either of the outputs. Removing the
|
|
295
|
+
* aliasing eases CBMC proofs.}
|
|
296
|
+
*
|
|
297
|
+
* @param[out] r Pointer to output byte array with at least
|
|
298
|
+
* MLDSA_K * MLDSA_POLYW1_PACKEDBYTES bytes.
|
|
299
|
+
* @param[in,out] v0 Pointer to input/output vector of polynomials. Output
|
|
300
|
+
* polynomials have coefficients a0.
|
|
301
|
+
* @param[out] scratch Scratch polynomial holding the high bits of the
|
|
302
|
+
* polynomial currently being packed.
|
|
285
303
|
*/
|
|
286
304
|
MLD_INTERNAL_API
|
|
287
|
-
void
|
|
305
|
+
void mld_polyveck_decompose_pack_w1(
|
|
306
|
+
uint8_t r[MLDSA_K * MLDSA_POLYW1_PACKEDBYTES], mld_polyveck *v0,
|
|
307
|
+
mld_poly *scratch)
|
|
288
308
|
__contract__(
|
|
289
|
-
requires(memory_no_alias(
|
|
309
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
290
310
|
requires(memory_no_alias(v0, sizeof(mld_polyveck)))
|
|
311
|
+
requires(memory_no_alias(scratch, sizeof(mld_poly)))
|
|
291
312
|
requires(forall(k0, 0, MLDSA_K,
|
|
292
313
|
array_bound(v0->vec[k0].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
293
|
-
assigns(memory_slice(
|
|
314
|
+
assigns(memory_slice(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
294
315
|
assigns(memory_slice(v0, sizeof(mld_polyveck)))
|
|
316
|
+
assigns(memory_slice(scratch, sizeof(mld_poly)))
|
|
295
317
|
ensures(forall(k1, 0, MLDSA_K,
|
|
296
|
-
|
|
297
|
-
ensures(forall(k2, 0, MLDSA_K,
|
|
298
|
-
array_abs_bound(v0->vec[k2].coeffs, 0, MLDSA_N, MLDSA_GAMMA2+1)))
|
|
318
|
+
array_abs_bound(v0->vec[k1].coeffs, 0, MLDSA_N, MLDSA_GAMMA2+1)))
|
|
299
319
|
);
|
|
300
320
|
#endif /* !MLD_CONFIG_NO_SIGN_API */
|
|
301
321
|
|
|
302
|
-
#if !defined(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
* coefficients are assumed to be standard representatives.
|
|
307
|
-
*
|
|
308
|
-
* @spec{Implements @[FIPS204, Algorithm 28, w1Encode].}
|
|
309
|
-
*
|
|
310
|
-
* @param[out] r Pointer to output byte array with at least
|
|
311
|
-
* MLDSA_K * MLDSA_POLYW1_PACKEDBYTES bytes.
|
|
312
|
-
* @param[in] w1 Pointer to input polynomial vector.
|
|
313
|
-
*/
|
|
314
|
-
MLD_INTERNAL_API
|
|
315
|
-
void mld_polyveck_pack_w1(uint8_t r[MLDSA_K * MLDSA_POLYW1_PACKEDBYTES],
|
|
316
|
-
const mld_polyveck *w1)
|
|
317
|
-
__contract__(
|
|
318
|
-
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
319
|
-
requires(memory_no_alias(w1, sizeof(mld_polyveck)))
|
|
320
|
-
requires(forall(k1, 0, MLDSA_K,
|
|
321
|
-
array_bound(w1->vec[k1].coeffs, 0, MLDSA_N, 0, (MLDSA_Q-1)/(2*MLDSA_GAMMA2))))
|
|
322
|
-
assigns(memory_slice(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
323
|
-
);
|
|
324
|
-
#endif /* !MLD_CONFIG_NO_SIGN_API */
|
|
325
|
-
|
|
326
|
-
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
327
|
-
#define mld_polyveck_pack_eta MLD_NAMESPACE_KL(polyveck_pack_eta)
|
|
328
|
-
/**
|
|
329
|
-
* Bit-pack polynomial vector with coefficients in [-MLDSA_ETA, MLDSA_ETA].
|
|
330
|
-
*
|
|
331
|
-
* @param[out] r Pointer to output byte array with
|
|
332
|
-
* MLDSA_K * MLDSA_POLYETA_PACKEDBYTES bytes.
|
|
333
|
-
* @param[in] p Pointer to input polynomial vector.
|
|
334
|
-
*/
|
|
335
|
-
MLD_INTERNAL_API
|
|
336
|
-
void mld_polyveck_pack_eta(uint8_t r[MLDSA_K * MLDSA_POLYETA_PACKEDBYTES],
|
|
337
|
-
const mld_polyveck *p)
|
|
338
|
-
__contract__(
|
|
339
|
-
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
|
|
340
|
-
requires(memory_no_alias(p, sizeof(mld_polyveck)))
|
|
341
|
-
requires(forall(k1, 0, MLDSA_K,
|
|
342
|
-
array_abs_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLDSA_ETA + 1)))
|
|
343
|
-
assigns(memory_slice(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
#define mld_polyvecl_pack_eta MLD_NAMESPACE_KL(polyvecl_pack_eta)
|
|
347
|
-
/**
|
|
348
|
-
* Bit-pack polynomial vector with coefficients in [-MLDSA_ETA, MLDSA_ETA].
|
|
349
|
-
*
|
|
350
|
-
* @param[out] r Pointer to output byte array with
|
|
351
|
-
* MLDSA_L * MLDSA_POLYETA_PACKEDBYTES bytes.
|
|
352
|
-
* @param[in] p Pointer to input polynomial vector.
|
|
353
|
-
*/
|
|
354
|
-
MLD_INTERNAL_API
|
|
355
|
-
void mld_polyvecl_pack_eta(uint8_t r[MLDSA_L * MLDSA_POLYETA_PACKEDBYTES],
|
|
356
|
-
const mld_polyvecl *p)
|
|
357
|
-
__contract__(
|
|
358
|
-
requires(memory_no_alias(r, MLDSA_L * MLDSA_POLYETA_PACKEDBYTES))
|
|
359
|
-
requires(memory_no_alias(p, sizeof(mld_polyvecl)))
|
|
360
|
-
requires(forall(k1, 0, MLDSA_L,
|
|
361
|
-
array_abs_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLDSA_ETA + 1)))
|
|
362
|
-
assigns(memory_slice(r, MLDSA_L * MLDSA_POLYETA_PACKEDBYTES))
|
|
363
|
-
);
|
|
364
|
-
|
|
365
|
-
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
366
|
-
|
|
367
|
-
#if !defined(MLD_CONFIG_NO_KEYPAIR_API) || \
|
|
368
|
-
(!defined(MLD_CONFIG_NO_SIGN_API) && \
|
|
322
|
+
#if (!defined(MLD_CONFIG_NO_KEYPAIR_API) && \
|
|
323
|
+
!defined(MLD_CONFIG_CORE_API_ONLY)) || \
|
|
324
|
+
((!defined(MLD_CONFIG_NO_KEYPAIR_API) || \
|
|
325
|
+
!defined(MLD_CONFIG_NO_SIGN_API)) && \
|
|
369
326
|
(!defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)))
|
|
370
327
|
#define mld_polyvecl_unpack_eta MLD_NAMESPACE_KL(polyvecl_unpack_eta)
|
|
371
328
|
/**
|
|
@@ -384,7 +341,8 @@ __contract__(
|
|
|
384
341
|
ensures(forall(k1, 0, MLDSA_L,
|
|
385
342
|
array_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLD_POLYETA_UNPACK_LOWER_BOUND, MLDSA_ETA + 1)))
|
|
386
343
|
);
|
|
387
|
-
#endif /* !MLD_CONFIG_NO_KEYPAIR_API
|
|
344
|
+
#endif /* (!MLD_CONFIG_NO_KEYPAIR_API && !MLD_CONFIG_CORE_API_ONLY) || \
|
|
345
|
+
((!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_NO_SIGN_API) && \
|
|
388
346
|
(!MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST)) */
|
|
389
347
|
|
|
390
348
|
#if !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
@@ -408,9 +366,10 @@ __contract__(
|
|
|
408
366
|
);
|
|
409
367
|
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
410
368
|
|
|
411
|
-
#if !defined(MLD_CONFIG_NO_KEYPAIR_API) ||
|
|
412
|
-
|
|
413
|
-
|
|
369
|
+
#if (!defined(MLD_CONFIG_NO_KEYPAIR_API) || \
|
|
370
|
+
!defined(MLD_CONFIG_NO_SIGN_API)) && \
|
|
371
|
+
(!defined(MLD_CONFIG_NO_SIGN_API) || defined(MLD_UNIT_TEST)) && \
|
|
372
|
+
(!defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST))
|
|
414
373
|
#define mld_polyveck_unpack_eta MLD_NAMESPACE_KL(polyveck_unpack_eta)
|
|
415
374
|
/**
|
|
416
375
|
* Unpack polynomial vector with coefficients in [-MLDSA_ETA, MLDSA_ETA].
|
|
@@ -428,8 +387,9 @@ __contract__(
|
|
|
428
387
|
ensures(forall(k1, 0, MLDSA_K,
|
|
429
388
|
array_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLD_POLYETA_UNPACK_LOWER_BOUND, MLDSA_ETA + 1)))
|
|
430
389
|
);
|
|
431
|
-
#endif /* !MLD_CONFIG_NO_KEYPAIR_API ||
|
|
432
|
-
(!
|
|
390
|
+
#endif /* (!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_NO_SIGN_API) && \
|
|
391
|
+
(!MLD_CONFIG_NO_SIGN_API || MLD_UNIT_TEST) && \
|
|
392
|
+
(!MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST) */
|
|
433
393
|
|
|
434
394
|
|
|
435
395
|
#endif /* !MLD_POLYVEC_H */
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
#include "polyvec_lazy.h"
|
|
16
|
-
|
|
17
16
|
#include "debug.h"
|
|
18
17
|
|
|
19
18
|
/* This namespacing is not done at the top to avoid a naming conflict
|
|
@@ -157,20 +156,19 @@ void mld_polyvec_matrix_pointwise_montgomery_row_eager(mld_poly *t_row,
|
|
|
157
156
|
|
|
158
157
|
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
159
158
|
MLD_INTERNAL_API
|
|
160
|
-
void mld_polyvec_matrix_pointwise_montgomery_yvec_eager(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
mld_polyvecl *scratch)
|
|
159
|
+
void mld_polyvec_matrix_pointwise_montgomery_yvec_eager(
|
|
160
|
+
mld_polyveck *w, mld_polymat_eager *mat, const mld_yvec_eager *y,
|
|
161
|
+
mld_yvec_scratch_eager *scratch)
|
|
164
162
|
{
|
|
165
163
|
unsigned int i;
|
|
166
164
|
*scratch = y->vec;
|
|
167
165
|
mld_polyvecl_ntt(scratch);
|
|
168
166
|
|
|
169
|
-
for (i = 0; i < MLDSA_K; ++
|
|
167
|
+
for (i = 0; i < MLDSA_K; i++)
|
|
170
168
|
__loop__(
|
|
171
169
|
assigns(i, memory_slice(w, sizeof(mld_polyveck)))
|
|
172
170
|
invariant(i <= MLDSA_K)
|
|
173
|
-
invariant(forall(k0, 0, i,
|
|
171
|
+
invariant(forall(k0, 0, i, MLDSA_K,
|
|
174
172
|
array_abs_bound(w->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
175
173
|
decreases(MLDSA_K - i)
|
|
176
174
|
)
|
|
@@ -208,7 +206,7 @@ void mld_polyvec_matrix_pointwise_montgomery_row_lazy(mld_poly *t_row,
|
|
|
208
206
|
mld_polymat_expand_entry(t_row, seed_ext, 0, (uint8_t)i);
|
|
209
207
|
mld_poly_pointwise_montgomery(t_row, &v->vec[0]);
|
|
210
208
|
|
|
211
|
-
for (l = 1; l < MLDSA_L; ++
|
|
209
|
+
for (l = 1; l < MLDSA_L; l++)
|
|
212
210
|
__loop__(
|
|
213
211
|
assigns(l, object_whole(seed_ext),
|
|
214
212
|
memory_slice(t_row, sizeof(mld_poly)),
|
|
@@ -231,18 +229,12 @@ void mld_polyvec_matrix_pointwise_montgomery_row_lazy(mld_poly *t_row,
|
|
|
231
229
|
|
|
232
230
|
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
233
231
|
MLD_INTERNAL_API
|
|
234
|
-
void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
mld_polyvecl *scratch)
|
|
232
|
+
void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(
|
|
233
|
+
mld_polyveck *w, mld_polymat_lazy *mat, const mld_yvec_lazy *y,
|
|
234
|
+
mld_yvec_scratch_lazy *scratch)
|
|
238
235
|
{
|
|
239
236
|
unsigned int k, l;
|
|
240
237
|
MLD_ALIGN uint8_t seed_ext[MLD_ALIGN_UP(MLDSA_SEEDBYTES + 2)];
|
|
241
|
-
/* Only the first poly of the polyvecl scratch is used. The polyvecl type
|
|
242
|
-
* matches the eager variant for API uniformity; in REDUCE_RAM mode the
|
|
243
|
-
* polyvecl storage is provided "for free" by the caller's polyveck/polyvecl
|
|
244
|
-
* union. */
|
|
245
|
-
mld_poly *y_ntt = &scratch->vec[0];
|
|
246
238
|
|
|
247
239
|
mld_memcpy(seed_ext, mat->rho, MLDSA_SEEDBYTES);
|
|
248
240
|
|
|
@@ -252,7 +244,7 @@ void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(mld_polyveck *w,
|
|
|
252
244
|
assigns(k, l, object_whole(seed_ext),
|
|
253
245
|
memory_slice(w, sizeof(mld_polyveck)),
|
|
254
246
|
memory_slice(mat, sizeof(mld_polymat_lazy)),
|
|
255
|
-
memory_slice(scratch, sizeof(
|
|
247
|
+
memory_slice(scratch, sizeof(mld_yvec_scratch_lazy)))
|
|
256
248
|
invariant(l <= MLDSA_L)
|
|
257
249
|
invariant(l == 0 ||
|
|
258
250
|
forall(k0, 0, MLDSA_K,
|
|
@@ -261,8 +253,8 @@ void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(mld_polyveck *w,
|
|
|
261
253
|
decreases(MLDSA_L - l)
|
|
262
254
|
)
|
|
263
255
|
{
|
|
264
|
-
mld_yvec_get_poly_lazy(
|
|
265
|
-
mld_poly_ntt(
|
|
256
|
+
mld_yvec_get_poly_lazy(scratch, y, l);
|
|
257
|
+
mld_poly_ntt(scratch);
|
|
266
258
|
for (k = 0; k < MLDSA_K; k++)
|
|
267
259
|
__loop__(
|
|
268
260
|
assigns(k, object_whole(seed_ext),
|
|
@@ -270,10 +262,10 @@ void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(mld_polyveck *w,
|
|
|
270
262
|
memory_slice(mat, sizeof(mld_polymat_lazy)))
|
|
271
263
|
invariant(k <= MLDSA_K)
|
|
272
264
|
invariant(l != 0 ||
|
|
273
|
-
forall(k1, 0, k,
|
|
265
|
+
forall(k1, 0, k, MLDSA_K,
|
|
274
266
|
array_abs_bound(w->vec[k1].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
275
267
|
invariant(l == 0 ||
|
|
276
|
-
forall(k2, 0, k,
|
|
268
|
+
forall(k2, 0, k, MLDSA_K,
|
|
277
269
|
array_abs_bound(w->vec[k2].coeffs, 0, MLDSA_N,
|
|
278
270
|
((int)l + 1) * MLDSA_Q)))
|
|
279
271
|
invariant(l == 0 ||
|
|
@@ -286,12 +278,12 @@ void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(mld_polyveck *w,
|
|
|
286
278
|
if (l == 0)
|
|
287
279
|
{
|
|
288
280
|
mld_polymat_expand_entry(&w->vec[k], seed_ext, 0, (uint8_t)k);
|
|
289
|
-
mld_poly_pointwise_montgomery(&w->vec[k],
|
|
281
|
+
mld_poly_pointwise_montgomery(&w->vec[k], scratch);
|
|
290
282
|
}
|
|
291
283
|
else
|
|
292
284
|
{
|
|
293
285
|
mld_polymat_expand_entry(&mat->cur, seed_ext, (uint8_t)l, (uint8_t)k);
|
|
294
|
-
mld_poly_pointwise_montgomery(&mat->cur,
|
|
286
|
+
mld_poly_pointwise_montgomery(&mat->cur, scratch);
|
|
295
287
|
mld_poly_add(&w->vec[k], &mat->cur);
|
|
296
288
|
}
|
|
297
289
|
}
|
|
@@ -79,6 +79,9 @@
|
|
|
79
79
|
#define mld_yvec_eager MLD_ADD_PARAM_SET(mld_yvec_eager)
|
|
80
80
|
#define mld_yvec_lazy MLD_ADD_PARAM_SET(mld_yvec_lazy)
|
|
81
81
|
#define mld_yvec MLD_ADD_PARAM_SET(mld_yvec)
|
|
82
|
+
#define mld_yvec_scratch MLD_ADD_PARAM_SET(mld_yvec_scratch)
|
|
83
|
+
#define mld_yvec_scratch_eager MLD_ADD_PARAM_SET(mld_yvec_scratch_eager)
|
|
84
|
+
#define mld_yvec_scratch_lazy MLD_ADD_PARAM_SET(mld_yvec_scratch_lazy)
|
|
82
85
|
#define mld_yvec_init_eager MLD_ADD_PARAM_SET(mld_yvec_init_eager)
|
|
83
86
|
#define mld_yvec_init_lazy MLD_ADD_PARAM_SET(mld_yvec_init_lazy)
|
|
84
87
|
#define mld_yvec_get_poly_eager MLD_ADD_PARAM_SET(mld_yvec_get_poly_eager)
|
|
@@ -127,6 +130,9 @@ typedef struct
|
|
|
127
130
|
mld_polyvecl vec; /**< Masking vector y. */
|
|
128
131
|
} mld_yvec_eager;
|
|
129
132
|
|
|
133
|
+
/** Scratch for the eager matrix-vector product: holds NTT(y) in full. */
|
|
134
|
+
typedef mld_polyvecl mld_yvec_scratch_eager;
|
|
135
|
+
|
|
130
136
|
/** Lazy yvec: store seed and base counter kappa, regenerate y[i] on demand. */
|
|
131
137
|
typedef struct
|
|
132
138
|
{
|
|
@@ -134,6 +140,9 @@ typedef struct
|
|
|
134
140
|
uint16_t kappa; /**< Base counter; component i uses kappa + i. */
|
|
135
141
|
} mld_yvec_lazy;
|
|
136
142
|
|
|
143
|
+
/** Scratch for the lazy matrix-vector product: holds one element of y. */
|
|
144
|
+
typedef mld_poly mld_yvec_scratch_lazy;
|
|
145
|
+
|
|
137
146
|
#if !defined(MLD_CONFIG_NO_KEYPAIR_API) || !defined(MLD_CONFIG_NO_SIGN_API)
|
|
138
147
|
/* s1vec */
|
|
139
148
|
|
|
@@ -275,11 +284,11 @@ __contract__(
|
|
|
275
284
|
)
|
|
276
285
|
{
|
|
277
286
|
unsigned int i;
|
|
278
|
-
for (i = 0; i < MLDSA_K; ++
|
|
287
|
+
for (i = 0; i < MLDSA_K; i++)
|
|
279
288
|
__loop__(
|
|
280
289
|
assigns(i, memory_slice(t0, sizeof(mld_sk_t0hat_eager)))
|
|
281
290
|
invariant(i <= MLDSA_K)
|
|
282
|
-
invariant(forall(k0, 0, i,
|
|
291
|
+
invariant(forall(k0, 0, i, MLDSA_K,
|
|
283
292
|
array_bound(t0->vec.vec[k0].coeffs, 0, MLDSA_N,
|
|
284
293
|
-(1 << (MLDSA_D - 1)) + 1, (1 << (MLDSA_D - 1)) + 1)))
|
|
285
294
|
decreases(MLDSA_K - i)
|
|
@@ -502,21 +511,20 @@ __contract__(
|
|
|
502
511
|
* @param[out] scratch Scratch polyvecl for NTT'd copy of y.
|
|
503
512
|
*/
|
|
504
513
|
MLD_INTERNAL_API
|
|
505
|
-
void mld_polyvec_matrix_pointwise_montgomery_yvec_eager(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
mld_polyvecl *scratch)
|
|
514
|
+
void mld_polyvec_matrix_pointwise_montgomery_yvec_eager(
|
|
515
|
+
mld_polyveck *w, mld_polymat_eager *mat, const mld_yvec_eager *y,
|
|
516
|
+
mld_yvec_scratch_eager *scratch)
|
|
509
517
|
__contract__(
|
|
510
518
|
requires(memory_no_alias(w, sizeof(mld_polyveck)))
|
|
511
519
|
requires(memory_no_alias(mat, sizeof(mld_polymat_eager)))
|
|
512
520
|
requires(memory_no_alias(y, sizeof(mld_yvec_eager)))
|
|
513
|
-
requires(memory_no_alias(scratch, sizeof(
|
|
521
|
+
requires(memory_no_alias(scratch, sizeof(mld_yvec_scratch_eager)))
|
|
514
522
|
requires(forall(k1, 0, MLDSA_K, forall(l1, 0, MLDSA_L,
|
|
515
523
|
array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
|
|
516
524
|
requires(forall(l2, 0, MLDSA_L,
|
|
517
525
|
array_bound(y->vec.vec[l2].coeffs, 0, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1)))
|
|
518
526
|
assigns(memory_slice(w, sizeof(mld_polyveck)))
|
|
519
|
-
assigns(memory_slice(scratch, sizeof(
|
|
527
|
+
assigns(memory_slice(scratch, sizeof(mld_yvec_scratch_eager)))
|
|
520
528
|
ensures(forall(k0, 0, MLDSA_K,
|
|
521
529
|
array_abs_bound(w->vec[k0].coeffs, 0, MLDSA_N, MLD_INTT_BOUND)))
|
|
522
530
|
);
|
|
@@ -569,33 +577,29 @@ __contract__(
|
|
|
569
577
|
/**
|
|
570
578
|
* Compute w = invNTT(A * NTT(y)) for the signing y vector.
|
|
571
579
|
*
|
|
572
|
-
* The lazy variant samples one
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
* the polyvecl scratch is used; the polyvecl type is shared with the eager
|
|
576
|
-
* variant for API uniformity (the storage is provided "for free" by the
|
|
577
|
-
* caller's polyveck/polyvecl union in REDUCE_RAM mode).
|
|
580
|
+
* The lazy variant samples one element of y at a time, NTTs it into scratch,
|
|
581
|
+
* and accumulates the matrix-vector product column-by-column with on-demand
|
|
582
|
+
* sampling of A[k][l].
|
|
578
583
|
*
|
|
579
584
|
* @param[out] w Pointer to output vector.
|
|
580
585
|
* @param[in,out] mat Pointer to input matrix.
|
|
581
586
|
* @param[in] y Pointer to y seed/kappa.
|
|
582
|
-
* @param[out] scratch Scratch
|
|
587
|
+
* @param[out] scratch Scratch for the NTT of the current element of y.
|
|
583
588
|
*/
|
|
584
589
|
MLD_INTERNAL_API
|
|
585
|
-
void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
mld_polyvecl *scratch)
|
|
590
|
+
void mld_polyvec_matrix_pointwise_montgomery_yvec_lazy(
|
|
591
|
+
mld_polyveck *w, mld_polymat_lazy *mat, const mld_yvec_lazy *y,
|
|
592
|
+
mld_yvec_scratch_lazy *scratch)
|
|
589
593
|
__contract__(
|
|
590
594
|
requires(memory_no_alias(w, sizeof(mld_polyveck)))
|
|
591
595
|
requires(memory_no_alias(mat, sizeof(mld_polymat_lazy)))
|
|
592
596
|
requires(memory_no_alias(y, sizeof(mld_yvec_lazy)))
|
|
593
|
-
requires(memory_no_alias(scratch, sizeof(
|
|
597
|
+
requires(memory_no_alias(scratch, sizeof(mld_yvec_scratch_lazy)))
|
|
594
598
|
requires(memory_no_alias(y->rhoprime, MLDSA_CRHBYTES))
|
|
595
599
|
requires(y->kappa <= MLD_MAX_KAPPA)
|
|
596
600
|
assigns(memory_slice(w, sizeof(mld_polyveck)))
|
|
597
601
|
assigns(memory_slice(mat, sizeof(mld_polymat_lazy)))
|
|
598
|
-
assigns(memory_slice(scratch, sizeof(
|
|
602
|
+
assigns(memory_slice(scratch, sizeof(mld_yvec_scratch_lazy)))
|
|
599
603
|
ensures(forall(k0, 0, MLDSA_K,
|
|
600
604
|
array_abs_bound(w->vec[k0].coeffs, 0, MLDSA_N, MLD_INTT_BOUND)))
|
|
601
605
|
);
|
|
@@ -609,6 +613,7 @@ typedef mld_sk_s2hat_lazy mld_sk_s2hat;
|
|
|
609
613
|
typedef mld_sk_t0hat_lazy mld_sk_t0hat;
|
|
610
614
|
typedef mld_polymat_lazy mld_polymat;
|
|
611
615
|
typedef mld_yvec_lazy mld_yvec;
|
|
616
|
+
typedef mld_yvec_scratch_lazy mld_yvec_scratch;
|
|
612
617
|
#define mld_unpack_sk_s1hat mld_unpack_sk_s1hat_lazy
|
|
613
618
|
#define mld_unpack_sk_s2hat mld_unpack_sk_s2hat_lazy
|
|
614
619
|
#define mld_unpack_sk_t0hat mld_unpack_sk_t0hat_lazy
|
|
@@ -630,6 +635,7 @@ typedef mld_sk_s2hat_eager mld_sk_s2hat;
|
|
|
630
635
|
typedef mld_sk_t0hat_eager mld_sk_t0hat;
|
|
631
636
|
typedef mld_polymat_eager mld_polymat;
|
|
632
637
|
typedef mld_yvec_eager mld_yvec;
|
|
638
|
+
typedef mld_yvec_scratch_eager mld_yvec_scratch;
|
|
633
639
|
#define mld_unpack_sk_s1hat mld_unpack_sk_s1hat_eager
|
|
634
640
|
#define mld_unpack_sk_s2hat mld_unpack_sk_s2hat_eager
|
|
635
641
|
#define mld_unpack_sk_t0hat mld_unpack_sk_t0hat_eager
|
|
@@ -20,9 +20,6 @@
|
|
|
20
20
|
#include "ct.h"
|
|
21
21
|
#include "debug.h"
|
|
22
22
|
|
|
23
|
-
/* check-magic: -4186625 == pow(2,32,MLDSA_Q) */
|
|
24
|
-
#define MLD_MONT (-4186625)
|
|
25
|
-
|
|
26
23
|
/* Upper bound for domain of mld_reduce32() */
|
|
27
24
|
#define MLD_REDUCE32_DOMAIN_MAX (INT32_MAX - ((int32_t)1 << 22))
|
|
28
25
|
|
|
@@ -36,13 +33,11 @@
|
|
|
36
33
|
*
|
|
37
34
|
* @spec{Implements @[FIPS204, Algorithm 49, MontgomeryReduce].}
|
|
38
35
|
*
|
|
39
|
-
* @param a Input integer to be reduced, of absolute value smaller
|
|
40
|
-
*
|
|
36
|
+
* @param a Input integer to be reduced, of absolute value smaller than
|
|
37
|
+
* 2^31 * MLDSA_Q.
|
|
41
38
|
*
|
|
42
39
|
* @return Integer congruent to a * R^-1 modulo MLDSA_Q, with absolute value
|
|
43
|
-
* <= |a| / 2^32 + MLDSA_Q / 2.
|
|
44
|
-
* In particular, if |a| < 2^31 * MLDSA_Q, the absolute value of the
|
|
45
|
-
* return value is < MLDSA_Q.
|
|
40
|
+
* <= |a| / 2^32 + MLDSA_Q / 2, and in particular < MLDSA_Q.
|
|
46
41
|
*/
|
|
47
42
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
48
43
|
static MLD_INLINE int32_t mld_montgomery_reduce(int64_t a)
|
|
@@ -114,6 +109,11 @@ __contract__(
|
|
|
114
109
|
{
|
|
115
110
|
int32_t t;
|
|
116
111
|
|
|
112
|
+
/*
|
|
113
|
+
* PORTABILITY: Right-shift on a signed integer is, strictly-speaking,
|
|
114
|
+
* implementation-defined for negative left argument. Here,
|
|
115
|
+
* we assume it's sign-preserving "arithmetic" shift right. (C99 6.5.7 (5))
|
|
116
|
+
*/
|
|
117
117
|
t = (a + ((int32_t)1 << 22)) >> 23;
|
|
118
118
|
t = a - t * MLDSA_Q;
|
|
119
119
|
mld_assert((t - a) % MLDSA_Q == 0);
|