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,102 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ #include "../../../common.h"
21
+
22
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
23
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
25
+ (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87))
26
+
27
+ #include <immintrin.h>
28
+ #include "arith_native_x86_64.h"
29
+ #include "consts.h"
30
+
31
+ #define MLD_MM256_BLENDV_EPI32(a, b, mask) \
32
+ _mm256_castps_si256(_mm256_blendv_ps(_mm256_castsi256_ps(a), \
33
+ _mm256_castsi256_ps(b), \
34
+ _mm256_castsi256_ps(mask)))
35
+
36
+ void mld_poly_use_hint_32_avx2(int32_t *b, const int32_t *a,
37
+ const int32_t *hint)
38
+ {
39
+ unsigned int i;
40
+ __m256i f, f0, f1, h, t;
41
+ const __m256i q_bound = _mm256_set1_epi32(87 * ((MLDSA_Q - 1) / 32));
42
+ /* check-magic: 1025 == floor(2**22 / 4092) */
43
+ const __m256i v = _mm256_set1_epi32(1025);
44
+ const __m256i alpha = _mm256_set1_epi32(2 * ((MLDSA_Q - 1) / 32));
45
+ const __m256i off = _mm256_set1_epi32(127);
46
+ const __m256i shift = _mm256_set1_epi32(512);
47
+ const __m256i mask = _mm256_set1_epi32(15);
48
+ const __m256i zero = _mm256_setzero_si256();
49
+
50
+ for (i = 0; i < MLDSA_N / 8; i++)
51
+ {
52
+ f = _mm256_load_si256((const __m256i *)&a[8 * i]);
53
+ h = _mm256_load_si256((const __m256i *)&hint[8 * i]);
54
+
55
+ /* Reference:
56
+ * - @[REF_AVX2] calls poly_decompose to compute all a1, a0 before the loop.
57
+ * - Our implementation of decompose() is slightly different from that in
58
+ * @[REF_AVX2]. See poly_decompose_32_avx2.c for more information.
59
+ */
60
+ /* f1, f2 = decompose(f) */
61
+ f1 = _mm256_add_epi32(f, off);
62
+ f1 = _mm256_srli_epi32(f1, 7);
63
+ f1 = _mm256_mulhi_epu16(f1, v);
64
+ f1 = _mm256_mulhrs_epi16(f1, shift);
65
+ t = _mm256_cmpgt_epi32(f, q_bound);
66
+ f0 = _mm256_mullo_epi32(f1, alpha);
67
+ f0 = _mm256_sub_epi32(f, f0);
68
+ f1 = _mm256_andnot_si256(t, f1);
69
+ f0 = _mm256_add_epi32(f0, t);
70
+
71
+ /* Reference: The reference avx2 implementation checks a0 >= 0, which is
72
+ * different from the specification and the reference C implementation. We
73
+ * follow the specification and check a0 > 0.
74
+ */
75
+ /* t = (f0 > 0) ? h : -h */
76
+ f0 = _mm256_cmpgt_epi32(f0, zero);
77
+ t = MLD_MM256_BLENDV_EPI32(h, zero, f0);
78
+ t = _mm256_slli_epi32(t, 1);
79
+ h = _mm256_sub_epi32(h, t);
80
+
81
+ /* f1 = (f1 + t) % 16 */
82
+ f1 = _mm256_add_epi32(f1, h);
83
+ f1 = _mm256_and_si256(f1, mask);
84
+
85
+ _mm256_store_si256((__m256i *)&b[8 * i], f1);
86
+ }
87
+ }
88
+
89
+ #else /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
90
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == \
91
+ 65 || MLD_CONFIG_PARAMETER_SET == 87) */
92
+
93
+ MLD_EMPTY_CU(avx2_poly_use_hint_32)
94
+
95
+ #endif /* !(MLD_ARITH_BACKEND_X86_64_DEFAULT && \
96
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
97
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
98
+ || MLD_CONFIG_PARAMETER_SET == 87)) */
99
+
100
+ /* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
101
+ * Don't modify by hand -- this is auto-generated by scripts/autogen. */
102
+ #undef MLD_MM256_BLENDV_EPI32
@@ -0,0 +1,104 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ #include "../../../common.h"
21
+
22
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
23
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
25
+ MLD_CONFIG_PARAMETER_SET == 44)
26
+
27
+ #include <immintrin.h>
28
+ #include "arith_native_x86_64.h"
29
+ #include "consts.h"
30
+
31
+ #define MLD_MM256_BLENDV_EPI32(a, b, mask) \
32
+ _mm256_castps_si256(_mm256_blendv_ps(_mm256_castsi256_ps(a), \
33
+ _mm256_castsi256_ps(b), \
34
+ _mm256_castsi256_ps(mask)))
35
+
36
+ void mld_poly_use_hint_88_avx2(int32_t *b, const int32_t *a,
37
+ const int32_t *hint)
38
+ {
39
+ unsigned int i;
40
+ __m256i f, f0, f1, h, t;
41
+ const __m256i q_bound = _mm256_set1_epi32(87 * ((MLDSA_Q - 1) / 88));
42
+ /* check-magic: 11275 == floor(2**24 / 1488) */
43
+ const __m256i v = _mm256_set1_epi32(11275);
44
+ const __m256i alpha = _mm256_set1_epi32(2 * ((MLDSA_Q - 1) / 88));
45
+ const __m256i off = _mm256_set1_epi32(127);
46
+ const __m256i shift = _mm256_set1_epi32(128);
47
+ const __m256i max = _mm256_set1_epi32(43);
48
+ const __m256i zero = _mm256_setzero_si256();
49
+
50
+ for (i = 0; i < MLDSA_N / 8; i++)
51
+ {
52
+ f = _mm256_load_si256((const __m256i *)&a[8 * i]);
53
+ h = _mm256_load_si256((const __m256i *)&hint[8 * i]);
54
+
55
+ /* Reference:
56
+ * - @[REF_AVX2] calls poly_decompose to compute all a1, a0 before the loop.
57
+ * - Our implementation of decompose() is slightly different from that in
58
+ * @[REF_AVX2]. See poly_decompose_88_avx2.c for more information.
59
+ */
60
+ /* f1, f2 = decompose(f) */
61
+ f1 = _mm256_add_epi32(f, off);
62
+ f1 = _mm256_srli_epi32(f1, 7);
63
+ f1 = _mm256_mulhi_epu16(f1, v);
64
+ f1 = _mm256_mulhrs_epi16(f1, shift);
65
+ t = _mm256_cmpgt_epi32(f, q_bound);
66
+ f0 = _mm256_mullo_epi32(f1, alpha);
67
+ f0 = _mm256_sub_epi32(f, f0);
68
+ f1 = _mm256_andnot_si256(t, f1);
69
+ f0 = _mm256_add_epi32(f0, t);
70
+
71
+ /* Reference: The reference avx2 implementation checks a0 >= 0, which is
72
+ * different from the specification and the reference C implementation. We
73
+ * follow the specification and check a0 > 0.
74
+ */
75
+ /* t = (f0 > 0) ? h : -h */
76
+ f0 = _mm256_cmpgt_epi32(f0, zero);
77
+ t = MLD_MM256_BLENDV_EPI32(h, zero, f0);
78
+ t = _mm256_slli_epi32(t, 1);
79
+ h = _mm256_sub_epi32(h, t);
80
+
81
+ /* f1 = (f1 + t) % 44 */
82
+ f1 = _mm256_add_epi32(f1, h);
83
+ f1 = MLD_MM256_BLENDV_EPI32(f1, max, f1);
84
+ f = _mm256_cmpgt_epi32(f1, max);
85
+ f1 = MLD_MM256_BLENDV_EPI32(f1, zero, f);
86
+
87
+ _mm256_store_si256((__m256i *)&b[8 * i], f1);
88
+ }
89
+ }
90
+
91
+ #else /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
92
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == \
93
+ 44) */
94
+
95
+ MLD_EMPTY_CU(avx2_poly_use_hint_88)
96
+
97
+ #endif /* !(MLD_ARITH_BACKEND_X86_64_DEFAULT && \
98
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
99
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == \
100
+ 44)) */
101
+
102
+ /* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
103
+ * Don't modify by hand -- this is auto-generated by scripts/autogen. */
104
+ #undef MLD_MM256_BLENDV_EPI32
@@ -0,0 +1,91 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ #include "../../../common.h"
21
+
22
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
23
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
25
+ MLD_CONFIG_PARAMETER_SET == 44)
26
+
27
+ #include <immintrin.h>
28
+ #include "arith_native_x86_64.h"
29
+
30
+ void mld_polyz_unpack_17_avx2(int32_t *r, const uint8_t *a)
31
+ {
32
+ unsigned int i;
33
+ __m256i f;
34
+ __m128i low, high;
35
+
36
+ const __m256i shufbidx = _mm256_set_epi8(
37
+ -1, 31, 30, 29, -1, 29, 28, 27, -1, 27, 26, 25, -1, 25, 24, 23, -1, 8, 7,
38
+ 6, -1, 6, 5, 4, -1, 4, 3, 2, -1, 2, 1, 0);
39
+ const __m256i srlvdidx = _mm256_set_epi32(6, 4, 2, 0, 6, 4, 2, 0);
40
+ const __m256i mask = _mm256_set1_epi32(0x3FFFF);
41
+ const __m256i gamma1 = _mm256_set1_epi32((1 << 17));
42
+
43
+ for (i = 0; i < MLDSA_N / 8; i++)
44
+ {
45
+ /* Load bytes 0..15 into low 128-bit vector */
46
+ low = _mm_loadu_si128((__m128i *)&a[18 * i]);
47
+ /* Load bytes 2..17 into high 128-bit vector */
48
+ high = _mm_loadu_si128((__m128i *)&a[18 * i + 2]);
49
+ /* Combine into 256-bit vector */
50
+ f = _mm256_inserti128_si256(_mm256_castsi128_si256(low), high, 1);
51
+
52
+ /* Shuffling 8-bit lanes
53
+ *
54
+ * ┌─ Indices 0-8 into low 128-bit half ───────────────────────────────────┐
55
+ * │ Shuffle: [-1, 8, 7, 6, -1, 6, 5, 4, -1, 4, 3, 2, -1, 2, 1, 0] │
56
+ * │ Result: [0, byte8, byte7, byte6, ..., 0, byte2, byte1, byte0] │
57
+ * └───────────────────────────────────────────────────────────────────────┘
58
+ *
59
+ * ┌─ Indices 16-31 into high 128-bit half ────────────────────────────────┐
60
+ * │ Shuffle: [-1,31, 30, 29, -1,29, 28, 27, -1,27, 26, 25, -1,25, 24, 23] │
61
+ * │ Result: [0, byte17, byte16, byte15, ..., 0, byte11, byte10, byte9] │
62
+ * └───────────────────────────────────────────────────────────────────────┘
63
+ */
64
+ f = _mm256_shuffle_epi8(f, shufbidx);
65
+
66
+ /* Keep only 18 out of 24 bits in each 32-bit lane */
67
+ /* Bits 0..23 16..39 32..55 48..71
68
+ * 72..95 88..111 104..127 120..143 */
69
+ f = _mm256_srlv_epi32(f, srlvdidx);
70
+ /* Bits 0..23 18..39 36..55 54..71
71
+ * 72..95 90..111 108..127 126..143 */
72
+ f = _mm256_and_si256(f, mask);
73
+ /* Bits 0..17 18..35 36..53 54..71
74
+ * 72..89 90..107 108..125 126..143 */
75
+
76
+ /* Map [0, 1, ..., 2^18-1] to [2^17, 2^17-1, ..., -2^17+1] */
77
+ f = _mm256_sub_epi32(gamma1, f);
78
+
79
+ _mm256_store_si256((__m256i *)&r[8 * i], f);
80
+ }
81
+ }
82
+ #else /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
83
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == \
84
+ 44) */
85
+
86
+ MLD_EMPTY_CU(avx2_polyz_unpack_17)
87
+
88
+ #endif /* !(MLD_ARITH_BACKEND_X86_64_DEFAULT && \
89
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
90
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == \
91
+ 44)) */
@@ -0,0 +1,93 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ #include "../../../common.h"
21
+
22
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
23
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
25
+ (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87))
26
+
27
+ #include <immintrin.h>
28
+ #include "arith_native_x86_64.h"
29
+
30
+ void mld_polyz_unpack_19_avx2(int32_t *r, const uint8_t *a)
31
+ {
32
+ unsigned int i;
33
+ __m256i f;
34
+ __m128i low, high;
35
+
36
+ const __m256i shufbidx = _mm256_set_epi8(
37
+ -1, 31, 30, 29, -1, 29, 28, 27, -1, 26, 25, 24, -1, 24, 23, 22, -1, 9, 8,
38
+ 7, -1, 7, 6, 5, -1, 4, 3, 2, -1, 2, 1, 0);
39
+ /* Equivalent to _mm256_set_epi32(4, 0, 4, 0, 4, 0, 4, 0) */
40
+ const __m256i srlvdidx = _mm256_set1_epi64x((uint64_t)4 << 32);
41
+ const __m256i mask = _mm256_set1_epi32(0xFFFFF);
42
+ const __m256i gamma1 = _mm256_set1_epi32((1 << 19));
43
+
44
+ for (i = 0; i < MLDSA_N / 8; i++)
45
+ {
46
+ /* Load bytes 0..15 into low 128-bit vector */
47
+ low = _mm_loadu_si128((__m128i *)&a[20 * i]);
48
+ /* Load bytes 4..19 into high 128-bit vector */
49
+ high = _mm_loadu_si128((__m128i *)&a[20 * i + 4]);
50
+ /* Combine into 256-bit vector */
51
+ f = _mm256_inserti128_si256(_mm256_castsi128_si256(low), high, 1);
52
+
53
+ /* Shuffling 8-bit lanes
54
+ *
55
+ * ┌─ Indices 0-9 into low 128-bit half ───────────────────────────────────┐
56
+ * │ Shuffle: [-1, 9, 8, 7, -1, 7, 6, 5, -1, 4, 3, 2, -1, 2, 1, 0] │
57
+ * │ Result: [0, byte9, byte8, byte7, ..., 0, byte2, byte1, byte0] │
58
+ * └───────────────────────────────────────────────────────────────────────┘
59
+ *
60
+ * ┌─ Indices 16-31 into high 128-bit half ────────────────────────────────┐
61
+ * │ Shuffle: [-1,31, 30, 29, -1,29, 28, 27, -1,26, 25, 24, -1,24, 23, 22] │
62
+ * │ Result: [0, byte19, byte18, byte17, ..., 0, byte12, byte11, byte10] │
63
+ * └───────────────────────────────────────────────────────────────────────┘
64
+ */
65
+ f = _mm256_shuffle_epi8(f, shufbidx);
66
+
67
+ /* Keep only 20 out of 24 bits in each 32-bit lane */
68
+ /* Bits 0..23 16..39 40..63 56..79
69
+ * 80..103 96..119 120..143 136..159 */
70
+ f = _mm256_srlv_epi32(f, srlvdidx);
71
+ /* Bits 0..23 20..39 40..63 60..79
72
+ * 80..103 100..119 120..143 140..159 */
73
+ f = _mm256_and_si256(f, mask);
74
+ /* Bits 0..19 20..39 40..59 60..79
75
+ * 80..99 100..119 120..139 140..159 */
76
+
77
+ /* Map [0, 1, ..., 2^20-1] to [2^19, 2^19-1, ..., -2^19+1] */
78
+ f = _mm256_sub_epi32(gamma1, f);
79
+
80
+ _mm256_store_si256((__m256i *)&r[8 * i], f);
81
+ }
82
+ }
83
+
84
+ #else /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
85
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == \
86
+ 65 || MLD_CONFIG_PARAMETER_SET == 87) */
87
+
88
+ MLD_EMPTY_CU(avx2_polyz_unpack_19)
89
+
90
+ #endif /* !(MLD_ARITH_BACKEND_X86_64_DEFAULT && \
91
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
92
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
93
+ || MLD_CONFIG_PARAMETER_SET == 87)) */
@@ -0,0 +1,126 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ #include "../../../common.h"
21
+
22
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
23
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
24
+
25
+ #include <immintrin.h>
26
+ #include "arith_native_x86_64.h"
27
+ #include "consts.h"
28
+
29
+ /*
30
+ * Reference: The pqcrystals implementation assumes a buffer that is 8 bytes
31
+ *. larger as the first loop overreads by 8 bytes that are then
32
+ * discarded. We instead do not pad the buffer and do not overread.
33
+ * The performance impact is negligible and it does not force the
34
+ * frontend to perform the unintuitive padding.
35
+ */
36
+
37
+ unsigned int mld_rej_uniform_avx2(
38
+ int32_t *MLD_RESTRICT r, const uint8_t buf[MLD_AVX2_REJ_UNIFORM_BUFLEN])
39
+ {
40
+ unsigned int ctr, pos;
41
+ uint32_t good;
42
+ __m256i d, tmp;
43
+ const __m256i bound = _mm256_set1_epi32(MLDSA_Q);
44
+ const __m256i mask = _mm256_set1_epi32(0x7FFFFF);
45
+ const __m256i idx8 =
46
+ _mm256_set_epi8(-1, 15, 14, 13, -1, 12, 11, 10, -1, 9, 8, 7, -1, 6, 5, 4,
47
+ -1, 11, 10, 9, -1, 8, 7, 6, -1, 5, 4, 3, -1, 2, 1, 0);
48
+
49
+ ctr = pos = 0;
50
+ while (ctr <= MLDSA_N - 8 && pos <= MLD_AVX2_REJ_UNIFORM_BUFLEN - 32)
51
+ {
52
+ d = _mm256_loadu_si256((__m256i *)&buf[pos]);
53
+
54
+ /* Permute 64-bit lanes
55
+ * 0x94 = 10010100b rearranges 64-bit lanes as: [3,2,1,0] -> [2,1,1,0]
56
+ *
57
+ * ╔═══════════════════════════════════════════════════════════════════════╗
58
+ * ║ Original Layout ║
59
+ * ╚═══════════════════════════════════════════════════════════════════════╝
60
+ * ┌─────────────────┬─────────────────┬─────────────────┬─────────────────┐
61
+ * │ Lane 0 │ Lane 1 │ Lane 2 │ Lane 3 │
62
+ * │ bytes 0..7 │ bytes 8..15 │ bytes 16..23 │ bytes 24..31 │
63
+ * └─────────────────┴─────────────────┴─────────────────┴─────────────────┘
64
+ *
65
+ * ╔═══════════════════════════════════════════════════════════════════════╗
66
+ * ║ Layout after permute ║
67
+ * ║ Byte indices in high half shifted down by 8 positions ║
68
+ * ╚═══════════════════════════════════════════════════════════════════════╝
69
+ * ┌───────────────┬─────────────────┐ ┌─────────────────┬─────────────────┐
70
+ * │ Lane 0 │ Lane 1 │ │ Lane 2 │ Lane 3 │
71
+ * │ bytes 0..7 │ bytes 8..15 │ │ bytes 8..15 │ bytes 16..23 │
72
+ * └───────────────┴─────────────────┘ └─────────────────┴─────────────────┘
73
+ * Lower 128-bit lane (bytes 0-15) Upper 128-bit lane (bytes 16-31)
74
+ */
75
+ d = _mm256_permute4x64_epi64(d, 0x94);
76
+
77
+ /* Shuffling 8-bit lanes
78
+ *
79
+ * ┌─ Indices 0-11 into low 128-bit half of permuted vector────────────────┐
80
+ * │ Shuffle: [-1, 11, 10, 9, -1, 8, 7, 6, -1, 5, 4, 3, -1, 2, 1, 0] │
81
+ * │ Result: [0, byte11, byte10, byte9, ..., 0, byte2, byte1, byte0] │
82
+ * └───────────────────────────────────────────────────────────────────────┘
83
+ *
84
+ * ┌─ Indices 4-15 into high 128-bit half of permuted vector ──────────────┐
85
+ * │ Shuffle: [-1, 15, 14, 13, -1, 12, 11, 10, -1, 9, 8, 7, -1, 6, 5, 4] │
86
+ * │ Result: [0, byte23, byte22, byte21, ..., 0, byte14, byte13, byte12 │
87
+ * └───────────────────────────────────────────────────────────────────────┘
88
+ */
89
+ d = _mm256_shuffle_epi8(d, idx8);
90
+ d = _mm256_and_si256(d, mask);
91
+ pos += 24;
92
+
93
+ tmp = _mm256_sub_epi32(d, bound);
94
+ good = (uint32_t)_mm256_movemask_ps((__m256)tmp);
95
+ tmp = _mm256_cvtepu8_epi32(
96
+ _mm_loadl_epi64((__m128i *)&mld_rej_uniform_table[good]));
97
+ d = _mm256_permutevar8x32_epi32(d, tmp);
98
+
99
+ _mm256_storeu_si256((__m256i *)&r[ctr], d);
100
+ ctr += (unsigned)_mm_popcnt_u32(good);
101
+ }
102
+
103
+ while (ctr < MLDSA_N && pos <= MLD_AVX2_REJ_UNIFORM_BUFLEN - 3)
104
+ {
105
+ uint32_t t = buf[pos++];
106
+ t |= (uint32_t)buf[pos++] << 8;
107
+ t |= (uint32_t)buf[pos++] << 16;
108
+ t &= 0x7FFFFF;
109
+
110
+ if (t < MLDSA_Q)
111
+ {
112
+ /* Safe because t < MLDSA_Q. */
113
+ r[ctr++] = (int32_t)t;
114
+ }
115
+ }
116
+
117
+ return ctr;
118
+ }
119
+
120
+ #else /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
121
+ */
122
+
123
+ MLD_EMPTY_CU(avx2_rej_uniform)
124
+
125
+ #endif /* !(MLD_ARITH_BACKEND_X86_64_DEFAULT && \
126
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED) */
@@ -0,0 +1,155 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+ #include "../../../common.h"
21
+
22
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
23
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_ETA == 2)
25
+
26
+ #include <immintrin.h>
27
+ #include "arith_native_x86_64.h"
28
+ #include "consts.h"
29
+
30
+ #define MLD_AVX2_ETA2 2
31
+
32
+ /*
33
+ * Reference: In the pqcrystals implementation this function is called
34
+ * rej_eta_avx and supports multiple values for ETA via preprocessor
35
+ * conditionals. We move the conditionals to the frontend.
36
+ */
37
+ unsigned int mld_rej_uniform_eta2_avx2(
38
+ int32_t *MLD_RESTRICT r,
39
+ const uint8_t buf[MLD_AVX2_REJ_UNIFORM_ETA2_BUFLEN])
40
+ {
41
+ unsigned int ctr, pos;
42
+ uint32_t good;
43
+ __m256i f0, f1, f2;
44
+ __m128i g0, g1;
45
+ const __m256i mask = _mm256_set1_epi8(15);
46
+ const __m256i eta = _mm256_set1_epi8(MLD_AVX2_ETA2);
47
+ const __m256i bound = mask;
48
+ /* check-magic: -6560 == 32*round(-2**10 / 5) */
49
+ const __m256i v = _mm256_set1_epi32(-6560);
50
+ const __m256i p = _mm256_set1_epi32(5);
51
+
52
+ ctr = pos = 0;
53
+ while (ctr <= MLDSA_N - 8 && pos <= MLD_AVX2_REJ_UNIFORM_ETA2_BUFLEN - 16)
54
+ {
55
+ f0 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i *)&buf[pos]));
56
+ f1 = _mm256_slli_epi16(f0, 4);
57
+ f0 = _mm256_or_si256(f0, f1);
58
+ f0 = _mm256_and_si256(f0, mask);
59
+
60
+ f1 = _mm256_sub_epi8(f0, bound);
61
+ f0 = _mm256_sub_epi8(eta, f0);
62
+ good = (uint32_t)_mm256_movemask_epi8(f1);
63
+
64
+ g0 = _mm256_castsi256_si128(f0);
65
+ g1 = _mm_loadl_epi64((__m128i *)&mld_rej_uniform_table[good & 0xFF]);
66
+ g1 = _mm_shuffle_epi8(g0, g1);
67
+ f1 = _mm256_cvtepi8_epi32(g1);
68
+ f2 = _mm256_mulhrs_epi16(f1, v);
69
+ f2 = _mm256_mullo_epi16(f2, p);
70
+ f1 = _mm256_add_epi32(f1, f2);
71
+ _mm256_storeu_si256((__m256i *)&r[ctr], f1);
72
+ ctr += (unsigned)_mm_popcnt_u32(good & 0xFF);
73
+ good >>= 8;
74
+ pos += 4;
75
+
76
+ if (ctr > MLDSA_N - 8)
77
+ {
78
+ break;
79
+ }
80
+ g0 = _mm_bsrli_si128(g0, 8);
81
+ g1 = _mm_loadl_epi64((__m128i *)&mld_rej_uniform_table[good & 0xFF]);
82
+ g1 = _mm_shuffle_epi8(g0, g1);
83
+ f1 = _mm256_cvtepi8_epi32(g1);
84
+ f2 = _mm256_mulhrs_epi16(f1, v);
85
+ f2 = _mm256_mullo_epi16(f2, p);
86
+ f1 = _mm256_add_epi32(f1, f2);
87
+ _mm256_storeu_si256((__m256i *)&r[ctr], f1);
88
+ ctr += (unsigned)_mm_popcnt_u32(good & 0xFF);
89
+ good >>= 8;
90
+ pos += 4;
91
+
92
+ if (ctr > MLDSA_N - 8)
93
+ {
94
+ break;
95
+ }
96
+ g0 = _mm256_extracti128_si256(f0, 1);
97
+ g1 = _mm_loadl_epi64((__m128i *)&mld_rej_uniform_table[good & 0xFF]);
98
+ g1 = _mm_shuffle_epi8(g0, g1);
99
+ f1 = _mm256_cvtepi8_epi32(g1);
100
+ f2 = _mm256_mulhrs_epi16(f1, v);
101
+ f2 = _mm256_mullo_epi16(f2, p);
102
+ f1 = _mm256_add_epi32(f1, f2);
103
+ _mm256_storeu_si256((__m256i *)&r[ctr], f1);
104
+ ctr += (unsigned)_mm_popcnt_u32(good & 0xFF);
105
+ good >>= 8;
106
+ pos += 4;
107
+
108
+ if (ctr > MLDSA_N - 8)
109
+ {
110
+ break;
111
+ }
112
+ g0 = _mm_bsrli_si128(g0, 8);
113
+ g1 = _mm_loadl_epi64((__m128i *)&mld_rej_uniform_table[good]);
114
+ g1 = _mm_shuffle_epi8(g0, g1);
115
+ f1 = _mm256_cvtepi8_epi32(g1);
116
+ f2 = _mm256_mulhrs_epi16(f1, v);
117
+ f2 = _mm256_mullo_epi16(f2, p);
118
+ f1 = _mm256_add_epi32(f1, f2);
119
+ _mm256_storeu_si256((__m256i *)&r[ctr], f1);
120
+ ctr += (unsigned)_mm_popcnt_u32(good);
121
+ pos += 4;
122
+ }
123
+
124
+ while (ctr < MLDSA_N && pos < MLD_AVX2_REJ_UNIFORM_ETA2_BUFLEN)
125
+ {
126
+ uint32_t t0 = buf[pos] & 0x0F;
127
+ uint32_t t1 = buf[pos++] >> 4;
128
+
129
+ if (t0 < 15)
130
+ {
131
+ t0 = t0 - (205 * t0 >> 10) * 5;
132
+ r[ctr++] = (int32_t)(2 - t0);
133
+ }
134
+ if (t1 < 15 && ctr < MLDSA_N)
135
+ {
136
+ t1 = t1 - (205 * t1 >> 10) * 5;
137
+ r[ctr++] = (int32_t)(2 - t1);
138
+ }
139
+ }
140
+
141
+ return ctr;
142
+ }
143
+
144
+ #else /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
145
+ && (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 2) */
146
+
147
+ MLD_EMPTY_CU(avx2_rej_uniform_eta2)
148
+
149
+ #endif /* !(MLD_ARITH_BACKEND_X86_64_DEFAULT && \
150
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
151
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 2)) */
152
+
153
+ /* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
154
+ * Don't modify by hand -- this is auto-generated by scripts/autogen. */
155
+ #undef MLD_AVX2_ETA2