pq_crypto 0.4.2 → 0.5.0
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 +25 -0
- data/GET_STARTED.md +21 -16
- data/README.md +26 -0
- data/SECURITY.md +22 -16
- data/ext/pqcrypto/extconf.rb +148 -99
- data/ext/pqcrypto/mldsa_api.h +1 -118
- data/ext/pqcrypto/mlkem_api.h +1 -42
- data/ext/pqcrypto/pq_externalmu.c +88 -216
- data/ext/pqcrypto/pqcrypto_native_api.h +129 -0
- data/ext/pqcrypto/pqcrypto_ruby_secure.c +0 -3
- data/ext/pqcrypto/pqcrypto_secure.c +135 -117
- data/ext/pqcrypto/pqcrypto_secure.h +1 -42
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/randombytes.h +9 -0
- data/ext/pqcrypto/vendor/.vendored +10 -5
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +105 -0
- data/ext/pqcrypto/vendor/mldsa-native/LICENSE +286 -0
- data/ext/pqcrypto/vendor/mldsa-native/META.yml +24 -0
- data/ext/pqcrypto/vendor/mldsa-native/README.md +221 -0
- data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +8 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +721 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +975 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +724 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +723 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +166 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +321 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.c +21 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +385 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +73 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +130 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +277 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +244 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +182 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +117 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +438 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +105 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +71 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +62 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +376 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +204 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +259 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1077 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +987 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +41 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +26 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +35 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +37 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +27 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +36 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +69 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +32 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +20 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +638 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +136 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +52 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +29 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +488 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +16 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/xkcp.h +31 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +247 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +231 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +150 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +753 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +129 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +145 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +177 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +653 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +79 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +55 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +85 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +85 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +102 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +110 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +72 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +69 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +40 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +189 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +135 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +128 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +543 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +62 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +649 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +23 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +315 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +124 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +2311 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +2383 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +239 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +131 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +187 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +61 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +52 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +102 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +104 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +91 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +93 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +126 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +155 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +160 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +293 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +224 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +77 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +991 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +393 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +946 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +360 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +877 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +725 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +249 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +1511 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +806 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +268 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +104 -0
- data/ext/pqcrypto/vendor/mlkem-native/LICENSE +294 -0
- data/ext/pqcrypto/vendor/mlkem-native/META.yml +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/README.md +223 -0
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +86 -0
- data/ext/pqcrypto/vendor/mlkem-native/SECURITY.md +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +23 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +660 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +538 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +681 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +709 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +174 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +274 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +717 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +688 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +64 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +128 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +251 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +158 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +208 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +80 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +463 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +98 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +70 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +375 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +203 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +258 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1076 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +986 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +46 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +34 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +35 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +26 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +35 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +117 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/README.md +10 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +79 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +35 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +667 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +40 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +51 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +290 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +314 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +28 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +33 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +41 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2.S +451 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +51 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +622 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +156 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +446 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +326 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/README.md +16 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +122 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +174 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +177 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/intt.S +628 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/ntt.S +562 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_mulcache_compute_asm.S +127 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_reduce_asm.S +150 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tobytes_asm.S +117 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tomont_asm.S +98 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +261 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +314 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +368 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_asm.S +226 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +542 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +637 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/README.md +11 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +128 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +45 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +81 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +145 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_izetas.inc +27 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +805 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas.inc +27 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas_basemul.inc +39 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/README.md +4 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +304 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +309 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +94 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +45 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +102 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +25 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/intt.S +719 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mulcache_compute.S +90 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntt.S +639 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttfrombytes.S +193 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntttobytes.S +181 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttunpack.S +174 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d10.S +382 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d11.S +448 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d4.S +163 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d5.S +220 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d10.S +228 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d11.S +277 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d4.S +180 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d5.S +192 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +502 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +750 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +998 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/reduce.S +218 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_asm.S +103 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +544 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/tomont.S +155 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/params.h +76 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +572 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +317 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +502 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +668 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +60 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +362 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +118 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/symmetric.h +70 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +260 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.c +20 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +464 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/zetas.inc +30 -0
- data/lib/pq_crypto/version.rb +1 -1
- data/lib/pq_crypto.rb +1 -1
- data/script/vendor_libs.rb +88 -159
- metadata +236 -160
- data/ext/pqcrypto/vendor/pqclean/common/aes.c +0 -639
- data/ext/pqcrypto/vendor/pqclean/common/aes.h +0 -64
- data/ext/pqcrypto/vendor/pqclean/common/compat.h +0 -73
- data/ext/pqcrypto/vendor/pqclean/common/crypto_declassify.h +0 -7
- data/ext/pqcrypto/vendor/pqclean/common/fips202.c +0 -928
- data/ext/pqcrypto/vendor/pqclean/common/fips202.h +0 -166
- data/ext/pqcrypto/vendor/pqclean/common/keccak2x/feat.S +0 -168
- data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.c +0 -684
- data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.h +0 -60
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SIMD256.c +0 -1028
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SnP.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-unrolling.macros +0 -198
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile +0 -8
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile.Microsoft_nmake +0 -8
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/SIMD256-config.h +0 -3
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/align.h +0 -34
- data/ext/pqcrypto/vendor/pqclean/common/keccak4x/brg_endian.h +0 -142
- data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.c +0 -101
- data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.h +0 -39
- data/ext/pqcrypto/vendor/pqclean/common/randombytes.c +0 -355
- data/ext/pqcrypto/vendor/pqclean/common/randombytes.h +0 -27
- data/ext/pqcrypto/vendor/pqclean/common/sha2.c +0 -769
- data/ext/pqcrypto/vendor/pqclean/common/sha2.h +0 -173
- data/ext/pqcrypto/vendor/pqclean/common/sp800-185.c +0 -156
- data/ext/pqcrypto/vendor/pqclean/common/sp800-185.h +0 -27
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/api.h +0 -18
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.c +0 -83
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.h +0 -11
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.c +0 -327
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.h +0 -22
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.c +0 -164
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.h +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.c +0 -146
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/params.h +0 -36
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.c +0 -311
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.h +0 -37
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.c +0 -198
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.h +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.c +0 -41
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric-shake.c +0 -71
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric.h +0 -30
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.c +0 -67
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/api.h +0 -18
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.c +0 -108
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.h +0 -11
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.c +0 -327
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.h +0 -22
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.c +0 -164
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.h +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.c +0 -146
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/params.h +0 -36
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.c +0 -299
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.h +0 -37
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.c +0 -188
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.h +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.c +0 -41
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric-shake.c +0 -71
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric.h +0 -30
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.c +0 -67
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/api.h +0 -18
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.c +0 -83
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.h +0 -11
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.c +0 -327
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.h +0 -22
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.c +0 -164
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.h +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.c +0 -146
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/params.h +0 -36
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.c +0 -299
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.h +0 -37
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.c +0 -188
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.h +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.c +0 -41
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric-shake.c +0 -71
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric.h +0 -30
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.c +0 -67
- data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.h +0 -13
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/api.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.h +0 -10
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.c +0 -261
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.h +0 -31
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/params.h +0 -44
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.c +0 -848
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.h +0 -52
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.c +0 -415
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.h +0 -65
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.c +0 -69
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.h +0 -17
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.c +0 -407
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.h +0 -47
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric-shake.c +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric.h +0 -34
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/api.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.h +0 -10
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.c +0 -261
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.h +0 -31
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/params.h +0 -44
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.c +0 -799
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.h +0 -52
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.c +0 -415
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.h +0 -65
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.c +0 -69
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.h +0 -17
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.c +0 -92
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.c +0 -407
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.h +0 -47
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric-shake.c +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric.h +0 -34
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/LICENSE +0 -5
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile +0 -19
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile.Microsoft_nmake +0 -23
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/api.h +0 -50
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.c +0 -98
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.h +0 -10
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.c +0 -261
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.h +0 -31
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/params.h +0 -44
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.c +0 -823
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.h +0 -52
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.c +0 -415
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.h +0 -65
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.c +0 -69
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.h +0 -17
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.c +0 -92
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.h +0 -14
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.c +0 -407
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.h +0 -47
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric-shake.c +0 -26
- data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric.h +0 -34
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mldsa-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
#ifndef MLD_POLYVEC_H
|
|
6
|
+
#define MLD_POLYVEC_H
|
|
7
|
+
|
|
8
|
+
#include "cbmc.h"
|
|
9
|
+
#include "common.h"
|
|
10
|
+
#include "poly.h"
|
|
11
|
+
#include "poly_kl.h"
|
|
12
|
+
|
|
13
|
+
/* Parameter set namespacing
|
|
14
|
+
* This is to facilitate building multiple instances
|
|
15
|
+
* of mldsa-native (e.g. with varying parameter sets)
|
|
16
|
+
* within a single compilation unit. */
|
|
17
|
+
#define mld_polyvecl MLD_ADD_PARAM_SET(mld_polyvecl)
|
|
18
|
+
#define mld_polyveck MLD_ADD_PARAM_SET(mld_polyveck)
|
|
19
|
+
#define mld_polymat MLD_ADD_PARAM_SET(mld_polymat)
|
|
20
|
+
/* End of parameter set namespacing */
|
|
21
|
+
|
|
22
|
+
/* Vectors of polynomials of length MLDSA_L */
|
|
23
|
+
typedef struct
|
|
24
|
+
{
|
|
25
|
+
mld_poly vec[MLDSA_L];
|
|
26
|
+
} mld_polyvecl;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#define mld_polyvecl_uniform_gamma1 MLD_NAMESPACE_KL(polyvecl_uniform_gamma1)
|
|
30
|
+
/*************************************************
|
|
31
|
+
* Name: mld_polyvecl_uniform_gamma1
|
|
32
|
+
*
|
|
33
|
+
* Description: Sample vector of polynomials with uniformly random coefficients
|
|
34
|
+
* in [-(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1] by unpacking output
|
|
35
|
+
* stream of SHAKE256(seed|nonce)
|
|
36
|
+
*
|
|
37
|
+
* Arguments: - mld_polyvecl *v: pointer to output vector
|
|
38
|
+
* - const uint8_t seed[]: byte array with seed of length
|
|
39
|
+
* MLDSA_CRHBYTES
|
|
40
|
+
* - uint16_t nonce: 16-bit nonce
|
|
41
|
+
*************************************************/
|
|
42
|
+
MLD_INTERNAL_API
|
|
43
|
+
void mld_polyvecl_uniform_gamma1(mld_polyvecl *v,
|
|
44
|
+
const uint8_t seed[MLDSA_CRHBYTES],
|
|
45
|
+
uint16_t nonce)
|
|
46
|
+
__contract__(
|
|
47
|
+
requires(memory_no_alias(v, sizeof(mld_polyvecl)))
|
|
48
|
+
requires(memory_no_alias(seed, MLDSA_CRHBYTES))
|
|
49
|
+
requires(nonce <= (UINT16_MAX - MLDSA_L) / MLDSA_L)
|
|
50
|
+
assigns(memory_slice(v, sizeof(mld_polyvecl)))
|
|
51
|
+
ensures(forall(k0, 0, MLDSA_L,
|
|
52
|
+
array_bound(v->vec[k0].coeffs, 0, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1)))
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
#define mld_polyvecl_ntt MLD_NAMESPACE_KL(polyvecl_ntt)
|
|
56
|
+
/*************************************************
|
|
57
|
+
* Name: mld_polyvecl_ntt
|
|
58
|
+
*
|
|
59
|
+
* Description: Forward NTT of all polynomials in vector of length MLDSA_L.
|
|
60
|
+
* Coefficients can grow by 8*MLDSA_Q in absolute value.
|
|
61
|
+
*
|
|
62
|
+
* Arguments: - mld_polyvecl *v: pointer to input/output vector
|
|
63
|
+
**************************************************/
|
|
64
|
+
MLD_INTERNAL_API
|
|
65
|
+
void mld_polyvecl_ntt(mld_polyvecl *v)
|
|
66
|
+
__contract__(
|
|
67
|
+
requires(memory_no_alias(v, sizeof(mld_polyvecl)))
|
|
68
|
+
requires(forall(k0, 0, MLDSA_L, array_abs_bound(v->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
69
|
+
assigns(memory_slice(v, sizeof(mld_polyvecl)))
|
|
70
|
+
ensures(forall(k1, 0, MLDSA_L, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
#define mld_polyvecl_pointwise_acc_montgomery \
|
|
74
|
+
MLD_NAMESPACE_KL(polyvecl_pointwise_acc_montgomery)
|
|
75
|
+
/*************************************************
|
|
76
|
+
* Name: mld_polyvecl_pointwise_acc_montgomery
|
|
77
|
+
*
|
|
78
|
+
* Description: Pointwise multiply vectors of polynomials of length MLDSA_L,
|
|
79
|
+
* multiply resulting vector by 2^{-32} and add (accumulate)
|
|
80
|
+
* polynomials in it.
|
|
81
|
+
* Input/output vectors are in NTT domain representation.
|
|
82
|
+
*
|
|
83
|
+
* The first input "u" must be the output of
|
|
84
|
+
* polyvec_matrix_expand() and so have coefficients in [0, Q-1]
|
|
85
|
+
* inclusive.
|
|
86
|
+
*
|
|
87
|
+
* The second input "v" is assumed to be output of an NTT, and
|
|
88
|
+
* hence must have coefficients bounded by [-9q+1, +9q-1]
|
|
89
|
+
* inclusive.
|
|
90
|
+
*
|
|
91
|
+
*
|
|
92
|
+
* Arguments: - mld_poly *w: output polynomial
|
|
93
|
+
* - const mld_polyvecl *u: pointer to first input vector
|
|
94
|
+
* - const mld_polyvecl *v: pointer to second input vector
|
|
95
|
+
**************************************************/
|
|
96
|
+
MLD_INTERNAL_API
|
|
97
|
+
void mld_polyvecl_pointwise_acc_montgomery(mld_poly *w, const mld_polyvecl *u,
|
|
98
|
+
const mld_polyvecl *v)
|
|
99
|
+
__contract__(
|
|
100
|
+
requires(memory_no_alias(w, sizeof(mld_poly)))
|
|
101
|
+
requires(memory_no_alias(u, sizeof(mld_polyvecl)))
|
|
102
|
+
requires(memory_no_alias(v, sizeof(mld_polyvecl)))
|
|
103
|
+
requires(forall(l0, 0, MLDSA_L,
|
|
104
|
+
array_bound(u->vec[l0].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
105
|
+
requires(forall(l1, 0, MLDSA_L,
|
|
106
|
+
array_abs_bound(v->vec[l1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
|
|
107
|
+
assigns(memory_slice(w, sizeof(mld_poly)))
|
|
108
|
+
ensures(array_abs_bound(w->coeffs, 0, MLDSA_N, MLDSA_Q))
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
#define mld_polyvecl_chknorm MLD_NAMESPACE_KL(polyvecl_chknorm)
|
|
113
|
+
/*************************************************
|
|
114
|
+
* Name: mld_polyvecl_chknorm
|
|
115
|
+
*
|
|
116
|
+
* Description: Check infinity norm of polynomials in vector of length MLDSA_L.
|
|
117
|
+
* Assumes input mld_polyvecl to be reduced by polyvecl_reduce().
|
|
118
|
+
*
|
|
119
|
+
* Arguments: - const mld_polyvecl *v: pointer to vector
|
|
120
|
+
* - int32_t B: norm bound
|
|
121
|
+
*
|
|
122
|
+
* Returns 0 if norm of all polynomials is strictly smaller than B <=
|
|
123
|
+
* (MLDSA_Q-1)/8 and 0xFFFFFFFF otherwise.
|
|
124
|
+
**************************************************/
|
|
125
|
+
MLD_INTERNAL_API
|
|
126
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
127
|
+
uint32_t mld_polyvecl_chknorm(const mld_polyvecl *v, int32_t B)
|
|
128
|
+
__contract__(
|
|
129
|
+
requires(memory_no_alias(v, sizeof(mld_polyvecl)))
|
|
130
|
+
requires(0 <= B && B <= (MLDSA_Q - 1) / 8)
|
|
131
|
+
requires(forall(k0, 0, MLDSA_L,
|
|
132
|
+
array_bound(v->vec[k0].coeffs, 0, MLDSA_N, -MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
|
|
133
|
+
ensures(return_value == 0 || return_value == 0xFFFFFFFF)
|
|
134
|
+
ensures((return_value == 0) == forall(k1, 0, MLDSA_L, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, B)))
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
/* Vectors of polynomials of length MLDSA_K */
|
|
138
|
+
typedef struct
|
|
139
|
+
{
|
|
140
|
+
mld_poly vec[MLDSA_K];
|
|
141
|
+
} mld_polyveck;
|
|
142
|
+
|
|
143
|
+
/* Matrix of polynomials (K x L) */
|
|
144
|
+
typedef struct
|
|
145
|
+
{
|
|
146
|
+
#if defined(MLD_CONFIG_REDUCE_RAM)
|
|
147
|
+
mld_polyvecl row_buffer;
|
|
148
|
+
uint8_t rho[MLDSA_SEEDBYTES];
|
|
149
|
+
#else
|
|
150
|
+
mld_polyvecl vec[MLDSA_K];
|
|
151
|
+
#endif
|
|
152
|
+
} mld_polymat;
|
|
153
|
+
|
|
154
|
+
#define mld_polyveck_reduce MLD_NAMESPACE_KL(polyveck_reduce)
|
|
155
|
+
/*************************************************
|
|
156
|
+
* Name: polyveck_reduce
|
|
157
|
+
*
|
|
158
|
+
* Description: Reduce coefficients of polynomials in vector of length MLDSA_K
|
|
159
|
+
* to representatives in
|
|
160
|
+
*[-MLD_REDUCE32_RANGE_MAX,MLD_REDUCE32_RANGE_MAX].
|
|
161
|
+
*
|
|
162
|
+
* Arguments: - mld_polyveck *v: pointer to input/output vector
|
|
163
|
+
**************************************************/
|
|
164
|
+
MLD_INTERNAL_API
|
|
165
|
+
void mld_polyveck_reduce(mld_polyveck *v)
|
|
166
|
+
__contract__(
|
|
167
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
168
|
+
requires(forall(k0, 0, MLDSA_K,
|
|
169
|
+
array_bound(v->vec[k0].coeffs, 0, MLDSA_N, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX)))
|
|
170
|
+
assigns(memory_slice(v, sizeof(mld_polyveck)))
|
|
171
|
+
ensures(forall(k1, 0, MLDSA_K,
|
|
172
|
+
array_bound(v->vec[k1].coeffs, 0, MLDSA_N, -MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
#define mld_polyveck_caddq MLD_NAMESPACE_KL(polyveck_caddq)
|
|
176
|
+
/*************************************************
|
|
177
|
+
* Name: mld_polyveck_caddq
|
|
178
|
+
*
|
|
179
|
+
* Description: For all coefficients of polynomials in vector of length MLDSA_K
|
|
180
|
+
* add MLDSA_Q if coefficient is negative.
|
|
181
|
+
*
|
|
182
|
+
* Arguments: - mld_polyveck *v: pointer to input/output vector
|
|
183
|
+
**************************************************/
|
|
184
|
+
MLD_INTERNAL_API
|
|
185
|
+
void mld_polyveck_caddq(mld_polyveck *v)
|
|
186
|
+
__contract__(
|
|
187
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
188
|
+
requires(forall(k0, 0, MLDSA_K,
|
|
189
|
+
array_abs_bound(v->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
190
|
+
assigns(memory_slice(v, sizeof(mld_polyveck)))
|
|
191
|
+
ensures(forall(k1, 0, MLDSA_K,
|
|
192
|
+
array_bound(v->vec[k1].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
#define mld_polyveck_add MLD_NAMESPACE_KL(polyveck_add)
|
|
196
|
+
/*************************************************
|
|
197
|
+
* Name: mld_polyveck_add
|
|
198
|
+
*
|
|
199
|
+
* Description: Add vectors of polynomials of length MLDSA_K.
|
|
200
|
+
* No modular reduction is performed.
|
|
201
|
+
*
|
|
202
|
+
* Arguments: - mld_polyveck *u: pointer to input-output vector of polynomials
|
|
203
|
+
* to be added to
|
|
204
|
+
* - const mld_polyveck *v: pointer to second input vector of
|
|
205
|
+
* polynomials
|
|
206
|
+
**************************************************/
|
|
207
|
+
MLD_INTERNAL_API
|
|
208
|
+
void mld_polyveck_add(mld_polyveck *u, const mld_polyveck *v)
|
|
209
|
+
__contract__(
|
|
210
|
+
requires(memory_no_alias(u, sizeof(mld_polyveck)))
|
|
211
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
212
|
+
requires(forall(p0, 0, MLDSA_K, array_abs_bound(u->vec[p0].coeffs, 0, MLDSA_N, MLD_INTT_BOUND)))
|
|
213
|
+
requires(forall(p1, 0, MLDSA_K,
|
|
214
|
+
array_bound(v->vec[p1].coeffs, 0, MLDSA_N, -MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
|
|
215
|
+
assigns(memory_slice(u, sizeof(mld_polyveck)))
|
|
216
|
+
ensures(forall(q2, 0, MLDSA_K,
|
|
217
|
+
array_bound(u->vec[q2].coeffs, 0, MLDSA_N, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX)))
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
#define mld_polyveck_sub MLD_NAMESPACE_KL(polyveck_sub)
|
|
221
|
+
/*************************************************
|
|
222
|
+
* Name: mld_polyveck_sub
|
|
223
|
+
*
|
|
224
|
+
* Description: Subtract vectors of polynomials of length MLDSA_K.
|
|
225
|
+
* No modular reduction is performed.
|
|
226
|
+
*
|
|
227
|
+
* Arguments: - mld_polyveck *u: pointer to first input vector
|
|
228
|
+
* - const mld_polyveck *v: pointer to second input vector to be
|
|
229
|
+
* subtracted from first input vector
|
|
230
|
+
**************************************************/
|
|
231
|
+
MLD_INTERNAL_API
|
|
232
|
+
void mld_polyveck_sub(mld_polyveck *u, const mld_polyveck *v)
|
|
233
|
+
__contract__(
|
|
234
|
+
requires(memory_no_alias(u, sizeof(mld_polyveck)))
|
|
235
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
236
|
+
requires(forall(k0, 0, MLDSA_K, array_abs_bound(u->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
237
|
+
requires(forall(k1, 0, MLDSA_K, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
238
|
+
assigns(memory_slice(u, sizeof(mld_polyveck)))
|
|
239
|
+
ensures(forall(k0, 0, MLDSA_K,
|
|
240
|
+
array_bound(u->vec[k0].coeffs, 0, MLDSA_N, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX)))
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
#define mld_polyveck_shiftl MLD_NAMESPACE_KL(polyveck_shiftl)
|
|
244
|
+
/*************************************************
|
|
245
|
+
* Name: mld_polyveck_shiftl
|
|
246
|
+
*
|
|
247
|
+
* Description: Multiply vector of polynomials of Length MLDSA_K by 2^MLDSA_D
|
|
248
|
+
*without modular reduction. Assumes input coefficients to be less than
|
|
249
|
+
*2^{31-MLDSA_D}.
|
|
250
|
+
*
|
|
251
|
+
* Arguments: - mld_polyveck *v: pointer to input/output vector
|
|
252
|
+
**************************************************/
|
|
253
|
+
MLD_INTERNAL_API
|
|
254
|
+
void mld_polyveck_shiftl(mld_polyveck *v)
|
|
255
|
+
__contract__(
|
|
256
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
257
|
+
requires(forall(k0, 0, MLDSA_K, array_bound(v->vec[k0].coeffs, 0, MLDSA_N, 0, 1 << 10)))
|
|
258
|
+
assigns(memory_slice(v, sizeof(mld_polyveck)))
|
|
259
|
+
ensures(forall(k1, 0, MLDSA_K, array_bound(v->vec[k1].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
#define mld_polyveck_ntt MLD_NAMESPACE_KL(polyveck_ntt)
|
|
263
|
+
/*************************************************
|
|
264
|
+
* Name: mld_polyveck_ntt
|
|
265
|
+
*
|
|
266
|
+
* Description: Forward NTT of all polynomials in vector of length MLDSA_K.
|
|
267
|
+
* Coefficients can grow by 8*MLDSA_Q in absolute value.
|
|
268
|
+
*
|
|
269
|
+
* Arguments: - mld_polyveck *v: pointer to input/output vector
|
|
270
|
+
**************************************************/
|
|
271
|
+
MLD_INTERNAL_API
|
|
272
|
+
void mld_polyveck_ntt(mld_polyveck *v)
|
|
273
|
+
__contract__(
|
|
274
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
275
|
+
requires(forall(k0, 0, MLDSA_K, array_abs_bound(v->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
276
|
+
assigns(memory_slice(v, sizeof(mld_polyveck)))
|
|
277
|
+
ensures(forall(k1, 0, MLDSA_K, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
#define mld_polyveck_invntt_tomont MLD_NAMESPACE_KL(polyveck_invntt_tomont)
|
|
281
|
+
/*************************************************
|
|
282
|
+
* Name: mld_polyveck_invntt_tomont
|
|
283
|
+
*
|
|
284
|
+
* Description: Inverse NTT and multiplication by 2^{32} of polynomials
|
|
285
|
+
* in vector of length MLDSA_K.
|
|
286
|
+
* Input coefficients need to be less than MLDSA_Q, and
|
|
287
|
+
* Output coefficients are bounded by MLD_INTT_BOUND.
|
|
288
|
+
* Arguments: - mld_polyveck *v: pointer to input/output vector
|
|
289
|
+
**************************************************/
|
|
290
|
+
MLD_INTERNAL_API
|
|
291
|
+
void mld_polyveck_invntt_tomont(mld_polyveck *v)
|
|
292
|
+
__contract__(
|
|
293
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
294
|
+
requires(forall(k0, 0, MLDSA_K, array_abs_bound(v->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
295
|
+
assigns(memory_slice(v, sizeof(mld_polyveck)))
|
|
296
|
+
ensures(forall(k1, 0, MLDSA_K, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLD_INTT_BOUND)))
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
#define mld_polyveck_pointwise_poly_montgomery \
|
|
300
|
+
MLD_NAMESPACE_KL(polyveck_pointwise_poly_montgomery)
|
|
301
|
+
/*************************************************
|
|
302
|
+
* Name: mld_polyveck_pointwise_poly_montgomery
|
|
303
|
+
*
|
|
304
|
+
* Description: Pointwise multiplication of a polynomial vector of length
|
|
305
|
+
* MLDSA_K by a single polynomial in NTT domain and multiplication
|
|
306
|
+
* of the resulting polynomial vector by 2^{-32}.
|
|
307
|
+
*
|
|
308
|
+
* Arguments: - mld_polyveck *r: pointer to output vector
|
|
309
|
+
* - mld_poly *a: pointer to input polynomial
|
|
310
|
+
* - mld_polyveck *v: pointer to input vector
|
|
311
|
+
**************************************************/
|
|
312
|
+
MLD_INTERNAL_API
|
|
313
|
+
void mld_polyveck_pointwise_poly_montgomery(mld_polyveck *r, const mld_poly *a,
|
|
314
|
+
const mld_polyveck *v)
|
|
315
|
+
__contract__(
|
|
316
|
+
requires(memory_no_alias(r, sizeof(mld_polyveck)))
|
|
317
|
+
requires(memory_no_alias(a, sizeof(mld_poly)))
|
|
318
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
319
|
+
requires(array_abs_bound(a->coeffs, 0, MLDSA_N, MLD_NTT_BOUND))
|
|
320
|
+
requires(forall(k0, 0, MLDSA_K, array_abs_bound(v->vec[k0].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
|
|
321
|
+
assigns(memory_slice(r, sizeof(mld_polyveck)))
|
|
322
|
+
ensures(forall(k1, 0, MLDSA_K, array_abs_bound(r->vec[k1].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
#define mld_polyveck_chknorm MLD_NAMESPACE_KL(polyveck_chknorm)
|
|
326
|
+
/*************************************************
|
|
327
|
+
* Name: mld_polyveck_chknorm
|
|
328
|
+
*
|
|
329
|
+
* Description: Check infinity norm of polynomials in vector of length MLDSA_K.
|
|
330
|
+
* Assumes input mld_polyveck to be reduced by polyveck_reduce().
|
|
331
|
+
*
|
|
332
|
+
* Arguments: - const mld_polyveck *v: pointer to vector
|
|
333
|
+
* - int32_t B: norm bound
|
|
334
|
+
*
|
|
335
|
+
* Returns 0 if norm of all polynomials are strictly smaller than B <=
|
|
336
|
+
*(MLDSA_Q-1)/8 and 0xFFFFFFFF otherwise.
|
|
337
|
+
**************************************************/
|
|
338
|
+
MLD_INTERNAL_API
|
|
339
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
340
|
+
uint32_t mld_polyveck_chknorm(const mld_polyveck *v, int32_t B)
|
|
341
|
+
__contract__(
|
|
342
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
343
|
+
requires(0 <= B && B <= (MLDSA_Q - 1) / 8)
|
|
344
|
+
requires(forall(k0, 0, MLDSA_K,
|
|
345
|
+
array_bound(v->vec[k0].coeffs, 0, MLDSA_N,
|
|
346
|
+
-MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
|
|
347
|
+
ensures(return_value == 0 || return_value == 0xFFFFFFFF)
|
|
348
|
+
ensures((return_value == 0) == forall(k1, 0, MLDSA_K, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, B)))
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
#define mld_polyveck_power2round MLD_NAMESPACE_KL(polyveck_power2round)
|
|
352
|
+
/*************************************************
|
|
353
|
+
* Name: mld_polyveck_power2round
|
|
354
|
+
*
|
|
355
|
+
* Description: For all coefficients a of polynomials in vector of length
|
|
356
|
+
*MLDSA_K, compute a0, a1 such that a mod^+ MLDSA_Q = a1*2^MLDSA_D + a0 with
|
|
357
|
+
*-2^{MLDSA_D-1} < a0 <= 2^{MLDSA_D-1}. Assumes coefficients to be standard
|
|
358
|
+
*representatives.
|
|
359
|
+
*
|
|
360
|
+
* Arguments: - mld_polyveck *v1: pointer to output vector of polynomials with
|
|
361
|
+
* coefficients a1
|
|
362
|
+
* - mld_polyveck *v0: pointer to output vector of polynomials with
|
|
363
|
+
* coefficients a0
|
|
364
|
+
* - const mld_polyveck *v: pointer to input vector
|
|
365
|
+
**************************************************/
|
|
366
|
+
MLD_INTERNAL_API
|
|
367
|
+
void mld_polyveck_power2round(mld_polyveck *v1, mld_polyveck *v0,
|
|
368
|
+
const mld_polyveck *v)
|
|
369
|
+
__contract__(
|
|
370
|
+
requires(memory_no_alias(v1, sizeof(mld_polyveck)))
|
|
371
|
+
requires(memory_no_alias(v0, sizeof(mld_polyveck)))
|
|
372
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
373
|
+
requires(forall(k0, 0, MLDSA_K, array_bound(v->vec[k0].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
374
|
+
assigns(memory_slice(v1, sizeof(mld_polyveck)))
|
|
375
|
+
assigns(memory_slice(v0, sizeof(mld_polyveck)))
|
|
376
|
+
ensures(forall(k1, 0, MLDSA_K, array_bound(v0->vec[k1].coeffs, 0, MLDSA_N, -(MLD_2_POW_D/2)+1, (MLD_2_POW_D/2)+1)))
|
|
377
|
+
ensures(forall(k2, 0, MLDSA_K, array_bound(v1->vec[k2].coeffs, 0, MLDSA_N, 0, ((MLDSA_Q - 1) / MLD_2_POW_D) + 1)))
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
#define mld_polyveck_decompose MLD_NAMESPACE_KL(polyveck_decompose)
|
|
381
|
+
/*************************************************
|
|
382
|
+
* Name: mld_polyveck_decompose
|
|
383
|
+
*
|
|
384
|
+
* Description: For all coefficients a of polynomials in vector of length
|
|
385
|
+
* MLDSA_K, compute high and low bits a0, a1 such a mod^+ MLDSA_Q = a1*ALPHA
|
|
386
|
+
* + a0 with -ALPHA/2 < a0 <= ALPHA/2 except a1 = (MLDSA_Q-1)/ALPHA where we set
|
|
387
|
+
* a1 = 0 and -ALPHA/2 <= a0 = a mod MLDSA_Q - MLDSA_Q < 0. Assumes coefficients
|
|
388
|
+
* to be standard representatives.
|
|
389
|
+
*
|
|
390
|
+
* Arguments: - mld_polyveck *v1: pointer to output vector of polynomials with
|
|
391
|
+
* coefficients a1
|
|
392
|
+
* - mld_polyveck *v0: pointer to input/output vector of
|
|
393
|
+
* polynomials with. Output polynomial has
|
|
394
|
+
* coefficients a0
|
|
395
|
+
*
|
|
396
|
+
* Reference: The reference implementation has the input polynomial as a
|
|
397
|
+
* separate argument that may be aliased with either of the outputs.
|
|
398
|
+
* Removing the aliasing eases CBMC proofs.
|
|
399
|
+
*
|
|
400
|
+
**************************************************/
|
|
401
|
+
MLD_INTERNAL_API
|
|
402
|
+
void mld_polyveck_decompose(mld_polyveck *v1, mld_polyveck *v0)
|
|
403
|
+
__contract__(
|
|
404
|
+
requires(memory_no_alias(v1, sizeof(mld_polyveck)))
|
|
405
|
+
requires(memory_no_alias(v0, sizeof(mld_polyveck)))
|
|
406
|
+
requires(forall(k0, 0, MLDSA_K,
|
|
407
|
+
array_bound(v0->vec[k0].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
408
|
+
assigns(memory_slice(v1, sizeof(mld_polyveck)))
|
|
409
|
+
assigns(memory_slice(v0, sizeof(mld_polyveck)))
|
|
410
|
+
ensures(forall(k1, 0, MLDSA_K,
|
|
411
|
+
array_bound(v1->vec[k1].coeffs, 0, MLDSA_N, 0, (MLDSA_Q-1)/(2*MLDSA_GAMMA2))))
|
|
412
|
+
ensures(forall(k2, 0, MLDSA_K,
|
|
413
|
+
array_abs_bound(v0->vec[k2].coeffs, 0, MLDSA_N, MLDSA_GAMMA2+1)))
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
#define mld_polyveck_make_hint MLD_NAMESPACE_KL(polyveck_make_hint)
|
|
417
|
+
/*************************************************
|
|
418
|
+
* Name: mld_polyveck_make_hint
|
|
419
|
+
*
|
|
420
|
+
* Description: Compute hint vector.
|
|
421
|
+
*
|
|
422
|
+
* Arguments: - mld_polyveck *h: pointer to output vector
|
|
423
|
+
* - const mld_polyveck *v0: pointer to low part of input vector
|
|
424
|
+
* - const mld_polyveck *v1: pointer to high part of input vector
|
|
425
|
+
*
|
|
426
|
+
* Returns number of 1 bits.
|
|
427
|
+
**************************************************/
|
|
428
|
+
MLD_INTERNAL_API
|
|
429
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
430
|
+
unsigned int mld_polyveck_make_hint(mld_polyveck *h, const mld_polyveck *v0,
|
|
431
|
+
const mld_polyveck *v1)
|
|
432
|
+
__contract__(
|
|
433
|
+
requires(memory_no_alias(h, sizeof(mld_polyveck)))
|
|
434
|
+
requires(memory_no_alias(v0, sizeof(mld_polyveck)))
|
|
435
|
+
requires(memory_no_alias(v1, sizeof(mld_polyveck)))
|
|
436
|
+
assigns(memory_slice(h, sizeof(mld_polyveck)))
|
|
437
|
+
ensures(return_value <= MLDSA_N * MLDSA_K)
|
|
438
|
+
ensures(forall(k1, 0, MLDSA_K, array_bound(h->vec[k1].coeffs, 0, MLDSA_N, 0, 2)))
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
#define mld_polyveck_use_hint MLD_NAMESPACE_KL(polyveck_use_hint)
|
|
442
|
+
/*************************************************
|
|
443
|
+
* Name: mld_polyveck_use_hint
|
|
444
|
+
*
|
|
445
|
+
* Description: Use hint vector to correct the high bits of input vector.
|
|
446
|
+
*
|
|
447
|
+
* Arguments: - mld_polyveck *w: pointer to output vector of polynomials with
|
|
448
|
+
* corrected high bits
|
|
449
|
+
* - const mld_polyveck *u: pointer to input vector
|
|
450
|
+
* - const mld_polyveck *h: pointer to input hint vector
|
|
451
|
+
**************************************************/
|
|
452
|
+
MLD_INTERNAL_API
|
|
453
|
+
void mld_polyveck_use_hint(mld_polyveck *w, const mld_polyveck *v,
|
|
454
|
+
const mld_polyveck *h)
|
|
455
|
+
__contract__(
|
|
456
|
+
requires(memory_no_alias(w, sizeof(mld_polyveck)))
|
|
457
|
+
requires(memory_no_alias(v, sizeof(mld_polyveck)))
|
|
458
|
+
requires(memory_no_alias(h, sizeof(mld_polyveck)))
|
|
459
|
+
requires(forall(k0, 0, MLDSA_K,
|
|
460
|
+
array_bound(v->vec[k0].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
|
|
461
|
+
requires(forall(k1, 0, MLDSA_K,
|
|
462
|
+
array_bound(h->vec[k1].coeffs, 0, MLDSA_N, 0, 2)))
|
|
463
|
+
assigns(memory_slice(w, sizeof(mld_polyveck)))
|
|
464
|
+
ensures(forall(k2, 0, MLDSA_K,
|
|
465
|
+
array_bound(w->vec[k2].coeffs, 0, MLDSA_N, 0, (MLDSA_Q-1)/(2*MLDSA_GAMMA2))))
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
#define mld_polyveck_pack_w1 MLD_NAMESPACE_KL(polyveck_pack_w1)
|
|
469
|
+
/*************************************************
|
|
470
|
+
* Name: mld_polyveck_pack_w1
|
|
471
|
+
*
|
|
472
|
+
* Description: Bit-pack polynomial vector w1 with coefficients in [0,15] or
|
|
473
|
+
* [0,43].
|
|
474
|
+
* Input coefficients are assumed to be standard representatives.
|
|
475
|
+
*
|
|
476
|
+
* Arguments: - uint8_t *r: pointer to output byte array with at least
|
|
477
|
+
* MLDSA_K* MLDSA_POLYW1_PACKEDBYTES bytes
|
|
478
|
+
* - const mld_polyveck *a: pointer to input polynomial vector
|
|
479
|
+
**************************************************/
|
|
480
|
+
MLD_INTERNAL_API
|
|
481
|
+
void mld_polyveck_pack_w1(uint8_t r[MLDSA_K * MLDSA_POLYW1_PACKEDBYTES],
|
|
482
|
+
const mld_polyveck *w1)
|
|
483
|
+
__contract__(
|
|
484
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
485
|
+
requires(memory_no_alias(w1, sizeof(mld_polyveck)))
|
|
486
|
+
requires(forall(k1, 0, MLDSA_K,
|
|
487
|
+
array_bound(w1->vec[k1].coeffs, 0, MLDSA_N, 0, (MLDSA_Q-1)/(2*MLDSA_GAMMA2))))
|
|
488
|
+
assigns(memory_slice(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
#define mld_polyveck_pack_eta MLD_NAMESPACE_KL(polyveck_pack_eta)
|
|
492
|
+
/*************************************************
|
|
493
|
+
* Name: mld_polyveck_pack_eta
|
|
494
|
+
*
|
|
495
|
+
* Description: Bit-pack polynomial vector with coefficients
|
|
496
|
+
* in [-MLDSA_ETA,MLDSA_ETA].
|
|
497
|
+
*
|
|
498
|
+
* Arguments: - uint8_t *r: pointer to output byte array with
|
|
499
|
+
* MLDSA_K * MLDSA_POLYETA_PACKEDBYTES bytes
|
|
500
|
+
* - const polyveck *p: pointer to input polynomial vector
|
|
501
|
+
**************************************************/
|
|
502
|
+
MLD_INTERNAL_API
|
|
503
|
+
void mld_polyveck_pack_eta(uint8_t r[MLDSA_K * MLDSA_POLYETA_PACKEDBYTES],
|
|
504
|
+
const mld_polyveck *p)
|
|
505
|
+
__contract__(
|
|
506
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
|
|
507
|
+
requires(memory_no_alias(p, sizeof(mld_polyveck)))
|
|
508
|
+
requires(forall(k1, 0, MLDSA_K,
|
|
509
|
+
array_abs_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLDSA_ETA + 1)))
|
|
510
|
+
assigns(memory_slice(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
#define mld_polyvecl_pack_eta MLD_NAMESPACE_KL(polyvecl_pack_eta)
|
|
514
|
+
/*************************************************
|
|
515
|
+
* Name: mld_polyvecl_pack_eta
|
|
516
|
+
*
|
|
517
|
+
* Description: Bit-pack polynomial vector with coefficients in
|
|
518
|
+
* [-MLDSA_ETA,MLDSA_ETA].
|
|
519
|
+
*
|
|
520
|
+
* Arguments: - uint8_t *r: pointer to output byte array with
|
|
521
|
+
* MLDSA_L * MLDSA_POLYETA_PACKEDBYTES bytes
|
|
522
|
+
* - const polyveck *p: pointer to input polynomial vector
|
|
523
|
+
**************************************************/
|
|
524
|
+
MLD_INTERNAL_API
|
|
525
|
+
void mld_polyvecl_pack_eta(uint8_t r[MLDSA_L * MLDSA_POLYETA_PACKEDBYTES],
|
|
526
|
+
const mld_polyvecl *p)
|
|
527
|
+
__contract__(
|
|
528
|
+
requires(memory_no_alias(r, MLDSA_L * MLDSA_POLYETA_PACKEDBYTES))
|
|
529
|
+
requires(memory_no_alias(p, sizeof(mld_polyvecl)))
|
|
530
|
+
requires(forall(k1, 0, MLDSA_L,
|
|
531
|
+
array_abs_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLDSA_ETA + 1)))
|
|
532
|
+
assigns(memory_slice(r, MLDSA_L * MLDSA_POLYETA_PACKEDBYTES))
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
#define mld_polyveck_pack_t0 MLD_NAMESPACE_KL(polyveck_pack_t0)
|
|
536
|
+
/*************************************************
|
|
537
|
+
* Name: mld_polyveck_pack_t0
|
|
538
|
+
*
|
|
539
|
+
* Description: Bit-pack polynomial vector to with coefficients in
|
|
540
|
+
* ]-2^{MLDSA_D-1}, 2^{MLDSA_D-1}].
|
|
541
|
+
*
|
|
542
|
+
* Arguments: - uint8_t *r: pointer to output byte array with
|
|
543
|
+
* MLDSA_K * MLDSA_POLYT0_PACKEDBYTES bytes
|
|
544
|
+
* - const mld_poly *p: pointer to input polynomial vector
|
|
545
|
+
**************************************************/
|
|
546
|
+
MLD_INTERNAL_API
|
|
547
|
+
void mld_polyveck_pack_t0(uint8_t r[MLDSA_K * MLDSA_POLYT0_PACKEDBYTES],
|
|
548
|
+
const mld_polyveck *p)
|
|
549
|
+
__contract__(
|
|
550
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYT0_PACKEDBYTES))
|
|
551
|
+
requires(memory_no_alias(p, sizeof(mld_polyveck)))
|
|
552
|
+
requires(forall(k0, 0, MLDSA_K,
|
|
553
|
+
array_bound(p->vec[k0].coeffs, 0, MLDSA_N, -(1<<(MLDSA_D-1)) + 1, (1<<(MLDSA_D-1)) + 1)))
|
|
554
|
+
assigns(memory_slice(r, MLDSA_K * MLDSA_POLYT0_PACKEDBYTES))
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
#define mld_polyvecl_unpack_eta MLD_NAMESPACE_KL(polyvecl_unpack_eta)
|
|
558
|
+
/*************************************************
|
|
559
|
+
* Name: mld_polyvecl_unpack_eta
|
|
560
|
+
*
|
|
561
|
+
* Description: Unpack polynomial vector with coefficients in
|
|
562
|
+
* [-MLDSA_ETA,MLDSA_ETA].
|
|
563
|
+
*
|
|
564
|
+
* Arguments: - mld_polyvecl *p: pointer to output polynomial vector
|
|
565
|
+
* - const uint8_t *r: input byte array with
|
|
566
|
+
* bit-packed polynomial vector
|
|
567
|
+
**************************************************/
|
|
568
|
+
MLD_INTERNAL_API
|
|
569
|
+
void mld_polyvecl_unpack_eta(
|
|
570
|
+
mld_polyvecl *p, const uint8_t r[MLDSA_L * MLDSA_POLYETA_PACKEDBYTES])
|
|
571
|
+
__contract__(
|
|
572
|
+
requires(memory_no_alias(r, MLDSA_L * MLDSA_POLYETA_PACKEDBYTES))
|
|
573
|
+
requires(memory_no_alias(p, sizeof(mld_polyvecl)))
|
|
574
|
+
assigns(memory_slice(p, sizeof(mld_polyvecl)))
|
|
575
|
+
ensures(forall(k1, 0, MLDSA_L,
|
|
576
|
+
array_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLD_POLYETA_UNPACK_LOWER_BOUND, MLDSA_ETA + 1)))
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
#define mld_polyvecl_unpack_z MLD_NAMESPACE_KL(polyvecl_unpack_z)
|
|
580
|
+
/*************************************************
|
|
581
|
+
* Name: mld_polyvecl_unpack_z
|
|
582
|
+
*
|
|
583
|
+
* Description: Unpack polynomial vector with coefficients in
|
|
584
|
+
* [-(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1].
|
|
585
|
+
*
|
|
586
|
+
* Arguments: - mld_polyvecl *z: pointer to output polynomial vector
|
|
587
|
+
* - const uint8_t *r: input byte array with
|
|
588
|
+
* bit-packed polynomial vector
|
|
589
|
+
**************************************************/
|
|
590
|
+
MLD_INTERNAL_API
|
|
591
|
+
void mld_polyvecl_unpack_z(mld_polyvecl *z,
|
|
592
|
+
const uint8_t r[MLDSA_L * MLDSA_POLYZ_PACKEDBYTES])
|
|
593
|
+
__contract__(
|
|
594
|
+
requires(memory_no_alias(r, MLDSA_L * MLDSA_POLYZ_PACKEDBYTES))
|
|
595
|
+
requires(memory_no_alias(z, sizeof(mld_polyvecl)))
|
|
596
|
+
assigns(memory_slice(z, sizeof(mld_polyvecl)))
|
|
597
|
+
ensures(forall(k1, 0, MLDSA_L,
|
|
598
|
+
array_bound(z->vec[k1].coeffs, 0, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1)))
|
|
599
|
+
);
|
|
600
|
+
|
|
601
|
+
#define mld_polyveck_unpack_eta MLD_NAMESPACE_KL(polyveck_unpack_eta)
|
|
602
|
+
/*************************************************
|
|
603
|
+
* Name: mld_polyveck_unpack_eta
|
|
604
|
+
*
|
|
605
|
+
* Description: Unpack polynomial vector with coefficients in
|
|
606
|
+
* [-MLDSA_ETA,MLDSA_ETA].
|
|
607
|
+
*
|
|
608
|
+
* Arguments: - mld_polyveck *p: pointer to output polynomial vector
|
|
609
|
+
* - const uint8_t *r: input byte array with
|
|
610
|
+
* bit-packed polynomial vector
|
|
611
|
+
**************************************************/
|
|
612
|
+
MLD_INTERNAL_API
|
|
613
|
+
void mld_polyveck_unpack_eta(
|
|
614
|
+
mld_polyveck *p, const uint8_t r[MLDSA_K * MLDSA_POLYETA_PACKEDBYTES])
|
|
615
|
+
__contract__(
|
|
616
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
|
|
617
|
+
requires(memory_no_alias(p, sizeof(mld_polyveck)))
|
|
618
|
+
assigns(memory_slice(p, sizeof(mld_polyveck)))
|
|
619
|
+
ensures(forall(k1, 0, MLDSA_K,
|
|
620
|
+
array_bound(p->vec[k1].coeffs, 0, MLDSA_N, MLD_POLYETA_UNPACK_LOWER_BOUND, MLDSA_ETA + 1)))
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
#define mld_polyveck_unpack_t0 MLD_NAMESPACE_KL(polyveck_unpack_t0)
|
|
624
|
+
/*************************************************
|
|
625
|
+
* Name: mld_polyveck_unpack_t0
|
|
626
|
+
*
|
|
627
|
+
* Description: Unpack polynomial vector with coefficients in
|
|
628
|
+
* ]-2^{MLDSA_D-1}, 2^{MLDSA_D-1}].
|
|
629
|
+
*
|
|
630
|
+
* Arguments: - mld_polyveck *p: pointer to output polynomial vector
|
|
631
|
+
* - const uint8_t *r: input byte array with
|
|
632
|
+
* bit-packed polynomial vector
|
|
633
|
+
**************************************************/
|
|
634
|
+
MLD_INTERNAL_API
|
|
635
|
+
void mld_polyveck_unpack_t0(mld_polyveck *p,
|
|
636
|
+
const uint8_t r[MLDSA_K * MLDSA_POLYT0_PACKEDBYTES])
|
|
637
|
+
__contract__(
|
|
638
|
+
requires(memory_no_alias(r, MLDSA_K * MLDSA_POLYT0_PACKEDBYTES))
|
|
639
|
+
requires(memory_no_alias(p, sizeof(mld_polyveck)))
|
|
640
|
+
assigns(memory_slice(p, sizeof(mld_polyveck)))
|
|
641
|
+
ensures(forall(k1, 0, MLDSA_K,
|
|
642
|
+
array_bound(p->vec[k1].coeffs, 0, MLDSA_N, -(1<<(MLDSA_D-1)) + 1, (1<<(MLDSA_D-1)) + 1)))
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
#define mld_polymat_get_row MLD_NAMESPACE_KL(polymat_get_row)
|
|
646
|
+
/*************************************************
|
|
647
|
+
* Name: mld_polymat_get_row
|
|
648
|
+
*
|
|
649
|
+
* Description: Retrieve a pointer to a specific row of the matrix.
|
|
650
|
+
* In MLD_CONFIG_REDUCE_RAM mode, generates the row on-demand.
|
|
651
|
+
*
|
|
652
|
+
* Arguments: - mld_polymat *mat: pointer to matrix
|
|
653
|
+
* - unsigned int row: row index (must be < MLDSA_K)
|
|
654
|
+
*
|
|
655
|
+
* Returns pointer to the row (mld_polyvecl)
|
|
656
|
+
**************************************************/
|
|
657
|
+
MLD_INTERNAL_API
|
|
658
|
+
MLD_MUST_CHECK_RETURN_VALUE
|
|
659
|
+
const mld_polyvecl *mld_polymat_get_row(mld_polymat *mat, unsigned int row);
|
|
660
|
+
|
|
661
|
+
#define mld_polyvec_matrix_expand MLD_NAMESPACE_KL(polyvec_matrix_expand)
|
|
662
|
+
/*************************************************
|
|
663
|
+
* Name: mld_polyvec_matrix_expand
|
|
664
|
+
*
|
|
665
|
+
* Description: Implementation of ExpandA. Generates matrix A with uniformly
|
|
666
|
+
* random coefficients a_{i,j} by performing rejection
|
|
667
|
+
* sampling on the output stream of SHAKE128(rho|j|i)
|
|
668
|
+
*
|
|
669
|
+
* Arguments: - mld_polymat *mat: pointer to output matrix
|
|
670
|
+
* - const uint8_t rho[]: byte array containing seed rho
|
|
671
|
+
**************************************************/
|
|
672
|
+
MLD_INTERNAL_API
|
|
673
|
+
void mld_polyvec_matrix_expand(mld_polymat *mat,
|
|
674
|
+
const uint8_t rho[MLDSA_SEEDBYTES])
|
|
675
|
+
__contract__(
|
|
676
|
+
requires(memory_no_alias(mat, sizeof(mld_polymat)))
|
|
677
|
+
requires(memory_no_alias(rho, MLDSA_SEEDBYTES))
|
|
678
|
+
assigns(memory_slice(mat, sizeof(mld_polymat)))
|
|
679
|
+
ensures(forall(k1, 0, MLDSA_K, forall(l1, 0, MLDSA_L,
|
|
680
|
+
array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
|
|
681
|
+
);
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
#define mld_polyvec_matrix_pointwise_montgomery \
|
|
686
|
+
MLD_NAMESPACE_KL(polyvec_matrix_pointwise_montgomery)
|
|
687
|
+
/*************************************************
|
|
688
|
+
* Name: mld_polyvec_matrix_pointwise_montgomery
|
|
689
|
+
*
|
|
690
|
+
* Description: Compute matrix-vector multiplication in NTT domain with
|
|
691
|
+
* pointwise multiplication and multiplication by 2^{-32}.
|
|
692
|
+
* Input matrix and vector must be in NTT domain representation.
|
|
693
|
+
*
|
|
694
|
+
* The first input "mat" must be the output of
|
|
695
|
+
* polyvec_matrix_expand() and so have coefficients in [0, Q-1]
|
|
696
|
+
* inclusive.
|
|
697
|
+
*
|
|
698
|
+
* The second input "v" is assumed to be output of an NTT, and
|
|
699
|
+
* hence must have coefficients bounded by [-9q+1, +9q-1]
|
|
700
|
+
* inclusive.
|
|
701
|
+
*
|
|
702
|
+
* Note: In MLD_CONFIG_REDUCE_RAM mode, mat cannot be const
|
|
703
|
+
* as rows are generated on-demand.
|
|
704
|
+
*
|
|
705
|
+
* Arguments: - mld_polyveck *t: pointer to output vector t
|
|
706
|
+
* - mld_polymat *mat: pointer to input matrix
|
|
707
|
+
* - const mld_polyvecl *v: pointer to input vector v
|
|
708
|
+
**************************************************/
|
|
709
|
+
MLD_INTERNAL_API
|
|
710
|
+
void mld_polyvec_matrix_pointwise_montgomery(mld_polyveck *t, mld_polymat *mat,
|
|
711
|
+
const mld_polyvecl *v)
|
|
712
|
+
__contract__(
|
|
713
|
+
requires(memory_no_alias(t, sizeof(mld_polyveck)))
|
|
714
|
+
requires(memory_no_alias(mat, sizeof(mld_polymat)))
|
|
715
|
+
requires(memory_no_alias(v, sizeof(mld_polyvecl)))
|
|
716
|
+
requires(forall(k1, 0, MLDSA_K, forall(l1, 0, MLDSA_L,
|
|
717
|
+
array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
|
|
718
|
+
requires(forall(l1, 0, MLDSA_L,
|
|
719
|
+
array_abs_bound(v->vec[l1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
|
|
720
|
+
assigns(memory_slice(t, sizeof(mld_polyveck)))
|
|
721
|
+
ensures(forall(k0, 0, MLDSA_K,
|
|
722
|
+
array_abs_bound(t->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
#endif /* !MLD_POLYVEC_H */
|