pq_crypto 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +1 -3
- data/ext/pqcrypto/pqcrypto_version.h +1 -1
- data/ext/pqcrypto/vendor/.vendored +7 -7
- data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +71 -0
- data/ext/pqcrypto/vendor/mldsa-native/README.md +26 -11
- data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +77 -150
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +93 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +74 -59
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +106 -40
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +94 -92
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/capability.h +31 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +55 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +1 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +12 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +3 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/auto.h +53 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +38 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +574 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +679 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +5 -6
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +6 -4
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +110 -120
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +109 -101
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +97 -93
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +1 -9
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +4 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/fastmul.h +74 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/slowmul.h +77 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/arith_native_rv32im.h +124 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_asm.S +331 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_slowmul_asm.S +381 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_asm.S +304 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_slowmul_asm.S +351 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_poly_pointwise_montgomery_rv32im_asm.S +139 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/rv32im_zetas.c +118 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +6 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +2 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +69 -67
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +12 -16
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +14 -18
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +23 -27
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +21 -42
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +28 -1
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +87 -28
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +61 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +23 -19
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +30 -0
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +55 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +67 -107
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +16 -24
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +27 -21
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +8 -8
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +191 -119
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +6 -3
- data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +16 -42
- data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +72 -0
- data/ext/pqcrypto/vendor/mlkem-native/README.md +9 -5
- data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +64 -312
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -34
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +41 -13
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +89 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +50 -46
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/capability.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +30 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +4 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +15 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +23 -8
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +11 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +7 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +8 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/auto.h +47 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +37 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +573 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +678 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +1 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +29 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +156 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +137 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/compress_d5_table.c +43 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d10_table.c +50 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d11_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d4_table.c +44 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d5_table.c +53 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_intt_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_ntt_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d10_aarch64_asm.S +439 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d11_aarch64_asm.S +452 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d4_aarch64_asm.S +106 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d5_aarch64_asm.S +124 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d10_aarch64_asm.S +108 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d11_aarch64_asm.S +116 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d4_aarch64_asm.S +93 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d5_aarch64_asm.S +104 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_frombytes_aarch64_asm.S +84 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_mulcache_compute_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_reduce_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tobytes_aarch64_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tomont_aarch64_asm.S +4 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S +4 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_rej_uniform_aarch64_asm.S +112 -104
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +0 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +16 -21
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +1 -0
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_intt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_ntt_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_reduce_ppc_asm.S +6 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +5 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +2 -2
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +5 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_intt_avx2_asm.S +36 -33
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntt_avx2_asm.S +67 -65
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttfrombytes_avx2_asm.S +8 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntttobytes_avx2_asm.S +6 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttunpack_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d10_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d11_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d4_avx2_asm.S +7 -5
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S +7 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S +6 -4
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S +118 -115
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S +174 -171
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S +230 -227
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_reduce_avx2_asm.S +17 -15
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_rej_uniform_avx2_asm.S +7 -6
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_tomont_avx2_asm.S +5 -3
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +4 -9
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +1 -1
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +31 -44
- data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +1 -1
- data/lib/pq_crypto/version.rb +1 -1
- data/script/vendor_libs.rb +6 -6
- metadata +36 -1
data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S
CHANGED
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
#include "../../../common.h"
|
|
52
|
-
#if defined(
|
|
52
|
+
#if defined(MLD_SYS_X86_64_AVX2) && \
|
|
53
|
+
defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
|
|
53
54
|
|
|
54
55
|
/*
|
|
55
56
|
* WARNING: This file is auto-derived from the mldsa-native source file
|
|
@@ -163,13 +164,14 @@ Lmld_rej_uniform_eta4_avx2_asm_high_nibble:
|
|
|
163
164
|
jmp Lmld_rej_uniform_eta4_avx2_asm_scalar
|
|
164
165
|
|
|
165
166
|
Lmld_rej_uniform_eta4_avx2_asm_done:
|
|
167
|
+
vzeroupper
|
|
166
168
|
retq
|
|
167
169
|
.cfi_endproc
|
|
168
170
|
|
|
169
171
|
MLD_ASM_FN_SIZE(rej_uniform_eta4_avx2_asm)
|
|
170
172
|
|
|
171
|
-
#endif /* MLD_ARITH_BACKEND_X86_64_DEFAULT &&
|
|
172
|
-
|
|
173
|
+
#endif /* MLD_SYS_X86_64_AVX2 && MLD_ARITH_BACKEND_X86_64_DEFAULT && \
|
|
174
|
+
!MLD_CONFIG_MULTILEVEL_NO_SHARED */
|
|
173
175
|
|
|
174
176
|
#if defined(__ELF__)
|
|
175
177
|
.section .note.GNU-stack,"",%progbits
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
* Copyright (c) The mldsa-native project authors
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
|
4
4
|
*/
|
|
5
|
-
#include <string.h>
|
|
6
|
-
|
|
7
|
-
#include "common.h"
|
|
8
5
|
#include "packing.h"
|
|
6
|
+
#include "common.h"
|
|
9
7
|
#include "poly.h"
|
|
10
8
|
#include "polyvec.h"
|
|
11
9
|
#include "rounding.h"
|
|
@@ -28,24 +26,15 @@ void mld_unpack_pk_t1(mld_poly *t1,
|
|
|
28
26
|
|
|
29
27
|
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
30
28
|
MLD_INTERNAL_API
|
|
31
|
-
void
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
MLD_INTERNAL_API
|
|
38
|
-
void mld_pack_sk_rho_key_tr_s2(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
39
|
-
const uint8_t rho[MLDSA_SEEDBYTES],
|
|
40
|
-
const uint8_t tr[MLDSA_TRBYTES],
|
|
41
|
-
const uint8_t key[MLDSA_SEEDBYTES],
|
|
42
|
-
const mld_polyveck *s2)
|
|
29
|
+
void mld_pack_sk_rho_key_tr(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
30
|
+
const uint8_t rho[MLDSA_SEEDBYTES],
|
|
31
|
+
const uint8_t tr[MLDSA_TRBYTES],
|
|
32
|
+
const uint8_t key[MLDSA_SEEDBYTES])
|
|
43
33
|
{
|
|
44
34
|
mld_memcpy(sk + MLDSA_SK_RHO_OFFSET, rho, MLDSA_SEEDBYTES);
|
|
45
35
|
mld_memcpy(sk + MLDSA_SK_KEY_OFFSET, key, MLDSA_SEEDBYTES);
|
|
46
36
|
mld_memcpy(sk + MLDSA_SK_TR_OFFSET, tr, MLDSA_TRBYTES);
|
|
47
|
-
/* s1 already packed via
|
|
48
|
-
mld_polyveck_pack_eta(sk + MLDSA_SK_S2_OFFSET, s2);
|
|
37
|
+
/* s1 and s2 already packed via mld_sample_pack_s1_s2 */
|
|
49
38
|
/* t0 already packed via mld_compute_pack_t0_t1 */
|
|
50
39
|
}
|
|
51
40
|
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
@@ -74,7 +63,8 @@ void mld_pack_sig_c(uint8_t sig[MLDSA_CRYPTO_BYTES],
|
|
|
74
63
|
|
|
75
64
|
MLD_INTERNAL_API
|
|
76
65
|
int mld_pack_sig_h(uint8_t sig[MLDSA_CRYPTO_BYTES], const mld_polyveck *w0,
|
|
77
|
-
const
|
|
66
|
+
const uint8_t w1_packed[MLDSA_K * MLDSA_POLYW1_PACKEDBYTES],
|
|
67
|
+
mld_poly *scratch)
|
|
78
68
|
{
|
|
79
69
|
unsigned int j, k, n;
|
|
80
70
|
|
|
@@ -100,11 +90,14 @@ int mld_pack_sig_h(uint8_t sig[MLDSA_CRYPTO_BYTES], const mld_polyveck *w0,
|
|
|
100
90
|
* before the call), so a data-dependent early return is fine. */
|
|
101
91
|
for (k = 0; k < MLDSA_K; k++)
|
|
102
92
|
__loop__(
|
|
103
|
-
assigns(k, j, n, memory_slice(sig_h, MLDSA_POLYVECH_PACKEDBYTES)
|
|
93
|
+
assigns(k, j, n, memory_slice(sig_h, MLDSA_POLYVECH_PACKEDBYTES),
|
|
94
|
+
memory_slice(scratch, sizeof(mld_poly)))
|
|
104
95
|
invariant(k <= MLDSA_K && n <= MLDSA_OMEGA)
|
|
105
96
|
decreases(MLDSA_K - k)
|
|
106
97
|
)
|
|
107
98
|
{
|
|
99
|
+
mld_polyw1_unpack(scratch, w1_packed + k * MLDSA_POLYW1_PACKEDBYTES);
|
|
100
|
+
|
|
108
101
|
for (j = 0; j < MLDSA_N; j++)
|
|
109
102
|
__loop__(
|
|
110
103
|
assigns(j, n, memory_slice(sig_h, MLDSA_POLYVECH_PACKEDBYTES))
|
|
@@ -113,7 +106,7 @@ int mld_pack_sig_h(uint8_t sig[MLDSA_CRYPTO_BYTES], const mld_polyveck *w0,
|
|
|
113
106
|
)
|
|
114
107
|
{
|
|
115
108
|
const unsigned int hint_bit =
|
|
116
|
-
mld_make_hint(w0->vec[k].coeffs[j],
|
|
109
|
+
mld_make_hint(w0->vec[k].coeffs[j], scratch->coeffs[j]);
|
|
117
110
|
if (hint_bit)
|
|
118
111
|
{
|
|
119
112
|
if (n == MLDSA_OMEGA)
|
|
@@ -161,13 +154,15 @@ int mld_sig_unpack_hints(mld_poly *h, const uint8_t sig[MLDSA_CRYPTO_BYTES],
|
|
|
161
154
|
|
|
162
155
|
mld_memset(h, 0, sizeof(mld_poly));
|
|
163
156
|
|
|
164
|
-
for (j = old_hint_count; j < new_hint_count; ++
|
|
157
|
+
for (j = old_hint_count; j < new_hint_count; j++)
|
|
165
158
|
__loop__(
|
|
166
159
|
invariant(j >= old_hint_count && j <= new_hint_count &&
|
|
167
160
|
new_hint_count <= MLDSA_OMEGA)
|
|
168
161
|
invariant(array_bound(h->coeffs, 0, MLDSA_N, 0, 2))
|
|
162
|
+
invariant(forall(hj, old_hint_count, j,
|
|
163
|
+
h->coeffs[packed_hints[hj]] == 1))
|
|
169
164
|
invariant(forall(p, 0, MLDSA_N,
|
|
170
|
-
|
|
165
|
+
h->coeffs[p] != 1 ||
|
|
171
166
|
exists(hj, old_hint_count, j, packed_hints[hj] == p)))
|
|
172
167
|
decreases(new_hint_count - j)
|
|
173
168
|
)
|
|
@@ -183,7 +178,7 @@ int mld_sig_unpack_hints(mld_poly *h, const uint8_t sig[MLDSA_CRYPTO_BYTES],
|
|
|
183
178
|
/* On the last row, also verify that the trailing index slots are zero. */
|
|
184
179
|
if (i == MLDSA_K - 1)
|
|
185
180
|
{
|
|
186
|
-
for (j = new_hint_count; j < MLDSA_OMEGA; ++
|
|
181
|
+
for (j = new_hint_count; j < MLDSA_OMEGA; j++)
|
|
187
182
|
__loop__(
|
|
188
183
|
invariant(j <= MLDSA_OMEGA)
|
|
189
184
|
decreases(MLDSA_OMEGA - j)
|
|
@@ -200,10 +195,11 @@ int mld_sig_unpack_hints(mld_poly *h, const uint8_t sig[MLDSA_CRYPTO_BYTES],
|
|
|
200
195
|
* row, i.e. packed_hints[old_hint_count, new_hint_count). Asserted here
|
|
201
196
|
* rather than posted as a contract to not unnecessarily increase proof
|
|
202
197
|
* complexity at callers that do not need the functional description. */
|
|
203
|
-
cassert(forall(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
cassert(forall(hj, old_hint_count, new_hint_count,
|
|
199
|
+
h->coeffs[packed_hints[hj]] == 1));
|
|
200
|
+
cassert(forall(p, 0, MLDSA_N,
|
|
201
|
+
h->coeffs[p] != 1 || exists(hj, old_hint_count, new_hint_count,
|
|
202
|
+
packed_hints[hj] == p)));
|
|
207
203
|
|
|
208
204
|
return 0;
|
|
209
205
|
}
|
|
@@ -19,57 +19,30 @@
|
|
|
19
19
|
#include "polyvec_lazy.h"
|
|
20
20
|
|
|
21
21
|
#if !defined(MLD_CONFIG_NO_KEYPAIR_API)
|
|
22
|
-
#define
|
|
22
|
+
#define mld_pack_sk_rho_key_tr MLD_NAMESPACE_KL(pack_sk_rho_key_tr)
|
|
23
23
|
/**
|
|
24
|
-
* Bit-pack
|
|
24
|
+
* Bit-pack rho, key, tr into the secret key.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
* component).}
|
|
28
|
-
*
|
|
29
|
-
* @param[out] sk Output byte array.
|
|
30
|
-
* @param[in] s1 Pointer to vector s1.
|
|
31
|
-
*/
|
|
32
|
-
MLD_INTERNAL_API
|
|
33
|
-
void mld_pack_sk_s1(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
34
|
-
const mld_polyvecl *s1)
|
|
35
|
-
__contract__(
|
|
36
|
-
requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
|
|
37
|
-
requires(memory_no_alias(s1, sizeof(mld_polyvecl)))
|
|
38
|
-
requires(forall(k1, 0, MLDSA_L,
|
|
39
|
-
array_abs_bound(s1->vec[k1].coeffs, 0, MLDSA_N, MLDSA_ETA + 1)))
|
|
40
|
-
assigns(memory_slice(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
#define mld_pack_sk_rho_key_tr_s2 MLD_NAMESPACE_KL(pack_sk_rho_key_tr_s2)
|
|
44
|
-
/**
|
|
45
|
-
* Bit-pack rho, key, tr, s2 into the secret key.
|
|
46
|
-
*
|
|
47
|
-
* s1 must already be packed via mld_pack_sk_s1, and t0 via
|
|
48
|
-
* mld_compute_pack_t0_t1.
|
|
26
|
+
* s1 and s2 must already be packed, and t0 via mld_compute_pack_t0_t1.
|
|
49
27
|
*
|
|
50
|
-
* @spec{Partially implements @[FIPS204, Algorithm 24, skEncode] (rho, key, tr
|
|
51
|
-
*
|
|
28
|
+
* @spec{Partially implements @[FIPS204, Algorithm 24, skEncode] (rho, key, tr
|
|
29
|
+
* components).}
|
|
52
30
|
*
|
|
53
31
|
* @param[out] sk Output byte array.
|
|
54
32
|
* @param[in] rho Byte array containing rho.
|
|
55
33
|
* @param[in] tr Byte array containing tr.
|
|
56
34
|
* @param[in] key Byte array containing key.
|
|
57
|
-
* @param[in] s2 Pointer to vector s2.
|
|
58
35
|
*/
|
|
59
36
|
MLD_INTERNAL_API
|
|
60
|
-
void
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const mld_polyveck *s2)
|
|
37
|
+
void mld_pack_sk_rho_key_tr(uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
|
|
38
|
+
const uint8_t rho[MLDSA_SEEDBYTES],
|
|
39
|
+
const uint8_t tr[MLDSA_TRBYTES],
|
|
40
|
+
const uint8_t key[MLDSA_SEEDBYTES])
|
|
65
41
|
__contract__(
|
|
66
42
|
requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
|
|
67
43
|
requires(memory_no_alias(rho, MLDSA_SEEDBYTES))
|
|
68
44
|
requires(memory_no_alias(tr, MLDSA_TRBYTES))
|
|
69
45
|
requires(memory_no_alias(key, MLDSA_SEEDBYTES))
|
|
70
|
-
requires(memory_no_alias(s2, sizeof(mld_polyveck)))
|
|
71
|
-
requires(forall(k2, 0, MLDSA_K,
|
|
72
|
-
array_abs_bound(s2->vec[k2].coeffs, 0, MLDSA_N, MLDSA_ETA + 1)))
|
|
73
46
|
assigns(memory_slice(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
|
|
74
47
|
);
|
|
75
48
|
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
@@ -107,9 +80,12 @@ __contract__(
|
|
|
107
80
|
* MakeHint valid only for the values arising during signing; see the block
|
|
108
81
|
* comment in mld_attempt_signature_generation (sign.c).}
|
|
109
82
|
*
|
|
110
|
-
* @param[in,out] sig
|
|
111
|
-
* @param[in] w0
|
|
112
|
-
* @param[in]
|
|
83
|
+
* @param[in,out] sig Byte array containing signature.
|
|
84
|
+
* @param[in] w0 Pointer to low part of input vector.
|
|
85
|
+
* @param[in] w1_packed Bit-packed high part of input vector, as produced
|
|
86
|
+
* by mld_polyw1_pack.
|
|
87
|
+
* @param[out] scratch Scratch polynomial, used to unpack one row of the
|
|
88
|
+
* high part at a time.
|
|
113
89
|
*
|
|
114
90
|
* @retval 0 Success.
|
|
115
91
|
* @retval MLD_ERR_FAIL The total number of hints exceeds MLDSA_OMEGA. In this
|
|
@@ -120,12 +96,15 @@ __contract__(
|
|
|
120
96
|
MLD_INTERNAL_API
|
|
121
97
|
MLD_MUST_CHECK_RETURN_VALUE
|
|
122
98
|
int mld_pack_sig_h(uint8_t sig[MLDSA_CRYPTO_BYTES], const mld_polyveck *w0,
|
|
123
|
-
const
|
|
99
|
+
const uint8_t w1_packed[MLDSA_K * MLDSA_POLYW1_PACKEDBYTES],
|
|
100
|
+
mld_poly *scratch)
|
|
124
101
|
__contract__(
|
|
125
102
|
requires(memory_no_alias(sig, MLDSA_CRYPTO_BYTES))
|
|
126
103
|
requires(memory_no_alias(w0, sizeof(mld_polyveck)))
|
|
127
|
-
requires(memory_no_alias(
|
|
104
|
+
requires(memory_no_alias(w1_packed, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
|
|
105
|
+
requires(memory_no_alias(scratch, sizeof(mld_poly)))
|
|
128
106
|
assigns(memory_slice(sig + MLDSA_SIG_H_OFFSET, MLDSA_POLYVECH_PACKEDBYTES))
|
|
107
|
+
assigns(memory_slice(scratch, sizeof(mld_poly)))
|
|
129
108
|
ensures(return_value == 0 || return_value == MLD_ERR_FAIL)
|
|
130
109
|
);
|
|
131
110
|
|
|
@@ -177,7 +156,7 @@ __contract__(
|
|
|
177
156
|
requires(memory_no_alias(t1, sizeof(mld_poly)))
|
|
178
157
|
requires(i < MLDSA_K)
|
|
179
158
|
assigns(memory_slice(t1, sizeof(mld_poly)))
|
|
180
|
-
ensures(array_bound(t1->coeffs, 0, MLDSA_N, 0, 1 <<
|
|
159
|
+
ensures(array_bound(t1->coeffs, 0, MLDSA_N, 0, 1 << MLDSA_POLYT1_PACKEDBITS))
|
|
181
160
|
);
|
|
182
161
|
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
183
162
|
|
|
@@ -16,7 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
#define MLDSA_GAMMA2_88 ((MLDSA_Q - 1) / 88)
|
|
18
18
|
#define MLDSA_GAMMA2_32 ((MLDSA_Q - 1) / 32)
|
|
19
|
+
/* Bits per w1 coefficient: bitlen((MLDSA_Q-1)/(2*MLDSA_GAMMA2) - 1), i.e.
|
|
20
|
+
* bitlen(43) for MLDSA_GAMMA2_88 and bitlen(15) for MLDSA_GAMMA2_32. */
|
|
21
|
+
#define MLDSA_POLYW1_PACKEDBITS_88 6
|
|
22
|
+
#define MLDSA_POLYW1_PACKEDBITS_32 4
|
|
23
|
+
/* check-magic: 192 == MLDSA_N * MLDSA_POLYW1_PACKEDBITS_88 / 8 */
|
|
19
24
|
#define MLDSA_POLYW1_PACKEDBYTES_88 192
|
|
25
|
+
/* check-magic: 128 == MLDSA_N * MLDSA_POLYW1_PACKEDBITS_32 / 8 */
|
|
20
26
|
#define MLDSA_POLYW1_PACKEDBYTES_32 128
|
|
21
27
|
|
|
22
28
|
#if MLD_CONFIG_PARAMETER_SET == 44
|
|
@@ -30,8 +36,13 @@
|
|
|
30
36
|
#define MLDSA_GAMMA2 MLDSA_GAMMA2_88
|
|
31
37
|
#define MLDSA_OMEGA 80
|
|
32
38
|
#define MLDSA_CTILDEBYTES 32
|
|
39
|
+
#define MLDSA_POLYZ_PACKEDBITS 18
|
|
40
|
+
/* check-magic: 576 == MLDSA_N * 18 / 8 */
|
|
33
41
|
#define MLDSA_POLYZ_PACKEDBYTES 576
|
|
34
42
|
#define MLDSA_POLYW1_PACKEDBYTES MLDSA_POLYW1_PACKEDBYTES_88
|
|
43
|
+
#define MLDSA_POLYW1_PACKEDBITS MLDSA_POLYW1_PACKEDBITS_88
|
|
44
|
+
#define MLDSA_POLYETA_PACKEDBITS 3
|
|
45
|
+
/* check-magic: 96 == MLDSA_N * 3 / 8 */
|
|
35
46
|
#define MLDSA_POLYETA_PACKEDBYTES 96
|
|
36
47
|
|
|
37
48
|
#elif MLD_CONFIG_PARAMETER_SET == 65
|
|
@@ -45,8 +56,13 @@
|
|
|
45
56
|
#define MLDSA_GAMMA2 MLDSA_GAMMA2_32
|
|
46
57
|
#define MLDSA_OMEGA 55
|
|
47
58
|
#define MLDSA_CTILDEBYTES 48
|
|
59
|
+
#define MLDSA_POLYZ_PACKEDBITS 20
|
|
60
|
+
/* check-magic: 640 == MLDSA_N * 20 / 8 */
|
|
48
61
|
#define MLDSA_POLYZ_PACKEDBYTES 640
|
|
49
62
|
#define MLDSA_POLYW1_PACKEDBYTES MLDSA_POLYW1_PACKEDBYTES_32
|
|
63
|
+
#define MLDSA_POLYW1_PACKEDBITS MLDSA_POLYW1_PACKEDBITS_32
|
|
64
|
+
#define MLDSA_POLYETA_PACKEDBITS 4
|
|
65
|
+
/* check-magic: 128 == MLDSA_N * 4 / 8 */
|
|
50
66
|
#define MLDSA_POLYETA_PACKEDBYTES 128
|
|
51
67
|
|
|
52
68
|
#elif MLD_CONFIG_PARAMETER_SET == 87
|
|
@@ -60,13 +76,24 @@
|
|
|
60
76
|
#define MLDSA_GAMMA2 MLDSA_GAMMA2_32
|
|
61
77
|
#define MLDSA_OMEGA 75
|
|
62
78
|
#define MLDSA_CTILDEBYTES 64
|
|
79
|
+
#define MLDSA_POLYZ_PACKEDBITS 20
|
|
80
|
+
/* check-magic: 640 == MLDSA_N * 20 / 8 */
|
|
63
81
|
#define MLDSA_POLYZ_PACKEDBYTES 640
|
|
64
82
|
#define MLDSA_POLYW1_PACKEDBYTES MLDSA_POLYW1_PACKEDBYTES_32
|
|
83
|
+
#define MLDSA_POLYW1_PACKEDBITS MLDSA_POLYW1_PACKEDBITS_32
|
|
84
|
+
#define MLDSA_POLYETA_PACKEDBITS 3
|
|
85
|
+
/* check-magic: 96 == MLDSA_N * 3 / 8 */
|
|
65
86
|
#define MLDSA_POLYETA_PACKEDBYTES 96
|
|
66
87
|
|
|
67
|
-
#
|
|
88
|
+
#else /* MLD_CONFIG_PARAMETER_SET == 87 */
|
|
89
|
+
#error Invalid value for MLD_CONFIG_PARAMETER_SET. Must be 44, 65, or 87.
|
|
90
|
+
#endif /* MLD_CONFIG_PARAMETER_SET != 44 && MLD_CONFIG_PARAMETER_SET != 65 && \
|
|
91
|
+
MLD_CONFIG_PARAMETER_SET != 87 */
|
|
68
92
|
|
|
93
|
+
#define MLDSA_POLYT1_PACKEDBITS 10
|
|
94
|
+
/* check-magic: 320 == MLDSA_N * MLDSA_POLYT1_PACKEDBITS / 8 */
|
|
69
95
|
#define MLDSA_POLYT1_PACKEDBYTES 320
|
|
96
|
+
/* check-magic: 416 == MLDSA_N * MLDSA_D / 8 */
|
|
70
97
|
#define MLDSA_POLYT0_PACKEDBYTES 416
|
|
71
98
|
#define MLDSA_POLYVECH_PACKEDBYTES (MLDSA_OMEGA + MLDSA_K)
|
|
72
99
|
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
#include "poly.h"
|
|
22
|
-
|
|
23
22
|
#include "common.h"
|
|
24
23
|
#include "ct.h"
|
|
25
24
|
#include "debug.h"
|
|
@@ -36,7 +35,7 @@ void mld_poly_reduce(mld_poly *a)
|
|
|
36
35
|
unsigned int i;
|
|
37
36
|
mld_assert_bound(a->coeffs, MLDSA_N, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX);
|
|
38
37
|
|
|
39
|
-
for (i = 0; i < MLDSA_N; ++
|
|
38
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
40
39
|
__loop__(
|
|
41
40
|
invariant(i <= MLDSA_N)
|
|
42
41
|
invariant(forall(k0, i, MLDSA_N, a->coeffs[k0] == loop_entry(*a).coeffs[k0]))
|
|
@@ -61,7 +60,7 @@ __contract__(
|
|
|
61
60
|
unsigned int i;
|
|
62
61
|
mld_assert_abs_bound(a->coeffs, MLDSA_N, MLDSA_Q);
|
|
63
62
|
|
|
64
|
-
for (i = 0; i < MLDSA_N; ++
|
|
63
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
65
64
|
__loop__(
|
|
66
65
|
invariant(i <= MLDSA_N)
|
|
67
66
|
invariant(forall(k0, i, MLDSA_N, a->coeffs[k0] == loop_entry(*a).coeffs[k0]))
|
|
@@ -99,14 +98,14 @@ MLD_INTERNAL_API
|
|
|
99
98
|
void mld_poly_add(mld_poly *r, const mld_poly *b)
|
|
100
99
|
{
|
|
101
100
|
unsigned int i;
|
|
102
|
-
for (i = 0; i < MLDSA_N; ++
|
|
101
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
103
102
|
__loop__(
|
|
104
103
|
assigns(i, memory_slice(r, sizeof(mld_poly)))
|
|
105
104
|
invariant(i <= MLDSA_N)
|
|
106
105
|
invariant(forall(k0, i, MLDSA_N, r->coeffs[k0] == loop_entry(*r).coeffs[k0]))
|
|
107
|
-
invariant(forall(k1, 0, i, r->coeffs[k1] == loop_entry(*r).coeffs[k1] + b->coeffs[k1]))
|
|
108
|
-
invariant(forall(k2, 0, i, r->coeffs[k2] < MLD_REDUCE32_DOMAIN_MAX))
|
|
109
|
-
invariant(forall(k2, 0, i, r->coeffs[k2] >= INT32_MIN))
|
|
106
|
+
invariant(forall(k1, 0, i, MLDSA_N, r->coeffs[k1] == loop_entry(*r).coeffs[k1] + b->coeffs[k1]))
|
|
107
|
+
invariant(forall(k2, 0, i, MLDSA_N, r->coeffs[k2] < MLD_REDUCE32_DOMAIN_MAX))
|
|
108
|
+
invariant(forall(k2, 0, i, MLDSA_N, r->coeffs[k2] >= INT32_MIN))
|
|
110
109
|
decreases(MLDSA_N - i)
|
|
111
110
|
)
|
|
112
111
|
{
|
|
@@ -126,7 +125,7 @@ void mld_poly_sub(mld_poly *r, const mld_poly *b)
|
|
|
126
125
|
mld_assert_abs_bound(b->coeffs, MLDSA_N, MLDSA_Q);
|
|
127
126
|
mld_assert_abs_bound(r->coeffs, MLDSA_N, MLDSA_Q);
|
|
128
127
|
|
|
129
|
-
for (i = 0; i < MLDSA_N; ++
|
|
128
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
130
129
|
__loop__(
|
|
131
130
|
invariant(i <= MLDSA_N)
|
|
132
131
|
invariant(array_bound(r->coeffs, 0, i, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX))
|
|
@@ -146,7 +145,7 @@ MLD_INTERNAL_API
|
|
|
146
145
|
void mld_poly_shiftl(mld_poly *a)
|
|
147
146
|
{
|
|
148
147
|
unsigned int i;
|
|
149
|
-
mld_assert_bound(a->coeffs, MLDSA_N, 0, 1 <<
|
|
148
|
+
mld_assert_bound(a->coeffs, MLDSA_N, 0, 1 << MLDSA_POLYT1_PACKEDBITS);
|
|
150
149
|
|
|
151
150
|
for (i = 0; i < MLDSA_N; i++)
|
|
152
151
|
__loop__(
|
|
@@ -432,7 +431,7 @@ __contract__(
|
|
|
432
431
|
* 1/256 performs that scaling of the inverse NTT.
|
|
433
432
|
* The reduced value is bounded by MLD_INTT_BOUND in absolute
|
|
434
433
|
* value.*/
|
|
435
|
-
for (j = 0; j < MLDSA_N; ++
|
|
434
|
+
for (j = 0; j < MLDSA_N; j++)
|
|
436
435
|
__loop__(
|
|
437
436
|
invariant(j <= MLDSA_N)
|
|
438
437
|
invariant(array_abs_bound(r, 0, j, MLD_INTT_BOUND))
|
|
@@ -480,7 +479,7 @@ __contract__(
|
|
|
480
479
|
mld_assert_abs_bound(a->coeffs, MLDSA_N, MLD_NTT_BOUND);
|
|
481
480
|
mld_assert_abs_bound(b->coeffs, MLDSA_N, MLD_NTT_BOUND);
|
|
482
481
|
|
|
483
|
-
for (i = 0; i < MLDSA_N; ++
|
|
482
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
484
483
|
__loop__(
|
|
485
484
|
invariant(i <= MLDSA_N)
|
|
486
485
|
invariant(array_abs_bound(a->coeffs, 0, i, MLDSA_Q))
|
|
@@ -519,7 +518,7 @@ void mld_poly_power2round(mld_poly *a1, mld_poly *a0, const mld_poly *a)
|
|
|
519
518
|
unsigned int i;
|
|
520
519
|
mld_assert_bound(a->coeffs, MLDSA_N, 0, MLDSA_Q);
|
|
521
520
|
|
|
522
|
-
for (i = 0; i < MLDSA_N; ++
|
|
521
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
523
522
|
__loop__(
|
|
524
523
|
assigns(i, memory_slice(a0, sizeof(mld_poly)), memory_slice(a1, sizeof(mld_poly)))
|
|
525
524
|
invariant(i <= MLDSA_N)
|
|
@@ -619,10 +618,10 @@ __contract__(
|
|
|
619
618
|
requires(buflen <= (MLD_POLY_UNIFORM_NBLOCKS * MLD_STREAM128_BLOCKBYTES) && buflen % 3 == 0)
|
|
620
619
|
requires(memory_no_alias(a, sizeof(int32_t) * target))
|
|
621
620
|
requires(memory_no_alias(buf, buflen))
|
|
622
|
-
requires(array_bound(a, 0, offset, 0, MLDSA_Q))
|
|
621
|
+
requires(array_bound(a, 0, offset, MLDSA_N, 0, MLDSA_Q))
|
|
623
622
|
assigns(memory_slice(a, sizeof(int32_t) * target))
|
|
624
623
|
ensures(offset <= return_value && return_value <= target)
|
|
625
|
-
ensures(array_bound(a, 0, return_value, 0, MLDSA_Q))
|
|
624
|
+
ensures(array_bound(a, 0, return_value, MLDSA_N, 0, MLDSA_Q))
|
|
626
625
|
)
|
|
627
626
|
{
|
|
628
627
|
#if defined(MLD_USE_NATIVE_REJ_UNIFORM)
|
|
@@ -727,10 +726,10 @@ void mld_poly_uniform_4x(mld_poly *vec0, mld_poly *vec1, mld_poly *vec2,
|
|
|
727
726
|
memory_slice(vec2, sizeof(mld_poly)), memory_slice(vec3, sizeof(mld_poly)))
|
|
728
727
|
invariant(ctr[0] <= MLDSA_N && ctr[1] <= MLDSA_N)
|
|
729
728
|
invariant(ctr[2] <= MLDSA_N && ctr[3] <= MLDSA_N)
|
|
730
|
-
invariant(array_bound(vec0->coeffs, 0, ctr[0], 0, MLDSA_Q))
|
|
731
|
-
invariant(array_bound(vec1->coeffs, 0, ctr[1], 0, MLDSA_Q))
|
|
732
|
-
invariant(array_bound(vec2->coeffs, 0, ctr[2], 0, MLDSA_Q))
|
|
733
|
-
invariant(array_bound(vec3->coeffs, 0, ctr[3], 0, MLDSA_Q)))
|
|
729
|
+
invariant(array_bound(vec0->coeffs, 0, ctr[0], MLDSA_N, 0, MLDSA_Q))
|
|
730
|
+
invariant(array_bound(vec1->coeffs, 0, ctr[1], MLDSA_N, 0, MLDSA_Q))
|
|
731
|
+
invariant(array_bound(vec2->coeffs, 0, ctr[2], MLDSA_N, 0, MLDSA_Q))
|
|
732
|
+
invariant(array_bound(vec3->coeffs, 0, ctr[3], MLDSA_N, 0, MLDSA_Q)))
|
|
734
733
|
{
|
|
735
734
|
mld_xof128_x4_squeezeblocks(buf, 1, &state);
|
|
736
735
|
ctr[0] = mld_rej_uniform(vec0->coeffs, MLDSA_N, ctr[0], buf[0], buflen);
|
|
@@ -757,9 +756,9 @@ MLD_INTERNAL_API
|
|
|
757
756
|
void mld_polyt1_pack(uint8_t r[MLDSA_POLYT1_PACKEDBYTES], const mld_poly *a)
|
|
758
757
|
{
|
|
759
758
|
unsigned int i;
|
|
760
|
-
mld_assert_bound(a->coeffs, MLDSA_N, 0, 1 <<
|
|
759
|
+
mld_assert_bound(a->coeffs, MLDSA_N, 0, 1 << MLDSA_POLYT1_PACKEDBITS);
|
|
761
760
|
|
|
762
|
-
for (i = 0; i < MLDSA_N / 4; ++
|
|
761
|
+
for (i = 0; i < MLDSA_N / 4; i++)
|
|
763
762
|
__loop__(
|
|
764
763
|
invariant(i <= MLDSA_N/4)
|
|
765
764
|
decreases(MLDSA_N / 4 - i))
|
|
@@ -785,10 +784,10 @@ void mld_polyt1_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT1_PACKEDBYTES])
|
|
|
785
784
|
{
|
|
786
785
|
unsigned int i;
|
|
787
786
|
|
|
788
|
-
for (i = 0; i < MLDSA_N / 4; ++
|
|
787
|
+
for (i = 0; i < MLDSA_N / 4; i++)
|
|
789
788
|
__loop__(
|
|
790
789
|
invariant(i <= MLDSA_N/4)
|
|
791
|
-
invariant(array_bound(r->coeffs, 0, i*4, 0, 1 <<
|
|
790
|
+
invariant(array_bound(r->coeffs, 0, i*4, 0, 1 << MLDSA_POLYT1_PACKEDBITS))
|
|
792
791
|
decreases(MLDSA_N / 4 - i))
|
|
793
792
|
{
|
|
794
793
|
r->coeffs[4 * i + 0] =
|
|
@@ -801,7 +800,7 @@ void mld_polyt1_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT1_PACKEDBYTES])
|
|
|
801
800
|
((a[5 * i + 3] >> 6) | ((int32_t)a[5 * i + 4] << 2)) & 0x3FF;
|
|
802
801
|
}
|
|
803
802
|
|
|
804
|
-
mld_assert_bound(r->coeffs, MLDSA_N, 0, 1 <<
|
|
803
|
+
mld_assert_bound(r->coeffs, MLDSA_N, 0, 1 << MLDSA_POLYT1_PACKEDBITS);
|
|
805
804
|
}
|
|
806
805
|
#endif /* !MLD_CONFIG_NO_VERIFY_API */
|
|
807
806
|
|
|
@@ -815,7 +814,7 @@ void mld_polyt0_pack(uint8_t r[MLDSA_POLYT0_PACKEDBYTES], const mld_poly *a)
|
|
|
815
814
|
mld_assert_bound(a->coeffs, MLDSA_N, -(1 << (MLDSA_D - 1)) + 1,
|
|
816
815
|
(1 << (MLDSA_D - 1)) + 1);
|
|
817
816
|
|
|
818
|
-
for (i = 0; i < MLDSA_N / 8; ++
|
|
817
|
+
for (i = 0; i < MLDSA_N / 8; i++)
|
|
819
818
|
__loop__(
|
|
820
819
|
invariant(i <= MLDSA_N/8)
|
|
821
820
|
decreases(MLDSA_N / 8 - i))
|
|
@@ -852,6 +851,8 @@ void mld_polyt0_pack(uint8_t r[MLDSA_POLYT0_PACKEDBYTES], const mld_poly *a)
|
|
|
852
851
|
r[13 * i + 11] |= (uint8_t)((t[7] << 3) & 0xFF);
|
|
853
852
|
r[13 * i + 12] = (uint8_t)((t[7] >> 5) & 0xFF);
|
|
854
853
|
}
|
|
854
|
+
/* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
|
|
855
|
+
mld_zeroize(t, sizeof(t));
|
|
855
856
|
}
|
|
856
857
|
#endif /* !MLD_CONFIG_NO_KEYPAIR_API */
|
|
857
858
|
|
|
@@ -861,7 +862,7 @@ void mld_polyt0_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT0_PACKEDBYTES])
|
|
|
861
862
|
{
|
|
862
863
|
unsigned int i;
|
|
863
864
|
|
|
864
|
-
for (i = 0; i < MLDSA_N / 8; ++
|
|
865
|
+
for (i = 0; i < MLDSA_N / 8; i++)
|
|
865
866
|
__loop__(
|
|
866
867
|
invariant(i <= MLDSA_N/8)
|
|
867
868
|
invariant(array_bound(r->coeffs, 0, i*8, -(1<<(MLDSA_D-1)) + 1, (1<<(MLDSA_D-1)) + 1))
|
|
@@ -918,6 +919,10 @@ void mld_polyt0_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYT0_PACKEDBYTES])
|
|
|
918
919
|
}
|
|
919
920
|
#endif /* !MLD_CONFIG_NO_SIGN_API || MLD_UNIT_TEST */
|
|
920
921
|
|
|
922
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API) || \
|
|
923
|
+
(!defined(MLD_CONFIG_NO_KEYPAIR_API) && \
|
|
924
|
+
!defined(MLD_CONFIG_CORE_API_ONLY)) || \
|
|
925
|
+
defined(MLD_UNIT_TEST)
|
|
921
926
|
MLD_STATIC_TESTABLE uint32_t mld_poly_chknorm_c(const mld_poly *a, int32_t B)
|
|
922
927
|
__contract__(
|
|
923
928
|
requires(memory_no_alias(a, sizeof(mld_poly)))
|
|
@@ -931,7 +936,7 @@ __contract__(
|
|
|
931
936
|
uint32_t t = 0;
|
|
932
937
|
mld_assert_bound(a->coeffs, MLDSA_N, -MLD_REDUCE32_RANGE_MAX,
|
|
933
938
|
MLD_REDUCE32_RANGE_MAX);
|
|
934
|
-
for (i = 0; i < MLDSA_N; ++
|
|
939
|
+
for (i = 0; i < MLDSA_N; i++)
|
|
935
940
|
__loop__(
|
|
936
941
|
invariant(i <= MLDSA_N)
|
|
937
942
|
invariant(t == 0 || t == 0xFFFFFFFF)
|
|
@@ -1004,6 +1009,9 @@ uint32_t mld_poly_chknorm(const mld_poly *a, int32_t B)
|
|
|
1004
1009
|
#endif /* MLD_USE_NATIVE_POLY_CHKNORM */
|
|
1005
1010
|
return mld_poly_chknorm_c(a, B);
|
|
1006
1011
|
}
|
|
1012
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API || \
|
|
1013
|
+
(!MLD_CONFIG_NO_KEYPAIR_API && !MLD_CONFIG_CORE_API_ONLY) || \
|
|
1014
|
+
MLD_UNIT_TEST */
|
|
1007
1015
|
|
|
1008
1016
|
#if !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)
|
|
1009
1017
|
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
@@ -1017,7 +1025,7 @@ void mld_polyw1_pack_88(uint8_t r[MLDSA_POLYW1_PACKEDBYTES_88],
|
|
|
1017
1025
|
mld_assert_bound(a->coeffs, MLDSA_N, 0,
|
|
1018
1026
|
(MLDSA_Q - 1) / (2 * MLDSA_GAMMA2_88));
|
|
1019
1027
|
|
|
1020
|
-
for (i = 0; i < MLDSA_N / 4; ++
|
|
1028
|
+
for (i = 0; i < MLDSA_N / 4; i++)
|
|
1021
1029
|
__loop__(
|
|
1022
1030
|
invariant(i <= MLDSA_N/4)
|
|
1023
1031
|
decreases(MLDSA_N / 4 - i))
|
|
@@ -1044,7 +1052,7 @@ void mld_polyw1_pack_32(uint8_t r[MLDSA_POLYW1_PACKEDBYTES_32],
|
|
|
1044
1052
|
mld_assert_bound(a->coeffs, MLDSA_N, 0,
|
|
1045
1053
|
(MLDSA_Q - 1) / (2 * MLDSA_GAMMA2_32));
|
|
1046
1054
|
|
|
1047
|
-
for (i = 0; i < MLDSA_N / 2; ++
|
|
1055
|
+
for (i = 0; i < MLDSA_N / 2; i++)
|
|
1048
1056
|
__loop__(
|
|
1049
1057
|
invariant(i <= MLDSA_N/2)
|
|
1050
1058
|
decreases(MLDSA_N / 2 - i))
|
|
@@ -1057,6 +1065,57 @@ void mld_polyw1_pack_32(uint8_t r[MLDSA_POLYW1_PACKEDBYTES_32],
|
|
|
1057
1065
|
|| MLD_CONFIG_PARAMETER_SET == 87 */
|
|
1058
1066
|
#endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API */
|
|
1059
1067
|
|
|
1068
|
+
#if !defined(MLD_CONFIG_NO_SIGN_API)
|
|
1069
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
|
|
1070
|
+
MLD_INTERNAL_API
|
|
1071
|
+
void mld_polyw1_unpack_88(mld_poly *r,
|
|
1072
|
+
const uint8_t a[MLDSA_POLYW1_PACKEDBYTES_88])
|
|
1073
|
+
{
|
|
1074
|
+
unsigned int i;
|
|
1075
|
+
|
|
1076
|
+
for (i = 0; i < MLDSA_N / 4; i++)
|
|
1077
|
+
__loop__(
|
|
1078
|
+
invariant(i <= MLDSA_N/4)
|
|
1079
|
+
invariant(array_bound(r->coeffs, 0, i*4, 0, 1 << MLDSA_POLYW1_PACKEDBITS_88))
|
|
1080
|
+
decreases(MLDSA_N / 4 - i))
|
|
1081
|
+
{
|
|
1082
|
+
r->coeffs[4 * i + 0] = a[3 * i + 0] & 0x3F;
|
|
1083
|
+
r->coeffs[4 * i + 1] =
|
|
1084
|
+
((a[3 * i + 0] >> 6) | ((int32_t)a[3 * i + 1] << 2)) & 0x3F;
|
|
1085
|
+
r->coeffs[4 * i + 2] =
|
|
1086
|
+
((a[3 * i + 1] >> 4) | ((int32_t)a[3 * i + 2] << 4)) & 0x3F;
|
|
1087
|
+
r->coeffs[4 * i + 3] = a[3 * i + 2] >> 2;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
mld_assert_bound(r->coeffs, MLDSA_N, 0, 1 << MLDSA_POLYW1_PACKEDBITS_88);
|
|
1091
|
+
}
|
|
1092
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44 \
|
|
1093
|
+
*/
|
|
1094
|
+
|
|
1095
|
+
#if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
|
|
1096
|
+
(MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
|
|
1097
|
+
MLD_INTERNAL_API
|
|
1098
|
+
void mld_polyw1_unpack_32(mld_poly *r,
|
|
1099
|
+
const uint8_t a[MLDSA_POLYW1_PACKEDBYTES_32])
|
|
1100
|
+
{
|
|
1101
|
+
unsigned int i;
|
|
1102
|
+
|
|
1103
|
+
for (i = 0; i < MLDSA_N / 2; i++)
|
|
1104
|
+
__loop__(
|
|
1105
|
+
invariant(i <= MLDSA_N/2)
|
|
1106
|
+
invariant(array_bound(r->coeffs, 0, i*2, 0, 1 << MLDSA_POLYW1_PACKEDBITS_32))
|
|
1107
|
+
decreases(MLDSA_N / 2 - i))
|
|
1108
|
+
{
|
|
1109
|
+
r->coeffs[2 * i + 0] = a[i] & 0x0F;
|
|
1110
|
+
r->coeffs[2 * i + 1] = a[i] >> 4;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
mld_assert_bound(r->coeffs, MLDSA_N, 0, 1 << MLDSA_POLYW1_PACKEDBITS_32);
|
|
1114
|
+
}
|
|
1115
|
+
#endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
|
|
1116
|
+
|| MLD_CONFIG_PARAMETER_SET == 87 */
|
|
1117
|
+
#endif /* !MLD_CONFIG_NO_SIGN_API */
|
|
1118
|
+
|
|
1060
1119
|
#else /* !MLD_CONFIG_MULTILEVEL_NO_SHARED */
|
|
1061
1120
|
MLD_EMPTY_CU(mld_poly)
|
|
1062
1121
|
#endif /* MLD_CONFIG_MULTILEVEL_NO_SHARED */
|