pq_crypto 0.3.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/.github/workflows/ci.yml +56 -0
- data/CHANGELOG.md +62 -0
- data/GET_STARTED.md +366 -40
- data/README.md +76 -233
- data/SECURITY.md +107 -82
- data/ext/pqcrypto/extconf.rb +169 -87
- data/ext/pqcrypto/mldsa_api.h +1 -48
- data/ext/pqcrypto/mlkem_api.h +1 -18
- data/ext/pqcrypto/pq_externalmu.c +89 -204
- data/ext/pqcrypto/pqcrypto_native_api.h +129 -0
- data/ext/pqcrypto/pqcrypto_ruby_secure.c +484 -84
- data/ext/pqcrypto/pqcrypto_secure.c +203 -78
- data/ext/pqcrypto/pqcrypto_secure.h +53 -14
- data/ext/pqcrypto/pqcrypto_version.h +7 -0
- 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/algorithm_registry.rb +200 -0
- data/lib/pq_crypto/hybrid_kem.rb +1 -12
- data/lib/pq_crypto/kem.rb +104 -13
- data/lib/pq_crypto/pkcs8.rb +387 -0
- data/lib/pq_crypto/serialization.rb +1 -14
- data/lib/pq_crypto/signature.rb +123 -17
- data/lib/pq_crypto/spki.rb +131 -0
- data/lib/pq_crypto/version.rb +1 -1
- data/lib/pq_crypto.rb +79 -20
- data/script/vendor_libs.rb +88 -155
- metadata +241 -73
- 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-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-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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* WARNING: This file is auto-generated from scripts/autogen
|
|
8
|
+
* in the mlkem-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "arith_native_riscv64.h"
|
|
13
|
+
|
|
14
|
+
const int16_t zeta[] = {
|
|
15
|
+
-1044, -758, 573, -1325, 1223, 652, -552, 1015, -1103, 430, 555,
|
|
16
|
+
843, -1251, 871, 1550, 105, -359, -1517, 264, 383, -1293, 1491,
|
|
17
|
+
-282, -1544, 422, 587, 177, -235, -291, -460, 1574, 1653, 1493,
|
|
18
|
+
1422, -829, 1458, 516, -8, -320, -666, -246, 778, 1159, -147,
|
|
19
|
+
-777, 1483, -602, 1119, 287, 202, -1602, -130, -1618, -1162, 126,
|
|
20
|
+
1469, -1590, 644, -872, 349, 418, 329, -156, -75, -171, 622,
|
|
21
|
+
-681, 1017, -853, -90, -271, 830, 817, 1097, 603, 610, 1322,
|
|
22
|
+
-1285, -1465, 384, 1577, 182, 732, 608, 107, -1421, -247, -951,
|
|
23
|
+
-1215, -136, 1218, -1335, -874, 220, -1187, -1659, 962, -1202, -1542,
|
|
24
|
+
411, -398, 961, -1508, -725, -1185, -1530, -1278, 794, -1510, -854,
|
|
25
|
+
-870, 478, -1474, 1468, -205, -1571, 448, -1065, 677, -1275, -108,
|
|
26
|
+
-308, 996, 991, 958, -1460, 1522, 1628,
|
|
27
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* WARNING: This file is auto-generated from scripts/autogen
|
|
8
|
+
* in the mlkem-native repository.
|
|
9
|
+
* Do not modify it directly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#include "arith_native_riscv64.h"
|
|
13
|
+
|
|
14
|
+
const int16_t roots[] = {
|
|
15
|
+
-1044, -1103, -1044, 1103, -1044, 430, -1044, -430, -1044, 555, -1044,
|
|
16
|
+
-555, -1044, 843, -1044, -843, -1044, -1251, -1044, 1251, -1044, 871,
|
|
17
|
+
-1044, -871, -1044, 1550, -1044, -1550, -1044, 105, -1044, -105, -1044,
|
|
18
|
+
422, -1044, -422, -1044, 587, -1044, -587, -1044, 177, -1044, -177,
|
|
19
|
+
-1044, -235, -1044, 235, -1044, -291, -1044, 291, -1044, -460, -1044,
|
|
20
|
+
460, -1044, 1574, -1044, -1574, -1044, 1653, -1044, -1653, -1044, -246,
|
|
21
|
+
-1044, 246, -1044, 778, -1044, -778, -1044, 1159, -1044, -1159, -1044,
|
|
22
|
+
-147, -1044, 147, -1044, -777, -1044, 777, -1044, 1483, -1044, -1483,
|
|
23
|
+
-1044, -602, -1044, 602, -1044, 1119, -1044, -1119, -1044, -1590, -1044,
|
|
24
|
+
1590, -1044, 644, -1044, -644, -1044, -872, -1044, 872, -1044, 349,
|
|
25
|
+
-1044, -349, -1044, 418, -1044, -418, -1044, 329, -1044, -329, -1044,
|
|
26
|
+
-156, -1044, 156, -1044, -75, -1044, 75, -1044, 817, -1044, -817,
|
|
27
|
+
-1044, 1097, -1044, -1097, -1044, 603, -1044, -603, -1044, 610, -1044,
|
|
28
|
+
-610, -1044, 1322, -1044, -1322, -1044, -1285, -1044, 1285, -1044, -1465,
|
|
29
|
+
-1044, 1465, -1044, 384, -1044, -384, -1044, -1215, -1044, 1215, -1044,
|
|
30
|
+
-136, -1044, 136, -1044, 1218, -1044, -1218, -1044, -1335, -1044, 1335,
|
|
31
|
+
-1044, -874, -1044, 874, -1044, 220, -1044, -220, -1044, -1187, -1044,
|
|
32
|
+
1187, -1044, -1659, -1044, 1659, -1044, -1185, -1044, 1185, -1044, -1530,
|
|
33
|
+
-1044, 1530, -1044, -1278, -1044, 1278, -1044, 794, -1044, -794, -1044,
|
|
34
|
+
-1510, -1044, 1510, -1044, -854, -1044, 854, -1044, -870, -1044, 870,
|
|
35
|
+
-1044, 478, -1044, -478, -1044, -108, -1044, 108, -1044, -308, -1044,
|
|
36
|
+
308, -1044, 996, -1044, -996, -1044, 991, -1044, -991, -1044, 958,
|
|
37
|
+
-1044, -958, -1044, -1460, -1044, 1460, -1044, 1522, -1044, -1522, -1044,
|
|
38
|
+
1628, -1044, -1628,
|
|
39
|
+
};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ifndef MLK_NATIVE_X86_64_META_H
|
|
7
|
+
#define MLK_NATIVE_X86_64_META_H
|
|
8
|
+
|
|
9
|
+
/* Identifier for this backend so that source and assembly files
|
|
10
|
+
* in the build can be appropriately guarded. */
|
|
11
|
+
#define MLK_ARITH_BACKEND_X86_64_DEFAULT
|
|
12
|
+
|
|
13
|
+
#define MLK_USE_NATIVE_NTT_CUSTOM_ORDER
|
|
14
|
+
#define MLK_USE_NATIVE_REJ_UNIFORM
|
|
15
|
+
#define MLK_USE_NATIVE_NTT
|
|
16
|
+
#define MLK_USE_NATIVE_INTT
|
|
17
|
+
#define MLK_USE_NATIVE_POLY_REDUCE
|
|
18
|
+
#define MLK_USE_NATIVE_POLY_TOMONT
|
|
19
|
+
#define MLK_USE_NATIVE_POLYVEC_BASEMUL_ACC_MONTGOMERY_CACHED
|
|
20
|
+
#define MLK_USE_NATIVE_POLY_MULCACHE_COMPUTE
|
|
21
|
+
#define MLK_USE_NATIVE_POLY_TOBYTES
|
|
22
|
+
#define MLK_USE_NATIVE_POLY_FROMBYTES
|
|
23
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D4
|
|
24
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D5
|
|
25
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D10
|
|
26
|
+
#define MLK_USE_NATIVE_POLY_COMPRESS_D11
|
|
27
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D4
|
|
28
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D5
|
|
29
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D10
|
|
30
|
+
#define MLK_USE_NATIVE_POLY_DECOMPRESS_D11
|
|
31
|
+
|
|
32
|
+
#if !defined(__ASSEMBLER__)
|
|
33
|
+
#include "../../common.h"
|
|
34
|
+
#include "../api.h"
|
|
35
|
+
#include "src/arith_native_x86_64.h"
|
|
36
|
+
#include "src/compress_consts.h"
|
|
37
|
+
|
|
38
|
+
static MLK_INLINE void mlk_poly_permute_bitrev_to_custom(int16_t data[MLKEM_N])
|
|
39
|
+
{
|
|
40
|
+
if (mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
41
|
+
{
|
|
42
|
+
mlk_nttunpack_avx2(data);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
47
|
+
static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
|
|
48
|
+
const uint8_t *buf,
|
|
49
|
+
unsigned buflen)
|
|
50
|
+
{
|
|
51
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2) || len != MLKEM_N ||
|
|
52
|
+
buflen % 12 != 0)
|
|
53
|
+
{
|
|
54
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
55
|
+
}
|
|
56
|
+
return (int)mlk_rej_uniform_asm(r, buf, buflen, mlk_rej_uniform_table);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
60
|
+
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
|
|
61
|
+
{
|
|
62
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
63
|
+
{
|
|
64
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
mlk_ntt_avx2(data, mlk_qdata);
|
|
68
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
72
|
+
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
|
|
73
|
+
{
|
|
74
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
75
|
+
{
|
|
76
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
mlk_invntt_avx2(data, mlk_qdata);
|
|
80
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
84
|
+
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
|
|
85
|
+
{
|
|
86
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
87
|
+
{
|
|
88
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
mlk_reduce_avx2(data);
|
|
92
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
96
|
+
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
|
|
97
|
+
{
|
|
98
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
99
|
+
{
|
|
100
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
mlk_tomont_avx2(data);
|
|
104
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
108
|
+
static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
|
|
109
|
+
const int16_t y[MLKEM_N])
|
|
110
|
+
{
|
|
111
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
112
|
+
{
|
|
113
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
mlk_poly_mulcache_compute_avx2(x, y, mlk_qdata);
|
|
117
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2
|
|
121
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
122
|
+
static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k2_native(
|
|
123
|
+
int16_t r[MLKEM_N], const int16_t a[2 * MLKEM_N],
|
|
124
|
+
const int16_t b[2 * MLKEM_N], const int16_t b_cache[2 * (MLKEM_N / 2)])
|
|
125
|
+
{
|
|
126
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
127
|
+
{
|
|
128
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
mlk_polyvec_basemul_acc_montgomery_cached_asm_k2(r, a, b, b_cache);
|
|
132
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
133
|
+
}
|
|
134
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 */
|
|
135
|
+
|
|
136
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 3
|
|
137
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
138
|
+
static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k3_native(
|
|
139
|
+
int16_t r[MLKEM_N], const int16_t a[3 * MLKEM_N],
|
|
140
|
+
const int16_t b[3 * MLKEM_N], const int16_t b_cache[3 * (MLKEM_N / 2)])
|
|
141
|
+
{
|
|
142
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
143
|
+
{
|
|
144
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
mlk_polyvec_basemul_acc_montgomery_cached_asm_k3(r, a, b, b_cache);
|
|
148
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
149
|
+
}
|
|
150
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 3 */
|
|
151
|
+
|
|
152
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4
|
|
153
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
154
|
+
static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
|
|
155
|
+
int16_t r[MLKEM_N], const int16_t a[4 * MLKEM_N],
|
|
156
|
+
const int16_t b[4 * MLKEM_N], const int16_t b_cache[4 * (MLKEM_N / 2)])
|
|
157
|
+
{
|
|
158
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
159
|
+
{
|
|
160
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
mlk_polyvec_basemul_acc_montgomery_cached_asm_k4(r, a, b, b_cache);
|
|
164
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
165
|
+
}
|
|
166
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
167
|
+
|
|
168
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
169
|
+
static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
|
|
170
|
+
const int16_t a[MLKEM_N])
|
|
171
|
+
{
|
|
172
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
173
|
+
{
|
|
174
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
mlk_ntttobytes_avx2(r, a);
|
|
178
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
182
|
+
static MLK_INLINE int mlk_poly_frombytes_native(
|
|
183
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYBYTES])
|
|
184
|
+
{
|
|
185
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
186
|
+
{
|
|
187
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
mlk_nttfrombytes_avx2(r, a);
|
|
191
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || (MLKEM_K == 2 || MLKEM_K == 3)
|
|
195
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
196
|
+
static MLK_INLINE int mlk_poly_compress_d4_native(
|
|
197
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4], const int16_t a[MLKEM_N])
|
|
198
|
+
{
|
|
199
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
200
|
+
{
|
|
201
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
mlk_poly_compress_d4_avx2(r, a, mlk_compress_d4_data);
|
|
205
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
209
|
+
static MLK_INLINE int mlk_poly_compress_d10_native(
|
|
210
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D10], const int16_t a[MLKEM_N])
|
|
211
|
+
{
|
|
212
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
213
|
+
{
|
|
214
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
mlk_poly_compress_d10_avx2(r, a, mlk_compress_d10_data);
|
|
218
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
222
|
+
static MLK_INLINE int mlk_poly_decompress_d4_native(
|
|
223
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4])
|
|
224
|
+
{
|
|
225
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
226
|
+
{
|
|
227
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
mlk_poly_decompress_d4_avx2(r, a, mlk_decompress_d4_data);
|
|
231
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
235
|
+
static MLK_INLINE int mlk_poly_decompress_d10_native(
|
|
236
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D10])
|
|
237
|
+
{
|
|
238
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
239
|
+
{
|
|
240
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
mlk_poly_decompress_d10_avx2(r, a, mlk_decompress_d10_data);
|
|
244
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
245
|
+
}
|
|
246
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3 */
|
|
247
|
+
|
|
248
|
+
#if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4
|
|
249
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
250
|
+
static MLK_INLINE int mlk_poly_compress_d5_native(
|
|
251
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5], const int16_t a[MLKEM_N])
|
|
252
|
+
{
|
|
253
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
254
|
+
{
|
|
255
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
mlk_poly_compress_d5_avx2(r, a, mlk_compress_d5_data);
|
|
259
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
263
|
+
static MLK_INLINE int mlk_poly_compress_d11_native(
|
|
264
|
+
uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D11], const int16_t a[MLKEM_N])
|
|
265
|
+
{
|
|
266
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
267
|
+
{
|
|
268
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
mlk_poly_compress_d11_avx2(r, a, mlk_compress_d11_data);
|
|
272
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
276
|
+
static MLK_INLINE int mlk_poly_decompress_d5_native(
|
|
277
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5])
|
|
278
|
+
{
|
|
279
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
280
|
+
{
|
|
281
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
mlk_poly_decompress_d5_avx2(r, a, mlk_decompress_d5_data);
|
|
285
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
289
|
+
static MLK_INLINE int mlk_poly_decompress_d11_native(
|
|
290
|
+
int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D11])
|
|
291
|
+
{
|
|
292
|
+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
|
|
293
|
+
{
|
|
294
|
+
return MLK_NATIVE_FUNC_FALLBACK;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
mlk_poly_decompress_d11_avx2(r, a, mlk_decompress_d11_data);
|
|
298
|
+
return MLK_NATIVE_FUNC_SUCCESS;
|
|
299
|
+
}
|
|
300
|
+
#endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
|
|
301
|
+
|
|
302
|
+
#endif /* !__ASSEMBLER__ */
|
|
303
|
+
|
|
304
|
+
#endif /* !MLK_NATIVE_X86_64_META_H */
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) The mlkem-native project authors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
|
+
*/
|
|
5
|
+
#ifndef MLK_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H
|
|
6
|
+
#define MLK_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H
|
|
7
|
+
|
|
8
|
+
#include "../../../common.h"
|
|
9
|
+
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
#include "compress_consts.h"
|
|
12
|
+
#include "consts.h"
|
|
13
|
+
|
|
14
|
+
#define MLK_AVX2_REJ_UNIFORM_BUFLEN \
|
|
15
|
+
(3 * 168) /* REJ_UNIFORM_NBLOCKS * SHAKE128_RATE */
|
|
16
|
+
|
|
17
|
+
#define mlk_rej_uniform_table MLK_NAMESPACE(rej_uniform_table)
|
|
18
|
+
extern const uint8_t mlk_rej_uniform_table[];
|
|
19
|
+
|
|
20
|
+
#define mlk_rej_uniform_asm MLK_NAMESPACE(rej_uniform_asm)
|
|
21
|
+
MLK_MUST_CHECK_RETURN_VALUE
|
|
22
|
+
uint64_t mlk_rej_uniform_asm(int16_t *r, const uint8_t *buf, unsigned buflen,
|
|
23
|
+
const uint8_t *table)
|
|
24
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
25
|
+
* in proofs/hol_light/x86_64/proofs/mlkem_rej_uniform.ml. */
|
|
26
|
+
__contract__(
|
|
27
|
+
requires(buflen % 12 == 0)
|
|
28
|
+
requires(memory_no_alias(buf, buflen))
|
|
29
|
+
requires(table == mlk_rej_uniform_table)
|
|
30
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
31
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
32
|
+
ensures(return_value <= MLKEM_N)
|
|
33
|
+
ensures(array_bound(r, 0, (unsigned) return_value, 0, MLKEM_Q))
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
#define mlk_ntt_avx2 MLK_NAMESPACE(ntt_avx2)
|
|
37
|
+
void mlk_ntt_avx2(int16_t *r, const int16_t *qdata)
|
|
38
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
39
|
+
* in proofs/hol_light/x86_64/proofs/mlkem_ntt.ml */
|
|
40
|
+
__contract__(
|
|
41
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
42
|
+
requires(array_abs_bound(r, 0, MLKEM_N, 8192))
|
|
43
|
+
requires(qdata == mlk_qdata)
|
|
44
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
45
|
+
/* check-magic: off */
|
|
46
|
+
ensures(array_abs_bound(r, 0, MLKEM_N, 23595))
|
|
47
|
+
/* check-magic: on */
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
#define mlk_invntt_avx2 MLK_NAMESPACE(invntt_avx2)
|
|
51
|
+
void mlk_invntt_avx2(int16_t *r, const int16_t *qdata)
|
|
52
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
53
|
+
* in proofs/hol_light/x86_64/proofs/mlkem_intt.ml */
|
|
54
|
+
__contract__(
|
|
55
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
56
|
+
requires(qdata == mlk_qdata)
|
|
57
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
58
|
+
/* check-magic: off */
|
|
59
|
+
ensures(array_abs_bound(r, 0, MLKEM_N, 26632))
|
|
60
|
+
/* check-magic: on */
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
#define mlk_nttunpack_avx2 MLK_NAMESPACE(nttunpack_avx2)
|
|
64
|
+
void mlk_nttunpack_avx2(int16_t *r)
|
|
65
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
66
|
+
* in proofs/hol_light/x86_64/proofs/mlkem_unpack.ml */
|
|
67
|
+
__contract__(
|
|
68
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
69
|
+
requires(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
70
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
71
|
+
/* Output is a permutation of input: every output coefficient
|
|
72
|
+
* is some input coefficient */
|
|
73
|
+
ensures(forall(i, 0, MLKEM_N, exists(j, 0, MLKEM_N,
|
|
74
|
+
r[i] == old(*(int16_t (*)[MLKEM_N])r)[j])))
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
#define mlk_reduce_avx2 MLK_NAMESPACE(reduce_avx2)
|
|
78
|
+
void mlk_reduce_avx2(int16_t *r)
|
|
79
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
80
|
+
* in proofs/hol_light/x86_64/proofs/mlkem_reduce.ml */
|
|
81
|
+
__contract__(
|
|
82
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
83
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
84
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
#define mlk_poly_mulcache_compute_avx2 MLK_NAMESPACE(poly_mulcache_compute_avx2)
|
|
88
|
+
void mlk_poly_mulcache_compute_avx2(int16_t *out, const int16_t *in,
|
|
89
|
+
const int16_t *qdata)
|
|
90
|
+
/* This must be kept in sync with the HOL-Light specification
|
|
91
|
+
* in proofs/hol_light/x86_64/proofs/mlkem_mulcache_compute.ml */
|
|
92
|
+
__contract__(
|
|
93
|
+
requires(memory_no_alias(out, sizeof(int16_t) * (MLKEM_N / 2)))
|
|
94
|
+
requires(memory_no_alias(in, sizeof(int16_t) * MLKEM_N))
|
|
95
|
+
requires(qdata == mlk_qdata)
|
|
96
|
+
assigns(memory_slice(out, sizeof(int16_t) * (MLKEM_N / 2)))
|
|
97
|
+
ensures(array_abs_bound(out, 0, MLKEM_N/2, MLKEM_Q))
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
#define mlk_polyvec_basemul_acc_montgomery_cached_asm_k2 \
|
|
101
|
+
MLK_NAMESPACE(polyvec_basemul_acc_montgomery_cached_asm_k2)
|
|
102
|
+
void mlk_polyvec_basemul_acc_montgomery_cached_asm_k2(int16_t *r,
|
|
103
|
+
const int16_t *a,
|
|
104
|
+
const int16_t *b,
|
|
105
|
+
const int16_t *b_cache)
|
|
106
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
107
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_basemul_acc_montgomery_cached_k2.ml.
|
|
108
|
+
*/
|
|
109
|
+
__contract__(
|
|
110
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
111
|
+
requires(memory_no_alias(a, sizeof(int16_t) * 2 * MLKEM_N))
|
|
112
|
+
requires(memory_no_alias(b, sizeof(int16_t) * 2 * MLKEM_N))
|
|
113
|
+
requires(memory_no_alias(b_cache, sizeof(int16_t) * 2 * (MLKEM_N / 2)))
|
|
114
|
+
requires(array_abs_bound(a, 0, 2 * MLKEM_N, MLKEM_UINT12_LIMIT + 1))
|
|
115
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
#define mlk_polyvec_basemul_acc_montgomery_cached_asm_k3 \
|
|
119
|
+
MLK_NAMESPACE(polyvec_basemul_acc_montgomery_cached_asm_k3)
|
|
120
|
+
void mlk_polyvec_basemul_acc_montgomery_cached_asm_k3(int16_t *r,
|
|
121
|
+
const int16_t *a,
|
|
122
|
+
const int16_t *b,
|
|
123
|
+
const int16_t *b_cache)
|
|
124
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
125
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_basemul_acc_montgomery_cached_k3.ml.
|
|
126
|
+
*/
|
|
127
|
+
__contract__(
|
|
128
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
129
|
+
requires(memory_no_alias(a, sizeof(int16_t) * 3 * MLKEM_N))
|
|
130
|
+
requires(memory_no_alias(b, sizeof(int16_t) * 3 * MLKEM_N))
|
|
131
|
+
requires(memory_no_alias(b_cache, sizeof(int16_t) * 3 * (MLKEM_N / 2)))
|
|
132
|
+
requires(array_abs_bound(a, 0, 3 * MLKEM_N, MLKEM_UINT12_LIMIT + 1))
|
|
133
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
#define mlk_polyvec_basemul_acc_montgomery_cached_asm_k4 \
|
|
137
|
+
MLK_NAMESPACE(polyvec_basemul_acc_montgomery_cached_asm_k4)
|
|
138
|
+
void mlk_polyvec_basemul_acc_montgomery_cached_asm_k4(int16_t *r,
|
|
139
|
+
const int16_t *a,
|
|
140
|
+
const int16_t *b,
|
|
141
|
+
const int16_t *b_cache)
|
|
142
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
143
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_basemul_acc_montgomery_cached_k4.ml.
|
|
144
|
+
*/
|
|
145
|
+
__contract__(
|
|
146
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
147
|
+
requires(memory_no_alias(a, sizeof(int16_t) * 4 * MLKEM_N))
|
|
148
|
+
requires(memory_no_alias(b, sizeof(int16_t) * 4 * MLKEM_N))
|
|
149
|
+
requires(memory_no_alias(b_cache, sizeof(int16_t) * 4 * (MLKEM_N / 2)))
|
|
150
|
+
requires(array_abs_bound(a, 0, 4 * MLKEM_N, MLKEM_UINT12_LIMIT + 1))
|
|
151
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
#define mlk_ntttobytes_avx2 MLK_NAMESPACE(ntttobytes_avx2)
|
|
155
|
+
void mlk_ntttobytes_avx2(uint8_t *r, const int16_t *a)
|
|
156
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
157
|
+
* proofs/hol_light/x86_64/proofs/mlkem_tobytes.ml.
|
|
158
|
+
*/
|
|
159
|
+
__contract__(
|
|
160
|
+
requires(memory_no_alias(r, MLKEM_POLYBYTES))
|
|
161
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
162
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
163
|
+
assigns(memory_slice(r, MLKEM_POLYBYTES))
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
#define mlk_nttfrombytes_avx2 MLK_NAMESPACE(nttfrombytes_avx2)
|
|
167
|
+
void mlk_nttfrombytes_avx2(int16_t *r, const uint8_t *a)
|
|
168
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
169
|
+
* proofs/hol_light/x86_64/proofs/mlkem_frombytes.ml.
|
|
170
|
+
*/
|
|
171
|
+
__contract__(
|
|
172
|
+
requires(memory_no_alias(a, MLKEM_POLYBYTES))
|
|
173
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
174
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
175
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT))
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
#define mlk_tomont_avx2 MLK_NAMESPACE(tomont_avx2)
|
|
179
|
+
void mlk_tomont_avx2(int16_t *r)
|
|
180
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
181
|
+
* proofs/hol_light/x86_64/proofs/mlkem_tomont.ml.
|
|
182
|
+
*/
|
|
183
|
+
__contract__(
|
|
184
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
185
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
186
|
+
ensures(array_abs_bound(r, 0, MLKEM_N, MLKEM_Q))
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
#define mlk_poly_compress_d4_avx2 MLK_NAMESPACE(poly_compress_d4_avx2)
|
|
190
|
+
void mlk_poly_compress_d4_avx2(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4],
|
|
191
|
+
const int16_t *MLK_RESTRICT a,
|
|
192
|
+
const uint8_t *data)
|
|
193
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
194
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d4.ml.
|
|
195
|
+
*/
|
|
196
|
+
__contract__(
|
|
197
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D4))
|
|
198
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
199
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
200
|
+
requires(data == mlk_compress_d4_data)
|
|
201
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D4))
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
#define mlk_poly_decompress_d4_avx2 MLK_NAMESPACE(poly_decompress_d4_avx2)
|
|
205
|
+
void mlk_poly_decompress_d4_avx2(int16_t *MLK_RESTRICT r,
|
|
206
|
+
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4],
|
|
207
|
+
const uint8_t *data)
|
|
208
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
209
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d4.ml.
|
|
210
|
+
*/
|
|
211
|
+
__contract__(
|
|
212
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
213
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D4))
|
|
214
|
+
requires(data == mlk_decompress_d4_data)
|
|
215
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
216
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
#define mlk_poly_compress_d10_avx2 MLK_NAMESPACE(poly_compress_d10_avx2)
|
|
220
|
+
void mlk_poly_compress_d10_avx2(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D10],
|
|
221
|
+
const int16_t *MLK_RESTRICT a,
|
|
222
|
+
const uint8_t *data)
|
|
223
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
224
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d10.ml.
|
|
225
|
+
*/
|
|
226
|
+
__contract__(
|
|
227
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D10))
|
|
228
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
229
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
230
|
+
requires(data == mlk_compress_d10_data)
|
|
231
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D10))
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
#define mlk_poly_decompress_d10_avx2 MLK_NAMESPACE(poly_decompress_d10_avx2)
|
|
235
|
+
void mlk_poly_decompress_d10_avx2(
|
|
236
|
+
int16_t *MLK_RESTRICT r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D10],
|
|
237
|
+
const uint8_t *data)
|
|
238
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
239
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d10.ml.
|
|
240
|
+
*/
|
|
241
|
+
__contract__(
|
|
242
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
243
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D10))
|
|
244
|
+
requires(data == mlk_decompress_d10_data)
|
|
245
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
246
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
#define mlk_poly_compress_d5_avx2 MLK_NAMESPACE(poly_compress_d5_avx2)
|
|
250
|
+
void mlk_poly_compress_d5_avx2(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5],
|
|
251
|
+
const int16_t *MLK_RESTRICT a,
|
|
252
|
+
const uint8_t *data)
|
|
253
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
254
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d5.ml.
|
|
255
|
+
*/
|
|
256
|
+
__contract__(
|
|
257
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D5))
|
|
258
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
259
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
260
|
+
requires(data == mlk_compress_d5_data)
|
|
261
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D5))
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
#define mlk_poly_decompress_d5_avx2 MLK_NAMESPACE(poly_decompress_d5_avx2)
|
|
265
|
+
void mlk_poly_decompress_d5_avx2(int16_t *MLK_RESTRICT r,
|
|
266
|
+
const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5],
|
|
267
|
+
const uint8_t *data)
|
|
268
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
269
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d5.ml.
|
|
270
|
+
*/
|
|
271
|
+
__contract__(
|
|
272
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
273
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D5))
|
|
274
|
+
requires(data == mlk_decompress_d5_data)
|
|
275
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
276
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
#define mlk_poly_compress_d11_avx2 MLK_NAMESPACE(poly_compress_d11_avx2)
|
|
280
|
+
void mlk_poly_compress_d11_avx2(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D11],
|
|
281
|
+
const int16_t *MLK_RESTRICT a,
|
|
282
|
+
const uint8_t *data)
|
|
283
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
284
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d11.ml.
|
|
285
|
+
*/
|
|
286
|
+
__contract__(
|
|
287
|
+
requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D11))
|
|
288
|
+
requires(memory_no_alias(a, sizeof(int16_t) * MLKEM_N))
|
|
289
|
+
requires(array_bound(a, 0, MLKEM_N, 0, MLKEM_Q))
|
|
290
|
+
requires(data == mlk_compress_d11_data)
|
|
291
|
+
assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_D11))
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
#define mlk_poly_decompress_d11_avx2 MLK_NAMESPACE(poly_decompress_d11_avx2)
|
|
295
|
+
void mlk_poly_decompress_d11_avx2(
|
|
296
|
+
int16_t *MLK_RESTRICT r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D11],
|
|
297
|
+
const uint8_t *data)
|
|
298
|
+
/* This must be kept in sync with the HOL-Light specification in
|
|
299
|
+
* proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d11.ml.
|
|
300
|
+
*/
|
|
301
|
+
__contract__(
|
|
302
|
+
requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
|
|
303
|
+
requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_D11))
|
|
304
|
+
requires(data == mlk_decompress_d11_data)
|
|
305
|
+
assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
|
|
306
|
+
ensures(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
#endif /* !MLK_NATIVE_X86_64_SRC_ARITH_NATIVE_X86_64_H */
|