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,688 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* References
|
|
7
|
+
* ==========
|
|
8
|
+
*
|
|
9
|
+
* - [FIPS203]
|
|
10
|
+
* FIPS 203 Module-Lattice-Based Key-Encapsulation Mechanism Standard
|
|
11
|
+
* National Institute of Standards and Technology
|
|
12
|
+
* https://csrc.nist.gov/pubs/fips/203/final
|
|
13
|
+
*
|
|
14
|
+
* - [REF]
|
|
15
|
+
* CRYSTALS-Kyber C reference implementation
|
|
16
|
+
* Bos, Ducas, Kiltz, Lepoint, Lyubashevsky, Schanck, Schwabe, Seiler, Stehlé
|
|
17
|
+
* https://github.com/pq-crystals/kyber/tree/main/ref
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#ifndef MLK_COMPRESS_H
|
|
21
|
+
#define MLK_COMPRESS_H
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#include "cbmc.h"
|
|
25
|
+
#include "common.h"
|
|
26
|
+
#include "debug.h"
|
|
27
|
+
#include "poly.h"
|
|
28
|
+
#include "verify.h"
|
|
29
|
+
|
|
30
|
+
/************************************************************
|
|
31
|
+
* Name: mlk_scalar_compress_d1
|
|
32
|
+
*
|
|
33
|
+
* Description: Computes round(u * 2 / q)
|
|
34
|
+
*
|
|
35
|
+
* Arguments: - u: Unsigned canonical modulus modulo q
|
|
36
|
+
* to be compressed.
|
|
37
|
+
*
|
|
38
|
+
* Specification: Compress_1 from @[FIPS203, Eq (4.7)].
|
|
39
|
+
*
|
|
40
|
+
************************************************************/
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* The multiplication in this routine will exceed UINT32_MAX
|
|
44
|
+
* and wrap around for large values of u. This is expected and required.
|
|
45
|
+
*/
|
|
46
|
+
#ifdef CBMC
|
|
47
|
+
#pragma CPROVER check push
|
|
48
|
+
#pragma CPROVER check disable "unsigned-overflow"
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
/* Reference: Part of poly_tomsg() in the reference implementation @[REF]. */
|
|
52
|
+
static MLK_INLINE uint8_t mlk_scalar_compress_d1(int16_t u)
|
|
53
|
+
__contract__(
|
|
54
|
+
requires(0 <= u && u <= MLKEM_Q - 1)
|
|
55
|
+
ensures(return_value < 2)
|
|
56
|
+
ensures(return_value == (((uint32_t)u * 2 + MLKEM_Q / 2) / MLKEM_Q) % 2) )
|
|
57
|
+
{
|
|
58
|
+
/* Compute as follows:
|
|
59
|
+
* ```
|
|
60
|
+
* round(u * 2 / MLKEM_Q)
|
|
61
|
+
* = round(u * 2 * (2^31 / MLKEM_Q) / 2^31)
|
|
62
|
+
* ~= round(u * 2 * round(2^31 / MLKEM_Q) / 2^31)
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
/* check-magic: 1290168 == 2*round(2^31 / MLKEM_Q) */
|
|
66
|
+
uint32_t d0 = (uint32_t)u * 1290168;
|
|
67
|
+
/* Unsigned shifting by 31 positions leaves only the top bit. */
|
|
68
|
+
return (uint8_t)((d0 + ((uint32_t)1u << 30)) >> 31);
|
|
69
|
+
}
|
|
70
|
+
#ifdef CBMC
|
|
71
|
+
#pragma CPROVER check pop
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
/************************************************************
|
|
75
|
+
* Name: mlk_scalar_compress_d4
|
|
76
|
+
*
|
|
77
|
+
* Description: Computes round(u * 16 / q) % 16
|
|
78
|
+
*
|
|
79
|
+
* Arguments: - u: Unsigned canonical modulus modulo q
|
|
80
|
+
* to be compressed.
|
|
81
|
+
*
|
|
82
|
+
* Specification: Compress_4 from @[FIPS203, Eq (4.7)].
|
|
83
|
+
*
|
|
84
|
+
************************************************************/
|
|
85
|
+
/*
|
|
86
|
+
* The multiplication in this routine will exceed UINT32_MAX
|
|
87
|
+
* and wrap around for large values of u. This is expected and required.
|
|
88
|
+
*/
|
|
89
|
+
#ifdef CBMC
|
|
90
|
+
#pragma CPROVER check push
|
|
91
|
+
#pragma CPROVER check disable "unsigned-overflow"
|
|
92
|
+
#endif
|
|
93
|
+
|
|
94
|
+
/* Reference: Embedded into `poly_compress()` in the
|
|
95
|
+
* reference implementation @[REF]. */
|
|
96
|
+
static MLK_INLINE uint8_t mlk_scalar_compress_d4(int16_t u)
|
|
97
|
+
__contract__(
|
|
98
|
+
requires(0 <= u && u <= MLKEM_Q - 1)
|
|
99
|
+
ensures(return_value < 16)
|
|
100
|
+
ensures(return_value == (((uint32_t)u * 16 + MLKEM_Q / 2) / MLKEM_Q) % 16))
|
|
101
|
+
{
|
|
102
|
+
/* Compute as follows:
|
|
103
|
+
* ```
|
|
104
|
+
* round(u * 16 / MLKEM_Q)
|
|
105
|
+
* = round(u * 16 * (2^28 / MLKEM_Q) / 2^28)
|
|
106
|
+
* ~= round(u * 16 * round(2^28 / MLKEM_Q) / 2^28)
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
/* check-magic: 1290160 == 16 * round(2^28 / MLKEM_Q) */
|
|
110
|
+
uint32_t d0 = (uint32_t)u * 1290160;
|
|
111
|
+
/* The return value is < 16, so not altered by the conversion to uint8_t. */
|
|
112
|
+
return (uint8_t)((d0 + ((uint32_t)1u << 27)) >> 28); /* round(d0/2^28) */
|
|
113
|
+
}
|
|
114
|
+
#ifdef CBMC
|
|
115
|
+
#pragma CPROVER check pop
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
/************************************************************
|
|
119
|
+
* Name: mlk_scalar_decompress_d4
|
|
120
|
+
*
|
|
121
|
+
* Description: Computes round(u * q / 16)
|
|
122
|
+
*
|
|
123
|
+
* Arguments: - u: Unsigned canonical modulus modulo 16
|
|
124
|
+
* to be decompressed.
|
|
125
|
+
*
|
|
126
|
+
* Specification: Decompress_4 from @[FIPS203, Eq (4.8)].
|
|
127
|
+
*
|
|
128
|
+
************************************************************/
|
|
129
|
+
|
|
130
|
+
/* Reference: Embedded into `poly_decompress()` in the
|
|
131
|
+
* reference implementation @[REF]. */
|
|
132
|
+
static MLK_INLINE int16_t mlk_scalar_decompress_d4(uint8_t u)
|
|
133
|
+
__contract__(
|
|
134
|
+
requires(0 <= u && u < 16)
|
|
135
|
+
ensures(return_value <= (MLKEM_Q - 1))
|
|
136
|
+
)
|
|
137
|
+
{
|
|
138
|
+
/* The return value is in 0..MLKEM_Q-1, hence not altered by the
|
|
139
|
+
* conversion to int16_t. */
|
|
140
|
+
return (int16_t)((((uint32_t)u * MLKEM_Q) + 8) >> 4);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/************************************************************
|
|
144
|
+
* Name: mlk_scalar_compress_d5
|
|
145
|
+
*
|
|
146
|
+
* Description: Computes round(u * 32 / q) % 32
|
|
147
|
+
*
|
|
148
|
+
* Arguments: - u: Unsigned canonical modulus modulo q
|
|
149
|
+
* to be compressed.
|
|
150
|
+
*
|
|
151
|
+
* Specification: Compress_5 from @[FIPS203, Eq (4.7)].
|
|
152
|
+
*
|
|
153
|
+
************************************************************/
|
|
154
|
+
/*
|
|
155
|
+
* The multiplication in this routine will exceed UINT32_MAX
|
|
156
|
+
* and wrap around for large values of u. This is expected and required.
|
|
157
|
+
*/
|
|
158
|
+
#ifdef CBMC
|
|
159
|
+
#pragma CPROVER check push
|
|
160
|
+
#pragma CPROVER check disable "unsigned-overflow"
|
|
161
|
+
#endif
|
|
162
|
+
|
|
163
|
+
/* Reference: Embedded into `poly_compress()` in the
|
|
164
|
+
* reference implementation @[REF]. */
|
|
165
|
+
static MLK_INLINE uint8_t mlk_scalar_compress_d5(int16_t u)
|
|
166
|
+
__contract__(
|
|
167
|
+
requires(0 <= u && u <= MLKEM_Q - 1)
|
|
168
|
+
ensures(return_value < 32)
|
|
169
|
+
ensures(return_value == (((uint32_t)u * 32 + MLKEM_Q / 2) / MLKEM_Q) % 32) )
|
|
170
|
+
{
|
|
171
|
+
/* Compute as follows:
|
|
172
|
+
* ```
|
|
173
|
+
* round(u * 32 / MLKEM_Q)
|
|
174
|
+
* = round(u * 32 * (2^27 / MLKEM_Q) / 2^27)
|
|
175
|
+
* ~= round(u * 32 * round(2^27 / MLKEM_Q) / 2^27)
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
/* check-magic: 1290176 == 2^5 * round(2^27 / MLKEM_Q) */
|
|
179
|
+
uint32_t d0 = (uint32_t)u * 1290176;
|
|
180
|
+
/* The return value is < 32, so not altered by the conversion to uint8_t. */
|
|
181
|
+
return (uint8_t)((d0 + ((uint32_t)1u << 26)) >> 27); /* round(d0/2^27) */
|
|
182
|
+
}
|
|
183
|
+
#ifdef CBMC
|
|
184
|
+
#pragma CPROVER check pop
|
|
185
|
+
#endif
|
|
186
|
+
|
|
187
|
+
/************************************************************
|
|
188
|
+
* Name: mlk_scalar_decompress_d5
|
|
189
|
+
*
|
|
190
|
+
* Description: Computes round(u * q / 32)
|
|
191
|
+
*
|
|
192
|
+
* Arguments: - u: Unsigned canonical modulus modulo 32
|
|
193
|
+
* to be decompressed.
|
|
194
|
+
*
|
|
195
|
+
* Specification: Decompress_5 from @[FIPS203, Eq (4.8)].
|
|
196
|
+
*
|
|
197
|
+
************************************************************/
|
|
198
|
+
|
|
199
|
+
/* Reference: Embedded into `poly_decompress()` in the
|
|
200
|
+
* reference implementation @[REF]. */
|
|
201
|
+
static MLK_INLINE int16_t mlk_scalar_decompress_d5(uint8_t u)
|
|
202
|
+
__contract__(
|
|
203
|
+
requires(0 <= u && u < 32)
|
|
204
|
+
ensures(0 <= return_value && return_value <= MLKEM_Q - 1)
|
|
205
|
+
)
|
|
206
|
+
{
|
|
207
|
+
/* The return value is in 0..MLKEM_Q-1, hence not altered by the
|
|
208
|
+
* conversion to int16_t. */
|
|
209
|
+
return (int16_t)((((uint32_t)u * MLKEM_Q) + 16) >> 5);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/************************************************************
|
|
213
|
+
* Name: mlk_scalar_compress_d10
|
|
214
|
+
*
|
|
215
|
+
* Description: Computes round(u * 2**10 / q) % 2**10
|
|
216
|
+
*
|
|
217
|
+
* Arguments: - u: Unsigned canonical modulus modulo q
|
|
218
|
+
* to be compressed.
|
|
219
|
+
*
|
|
220
|
+
* Specification: Compress_10 from @[FIPS203, Eq (4.7)].
|
|
221
|
+
*
|
|
222
|
+
************************************************************/
|
|
223
|
+
/*
|
|
224
|
+
* The multiplication in this routine will exceed UINT32_MAX
|
|
225
|
+
* and wrap around for large values of u. This is expected and required.
|
|
226
|
+
*/
|
|
227
|
+
#ifdef CBMC
|
|
228
|
+
#pragma CPROVER check push
|
|
229
|
+
#pragma CPROVER check disable "unsigned-overflow"
|
|
230
|
+
#endif
|
|
231
|
+
|
|
232
|
+
/* Reference: Embedded into `polyvec_compress()` in the
|
|
233
|
+
* reference implementation @[REF]. */
|
|
234
|
+
static MLK_INLINE uint16_t mlk_scalar_compress_d10(int16_t u)
|
|
235
|
+
__contract__(
|
|
236
|
+
requires(0 <= u && u <= MLKEM_Q - 1)
|
|
237
|
+
ensures(return_value < (1u << 10))
|
|
238
|
+
ensures(return_value == (((uint32_t)u * (1u << 10) + MLKEM_Q / 2) / MLKEM_Q) % (1 << 10)))
|
|
239
|
+
{
|
|
240
|
+
/* Compute as follows:
|
|
241
|
+
* ```
|
|
242
|
+
* round(u * 1024 / MLKEM_Q)
|
|
243
|
+
* = round(u * 1024 * (2^33 / MLKEM_Q) / 2^33)
|
|
244
|
+
* ~= round(u * 1024 * round(2^33 / MLKEM_Q) / 2^33)
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
/* check-magic: 2642263040 == 2^10 * round(2^33 / MLKEM_Q) */
|
|
248
|
+
uint64_t d0 = (uint64_t)u * 2642263040;
|
|
249
|
+
d0 = (d0 + ((uint64_t)1u << 32)) >> 33; /* round(d0/2^33) */
|
|
250
|
+
return (d0 & 0x3FF);
|
|
251
|
+
}
|
|
252
|
+
#ifdef CBMC
|
|
253
|
+
#pragma CPROVER check pop
|
|
254
|
+
#endif
|
|
255
|
+
|
|
256
|
+
/************************************************************
|
|
257
|
+
* Name: mlk_scalar_decompress_d10
|
|
258
|
+
*
|
|
259
|
+
* Description: Computes round(u * q / 1024)
|
|
260
|
+
*
|
|
261
|
+
* Arguments: - u: Unsigned canonical modulus modulo 1024
|
|
262
|
+
* to be decompressed.
|
|
263
|
+
*
|
|
264
|
+
* Specification: Decompress_10 from @[FIPS203, Eq (4.8)].
|
|
265
|
+
*
|
|
266
|
+
************************************************************/
|
|
267
|
+
|
|
268
|
+
/* Reference: Embedded into `polyvec_decompress()` in the
|
|
269
|
+
* reference implementation @[REF]. */
|
|
270
|
+
static MLK_INLINE int16_t mlk_scalar_decompress_d10(uint16_t u)
|
|
271
|
+
__contract__(
|
|
272
|
+
requires(0 <= u && u < 1024)
|
|
273
|
+
ensures(0 <= return_value && return_value <= (MLKEM_Q - 1))
|
|
274
|
+
)
|
|
275
|
+
{
|
|
276
|
+
/* The return value is in 0..MLKEM_Q-1, hence not altered by the
|
|
277
|
+
* conversion to int16_t. */
|
|
278
|
+
return (int16_t)((((uint32_t)u * MLKEM_Q) + 512) >> 10);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/************************************************************
|
|
282
|
+
* Name: mlk_scalar_compress_d11
|
|
283
|
+
*
|
|
284
|
+
* Description: Computes round(u * 2**11 / q) % 2**11
|
|
285
|
+
*
|
|
286
|
+
* Arguments: - u: Unsigned canonical modulus modulo q
|
|
287
|
+
* to be compressed.
|
|
288
|
+
*
|
|
289
|
+
* Specification: Compress_11 from @[FIPS203, Eq (4.7)].
|
|
290
|
+
*
|
|
291
|
+
************************************************************/
|
|
292
|
+
/*
|
|
293
|
+
* The multiplication in this routine will exceed UINT32_MAX
|
|
294
|
+
* and wrap around for large values of u. This is expected and required.
|
|
295
|
+
*/
|
|
296
|
+
#ifdef CBMC
|
|
297
|
+
#pragma CPROVER check push
|
|
298
|
+
#pragma CPROVER check disable "unsigned-overflow"
|
|
299
|
+
#endif
|
|
300
|
+
|
|
301
|
+
/* Reference: Embedded into `polyvec_compress()` in the
|
|
302
|
+
* reference implementation @[REF]. */
|
|
303
|
+
static MLK_INLINE uint16_t mlk_scalar_compress_d11(int16_t u)
|
|
304
|
+
__contract__(
|
|
305
|
+
requires(0 <= u && u <= MLKEM_Q - 1)
|
|
306
|
+
ensures(return_value < (1u << 11))
|
|
307
|
+
ensures(return_value == (((uint32_t)u * (1u << 11) + MLKEM_Q / 2) / MLKEM_Q) % (1 << 11)))
|
|
308
|
+
{
|
|
309
|
+
/* Compute as follows:
|
|
310
|
+
* ```
|
|
311
|
+
* round(u * 2048 / MLKEM_Q)
|
|
312
|
+
* = round(u * 2048 * (2^33 / MLKEM_Q) / 2^33)
|
|
313
|
+
* ~= round(u * 2048 * round(2^33 / MLKEM_Q) / 2^33)
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
/* check-magic: 5284526080 == 2^11 * round(2^33 / MLKEM_Q) */
|
|
317
|
+
uint64_t d0 = (uint64_t)u * 5284526080;
|
|
318
|
+
d0 = (d0 + ((uint64_t)1u << 32)) >> 33; /* round(d0/2^33) */
|
|
319
|
+
return (d0 & 0x7FF);
|
|
320
|
+
}
|
|
321
|
+
#ifdef CBMC
|
|
322
|
+
#pragma CPROVER check pop
|
|
323
|
+
#endif
|
|
324
|
+
|
|
325
|
+
/************************************************************
|
|
326
|
+
* Name: mlk_scalar_decompress_d11
|
|
327
|
+
*
|
|
328
|
+
* Description: Computes round(u * q / 2048)
|
|
329
|
+
*
|
|
330
|
+
* Arguments: - u: Unsigned canonical modulus modulo 2048
|
|
331
|
+
* to be decompressed.
|
|
332
|
+
*
|
|
333
|
+
* Specification: Decompress_11 from @[FIPS203, Eq (4.8)].
|
|
334
|
+
*
|
|
335
|
+
************************************************************/
|
|
336
|
+
|
|
337
|
+
/* Reference: Embedded into `polyvec_decompress()` in the
|
|
338
|
+
* reference implementation @[REF]. */
|
|
339
|
+
static MLK_INLINE int16_t mlk_scalar_decompress_d11(uint16_t u)
|
|
340
|
+
__contract__(
|
|
341
|
+
requires(0 <= u && u < 2048)
|
|
342
|
+
ensures(0 <= return_value && return_value <= (MLKEM_Q - 1))
|
|
343
|
+
)
|
|
344
|
+
{
|
|
345
|
+
/* The return value is in 0..MLKEM_Q-1, hence not altered by the
|
|
346
|
+
* conversion to int16_t. */
|
|
347
|
+
return (int16_t)((((uint32_t)u * MLKEM_Q) + 1024) >> 11);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || (MLKEM_K == 2 || MLKEM_K == 3)
|
|
351
|
+
#define mlk_poly_compress_d4 MLK_NAMESPACE(poly_compress_d4)
|
|
352
|
+
/*************************************************
|
|
353
|
+
* Name: mlk_poly_compress_d4
|
|
354
|
+
*
|
|
355
|
+
* Description: Compression (4 bits) and subsequent serialization of a
|
|
356
|
+
* polynomial
|
|
357
|
+
*
|
|
358
|
+
* Arguments: - uint8_t *r: pointer to output byte array
|
|
359
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D4 bytes)
|
|
360
|
+
* - const mlk_poly *a: pointer to input polynomial
|
|
361
|
+
* Coefficients must be unsigned canonical,
|
|
362
|
+
* i.e. in [0,1,..,MLKEM_Q-1].
|
|
363
|
+
*
|
|
364
|
+
* Specification: Implements `ByteEncode_4 (Compress_4 (a))`:
|
|
365
|
+
* - ByteEncode_d: @[FIPS203, Algorithm 5],
|
|
366
|
+
* - Compress_d: @[FIPS203, Eq (4.7)]
|
|
367
|
+
* Extended to vectors as per
|
|
368
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
369
|
+
* - `ByteEncode_{d_v} (Compress_{d_v} (v))` appears in
|
|
370
|
+
* @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L23],
|
|
371
|
+
* where `d_v=4` for ML-KEM-{512,768} @[FIPS203, Table 2].
|
|
372
|
+
*
|
|
373
|
+
**************************************************/
|
|
374
|
+
MLK_INTERNAL_API
|
|
375
|
+
void mlk_poly_compress_d4(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4],
|
|
376
|
+
const mlk_poly *a);
|
|
377
|
+
|
|
378
|
+
#define mlk_poly_compress_d10 MLK_NAMESPACE(poly_compress_d10)
|
|
379
|
+
/*************************************************
|
|
380
|
+
* Name: mlk_poly_compress_d10
|
|
381
|
+
*
|
|
382
|
+
* Description: Compression (10 bits) and subsequent serialization of a
|
|
383
|
+
* polynomial
|
|
384
|
+
*
|
|
385
|
+
* Arguments: - uint8_t *r: pointer to output byte array
|
|
386
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D10 bytes)
|
|
387
|
+
* - const mlk_poly *a: pointer to input polynomial
|
|
388
|
+
* Coefficients must be unsigned canonical,
|
|
389
|
+
* i.e. in [0,1,..,MLKEM_Q-1].
|
|
390
|
+
*
|
|
391
|
+
* Specification: Implements `ByteEncode_10 (Compress_10 (a))`:
|
|
392
|
+
* - ByteEncode_d: @[FIPS203, Algorithm 5],
|
|
393
|
+
* - Compress_d: @[FIPS203, Eq (4.7)]
|
|
394
|
+
* Extended to vectors as per
|
|
395
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
396
|
+
* - `ByteEncode_{d_u} (Compress_{d_u} (u))` appears in
|
|
397
|
+
* @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L22],
|
|
398
|
+
* where `d_u=10` for ML-KEM-{512,768} @[FIPS203, Table 2].
|
|
399
|
+
*
|
|
400
|
+
**************************************************/
|
|
401
|
+
MLK_INTERNAL_API
|
|
402
|
+
void mlk_poly_compress_d10(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D10],
|
|
403
|
+
const mlk_poly *a);
|
|
404
|
+
|
|
405
|
+
#define mlk_poly_decompress_d4 MLK_NAMESPACE(poly_decompress_d4)
|
|
406
|
+
/*************************************************
|
|
407
|
+
* Name: mlk_poly_decompress_d4
|
|
408
|
+
*
|
|
409
|
+
* Description: De-serialization and subsequent decompression (dv bits) of a
|
|
410
|
+
* polynomial; approximate inverse of poly_compress
|
|
411
|
+
*
|
|
412
|
+
* Arguments: - mlk_poly *r: pointer to output polynomial
|
|
413
|
+
* - const uint8_t *a: pointer to input byte array
|
|
414
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D4 bytes)
|
|
415
|
+
*
|
|
416
|
+
* Upon return, the coefficients of the output polynomial are unsigned-canonical
|
|
417
|
+
* (non-negative and smaller than MLKEM_Q).
|
|
418
|
+
*
|
|
419
|
+
* Specification: Implements `Decompress_4 (ByteDecode_4 (a))`:
|
|
420
|
+
* - ByteDecode_d: @[FIPS203, Algorithm 6],
|
|
421
|
+
* - Decompress_d: @[FIPS203, Eq (4.8)]
|
|
422
|
+
* Extended to vectors as per
|
|
423
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
424
|
+
* - `Decompress_{d_v} (ByteDecode_{d_v} (v))` appears in
|
|
425
|
+
* @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L4],
|
|
426
|
+
* where `d_v=4` for ML-KEM-{512,768} @[FIPS203, Table 2].
|
|
427
|
+
*
|
|
428
|
+
**************************************************/
|
|
429
|
+
MLK_INTERNAL_API
|
|
430
|
+
void mlk_poly_decompress_d4(mlk_poly *r,
|
|
431
|
+
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4]);
|
|
432
|
+
|
|
433
|
+
#define mlk_poly_decompress_d10 MLK_NAMESPACE(poly_decompress_d10)
|
|
434
|
+
/*************************************************
|
|
435
|
+
* Name: mlk_poly_decompress_d10
|
|
436
|
+
*
|
|
437
|
+
* Description: De-serialization and subsequent decompression (10 bits) of a
|
|
438
|
+
* polynomial; approximate inverse of mlk_poly_compress_d10
|
|
439
|
+
*
|
|
440
|
+
* Arguments: - mlk_poly *r: pointer to output polynomial
|
|
441
|
+
* - const uint8_t *a: pointer to input byte array
|
|
442
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D10 bytes)
|
|
443
|
+
*
|
|
444
|
+
* Upon return, the coefficients of the output polynomial are unsigned-canonical
|
|
445
|
+
* (non-negative and smaller than MLKEM_Q).
|
|
446
|
+
*
|
|
447
|
+
* Specification: Implements `Decompress_10 (ByteDecode_10 (a))`:
|
|
448
|
+
* - ByteDecode_d: @[FIPS203, Algorithm 6],
|
|
449
|
+
* - Decompress_d: @[FIPS203, Eq (4.8)]
|
|
450
|
+
* Extended to vectors as per
|
|
451
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
452
|
+
* - `Decompress_{d_u} (ByteDecode_{d_u} (u))` appears in
|
|
453
|
+
* @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L3],
|
|
454
|
+
* where `d_u=10` for ML-KEM-{512,768} @[FIPS203, Table 2].
|
|
455
|
+
*
|
|
456
|
+
**************************************************/
|
|
457
|
+
MLK_INTERNAL_API
|
|
458
|
+
void mlk_poly_decompress_d10(mlk_poly *r,
|
|
459
|
+
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D10]);
|
|
460
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3 */
|
|
461
|
+
|
|
462
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4
|
|
463
|
+
#define mlk_poly_compress_d5 MLK_NAMESPACE(poly_compress_d5)
|
|
464
|
+
/*************************************************
|
|
465
|
+
* Name: mlk_poly_compress_d5
|
|
466
|
+
*
|
|
467
|
+
* Description: Compression (5 bits) and subsequent serialization of a
|
|
468
|
+
* polynomial
|
|
469
|
+
*
|
|
470
|
+
* Arguments: - uint8_t *r: pointer to output byte array
|
|
471
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D5 bytes)
|
|
472
|
+
* - const mlk_poly *a: pointer to input polynomial
|
|
473
|
+
* Coefficients must be unsigned canonical,
|
|
474
|
+
* i.e. in [0,1,..,MLKEM_Q-1].
|
|
475
|
+
*
|
|
476
|
+
* Specification: Implements `ByteEncode_5 (Compress_5 (a))`:
|
|
477
|
+
* - ByteEncode_d: @[FIPS203, Algorithm 5],
|
|
478
|
+
* - Compress_d: @[FIPS203, Eq (4.7)]
|
|
479
|
+
* Extended to vectors as per
|
|
480
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
481
|
+
* - `ByteEncode_{d_v} (Compress_{d_v} (v))` appears in
|
|
482
|
+
* @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L23],
|
|
483
|
+
* where `d_v=5` for ML-KEM-1024 @[FIPS203, Table 2].
|
|
484
|
+
*
|
|
485
|
+
**************************************************/
|
|
486
|
+
MLK_INTERNAL_API
|
|
487
|
+
void mlk_poly_compress_d5(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5],
|
|
488
|
+
const mlk_poly *a);
|
|
489
|
+
|
|
490
|
+
#define mlk_poly_compress_d11 MLK_NAMESPACE(poly_compress_d11)
|
|
491
|
+
/*************************************************
|
|
492
|
+
* Name: mlk_poly_compress_d11
|
|
493
|
+
*
|
|
494
|
+
* Description: Compression (11 bits) and subsequent serialization of a
|
|
495
|
+
* polynomial
|
|
496
|
+
*
|
|
497
|
+
* Arguments: - uint8_t *r: pointer to output byte array
|
|
498
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D11 bytes)
|
|
499
|
+
* - const mlk_poly *a: pointer to input polynomial
|
|
500
|
+
* Coefficients must be unsigned canonical,
|
|
501
|
+
* i.e. in [0,1,..,MLKEM_Q-1].
|
|
502
|
+
*
|
|
503
|
+
* Specification: `ByteEncode_11 (Compress_11 (a))`:
|
|
504
|
+
* - ByteEncode_d: @[FIPS203, Algorithm 5],
|
|
505
|
+
* - Compress_d: @[FIPS203, Eq (4.7)]
|
|
506
|
+
* Extended to vectors as per
|
|
507
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
508
|
+
* - `ByteEncode_{d_u} (Compress_{d_u} (u))` appears in
|
|
509
|
+
* @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L22],
|
|
510
|
+
* where `d_u=11` for ML-KEM-1024 @[FIPS203, Table 2].
|
|
511
|
+
*
|
|
512
|
+
**************************************************/
|
|
513
|
+
MLK_INTERNAL_API
|
|
514
|
+
void mlk_poly_compress_d11(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D11],
|
|
515
|
+
const mlk_poly *a);
|
|
516
|
+
|
|
517
|
+
#define mlk_poly_decompress_d5 MLK_NAMESPACE(poly_decompress_d5)
|
|
518
|
+
/*************************************************
|
|
519
|
+
* Name: mlk_poly_decompress_d5
|
|
520
|
+
*
|
|
521
|
+
* Description: De-serialization and subsequent decompression (dv bits) of a
|
|
522
|
+
* polynomial; approximate inverse of poly_compress
|
|
523
|
+
*
|
|
524
|
+
* Arguments: - mlk_poly *r: pointer to output polynomial
|
|
525
|
+
* - const uint8_t *a: pointer to input byte array
|
|
526
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D5 bytes)
|
|
527
|
+
*
|
|
528
|
+
* Upon return, the coefficients of the output polynomial are unsigned-canonical
|
|
529
|
+
* (non-negative and smaller than MLKEM_Q).
|
|
530
|
+
*
|
|
531
|
+
* Specification: Implements `Decompress_5 (ByteDecode_5 (a))`:
|
|
532
|
+
* - ByteDecode_d: @[FIPS203, Algorithm 6],
|
|
533
|
+
* - Decompress_d: @[FIPS203, Eq (4.8)]
|
|
534
|
+
* Extended to vectors as per
|
|
535
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
536
|
+
* - `Decompress_{d_v} (ByteDecode_{d_v} (v))` appears in
|
|
537
|
+
* @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L4],
|
|
538
|
+
* where `d_v=5` for ML-KEM-1024 @[FIPS203, Table 2].
|
|
539
|
+
*
|
|
540
|
+
**************************************************/
|
|
541
|
+
MLK_INTERNAL_API
|
|
542
|
+
void mlk_poly_decompress_d5(mlk_poly *r,
|
|
543
|
+
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5]);
|
|
544
|
+
|
|
545
|
+
#define mlk_poly_decompress_d11 MLK_NAMESPACE(poly_decompress_d11)
|
|
546
|
+
/*************************************************
|
|
547
|
+
* Name: mlk_poly_decompress_d11
|
|
548
|
+
*
|
|
549
|
+
* Description: De-serialization and subsequent decompression (11 bits) of a
|
|
550
|
+
* polynomial; approximate inverse of mlk_poly_compress_d11
|
|
551
|
+
*
|
|
552
|
+
* Arguments: - mlk_poly *r: pointer to output polynomial
|
|
553
|
+
* - const uint8_t *a: pointer to input byte array
|
|
554
|
+
* (of length MLKEM_POLYCOMPRESSEDBYTES_D11 bytes)
|
|
555
|
+
*
|
|
556
|
+
* Upon return, the coefficients of the output polynomial are unsigned-canonical
|
|
557
|
+
* (non-negative and smaller than MLKEM_Q).
|
|
558
|
+
*
|
|
559
|
+
* Specification: Implements `Decompress_11 (ByteDecode_11 (a))`:
|
|
560
|
+
* - ByteDecode_d: @[FIPS203, Algorithm 6],
|
|
561
|
+
* - Decompress_d: @[FIPS203, Eq (4.8)]
|
|
562
|
+
* Extended to vectors as per
|
|
563
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
564
|
+
* - `Decompress_{d_u} (ByteDecode_{d_u} (u))` appears in
|
|
565
|
+
* @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L3],
|
|
566
|
+
* where `d_u=11` for ML-KEM-1024 @[FIPS203, Table 2].
|
|
567
|
+
*
|
|
568
|
+
**************************************************/
|
|
569
|
+
MLK_INTERNAL_API
|
|
570
|
+
void mlk_poly_decompress_d11(mlk_poly *r,
|
|
571
|
+
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D11]);
|
|
572
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
573
|
+
|
|
574
|
+
#define mlk_poly_tobytes MLK_NAMESPACE(poly_tobytes)
|
|
575
|
+
/*************************************************
|
|
576
|
+
* Name: mlk_poly_tobytes
|
|
577
|
+
*
|
|
578
|
+
* Description: Serialization of a polynomial.
|
|
579
|
+
* Signed coefficients are converted to
|
|
580
|
+
* unsigned form before serialization.
|
|
581
|
+
*
|
|
582
|
+
* Arguments: INPUT:
|
|
583
|
+
* - a: const pointer to input polynomial,
|
|
584
|
+
* with each coefficient in the range [0,1,..,Q-1]
|
|
585
|
+
* OUTPUT
|
|
586
|
+
* - r: pointer to output byte array
|
|
587
|
+
* (of MLKEM_POLYBYTES bytes)
|
|
588
|
+
*
|
|
589
|
+
* Specification: Implements ByteEncode_12 @[FIPS203, Algorithm 5].
|
|
590
|
+
* Extended to vectors as per
|
|
591
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
592
|
+
*
|
|
593
|
+
**************************************************/
|
|
594
|
+
MLK_INTERNAL_API
|
|
595
|
+
void mlk_poly_tobytes(uint8_t r[MLKEM_POLYBYTES], const mlk_poly *a)
|
|
596
|
+
__contract__(
|
|
597
|
+
requires(memory_no_alias(r, MLKEM_POLYBYTES))
|
|
598
|
+
requires(memory_no_alias(a, sizeof(mlk_poly)))
|
|
599
|
+
requires(array_bound(a->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
|
|
600
|
+
assigns(memory_slice(r, MLKEM_POLYBYTES))
|
|
601
|
+
);
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
#define mlk_poly_frombytes MLK_NAMESPACE(poly_frombytes)
|
|
605
|
+
/*************************************************
|
|
606
|
+
* Name: mlk_poly_frombytes
|
|
607
|
+
*
|
|
608
|
+
* Description: De-serialization of a polynomial.
|
|
609
|
+
*
|
|
610
|
+
* Arguments: INPUT
|
|
611
|
+
* - a: pointer to input byte array
|
|
612
|
+
* (of MLKEM_POLYBYTES bytes)
|
|
613
|
+
* OUTPUT
|
|
614
|
+
* - r: pointer to output polynomial, with
|
|
615
|
+
* each coefficient unsigned and in the range
|
|
616
|
+
* 0 .. 4095
|
|
617
|
+
*
|
|
618
|
+
* Specification: Implements ByteDecode_12 @[FIPS203, Algorithm 6].
|
|
619
|
+
* Extended to vectors as per
|
|
620
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
621
|
+
*
|
|
622
|
+
**************************************************/
|
|
623
|
+
MLK_INTERNAL_API
|
|
624
|
+
void mlk_poly_frombytes(mlk_poly *r, const uint8_t a[MLKEM_POLYBYTES])
|
|
625
|
+
__contract__(
|
|
626
|
+
requires(memory_no_alias(a, MLKEM_POLYBYTES))
|
|
627
|
+
requires(memory_no_alias(r, sizeof(mlk_poly)))
|
|
628
|
+
assigns(memory_slice(r, sizeof(mlk_poly)))
|
|
629
|
+
ensures(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT))
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
#define mlk_poly_frommsg MLK_NAMESPACE(poly_frommsg)
|
|
634
|
+
/*************************************************
|
|
635
|
+
* Name: mlk_poly_frommsg
|
|
636
|
+
*
|
|
637
|
+
* Description: Convert 32-byte message to polynomial
|
|
638
|
+
*
|
|
639
|
+
* Arguments: - mlk_poly *r: pointer to output polynomial
|
|
640
|
+
* - const uint8_t *msg: pointer to input message
|
|
641
|
+
*
|
|
642
|
+
* Specification: Implements `Decompress_1 (ByteDecode_1 (a))`:
|
|
643
|
+
* - ByteDecode_d: @[FIPS203, Algorithm 6],
|
|
644
|
+
* - Decompress_d: @[FIPS203, Eq (4.8)]
|
|
645
|
+
* Extended to vectors as per
|
|
646
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
647
|
+
* - `Decompress_1 (ByteDecode_1 (w))` appears in
|
|
648
|
+
* @[FIPS203, Algorithm 15 (K-PKE.Encrypt), L20].
|
|
649
|
+
*
|
|
650
|
+
**************************************************/
|
|
651
|
+
MLK_INTERNAL_API
|
|
652
|
+
void mlk_poly_frommsg(mlk_poly *r, const uint8_t msg[MLKEM_INDCPA_MSGBYTES])
|
|
653
|
+
__contract__(
|
|
654
|
+
requires(memory_no_alias(msg, MLKEM_INDCPA_MSGBYTES))
|
|
655
|
+
requires(memory_no_alias(r, sizeof(mlk_poly)))
|
|
656
|
+
assigns(memory_slice(r, sizeof(mlk_poly)))
|
|
657
|
+
ensures(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
#define mlk_poly_tomsg MLK_NAMESPACE(poly_tomsg)
|
|
661
|
+
/*************************************************
|
|
662
|
+
* Name: mlk_poly_tomsg
|
|
663
|
+
*
|
|
664
|
+
* Description: Convert polynomial to 32-byte message
|
|
665
|
+
*
|
|
666
|
+
* Arguments: - uint8_t *msg: pointer to output message
|
|
667
|
+
* - const mlk_poly *r: pointer to input polynomial
|
|
668
|
+
* Coefficients must be unsigned canonical
|
|
669
|
+
*
|
|
670
|
+
* Specification: Implements `ByteEncode_1 (Compress_1 (a))`:
|
|
671
|
+
* - ByteEncode_d: @[FIPS203, Algorithm 5],
|
|
672
|
+
* - Compress_d: @[FIPS203, Eq (4.7)]
|
|
673
|
+
* Extended to vectors as per
|
|
674
|
+
* @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
|
|
675
|
+
* - `ByteEncode_1 (Compress_1 (w))` appears in
|
|
676
|
+
* @[FIPS203, Algorithm 14 (K-PKE.Decrypt), L7].
|
|
677
|
+
*
|
|
678
|
+
**************************************************/
|
|
679
|
+
MLK_INTERNAL_API
|
|
680
|
+
void mlk_poly_tomsg(uint8_t msg[MLKEM_INDCPA_MSGBYTES], const mlk_poly *r)
|
|
681
|
+
__contract__(
|
|
682
|
+
requires(memory_no_alias(msg, MLKEM_INDCPA_MSGBYTES))
|
|
683
|
+
requires(memory_no_alias(r, sizeof(mlk_poly)))
|
|
684
|
+
requires(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
|
|
685
|
+
assigns(memory_slice(msg, MLKEM_INDCPA_MSGBYTES))
|
|
686
|
+
);
|
|
687
|
+
|
|
688
|
+
#endif /* !MLK_COMPRESS_H */
|