pq_crypto 0.4.2 → 0.5.1

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.
Files changed (410) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +27 -2
  3. data/CHANGELOG.md +59 -0
  4. data/GET_STARTED.md +21 -16
  5. data/README.md +26 -0
  6. data/SECURITY.md +22 -16
  7. data/ext/pqcrypto/extconf.rb +183 -99
  8. data/ext/pqcrypto/mldsa_api.h +1 -118
  9. data/ext/pqcrypto/mlkem_api.h +1 -42
  10. data/ext/pqcrypto/pq_externalmu.c +88 -216
  11. data/ext/pqcrypto/pqcrypto_native_api.h +132 -0
  12. data/ext/pqcrypto/pqcrypto_ruby_secure.c +234 -12
  13. data/ext/pqcrypto/pqcrypto_secure.c +429 -334
  14. data/ext/pqcrypto/pqcrypto_secure.h +13 -45
  15. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  16. data/ext/pqcrypto/randombytes.h +9 -0
  17. data/ext/pqcrypto/vendor/.vendored +12 -5
  18. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +105 -0
  19. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +286 -0
  20. data/ext/pqcrypto/vendor/mldsa-native/META.yml +24 -0
  21. data/ext/pqcrypto/vendor/mldsa-native/README.md +221 -0
  22. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +8 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +721 -0
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +975 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +724 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +723 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +166 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +321 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +385 -0
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +73 -0
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +130 -0
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +277 -0
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +244 -0
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +182 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +117 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +438 -0
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +105 -0
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +71 -0
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +62 -0
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +376 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +204 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +259 -0
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1077 -0
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +987 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +41 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +26 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +35 -0
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +37 -0
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +27 -0
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +36 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +69 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +32 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +20 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +638 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +136 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +52 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +29 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +488 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +16 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/xkcp.h +31 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +247 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +231 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +150 -0
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +753 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +129 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +145 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +177 -0
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +653 -0
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +79 -0
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +53 -0
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +55 -0
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +85 -0
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +85 -0
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +102 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +110 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +72 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +69 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +40 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +189 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +135 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +128 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +543 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +62 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +649 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +23 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +315 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +124 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +2311 -0
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +2383 -0
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +239 -0
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +131 -0
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +139 -0
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +155 -0
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +187 -0
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +61 -0
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +52 -0
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +155 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +155 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +102 -0
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +104 -0
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +91 -0
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +93 -0
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +126 -0
  108. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +155 -0
  109. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +139 -0
  110. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +160 -0
  111. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +293 -0
  112. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +224 -0
  113. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +77 -0
  114. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +991 -0
  115. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +393 -0
  116. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +946 -0
  117. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +360 -0
  118. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +877 -0
  119. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +725 -0
  120. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  121. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +139 -0
  122. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +249 -0
  123. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +1511 -0
  124. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +806 -0
  125. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  126. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +268 -0
  127. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  128. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +104 -0
  129. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +294 -0
  130. data/ext/pqcrypto/vendor/mlkem-native/META.yml +30 -0
  131. data/ext/pqcrypto/vendor/mlkem-native/README.md +223 -0
  132. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +86 -0
  133. data/ext/pqcrypto/vendor/mlkem-native/SECURITY.md +8 -0
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +23 -0
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +660 -0
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +538 -0
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +681 -0
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +709 -0
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +174 -0
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +274 -0
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +717 -0
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +688 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +64 -0
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +128 -0
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +251 -0
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +158 -0
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +208 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +80 -0
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +463 -0
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +98 -0
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +70 -0
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +375 -0
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +203 -0
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +258 -0
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1076 -0
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +986 -0
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +46 -0
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +25 -0
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +34 -0
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +35 -0
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +26 -0
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +35 -0
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +117 -0
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/README.md +10 -0
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +79 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +35 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +667 -0
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +40 -0
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +51 -0
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +290 -0
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +314 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +28 -0
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +33 -0
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +41 -0
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2.S +451 -0
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +51 -0
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +622 -0
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +156 -0
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +446 -0
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +326 -0
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/README.md +16 -0
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +122 -0
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +174 -0
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +177 -0
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/intt.S +628 -0
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/ntt.S +562 -0
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_mulcache_compute_asm.S +127 -0
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_reduce_asm.S +150 -0
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tobytes_asm.S +117 -0
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tomont_asm.S +98 -0
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +261 -0
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +314 -0
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +368 -0
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_asm.S +226 -0
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +542 -0
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +637 -0
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +25 -0
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/README.md +11 -0
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +128 -0
  201. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +45 -0
  202. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +81 -0
  203. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +145 -0
  204. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_izetas.inc +27 -0
  205. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +805 -0
  206. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas.inc +27 -0
  207. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas_basemul.inc +39 -0
  208. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/README.md +4 -0
  209. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +304 -0
  210. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +309 -0
  211. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +94 -0
  212. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +45 -0
  213. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +102 -0
  214. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +25 -0
  215. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/intt.S +719 -0
  216. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mulcache_compute.S +90 -0
  217. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntt.S +639 -0
  218. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttfrombytes.S +193 -0
  219. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntttobytes.S +181 -0
  220. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttunpack.S +174 -0
  221. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d10.S +382 -0
  222. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d11.S +448 -0
  223. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d4.S +163 -0
  224. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d5.S +220 -0
  225. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d10.S +228 -0
  226. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d11.S +277 -0
  227. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d4.S +180 -0
  228. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d5.S +192 -0
  229. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +502 -0
  230. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +750 -0
  231. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +998 -0
  232. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/reduce.S +218 -0
  233. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_asm.S +103 -0
  234. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +544 -0
  235. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/tomont.S +155 -0
  236. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/params.h +76 -0
  237. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +572 -0
  238. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +317 -0
  239. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +502 -0
  240. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +668 -0
  241. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +60 -0
  242. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +362 -0
  243. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +118 -0
  244. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/symmetric.h +70 -0
  245. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +260 -0
  246. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.c +20 -0
  247. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +464 -0
  248. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/zetas.inc +30 -0
  249. data/lib/pq_crypto/hybrid_kem.rb +10 -1
  250. data/lib/pq_crypto/version.rb +1 -1
  251. data/lib/pq_crypto.rb +5 -1
  252. data/script/vendor_libs.rb +228 -154
  253. metadata +236 -160
  254. data/ext/pqcrypto/vendor/pqclean/common/aes.c +0 -639
  255. data/ext/pqcrypto/vendor/pqclean/common/aes.h +0 -64
  256. data/ext/pqcrypto/vendor/pqclean/common/compat.h +0 -73
  257. data/ext/pqcrypto/vendor/pqclean/common/crypto_declassify.h +0 -7
  258. data/ext/pqcrypto/vendor/pqclean/common/fips202.c +0 -928
  259. data/ext/pqcrypto/vendor/pqclean/common/fips202.h +0 -166
  260. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/feat.S +0 -168
  261. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.c +0 -684
  262. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.h +0 -60
  263. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SIMD256.c +0 -1028
  264. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SnP.h +0 -50
  265. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-unrolling.macros +0 -198
  266. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile +0 -8
  267. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile.Microsoft_nmake +0 -8
  268. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/SIMD256-config.h +0 -3
  269. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/align.h +0 -34
  270. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/brg_endian.h +0 -142
  271. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.c +0 -101
  272. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.h +0 -39
  273. data/ext/pqcrypto/vendor/pqclean/common/randombytes.c +0 -355
  274. data/ext/pqcrypto/vendor/pqclean/common/randombytes.h +0 -27
  275. data/ext/pqcrypto/vendor/pqclean/common/sha2.c +0 -769
  276. data/ext/pqcrypto/vendor/pqclean/common/sha2.h +0 -173
  277. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.c +0 -156
  278. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.h +0 -27
  279. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/LICENSE +0 -5
  280. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile +0 -19
  281. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile.Microsoft_nmake +0 -23
  282. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/api.h +0 -18
  283. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.c +0 -83
  284. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.h +0 -11
  285. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.c +0 -327
  286. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.h +0 -22
  287. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.c +0 -164
  288. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.h +0 -23
  289. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.c +0 -146
  290. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.h +0 -14
  291. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/params.h +0 -36
  292. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.c +0 -311
  293. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.h +0 -37
  294. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.c +0 -198
  295. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.h +0 -26
  296. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.c +0 -41
  297. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.h +0 -13
  298. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric-shake.c +0 -71
  299. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric.h +0 -30
  300. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.c +0 -67
  301. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.h +0 -13
  302. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/LICENSE +0 -5
  303. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile +0 -19
  304. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile.Microsoft_nmake +0 -23
  305. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/api.h +0 -18
  306. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.c +0 -108
  307. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.h +0 -11
  308. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.c +0 -327
  309. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.h +0 -22
  310. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.c +0 -164
  311. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.h +0 -23
  312. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.c +0 -146
  313. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.h +0 -14
  314. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/params.h +0 -36
  315. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.c +0 -299
  316. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.h +0 -37
  317. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.c +0 -188
  318. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.h +0 -26
  319. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.c +0 -41
  320. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.h +0 -13
  321. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric-shake.c +0 -71
  322. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric.h +0 -30
  323. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.c +0 -67
  324. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.h +0 -13
  325. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/LICENSE +0 -5
  326. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile +0 -19
  327. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile.Microsoft_nmake +0 -23
  328. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/api.h +0 -18
  329. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.c +0 -83
  330. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.h +0 -11
  331. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.c +0 -327
  332. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.h +0 -22
  333. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.c +0 -164
  334. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.h +0 -23
  335. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.c +0 -146
  336. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.h +0 -14
  337. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/params.h +0 -36
  338. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.c +0 -299
  339. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.h +0 -37
  340. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.c +0 -188
  341. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.h +0 -26
  342. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.c +0 -41
  343. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.h +0 -13
  344. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric-shake.c +0 -71
  345. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric.h +0 -30
  346. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.c +0 -67
  347. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.h +0 -13
  348. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/LICENSE +0 -5
  349. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile +0 -19
  350. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile.Microsoft_nmake +0 -23
  351. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/api.h +0 -50
  352. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.c +0 -98
  353. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.h +0 -10
  354. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.c +0 -261
  355. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.h +0 -31
  356. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/params.h +0 -44
  357. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.c +0 -848
  358. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.h +0 -52
  359. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.c +0 -415
  360. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.h +0 -65
  361. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.c +0 -69
  362. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.h +0 -17
  363. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.c +0 -98
  364. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.h +0 -14
  365. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.c +0 -407
  366. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.h +0 -47
  367. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric-shake.c +0 -26
  368. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric.h +0 -34
  369. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/LICENSE +0 -5
  370. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile +0 -19
  371. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile.Microsoft_nmake +0 -23
  372. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/api.h +0 -50
  373. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.c +0 -98
  374. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.h +0 -10
  375. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.c +0 -261
  376. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.h +0 -31
  377. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/params.h +0 -44
  378. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.c +0 -799
  379. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.h +0 -52
  380. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.c +0 -415
  381. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.h +0 -65
  382. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.c +0 -69
  383. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.h +0 -17
  384. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.c +0 -92
  385. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.h +0 -14
  386. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.c +0 -407
  387. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.h +0 -47
  388. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric-shake.c +0 -26
  389. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric.h +0 -34
  390. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/LICENSE +0 -5
  391. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile +0 -19
  392. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile.Microsoft_nmake +0 -23
  393. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/api.h +0 -50
  394. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.c +0 -98
  395. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.h +0 -10
  396. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.c +0 -261
  397. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.h +0 -31
  398. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/params.h +0 -44
  399. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.c +0 -823
  400. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.h +0 -52
  401. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.c +0 -415
  402. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.h +0 -65
  403. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.c +0 -69
  404. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.h +0 -17
  405. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.c +0 -92
  406. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.h +0 -14
  407. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.c +0 -407
  408. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.h +0 -47
  409. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric-shake.c +0 -26
  410. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric.h +0 -34
@@ -0,0 +1,877 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [FIPS204]
10
+ * FIPS 204 Module-Lattice-Based Digital Signature Standard
11
+ * National Institute of Standards and Technology
12
+ * https://csrc.nist.gov/pubs/fips/204/final
13
+ */
14
+
15
+ #include "polyvec.h"
16
+
17
+ #include "debug.h"
18
+
19
+ /* This namespacing is not done at the top to avoid a naming conflict
20
+ * with native backends, which are currently not yet namespaced. */
21
+ #define mld_polymat_permute_bitrev_to_custom \
22
+ MLD_ADD_PARAM_SET(mld_polymat_permute_bitrev_to_custom)
23
+ #define mld_polyvecl_permute_bitrev_to_custom \
24
+ MLD_ADD_PARAM_SET(mld_polyvecl_permute_bitrev_to_custom)
25
+ #define mld_polyvecl_pointwise_acc_montgomery_c \
26
+ MLD_ADD_PARAM_SET(mld_polyvecl_pointwise_acc_montgomery_c)
27
+
28
+ #if !defined(MLD_CONFIG_REDUCE_RAM)
29
+ /* Helper function to ensure that the polynomial entries in the output
30
+ * of mld_polyvec_matrix_expand use the standard (bitreversed) ordering
31
+ * of coefficients.
32
+ * No-op unless a native backend with a custom ordering is used.
33
+ */
34
+
35
+ static void mld_polyvecl_permute_bitrev_to_custom(mld_polyvecl *v)
36
+ __contract__(
37
+ /* We don't specify that this should be a permutation, but only
38
+ * that it does not change the bound established at the end of
39
+ * mld_polyvec_matrix_expand.
40
+ */
41
+ requires(memory_no_alias(v, sizeof(mld_polyvecl)))
42
+ requires(forall(x, 0, MLDSA_L,
43
+ array_bound(v->vec[x].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
44
+ assigns(memory_slice(v, sizeof(mld_polyvecl)))
45
+ ensures(forall(x, 0, MLDSA_L,
46
+ array_bound(v->vec[x].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
47
+ {
48
+ #if defined(MLD_USE_NATIVE_NTT_CUSTOM_ORDER)
49
+ unsigned i;
50
+ for (i = 0; i < MLDSA_L; i++)
51
+ __loop__(
52
+ assigns(i, memory_slice(v, sizeof(mld_polyvecl)))
53
+ invariant(i <= MLDSA_L)
54
+ invariant(forall(x, 0, MLDSA_L,
55
+ array_bound(v->vec[x].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
56
+ decreases(MLDSA_L - i))
57
+ {
58
+ mld_poly_permute_bitrev_to_custom(v->vec[i].coeffs);
59
+ }
60
+ #else /* MLD_USE_NATIVE_NTT_CUSTOM_ORDER */
61
+ /* Nothing to do */
62
+ (void)v;
63
+ #endif /* !MLD_USE_NATIVE_NTT_CUSTOM_ORDER */
64
+ }
65
+
66
+ static void mld_polymat_permute_bitrev_to_custom(mld_polymat *mat)
67
+ __contract__(
68
+ /* We don't specify that this should be a permutation, but only
69
+ * that it does not change the bound established at the end of
70
+ * mld_polyvec_matrix_expand.
71
+ */
72
+ requires(memory_no_alias(mat, sizeof(mld_polymat)))
73
+ requires(forall(k1, 0, MLDSA_K, forall(l1, 0, MLDSA_L,
74
+ array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
75
+ assigns(memory_slice(mat, sizeof(mld_polymat)))
76
+ ensures(forall(k1, 0, MLDSA_K, forall(l1, 0, MLDSA_L,
77
+ array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
78
+ )
79
+ {
80
+ unsigned int i;
81
+ for (i = 0; i < MLDSA_K; i++)
82
+ __loop__(
83
+ assigns(i, memory_slice(mat, sizeof(mld_polymat)))
84
+ invariant(i <= MLDSA_K)
85
+ invariant(forall(k1, 0, MLDSA_K, forall(l1, 0, MLDSA_L,
86
+ array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
87
+ decreases(MLDSA_K - i))
88
+ {
89
+ mld_polyvecl_permute_bitrev_to_custom(&mat->vec[i]);
90
+ }
91
+ }
92
+ #endif /* !MLD_CONFIG_REDUCE_RAM */
93
+
94
+ MLD_INTERNAL_API
95
+ const mld_polyvecl *mld_polymat_get_row(mld_polymat *mat, unsigned int row)
96
+ {
97
+ #if defined(MLD_CONFIG_REDUCE_RAM)
98
+ unsigned int i;
99
+ MLD_ALIGN uint8_t seed_ext[MLD_ALIGN_UP(MLDSA_SEEDBYTES + 2)];
100
+
101
+ mld_memcpy(seed_ext, mat->rho, MLDSA_SEEDBYTES);
102
+
103
+ /* Generate row on-demand */
104
+ for (i = 0; i < MLDSA_L; i++)
105
+ {
106
+ uint8_t x = (uint8_t)row;
107
+ uint8_t y = (uint8_t)i;
108
+
109
+ seed_ext[MLDSA_SEEDBYTES + 0] = y;
110
+ seed_ext[MLDSA_SEEDBYTES + 1] = x;
111
+
112
+ mld_poly_uniform(&mat->row_buffer.vec[i], seed_ext);
113
+
114
+ #if defined(MLD_USE_NATIVE_NTT_CUSTOM_ORDER)
115
+ mld_poly_permute_bitrev_to_custom(mat->row_buffer.vec[i].coeffs);
116
+ #endif
117
+ }
118
+
119
+ /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
120
+ mld_zeroize(seed_ext, sizeof(seed_ext));
121
+
122
+ return &mat->row_buffer;
123
+ #else /* MLD_CONFIG_REDUCE_RAM */
124
+ return &mat->vec[row];
125
+ #endif /* !MLD_CONFIG_REDUCE_RAM */
126
+ }
127
+
128
+ MLD_INTERNAL_API
129
+ void mld_polyvec_matrix_expand(mld_polymat *mat,
130
+ const uint8_t rho[MLDSA_SEEDBYTES])
131
+ {
132
+ #if defined(MLD_CONFIG_REDUCE_RAM)
133
+ /* In REDUCE_RAM mode, just copy the seed for later on-demand generation */
134
+ mld_memcpy(mat->rho, rho, MLDSA_SEEDBYTES);
135
+ #else
136
+ unsigned int i, j;
137
+ /*
138
+ * We generate four separate seed arrays rather than a single one to work
139
+ * around limitations in CBMC function contracts dealing with disjoint slices
140
+ * of the same parent object.
141
+ */
142
+
143
+ MLD_ALIGN uint8_t seed_ext[4][MLD_ALIGN_UP(MLDSA_SEEDBYTES + 2)];
144
+
145
+ for (j = 0; j < 4; j++)
146
+ __loop__(
147
+ assigns(j, object_whole(seed_ext))
148
+ invariant(j <= 4)
149
+ decreases(4 - j)
150
+ )
151
+ {
152
+ mld_memcpy(seed_ext[j], rho, MLDSA_SEEDBYTES);
153
+ }
154
+
155
+ #if !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
156
+ /* Sample 4 matrix entries a time. */
157
+ for (i = 0; i < (MLDSA_K * MLDSA_L / 4) * 4; i += 4)
158
+ __loop__(
159
+ assigns(i, j, object_whole(seed_ext), memory_slice(mat, sizeof(mld_polymat)))
160
+ invariant(i <= (MLDSA_K * MLDSA_L / 4) * 4 && i % 4 == 0)
161
+ /* vectors 0 .. i / MLDSA_L are completely sampled */
162
+ invariant(forall(k1, 0, i / MLDSA_L, forall(l1, 0, MLDSA_L,
163
+ array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
164
+ /* last vector is sampled up to i % MLDSA_L */
165
+ invariant(forall(k2, i / MLDSA_L, i / MLDSA_L + 1, forall(l2, 0, i % MLDSA_L,
166
+ array_bound(mat->vec[k2].vec[l2].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
167
+ decreases((MLDSA_K * MLDSA_L / 4) * 4 - i)
168
+ )
169
+ {
170
+ for (j = 0; j < 4; j++)
171
+ __loop__(
172
+ assigns(j, object_whole(seed_ext))
173
+ invariant(j <= 4)
174
+ decreases(4 - j)
175
+ )
176
+ {
177
+ uint8_t x = (uint8_t)((i + j) / MLDSA_L);
178
+ uint8_t y = (uint8_t)((i + j) % MLDSA_L);
179
+
180
+ seed_ext[j][MLDSA_SEEDBYTES + 0] = y;
181
+ seed_ext[j][MLDSA_SEEDBYTES + 1] = x;
182
+ }
183
+
184
+ mld_poly_uniform_4x(&mat->vec[i / MLDSA_L].vec[i % MLDSA_L],
185
+ &mat->vec[(i + 1) / MLDSA_L].vec[(i + 1) % MLDSA_L],
186
+ &mat->vec[(i + 2) / MLDSA_L].vec[(i + 2) % MLDSA_L],
187
+ &mat->vec[(i + 3) / MLDSA_L].vec[(i + 3) % MLDSA_L],
188
+ seed_ext);
189
+ }
190
+ #else /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
191
+ i = 0;
192
+ #endif /* MLD_CONFIG_SERIAL_FIPS202_ONLY */
193
+
194
+ /* Entries omitted by the batch-sampling are sampled individually. */
195
+ while (i < MLDSA_K * MLDSA_L)
196
+ __loop__(
197
+ assigns(i, object_whole(seed_ext), memory_slice(mat, sizeof(mld_polymat)))
198
+ invariant(i <= MLDSA_K * MLDSA_L)
199
+ /* vectors 0 .. i / MLDSA_L are completely sampled */
200
+ invariant(forall(k1, 0, i / MLDSA_L, forall(l1, 0, MLDSA_L,
201
+ array_bound(mat->vec[k1].vec[l1].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
202
+ /* last vector is sampled up to i % MLDSA_L */
203
+ invariant(forall(k2, i / MLDSA_L, i / MLDSA_L + 1, forall(l2, 0, i % MLDSA_L,
204
+ array_bound(mat->vec[k2].vec[l2].coeffs, 0, MLDSA_N, 0, MLDSA_Q))))
205
+ decreases(MLDSA_K * MLDSA_L - i)
206
+ )
207
+ {
208
+ uint8_t x = (uint8_t)(i / MLDSA_L);
209
+ uint8_t y = (uint8_t)(i % MLDSA_L);
210
+ mld_poly *this_poly = &mat->vec[i / MLDSA_L].vec[i % MLDSA_L];
211
+
212
+ seed_ext[0][MLDSA_SEEDBYTES + 0] = y;
213
+ seed_ext[0][MLDSA_SEEDBYTES + 1] = x;
214
+
215
+ mld_poly_uniform(this_poly, seed_ext[0]);
216
+ i++;
217
+ }
218
+
219
+ mld_polymat_permute_bitrev_to_custom(mat);
220
+
221
+ /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
222
+ mld_zeroize(seed_ext, sizeof(seed_ext));
223
+ #endif /* !MLD_CONFIG_REDUCE_RAM */
224
+ }
225
+
226
+ MLD_INTERNAL_API
227
+ void mld_polyvec_matrix_pointwise_montgomery(mld_polyveck *t, mld_polymat *mat,
228
+ const mld_polyvecl *v)
229
+ {
230
+ unsigned int i;
231
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLD_NTT_BOUND);
232
+
233
+ for (i = 0; i < MLDSA_K; ++i)
234
+ __loop__(
235
+ assigns(i, memory_slice(t, sizeof(mld_polyveck)))
236
+ invariant(i <= MLDSA_K)
237
+ invariant(forall(k0, 0, i,
238
+ array_abs_bound(t->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
239
+ decreases(MLDSA_K - i)
240
+ )
241
+ {
242
+ const mld_polyvecl *row = mld_polymat_get_row(mat, i);
243
+ mld_polyvecl_pointwise_acc_montgomery(&t->vec[i], row, v);
244
+ }
245
+
246
+ mld_assert_abs_bound_2d(t->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
247
+ }
248
+
249
+ /**************************************************************/
250
+ /************ Vectors of polynomials of length MLDSA_L **************/
251
+ /**************************************************************/
252
+ MLD_INTERNAL_API
253
+ void mld_polyvecl_uniform_gamma1(mld_polyvecl *v,
254
+ const uint8_t seed[MLDSA_CRHBYTES],
255
+ uint16_t nonce)
256
+ {
257
+ #if defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
258
+ int i;
259
+ #endif
260
+
261
+ /* Safety: nonce is at most ((UINT16_MAX - MLDSA_L) / MLDSA_L), and, hence,
262
+ * this cast is safe. See MLD_NONCE_UB comment in sign.c. */
263
+ nonce = (uint16_t)(MLDSA_L * nonce);
264
+ /* Now, nonce <= UINT16_MAX - (MLDSA_L - 1), so the casts below are safe. */
265
+ #if defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
266
+ for (i = 0; i < MLDSA_L; i++)
267
+ {
268
+ mld_poly_uniform_gamma1(&v->vec[i], seed, (uint16_t)(nonce + i));
269
+ }
270
+ #else /* MLD_CONFIG_SERIAL_FIPS202_ONLY */
271
+ #if MLDSA_L == 4
272
+ mld_poly_uniform_gamma1_4x(&v->vec[0], &v->vec[1], &v->vec[2], &v->vec[3],
273
+ seed, nonce, (uint16_t)(nonce + 1),
274
+ (uint16_t)(nonce + 2), (uint16_t)(nonce + 3));
275
+ #elif MLDSA_L == 5
276
+ mld_poly_uniform_gamma1_4x(&v->vec[0], &v->vec[1], &v->vec[2], &v->vec[3],
277
+ seed, nonce, (uint16_t)(nonce + 1),
278
+ (uint16_t)(nonce + 2), (uint16_t)(nonce + 3));
279
+ mld_poly_uniform_gamma1(&v->vec[4], seed, (uint16_t)(nonce + 4));
280
+ #elif MLDSA_L == 7
281
+ mld_poly_uniform_gamma1_4x(&v->vec[0], &v->vec[1], &v->vec[2],
282
+ &v->vec[3 /* irrelevant */], seed, nonce,
283
+ (uint16_t)(nonce + 1), (uint16_t)(nonce + 2),
284
+ 0xFF /* irrelevant */);
285
+ mld_poly_uniform_gamma1_4x(&v->vec[3], &v->vec[4], &v->vec[5], &v->vec[6],
286
+ seed, (uint16_t)(nonce + 3), (uint16_t)(nonce + 4),
287
+ (uint16_t)(nonce + 5), (uint16_t)(nonce + 6));
288
+ #endif /* MLDSA_L == 7 */
289
+ #endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
290
+
291
+ mld_assert_bound_2d(v->vec, MLDSA_L, MLDSA_N, -(MLDSA_GAMMA1 - 1),
292
+ MLDSA_GAMMA1 + 1);
293
+ }
294
+
295
+ MLD_INTERNAL_API
296
+ void mld_polyvecl_ntt(mld_polyvecl *v)
297
+ {
298
+ unsigned int i;
299
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLDSA_Q);
300
+
301
+ for (i = 0; i < MLDSA_L; ++i)
302
+ __loop__(
303
+ assigns(i, memory_slice(v, sizeof(mld_polyvecl)))
304
+ invariant(i <= MLDSA_L)
305
+ invariant(forall(k0, i, MLDSA_L, forall(k1, 0, MLDSA_N, v->vec[k0].coeffs[k1] == loop_entry(*v).vec[k0].coeffs[k1])))
306
+ invariant(forall(k1, 0, i, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
307
+ decreases(MLDSA_L - i))
308
+ {
309
+ mld_poly_ntt(&v->vec[i]);
310
+ }
311
+
312
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLD_NTT_BOUND);
313
+ }
314
+
315
+ MLD_STATIC_TESTABLE void mld_polyvecl_pointwise_acc_montgomery_c(
316
+ mld_poly *w, const mld_polyvecl *u, const mld_polyvecl *v)
317
+ __contract__(
318
+ requires(memory_no_alias(w, sizeof(mld_poly)))
319
+ requires(memory_no_alias(u, sizeof(mld_polyvecl)))
320
+ requires(memory_no_alias(v, sizeof(mld_polyvecl)))
321
+ requires(forall(l0, 0, MLDSA_L,
322
+ array_bound(u->vec[l0].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
323
+ requires(forall(l1, 0, MLDSA_L,
324
+ array_abs_bound(v->vec[l1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
325
+ assigns(memory_slice(w, sizeof(mld_poly)))
326
+ ensures(array_abs_bound(w->coeffs, 0, MLDSA_N, MLDSA_Q))
327
+ )
328
+ {
329
+ unsigned int i, j;
330
+ mld_assert_bound_2d(u->vec, MLDSA_L, MLDSA_N, 0, MLDSA_Q);
331
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLD_NTT_BOUND);
332
+ for (i = 0; i < MLDSA_N; i++)
333
+ __loop__(
334
+ assigns(i, j, memory_slice(w, sizeof(mld_poly)))
335
+ invariant(i <= MLDSA_N)
336
+ invariant(array_abs_bound(w->coeffs, 0, i, MLDSA_Q))
337
+ decreases(MLDSA_N - i)
338
+ )
339
+ {
340
+ int64_t t = 0;
341
+ int32_t r;
342
+ for (j = 0; j < MLDSA_L; j++)
343
+ __loop__(
344
+ assigns(j, t)
345
+ invariant(j <= MLDSA_L)
346
+ invariant(t >= -(int64_t)j*(MLDSA_Q - 1)*(MLD_NTT_BOUND - 1))
347
+ invariant(t <= (int64_t)j*(MLDSA_Q - 1)*(MLD_NTT_BOUND - 1))
348
+ decreases(MLDSA_L - j)
349
+ )
350
+ {
351
+ t += (int64_t)u->vec[j].coeffs[i] * v->vec[j].coeffs[i];
352
+ }
353
+
354
+ r = mld_montgomery_reduce(t);
355
+ w->coeffs[i] = r;
356
+ }
357
+
358
+ mld_assert_abs_bound(w->coeffs, MLDSA_N, MLDSA_Q);
359
+ }
360
+
361
+ MLD_INTERNAL_API
362
+ void mld_polyvecl_pointwise_acc_montgomery(mld_poly *w, const mld_polyvecl *u,
363
+ const mld_polyvecl *v)
364
+ {
365
+ #if defined(MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L4) && \
366
+ MLD_CONFIG_PARAMETER_SET == 44
367
+ int ret;
368
+ mld_assert_bound_2d(u->vec, MLDSA_L, MLDSA_N, 0, MLDSA_Q);
369
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLD_NTT_BOUND);
370
+ ret = mld_polyvecl_pointwise_acc_montgomery_l4_native(
371
+ w->coeffs, (const int32_t (*)[MLDSA_N])u->vec,
372
+ (const int32_t (*)[MLDSA_N])v->vec);
373
+ if (ret == MLD_NATIVE_FUNC_SUCCESS)
374
+ {
375
+ mld_assert_abs_bound(w->coeffs, MLDSA_N, MLDSA_Q);
376
+ return;
377
+ }
378
+ #elif defined(MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L5) && \
379
+ MLD_CONFIG_PARAMETER_SET == 65
380
+ int ret;
381
+ mld_assert_bound_2d(u->vec, MLDSA_L, MLDSA_N, 0, MLDSA_Q);
382
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLD_NTT_BOUND);
383
+ ret = mld_polyvecl_pointwise_acc_montgomery_l5_native(
384
+ w->coeffs, (const int32_t (*)[MLDSA_N])u->vec,
385
+ (const int32_t (*)[MLDSA_N])v->vec);
386
+ if (ret == MLD_NATIVE_FUNC_SUCCESS)
387
+ {
388
+ mld_assert_abs_bound(w->coeffs, MLDSA_N, MLDSA_Q);
389
+ return;
390
+ }
391
+ #elif defined(MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7) && \
392
+ MLD_CONFIG_PARAMETER_SET == 87
393
+ int ret;
394
+ mld_assert_bound_2d(u->vec, MLDSA_L, MLDSA_N, 0, MLDSA_Q);
395
+ mld_assert_abs_bound_2d(v->vec, MLDSA_L, MLDSA_N, MLD_NTT_BOUND);
396
+ ret = mld_polyvecl_pointwise_acc_montgomery_l7_native(
397
+ w->coeffs, (const int32_t (*)[MLDSA_N])u->vec,
398
+ (const int32_t (*)[MLDSA_N])v->vec);
399
+ if (ret == MLD_NATIVE_FUNC_SUCCESS)
400
+ {
401
+ mld_assert_abs_bound(w->coeffs, MLDSA_N, MLDSA_Q);
402
+ return;
403
+ }
404
+ #endif /* !(MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L4 && \
405
+ MLD_CONFIG_PARAMETER_SET == 44) && \
406
+ !(MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L5 && \
407
+ MLD_CONFIG_PARAMETER_SET == 65) && \
408
+ MLD_USE_NATIVE_POLYVECL_POINTWISE_ACC_MONTGOMERY_L7 && \
409
+ MLD_CONFIG_PARAMETER_SET == 87 */
410
+ /* The first input is bounded by [0, Q-1] inclusive
411
+ * The second input is bounded by [-9Q+1, 9Q-1] inclusive . Hence, we can
412
+ * safely accumulate in 64-bits without intermediate reductions as
413
+ * MLDSA_L * (MLD_NTT_BOUND-1) * (Q-1) < INT64_MAX
414
+ *
415
+ * The worst case is ML-DSA-87: 7 * (9Q-1) * (Q-1) < 2**52
416
+ * (and likewise for negative values)
417
+ */
418
+ mld_polyvecl_pointwise_acc_montgomery_c(w, u, v);
419
+ }
420
+
421
+ MLD_INTERNAL_API
422
+ uint32_t mld_polyvecl_chknorm(const mld_polyvecl *v, int32_t bound)
423
+ {
424
+ unsigned int i;
425
+ uint32_t t = 0;
426
+ mld_assert_bound_2d(v->vec, MLDSA_L, MLDSA_N, -MLD_REDUCE32_RANGE_MAX,
427
+ MLD_REDUCE32_RANGE_MAX);
428
+
429
+ for (i = 0; i < MLDSA_L; ++i)
430
+ __loop__(
431
+ invariant(i <= MLDSA_L)
432
+ invariant(t == 0 || t == 0xFFFFFFFF)
433
+ invariant((t == 0) == forall(k1, 0, i, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, bound)))
434
+ decreases(MLDSA_L - i)
435
+ )
436
+ {
437
+ /* Reference: Leaks which polynomial violates the bound via a conditional.
438
+ * We are more conservative to reduce the number of declassifications in
439
+ * constant-time testing.
440
+ */
441
+ t |= mld_poly_chknorm(&v->vec[i], bound);
442
+ }
443
+ return t;
444
+ }
445
+
446
+ /**************************************************************/
447
+ /************ Vectors of polynomials of length MLDSA_K **************/
448
+ /**************************************************************/
449
+ MLD_INTERNAL_API
450
+ void mld_polyveck_reduce(mld_polyveck *v)
451
+ {
452
+ unsigned int i;
453
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, INT32_MIN,
454
+ MLD_REDUCE32_DOMAIN_MAX);
455
+
456
+ for (i = 0; i < MLDSA_K; ++i)
457
+ __loop__(
458
+ assigns(i, memory_slice(v, sizeof(mld_polyveck)))
459
+ invariant(i <= MLDSA_K)
460
+ invariant(forall(k0, i, MLDSA_K, forall(k1, 0, MLDSA_N, v->vec[k0].coeffs[k1] == loop_entry(*v).vec[k0].coeffs[k1])))
461
+ invariant(forall(k2, 0, i,
462
+ array_bound(v->vec[k2].coeffs, 0, MLDSA_N, -MLD_REDUCE32_RANGE_MAX, MLD_REDUCE32_RANGE_MAX)))
463
+ decreases(MLDSA_K - i)
464
+ )
465
+ {
466
+ mld_poly_reduce(&v->vec[i]);
467
+ }
468
+
469
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, -MLD_REDUCE32_RANGE_MAX,
470
+ MLD_REDUCE32_RANGE_MAX);
471
+ }
472
+
473
+ MLD_INTERNAL_API
474
+ void mld_polyveck_caddq(mld_polyveck *v)
475
+ {
476
+ unsigned int i;
477
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
478
+
479
+ for (i = 0; i < MLDSA_K; ++i)
480
+ __loop__(
481
+ assigns(i, memory_slice(v, sizeof(mld_polyveck)))
482
+ invariant(i <= MLDSA_K)
483
+ invariant(forall(k0, i, MLDSA_K, forall(k1, 0, MLDSA_N, v->vec[k0].coeffs[k1] == loop_entry(*v).vec[k0].coeffs[k1])))
484
+ invariant(forall(k1, 0, i, array_bound(v->vec[k1].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
485
+ decreases(MLDSA_K - i))
486
+ {
487
+ mld_poly_caddq(&v->vec[i]);
488
+ }
489
+
490
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, 0, MLDSA_Q);
491
+ }
492
+
493
+ /* Reference: We use destructive version (output=first input) to avoid
494
+ * reasoning about aliasing in the CBMC specification */
495
+ MLD_INTERNAL_API
496
+ void mld_polyveck_add(mld_polyveck *u, const mld_polyveck *v)
497
+ {
498
+ unsigned int i;
499
+
500
+ for (i = 0; i < MLDSA_K; ++i)
501
+ __loop__(
502
+ assigns(i, memory_slice(u, sizeof(mld_polyveck)))
503
+ invariant(i <= MLDSA_K)
504
+ invariant(forall(k0, i, MLDSA_K,
505
+ forall(k1, 0, MLDSA_N, u->vec[k0].coeffs[k1] == loop_entry(*u).vec[k0].coeffs[k1])))
506
+ invariant(forall(k6, 0, i, array_bound(u->vec[k6].coeffs, 0, MLDSA_N, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX)))
507
+ decreases(MLDSA_K - i)
508
+ )
509
+ {
510
+ mld_poly_add(&u->vec[i], &v->vec[i]);
511
+ }
512
+ mld_assert_bound_2d(u->vec, MLDSA_K, MLDSA_N, INT32_MIN,
513
+ MLD_REDUCE32_DOMAIN_MAX);
514
+ }
515
+
516
+ MLD_INTERNAL_API
517
+ void mld_polyveck_sub(mld_polyveck *u, const mld_polyveck *v)
518
+ {
519
+ unsigned int i;
520
+ mld_assert_abs_bound_2d(u->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
521
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
522
+
523
+ for (i = 0; i < MLDSA_K; ++i)
524
+ __loop__(
525
+ assigns(i, memory_slice(u, sizeof(mld_polyveck)))
526
+ invariant(i <= MLDSA_K)
527
+ invariant(forall(k0, 0, i,
528
+ array_bound(u->vec[k0].coeffs, 0, MLDSA_N, INT32_MIN, MLD_REDUCE32_DOMAIN_MAX)))
529
+ invariant(forall(k1, i, MLDSA_K,
530
+ forall(n1, 0, MLDSA_N, u->vec[k1].coeffs[n1] == loop_entry(*u).vec[k1].coeffs[n1])))
531
+ decreases(MLDSA_K - i))
532
+ {
533
+ mld_poly_sub(&u->vec[i], &v->vec[i]);
534
+ }
535
+
536
+ mld_assert_bound_2d(u->vec, MLDSA_K, MLDSA_N, INT32_MIN,
537
+ MLD_REDUCE32_DOMAIN_MAX);
538
+ }
539
+
540
+ MLD_INTERNAL_API
541
+ void mld_polyveck_shiftl(mld_polyveck *v)
542
+ {
543
+ unsigned int i;
544
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, 0, 1 << 10);
545
+
546
+ for (i = 0; i < MLDSA_K; ++i)
547
+ __loop__(
548
+ assigns(i, memory_slice(v, sizeof(mld_polyveck)))
549
+ invariant(i <= MLDSA_K)
550
+ invariant(forall(k1, 0, i, array_bound(v->vec[k1].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
551
+ invariant(forall(k1, i, MLDSA_K,
552
+ forall(n1, 0, MLDSA_N, v->vec[k1].coeffs[n1] == loop_entry(*v).vec[k1].coeffs[n1])))
553
+ decreases(MLDSA_K - i)
554
+ )
555
+ {
556
+ mld_poly_shiftl(&v->vec[i]);
557
+ }
558
+
559
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, 0, MLDSA_Q);
560
+ }
561
+
562
+ MLD_INTERNAL_API
563
+ void mld_polyveck_ntt(mld_polyveck *v)
564
+ {
565
+ unsigned int i;
566
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
567
+
568
+ for (i = 0; i < MLDSA_K; ++i)
569
+ __loop__(
570
+ assigns(i, memory_slice(v, sizeof(mld_polyveck)))
571
+ invariant(i <= MLDSA_K)
572
+ invariant(forall(k0, i, MLDSA_K, forall(k1, 0, MLDSA_N, v->vec[k0].coeffs[k1] == loop_entry(*v).vec[k0].coeffs[k1])))
573
+ invariant(forall(k1, 0, i, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLD_NTT_BOUND)))
574
+ decreases(MLDSA_K - i))
575
+ {
576
+ mld_poly_ntt(&v->vec[i]);
577
+ }
578
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLD_NTT_BOUND);
579
+ }
580
+
581
+ MLD_INTERNAL_API
582
+ void mld_polyveck_invntt_tomont(mld_polyveck *v)
583
+ {
584
+ unsigned int i;
585
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
586
+
587
+ for (i = 0; i < MLDSA_K; ++i)
588
+ __loop__(
589
+ assigns(i, memory_slice(v, sizeof(mld_polyveck)))
590
+ invariant(i <= MLDSA_K)
591
+ invariant(forall(k0, i, MLDSA_K, forall(k1, 0, MLDSA_N, v->vec[k0].coeffs[k1] == loop_entry(*v).vec[k0].coeffs[k1])))
592
+ invariant(forall(k1, 0, i, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, MLD_INTT_BOUND)))
593
+ decreases(MLDSA_K - i))
594
+ {
595
+ mld_poly_invntt_tomont(&v->vec[i]);
596
+ }
597
+
598
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLD_INTT_BOUND);
599
+ }
600
+
601
+ MLD_INTERNAL_API
602
+ void mld_polyveck_pointwise_poly_montgomery(mld_polyveck *r, const mld_poly *a,
603
+ const mld_polyveck *v)
604
+ {
605
+ unsigned int i;
606
+ mld_assert_abs_bound_2d(v->vec, MLDSA_K, MLDSA_N, MLD_NTT_BOUND);
607
+
608
+ for (i = 0; i < MLDSA_K; ++i)
609
+ __loop__(
610
+ assigns(i, memory_slice(r, sizeof(mld_polyveck)))
611
+ invariant(i <= MLDSA_K)
612
+ invariant(forall(k2, 0, i, array_abs_bound(r->vec[k2].coeffs, 0, MLDSA_N, MLDSA_Q)))
613
+ decreases(MLDSA_K - i)
614
+ )
615
+ {
616
+ mld_poly_pointwise_montgomery(&r->vec[i], a, &v->vec[i]);
617
+ }
618
+ mld_assert_abs_bound_2d(r->vec, MLDSA_K, MLDSA_N, MLDSA_Q);
619
+ }
620
+
621
+ MLD_INTERNAL_API
622
+ uint32_t mld_polyveck_chknorm(const mld_polyveck *v, int32_t bound)
623
+ {
624
+ unsigned int i;
625
+ uint32_t t = 0;
626
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, -MLD_REDUCE32_RANGE_MAX,
627
+ MLD_REDUCE32_RANGE_MAX);
628
+
629
+ for (i = 0; i < MLDSA_K; ++i)
630
+ __loop__(
631
+ invariant(i <= MLDSA_K)
632
+ invariant(t == 0 || t == 0xFFFFFFFF)
633
+ invariant((t == 0) == forall(k1, 0, i, array_abs_bound(v->vec[k1].coeffs, 0, MLDSA_N, bound)))
634
+ decreases(MLDSA_K - i)
635
+ )
636
+ {
637
+ /* Reference: Leaks which polynomial violates the bound via a conditional.
638
+ * We are more conservative to reduce the number of declassifications in
639
+ * constant-time testing.
640
+ */
641
+ t |= mld_poly_chknorm(&v->vec[i], bound);
642
+ }
643
+
644
+ return t;
645
+ }
646
+
647
+ MLD_INTERNAL_API
648
+ void mld_polyveck_power2round(mld_polyveck *v1, mld_polyveck *v0,
649
+ const mld_polyveck *v)
650
+ {
651
+ unsigned int i;
652
+ mld_assert_bound_2d(v->vec, MLDSA_K, MLDSA_N, 0, MLDSA_Q);
653
+
654
+ for (i = 0; i < MLDSA_K; ++i)
655
+ __loop__(
656
+ assigns(i, memory_slice(v0, sizeof(mld_polyveck)), memory_slice(v1, sizeof(mld_polyveck)))
657
+ invariant(i <= MLDSA_K)
658
+ invariant(forall(k1, 0, i, array_bound(v0->vec[k1].coeffs, 0, MLDSA_N, -(MLD_2_POW_D/2)+1, (MLD_2_POW_D/2)+1)))
659
+ invariant(forall(k2, 0, i, array_bound(v1->vec[k2].coeffs, 0, MLDSA_N, 0, ((MLDSA_Q - 1) / MLD_2_POW_D) + 1)))
660
+ decreases(MLDSA_K - i)
661
+ )
662
+ {
663
+ mld_poly_power2round(&v1->vec[i], &v0->vec[i], &v->vec[i]);
664
+ }
665
+
666
+ mld_assert_bound_2d(v0->vec, MLDSA_K, MLDSA_N, -(MLD_2_POW_D / 2) + 1,
667
+ (MLD_2_POW_D / 2) + 1);
668
+ mld_assert_bound_2d(v1->vec, MLDSA_K, MLDSA_N, 0,
669
+ ((MLDSA_Q - 1) / MLD_2_POW_D) + 1);
670
+ }
671
+
672
+ MLD_INTERNAL_API
673
+ void mld_polyveck_decompose(mld_polyveck *v1, mld_polyveck *v0)
674
+ {
675
+ unsigned int i;
676
+ mld_assert_bound_2d(v0->vec, MLDSA_K, MLDSA_N, 0, MLDSA_Q);
677
+
678
+ for (i = 0; i < MLDSA_K; ++i)
679
+ __loop__(
680
+ assigns(i, memory_slice(v0, sizeof(mld_polyveck)), memory_slice(v1, sizeof(mld_polyveck)))
681
+ invariant(i <= MLDSA_K)
682
+ invariant(forall(k1, 0, i,
683
+ array_bound(v1->vec[k1].coeffs, 0, MLDSA_N, 0, (MLDSA_Q-1)/(2*MLDSA_GAMMA2))))
684
+ invariant(forall(k2, 0, i,
685
+ array_abs_bound(v0->vec[k2].coeffs, 0, MLDSA_N, MLDSA_GAMMA2+1)))
686
+ invariant(forall(k3, i, MLDSA_K,
687
+ array_bound(v0->vec[k3].coeffs, 0, MLDSA_N, 0, MLDSA_Q)))
688
+ decreases(MLDSA_K - i)
689
+ )
690
+ {
691
+ mld_poly_decompose(&v1->vec[i], &v0->vec[i]);
692
+ }
693
+
694
+ mld_assert_bound_2d(v1->vec, MLDSA_K, MLDSA_N, 0,
695
+ (MLDSA_Q - 1) / (2 * MLDSA_GAMMA2));
696
+ mld_assert_abs_bound_2d(v0->vec, MLDSA_K, MLDSA_N, MLDSA_GAMMA2 + 1);
697
+ }
698
+
699
+ MLD_INTERNAL_API
700
+ unsigned int mld_polyveck_make_hint(mld_polyveck *h, const mld_polyveck *v0,
701
+ const mld_polyveck *v1)
702
+ {
703
+ unsigned int i, s = 0;
704
+
705
+ for (i = 0; i < MLDSA_K; ++i)
706
+ __loop__(
707
+ assigns(i, s, memory_slice(h, sizeof(mld_polyveck)))
708
+ invariant(i <= MLDSA_K)
709
+ invariant(s <= i * MLDSA_N)
710
+ invariant(forall(k1, 0, i, array_bound(h->vec[k1].coeffs, 0, MLDSA_N, 0, 2)))
711
+ decreases(MLDSA_K - i)
712
+ )
713
+ {
714
+ s += mld_poly_make_hint(&h->vec[i], &v0->vec[i], &v1->vec[i]);
715
+ }
716
+
717
+ mld_assert_bound_2d(h->vec, MLDSA_K, MLDSA_N, 0, 2);
718
+ return s;
719
+ }
720
+
721
+ MLD_INTERNAL_API
722
+ void mld_polyveck_use_hint(mld_polyveck *w, const mld_polyveck *u,
723
+ const mld_polyveck *h)
724
+ {
725
+ unsigned int i;
726
+ mld_assert_bound_2d(u->vec, MLDSA_K, MLDSA_N, 0, MLDSA_Q);
727
+ mld_assert_bound_2d(h->vec, MLDSA_K, MLDSA_N, 0, 2);
728
+
729
+ for (i = 0; i < MLDSA_K; ++i)
730
+ __loop__(
731
+ assigns(i, memory_slice(w, sizeof(mld_polyveck)))
732
+ invariant(i <= MLDSA_K)
733
+ invariant(forall(k2, 0, i,
734
+ array_bound(w->vec[k2].coeffs, 0, MLDSA_N, 0,
735
+ (MLDSA_Q - 1) / (2 * MLDSA_GAMMA2))))
736
+ decreases(MLDSA_K - i)
737
+ )
738
+ {
739
+ mld_poly_use_hint(&w->vec[i], &u->vec[i], &h->vec[i]);
740
+ }
741
+
742
+ mld_assert_bound_2d(w->vec, MLDSA_K, MLDSA_N, 0,
743
+ (MLDSA_Q - 1) / (2 * MLDSA_GAMMA2));
744
+ }
745
+
746
+ MLD_INTERNAL_API
747
+ void mld_polyveck_pack_w1(uint8_t r[MLDSA_K * MLDSA_POLYW1_PACKEDBYTES],
748
+ const mld_polyveck *w1)
749
+ {
750
+ unsigned int i;
751
+ mld_assert_bound_2d(w1->vec, MLDSA_K, MLDSA_N, 0,
752
+ (MLDSA_Q - 1) / (2 * MLDSA_GAMMA2));
753
+
754
+ for (i = 0; i < MLDSA_K; ++i)
755
+ __loop__(
756
+ assigns(i, memory_slice(r, MLDSA_K * MLDSA_POLYW1_PACKEDBYTES))
757
+ invariant(i <= MLDSA_K)
758
+ decreases(MLDSA_K - i)
759
+ )
760
+ {
761
+ mld_polyw1_pack(&r[i * MLDSA_POLYW1_PACKEDBYTES], &w1->vec[i]);
762
+ }
763
+ }
764
+
765
+ MLD_INTERNAL_API
766
+ void mld_polyveck_pack_eta(uint8_t r[MLDSA_K * MLDSA_POLYETA_PACKEDBYTES],
767
+ const mld_polyveck *p)
768
+ {
769
+ unsigned int i;
770
+ mld_assert_abs_bound_2d(p->vec, MLDSA_K, MLDSA_N, MLDSA_ETA + 1);
771
+ for (i = 0; i < MLDSA_K; ++i)
772
+ __loop__(
773
+ assigns(i, memory_slice(r, MLDSA_K * MLDSA_POLYETA_PACKEDBYTES))
774
+ invariant(i <= MLDSA_K)
775
+ decreases(MLDSA_K - i)
776
+ )
777
+ {
778
+ mld_polyeta_pack(&r[i * MLDSA_POLYETA_PACKEDBYTES], &p->vec[i]);
779
+ }
780
+ }
781
+
782
+ MLD_INTERNAL_API
783
+ void mld_polyvecl_pack_eta(uint8_t r[MLDSA_L * MLDSA_POLYETA_PACKEDBYTES],
784
+ const mld_polyvecl *p)
785
+ {
786
+ unsigned int i;
787
+ mld_assert_abs_bound_2d(p->vec, MLDSA_L, MLDSA_N, MLDSA_ETA + 1);
788
+ for (i = 0; i < MLDSA_L; ++i)
789
+ __loop__(
790
+ assigns(i, memory_slice(r, MLDSA_L * MLDSA_POLYETA_PACKEDBYTES))
791
+ invariant(i <= MLDSA_L)
792
+ decreases(MLDSA_L - i)
793
+ )
794
+ {
795
+ mld_polyeta_pack(&r[i * MLDSA_POLYETA_PACKEDBYTES], &p->vec[i]);
796
+ }
797
+ }
798
+
799
+ MLD_INTERNAL_API
800
+ void mld_polyveck_pack_t0(uint8_t r[MLDSA_K * MLDSA_POLYT0_PACKEDBYTES],
801
+ const mld_polyveck *p)
802
+ {
803
+ unsigned int i;
804
+ mld_assert_bound_2d(p->vec, MLDSA_K, MLDSA_N, -(1 << (MLDSA_D - 1)) + 1,
805
+ (1 << (MLDSA_D - 1)) + 1);
806
+ for (i = 0; i < MLDSA_K; ++i)
807
+ __loop__(
808
+ assigns(i, memory_slice(r, MLDSA_K * MLDSA_POLYT0_PACKEDBYTES))
809
+ invariant(i <= MLDSA_K)
810
+ decreases(MLDSA_K - i)
811
+ )
812
+ {
813
+ mld_polyt0_pack(&r[i * MLDSA_POLYT0_PACKEDBYTES], &p->vec[i]);
814
+ }
815
+ }
816
+
817
+ MLD_INTERNAL_API
818
+ void mld_polyvecl_unpack_eta(
819
+ mld_polyvecl *p, const uint8_t r[MLDSA_L * MLDSA_POLYETA_PACKEDBYTES])
820
+ {
821
+ unsigned int i;
822
+ for (i = 0; i < MLDSA_L; ++i)
823
+ {
824
+ mld_polyeta_unpack(&p->vec[i], r + i * MLDSA_POLYETA_PACKEDBYTES);
825
+ }
826
+
827
+ mld_assert_bound_2d(p->vec, MLDSA_L, MLDSA_N, MLD_POLYETA_UNPACK_LOWER_BOUND,
828
+ MLDSA_ETA + 1);
829
+ }
830
+
831
+ MLD_INTERNAL_API
832
+ void mld_polyvecl_unpack_z(mld_polyvecl *z,
833
+ const uint8_t r[MLDSA_L * MLDSA_POLYZ_PACKEDBYTES])
834
+ {
835
+ unsigned int i;
836
+ for (i = 0; i < MLDSA_L; ++i)
837
+ {
838
+ mld_polyz_unpack(&z->vec[i], r + i * MLDSA_POLYZ_PACKEDBYTES);
839
+ }
840
+
841
+ mld_assert_bound_2d(z->vec, MLDSA_L, MLDSA_N, -(MLDSA_GAMMA1 - 1),
842
+ MLDSA_GAMMA1 + 1);
843
+ }
844
+
845
+ MLD_INTERNAL_API
846
+ void mld_polyveck_unpack_eta(
847
+ mld_polyveck *p, const uint8_t r[MLDSA_K * MLDSA_POLYETA_PACKEDBYTES])
848
+ {
849
+ unsigned int i;
850
+ for (i = 0; i < MLDSA_K; ++i)
851
+ {
852
+ mld_polyeta_unpack(&p->vec[i], r + i * MLDSA_POLYETA_PACKEDBYTES);
853
+ }
854
+
855
+ mld_assert_bound_2d(p->vec, MLDSA_K, MLDSA_N, MLD_POLYETA_UNPACK_LOWER_BOUND,
856
+ MLDSA_ETA + 1);
857
+ }
858
+
859
+ MLD_INTERNAL_API
860
+ void mld_polyveck_unpack_t0(mld_polyveck *p,
861
+ const uint8_t r[MLDSA_K * MLDSA_POLYT0_PACKEDBYTES])
862
+ {
863
+ unsigned int i;
864
+ for (i = 0; i < MLDSA_K; ++i)
865
+ {
866
+ mld_polyt0_unpack(&p->vec[i], r + i * MLDSA_POLYT0_PACKEDBYTES);
867
+ }
868
+
869
+ mld_assert_bound_2d(p->vec, MLDSA_K, MLDSA_N, -(1 << (MLDSA_D - 1)) + 1,
870
+ (1 << (MLDSA_D - 1)) + 1);
871
+ }
872
+
873
+ /* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
874
+ * Don't modify by hand -- this is auto-generated by scripts/autogen. */
875
+ #undef mld_polymat_permute_bitrev_to_custom
876
+ #undef mld_polyvecl_permute_bitrev_to_custom
877
+ #undef mld_polyvecl_pointwise_acc_montgomery_c