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,668 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [FIPS203]
10
+ * FIPS 203 Module-Lattice-Based Key-Encapsulation Mechanism Standard
11
+ * National Institute of Standards and Technology
12
+ * https://csrc.nist.gov/pubs/fips/203/final
13
+ */
14
+
15
+ #ifndef MLK_POLY_K_H
16
+ #define MLK_POLY_K_H
17
+
18
+ #include "common.h"
19
+ #include "compress.h"
20
+ #include "poly.h"
21
+
22
+ /* Parameter set namespacing
23
+ * This is to facilitate building multiple instances
24
+ * of mlkem-native (e.g. with varying parameter sets)
25
+ * within a single compilation unit. */
26
+ #define mlk_polyvec MLK_ADD_PARAM_SET(mlk_polyvec)
27
+ #define mlk_polymat MLK_ADD_PARAM_SET(mlk_polymat)
28
+ #define mlk_polyvec_mulcache MLK_ADD_PARAM_SET(mlk_polyvec_mulcache)
29
+ /* End of parameter set namespacing */
30
+
31
+ typedef struct
32
+ {
33
+ mlk_poly vec[MLKEM_K];
34
+ } MLK_ALIGN mlk_polyvec;
35
+
36
+ typedef struct
37
+ {
38
+ mlk_polyvec vec[MLKEM_K];
39
+ } MLK_ALIGN mlk_polymat;
40
+
41
+ typedef struct
42
+ {
43
+ mlk_poly_mulcache vec[MLKEM_K];
44
+ } MLK_ALIGN mlk_polyvec_mulcache;
45
+
46
+ #define mlk_poly_compress_du MLK_NAMESPACE_K(poly_compress_du)
47
+ /*************************************************
48
+ * Name: mlk_poly_compress_du
49
+ *
50
+ * Description: Compression (du bits) and subsequent serialization of a
51
+ * polynomial
52
+ *
53
+ * Arguments: - uint8_t *r: pointer to output byte array
54
+ * (of length MLKEM_POLYCOMPRESSEDBYTES_DU bytes)
55
+ * - const mlk_poly *a: pointer to input polynomial
56
+ * Coefficients must be unsigned canonical,
57
+ * i.e. in [0,1,..,MLKEM_Q-1].
58
+ *
59
+ * Specification: Implements `ByteEncode_{d_u} (Compress_{d_u} (u))`
60
+ * in @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L22],
61
+ * with level-specific d_u defined in @[FIPS203, Table 2],
62
+ * and given by MLKEM_DU here.
63
+ *
64
+ **************************************************/
65
+ static MLK_INLINE void mlk_poly_compress_du(
66
+ uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_DU], const mlk_poly *a)
67
+ __contract__(
68
+ requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_DU))
69
+ requires(memory_no_alias(a, sizeof(mlk_poly)))
70
+ requires(array_bound(a->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
71
+ assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_DU)))
72
+ {
73
+ #if MLKEM_DU == 10
74
+ mlk_poly_compress_d10(r, a);
75
+ #elif MLKEM_DU == 11
76
+ mlk_poly_compress_d11(r, a);
77
+ #else
78
+ #error "Invalid value of MLKEM_DU"
79
+ #endif
80
+ }
81
+
82
+ #define mlk_poly_decompress_du MLK_NAMESPACE_K(poly_decompress_du)
83
+ /*************************************************
84
+ * Name: mlk_poly_decompress_du
85
+ *
86
+ * Description: De-serialization and subsequent decompression (du bits) of a
87
+ * polynomial; approximate inverse of mlk_poly_compress_du
88
+ *
89
+ * Arguments: - mlk_poly *r: pointer to output polynomial
90
+ * - const uint8_t *a: pointer to input byte array
91
+ * (of length MLKEM_POLYCOMPRESSEDBYTES_DU bytes)
92
+ *
93
+ * Upon return, the coefficients of the output polynomial are unsigned-canonical
94
+ * (non-negative and smaller than MLKEM_Q).
95
+ *
96
+ * Specification: Implements `Decompress_{d_u} (ByteDecode_{d_u} (u))`
97
+ * in @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L3].
98
+ * with level-specific d_u defined in @[FIPS203, Table 2],
99
+ * and given by MLKEM_DU here.
100
+ *
101
+ **************************************************/
102
+ static MLK_INLINE void mlk_poly_decompress_du(
103
+ mlk_poly *r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_DU])
104
+ __contract__(
105
+ requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_DU))
106
+ requires(memory_no_alias(r, sizeof(mlk_poly)))
107
+ assigns(memory_slice(r, sizeof(mlk_poly)))
108
+ ensures(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_Q)))
109
+ {
110
+ #if MLKEM_DU == 10
111
+ mlk_poly_decompress_d10(r, a);
112
+ #elif MLKEM_DU == 11
113
+ mlk_poly_decompress_d11(r, a);
114
+ #else
115
+ #error "Invalid value of MLKEM_DU"
116
+ #endif
117
+ }
118
+
119
+ #define mlk_poly_compress_dv MLK_NAMESPACE_K(poly_compress_dv)
120
+ /*************************************************
121
+ * Name: mlk_poly_compress_dv
122
+ *
123
+ * Description: Compression (dv bits) and subsequent serialization of a
124
+ * polynomial
125
+ *
126
+ * Arguments: - uint8_t *r: pointer to output byte array
127
+ * (of length MLKEM_POLYCOMPRESSEDBYTES_DV bytes)
128
+ * - const mlk_poly *a: pointer to input polynomial
129
+ * Coefficients must be unsigned canonical,
130
+ * i.e. in [0,1,..,MLKEM_Q-1].
131
+ *
132
+ * Specification: Implements `ByteEncode_{d_v} (Compress_{d_v} (v))`
133
+ * in @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L23].
134
+ * with level-specific d_v defined in @[FIPS203, Table 2],
135
+ * and given by MLKEM_DV here.
136
+ *
137
+ **************************************************/
138
+ static MLK_INLINE void mlk_poly_compress_dv(
139
+ uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_DV], const mlk_poly *a)
140
+ __contract__(
141
+ requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_DV))
142
+ requires(memory_no_alias(a, sizeof(mlk_poly)))
143
+ requires(array_bound(a->coeffs, 0, MLKEM_N, 0, MLKEM_Q))
144
+ assigns(memory_slice(r, MLKEM_POLYCOMPRESSEDBYTES_DV)))
145
+ {
146
+ #if MLKEM_DV == 4
147
+ mlk_poly_compress_d4(r, a);
148
+ #elif MLKEM_DV == 5
149
+ mlk_poly_compress_d5(r, a);
150
+ #else
151
+ #error "Invalid value of MLKEM_DV"
152
+ #endif
153
+ }
154
+
155
+
156
+ #define mlk_poly_decompress_dv MLK_NAMESPACE_K(poly_decompress_dv)
157
+ /*************************************************
158
+ * Name: mlk_poly_decompress_dv
159
+ *
160
+ * Description: De-serialization and subsequent decompression (dv bits) of a
161
+ * polynomial; approximate inverse of poly_compress
162
+ *
163
+ * Arguments: - mlk_poly *r: pointer to output polynomial
164
+ * - const uint8_t *a: pointer to input byte array
165
+ * (of length MLKEM_POLYCOMPRESSEDBYTES_DV bytes)
166
+ *
167
+ * Upon return, the coefficients of the output polynomial are unsigned-canonical
168
+ * (non-negative and smaller than MLKEM_Q).
169
+ *
170
+ * Specification: Implements `Decompress_{d_v} (ByteDecode_{d_v} (v))`
171
+ * in @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L4].
172
+ * with level-specific d_v defined in @[FIPS203, Table 2],
173
+ * and given by MLKEM_DV here.
174
+ *
175
+ **************************************************/
176
+ static MLK_INLINE void mlk_poly_decompress_dv(
177
+ mlk_poly *r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_DV])
178
+ __contract__(
179
+ requires(memory_no_alias(a, MLKEM_POLYCOMPRESSEDBYTES_DV))
180
+ requires(memory_no_alias(r, sizeof(mlk_poly)))
181
+ assigns(memory_slice(r, sizeof(mlk_poly)))
182
+ ensures(array_bound(r->coeffs, 0, MLKEM_N, 0, MLKEM_Q)))
183
+ {
184
+ #if MLKEM_DV == 4
185
+ mlk_poly_decompress_d4(r, a);
186
+ #elif MLKEM_DV == 5
187
+ mlk_poly_decompress_d5(r, a);
188
+ #else
189
+ #error "Invalid value of MLKEM_DV"
190
+ #endif
191
+ }
192
+
193
+ #define mlk_polyvec_compress_du MLK_NAMESPACE_K(polyvec_compress_du)
194
+ /*************************************************
195
+ * Name: mlk_polyvec_compress_du
196
+ *
197
+ * Description: Compress and serialize vector of polynomials
198
+ *
199
+ * Arguments: - uint8_t *r: pointer to output byte array
200
+ * (needs space for MLKEM_POLYVECCOMPRESSEDBYTES_DU)
201
+ * - const mlk_polyvec a: pointer to input vector of polynomials.
202
+ * Coefficients must be unsigned canonical,
203
+ * i.e. in [0,1,..,MLKEM_Q-1].
204
+ *
205
+ * Specification: Implements `ByteEncode_{d_u} (Compress_{d_u} (u))`
206
+ * in @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L22].
207
+ * with level-specific d_u defined in @[FIPS203, Table 2],
208
+ * and given by MLKEM_DU here.
209
+ *
210
+ **************************************************/
211
+ MLK_INTERNAL_API
212
+ void mlk_polyvec_compress_du(uint8_t r[MLKEM_POLYVECCOMPRESSEDBYTES_DU],
213
+ const mlk_polyvec *a)
214
+ __contract__(
215
+ requires(memory_no_alias(r, MLKEM_POLYVECCOMPRESSEDBYTES_DU))
216
+ requires(memory_no_alias(a, sizeof(mlk_polyvec)))
217
+ requires(forall(k0, 0, MLKEM_K,
218
+ array_bound(a->vec[k0].coeffs, 0, MLKEM_N, 0, MLKEM_Q)))
219
+ assigns(memory_slice(r, MLKEM_POLYVECCOMPRESSEDBYTES_DU))
220
+ );
221
+
222
+ #define mlk_polyvec_decompress_du MLK_NAMESPACE_K(polyvec_decompress_du)
223
+ /*************************************************
224
+ * Name: mlk_polyvec_decompress_du
225
+ *
226
+ * Description: De-serialize and decompress vector of polynomials;
227
+ * approximate inverse of mlk_polyvec_compress_du
228
+ *
229
+ * Arguments: - mlk_polyvec r: pointer to output vector of polynomials.
230
+ * Output will have coefficients normalized to [0,..,q-1].
231
+ * - const uint8_t *a: pointer to input byte array
232
+ * (of length MLKEM_POLYVECCOMPRESSEDBYTES_DU)
233
+ *
234
+ * Specification: Implements `Decompress_{d_u} (ByteDecode_{d_u} (u))`
235
+ * in @[FIPS203, Algorithm 15 (K-PKE.Decrypt), L3].
236
+ * with level-specific d_u defined in @[FIPS203, Table 2],
237
+ * and given by MLKEM_DU here.
238
+ *
239
+ **************************************************/
240
+ MLK_INTERNAL_API
241
+ void mlk_polyvec_decompress_du(mlk_polyvec *r,
242
+ const uint8_t a[MLKEM_POLYVECCOMPRESSEDBYTES_DU])
243
+ __contract__(
244
+ requires(memory_no_alias(a, MLKEM_POLYVECCOMPRESSEDBYTES_DU))
245
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
246
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
247
+ ensures(forall(k0, 0, MLKEM_K,
248
+ array_bound(r->vec[k0].coeffs, 0, MLKEM_N, 0, MLKEM_Q)))
249
+ );
250
+
251
+ #define mlk_polyvec_tobytes MLK_NAMESPACE_K(polyvec_tobytes)
252
+ /*************************************************
253
+ * Name: mlk_polyvec_tobytes
254
+ *
255
+ * Description: Serialize vector of polynomials
256
+ *
257
+ * Arguments: - uint8_t *r: pointer to output byte array
258
+ * (needs space for MLKEM_POLYVECBYTES)
259
+ * - const mlk_polyvec a: pointer to input vector of polynomials
260
+ * Each polynomial must have coefficients in [0,..,q-1].
261
+ *
262
+ * Specification: Implements ByteEncode_12 @[FIPS203, Algorithm 5].
263
+ * Extended to vectors as per
264
+ * @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
265
+ * and @[FIPS203, 2.4.6, Matrices and Vectors]
266
+ *
267
+ **************************************************/
268
+ MLK_INTERNAL_API
269
+ void mlk_polyvec_tobytes(uint8_t r[MLKEM_POLYVECBYTES], const mlk_polyvec *a)
270
+ __contract__(
271
+ requires(memory_no_alias(a, sizeof(mlk_polyvec)))
272
+ requires(memory_no_alias(r, MLKEM_POLYVECBYTES))
273
+ requires(forall(k0, 0, MLKEM_K,
274
+ array_bound(a->vec[k0].coeffs, 0, MLKEM_N, 0, MLKEM_Q)))
275
+ assigns(memory_slice(r, MLKEM_POLYVECBYTES))
276
+ );
277
+
278
+ #define mlk_polyvec_frombytes MLK_NAMESPACE_K(polyvec_frombytes)
279
+ /*************************************************
280
+ * Name: mlk_polyvec_frombytes
281
+ *
282
+ * Description: De-serialize vector of polynomials;
283
+ * inverse of mlk_polyvec_tobytes
284
+ *
285
+ * Arguments: - const mlk_polyvec a: pointer to output vector of polynomials
286
+ * (of length MLKEM_POLYVECBYTES). Output will have coefficients
287
+ * normalized in [0..4095].
288
+ * - uint8_t *r: pointer to input byte array
289
+ *
290
+ * Specification: Implements ByteDecode_12 @[FIPS203, Algorithm 6].
291
+ * Extended to vectors as per
292
+ * @[FIPS203, 2.4.8 Applying Algorithms to Arrays]
293
+ * and @[FIPS203, 2.4.6, Matrices and Vectors]
294
+ *
295
+ **************************************************/
296
+ MLK_INTERNAL_API
297
+ void mlk_polyvec_frombytes(mlk_polyvec *r, const uint8_t a[MLKEM_POLYVECBYTES])
298
+ __contract__(
299
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
300
+ requires(memory_no_alias(a, MLKEM_POLYVECBYTES))
301
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
302
+ ensures(forall(k0, 0, MLKEM_K,
303
+ array_bound(r->vec[k0].coeffs, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT)))
304
+ );
305
+
306
+ #define mlk_polyvec_ntt MLK_NAMESPACE_K(polyvec_ntt)
307
+ /*************************************************
308
+ * Name: mlk_polyvec_ntt
309
+ *
310
+ * Description: Apply forward NTT to all elements of a vector of polynomials.
311
+ *
312
+ * The input is assumed to be in normal order and
313
+ * coefficient-wise bound by MLKEM_Q in absolute value.
314
+ *
315
+ * The output polynomial is in bitreversed order, and
316
+ * coefficient-wise bound by MLK_NTT_BOUND in absolute value.
317
+ *
318
+ * Arguments: - mlk_polyvec r: pointer to in/output vector of polynomials
319
+ *
320
+ * Specification:
321
+ * - Implements @[FIPS203, Algorithm 9, NTT]
322
+ * - Extended to vectors as per @[FIPS203, 2.4.6, Matrices and Vectors]
323
+ *
324
+ **************************************************/
325
+ MLK_INTERNAL_API
326
+ void mlk_polyvec_ntt(mlk_polyvec *r)
327
+ __contract__(
328
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
329
+ requires(forall(j, 0, MLKEM_K,
330
+ array_abs_bound(r->vec[j].coeffs, 0, MLKEM_N, MLKEM_Q)))
331
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
332
+ ensures(forall(j, 0, MLKEM_K,
333
+ array_abs_bound(r->vec[j].coeffs, 0, MLKEM_N, MLK_NTT_BOUND)))
334
+ );
335
+
336
+ #define mlk_polyvec_invntt_tomont MLK_NAMESPACE_K(polyvec_invntt_tomont)
337
+ /*************************************************
338
+ * Name: mlk_polyvec_invntt_tomont
339
+ *
340
+ * Description: Apply inverse NTT to all elements of a vector of polynomials
341
+ * and multiply by Montgomery factor 2^16
342
+ *
343
+ * The input is assumed to be in bitreversed order, and can
344
+ * have arbitrary coefficients in int16_t.
345
+ *
346
+ * The output polynomial is in normal order, and
347
+ * coefficient-wise bound by MLK_INVNTT_BOUND in absolute value.
348
+ *
349
+ * Arguments: - mlk_polyvec r: pointer to in/output vector of polynomials
350
+ *
351
+ * Specification:
352
+ * - Implements @[FIPS203, Algorithm 10, NTT^{-1}]
353
+ * - Extended to vectors as per @[FIPS203, 2.4.6, Matrices and Vectors]
354
+ *
355
+ **************************************************/
356
+ MLK_INTERNAL_API
357
+ void mlk_polyvec_invntt_tomont(mlk_polyvec *r)
358
+ __contract__(
359
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
360
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
361
+ ensures(forall(j, 0, MLKEM_K,
362
+ array_abs_bound(r->vec[j].coeffs, 0, MLKEM_N, MLK_INVNTT_BOUND)))
363
+ );
364
+
365
+ #define mlk_polyvec_basemul_acc_montgomery_cached \
366
+ MLK_NAMESPACE_K(polyvec_basemul_acc_montgomery_cached)
367
+ /*************************************************
368
+ * Name: mlk_polyvec_basemul_acc_montgomery_cached
369
+ *
370
+ * Description: Scalar product of two vectors of polynomials in NTT domain,
371
+ * using mulcache for second operand.
372
+ *
373
+ * Bounds:
374
+ * - Every coefficient of a is assumed to be in [0..4095]
375
+ * - No bounds guarantees for the coefficients in the result.
376
+ *
377
+ * Arguments: - mlk_poly *r: pointer to output polynomial
378
+ * - const mlk_polyvec a: pointer to first input polynomial vector
379
+ * - const mlk_polyvec b: pointer to second input polynomial
380
+ * vector
381
+ * - const mlk_polyvec_mulcache b_cache: pointer to mulcache
382
+ * for second input polynomial vector. Can be computed
383
+ * via mlk_polyvec_mulcache_compute().
384
+ *
385
+ * Specification: Implements
386
+ * - @[FIPS203, Section 2.4.7, Eq (2.14)]
387
+ * - @[FIPS203, Algorithm 11, MultiplyNTTs]
388
+ * - @[FIPS203, Algorithm 12, BaseCaseMultiply]
389
+ *
390
+ **************************************************/
391
+ MLK_INTERNAL_API
392
+ void mlk_polyvec_basemul_acc_montgomery_cached(
393
+ mlk_poly *r, const mlk_polyvec *a, const mlk_polyvec *b,
394
+ const mlk_polyvec_mulcache *b_cache)
395
+ __contract__(
396
+ requires(memory_no_alias(r, sizeof(mlk_poly)))
397
+ requires(memory_no_alias(a, sizeof(mlk_polyvec)))
398
+ requires(memory_no_alias(b, sizeof(mlk_polyvec)))
399
+ requires(memory_no_alias(b_cache, sizeof(mlk_polyvec_mulcache)))
400
+ requires(forall(k1, 0, MLKEM_K,
401
+ array_bound(a->vec[k1].coeffs, 0, MLKEM_N, 0, MLKEM_UINT12_LIMIT)))
402
+ assigns(memory_slice(r, sizeof(mlk_poly)))
403
+ );
404
+
405
+ #define mlk_polyvec_mulcache_compute MLK_NAMESPACE_K(polyvec_mulcache_compute)
406
+ /************************************************************
407
+ * Name: mlk_polyvec_mulcache_compute
408
+ *
409
+ * Description: Computes the mulcache for a vector of polynomials in NTT domain
410
+ *
411
+ * The mulcache of a degree-2 polynomial b := b0 + b1*X
412
+ * in Fq[X]/(X^2-zeta) is the value b1*zeta, needed when
413
+ * computing products of b in Fq[X]/(X^2-zeta).
414
+ *
415
+ * The mulcache of a polynomial in NTT domain -- which is
416
+ * a 128-tuple of degree-2 polynomials in Fq[X]/(X^2-zeta),
417
+ * for varying zeta, is the 128-tuple of mulcaches of those
418
+ * polynomials.
419
+ *
420
+ * The mulcache of a vector of polynomials is the vector
421
+ * of mulcaches of its entries.
422
+ *
423
+ * Arguments: - x: Pointer to mulcache to be populated
424
+ * - a: Pointer to input polynomial vector
425
+ *
426
+ * Specification:
427
+ * - Caches `b_1 * \gamma` in @[FIPS203, Algorithm 12, BaseCaseMultiply, L1]
428
+ *
429
+ ************************************************************/
430
+ /*
431
+ * NOTE: The default C implementation of this function populates
432
+ * the mulcache with values in (-q,q), but this is not needed for the
433
+ * higher level safety proofs, and thus not part of the spec.
434
+ */
435
+ MLK_INTERNAL_API
436
+ void mlk_polyvec_mulcache_compute(mlk_polyvec_mulcache *x, const mlk_polyvec *a)
437
+ __contract__(
438
+ requires(memory_no_alias(x, sizeof(mlk_polyvec_mulcache)))
439
+ requires(memory_no_alias(a, sizeof(mlk_polyvec)))
440
+ assigns(memory_slice(x, sizeof(mlk_polyvec_mulcache)))
441
+ );
442
+
443
+ #define mlk_polyvec_reduce MLK_NAMESPACE_K(polyvec_reduce)
444
+ /*************************************************
445
+ * Name: mlk_polyvec_reduce
446
+ *
447
+ * Description: Applies Barrett reduction to each coefficient
448
+ * of each element of a vector of polynomials;
449
+ * for details of the Barrett reduction see comments in poly.c
450
+ *
451
+ * Arguments: - mlk_polyvec r: pointer to input/output polynomial
452
+ *
453
+ * Specification: Normalizes on unsigned canoncial representatives
454
+ * ahead of calling @[FIPS203, Compress_d, Eq (4.7)].
455
+ * This is not made explicit in FIPS 203.
456
+ *
457
+ **************************************************/
458
+ /*
459
+ * NOTE: The semantics of mlk_polyvec_reduce() is different in
460
+ * the reference implementation, which requires
461
+ * signed canonical output data. Unsigned canonical
462
+ * outputs are better suited to the only remaining
463
+ * use of mlk_poly_reduce() in the context of (de)serialization.
464
+ */
465
+ MLK_INTERNAL_API
466
+ void mlk_polyvec_reduce(mlk_polyvec *r)
467
+ __contract__(
468
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
469
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
470
+ ensures(forall(k0, 0, MLKEM_K,
471
+ array_bound(r->vec[k0].coeffs, 0, MLKEM_N, 0, MLKEM_Q)))
472
+ );
473
+
474
+ #define mlk_polyvec_add MLK_NAMESPACE_K(polyvec_add)
475
+ /*************************************************
476
+ * Name: mlk_polyvec_add
477
+ *
478
+ * Description: Add vectors of polynomials
479
+ *
480
+ * Arguments: - mlk_polyvec r: pointer to input-output vector of polynomials to
481
+ * be added to
482
+ * - const mlk_polyvec b: pointer to second input vector of
483
+ * polynomials
484
+ *
485
+ * The coefficients of r and b must be so that the addition does
486
+ * not overflow. Otherwise, the behaviour of this function is undefined.
487
+ *
488
+ * The coefficients returned in *r are in int16_t which is sufficient
489
+ * to prove type-safety of calling units. Therefore, no stronger
490
+ * ensures clause is required on this function.
491
+ *
492
+ * Specification:
493
+ * - @[FIPS203, 2.4.5, Arithmetic With Polynomials and NTT Representations]
494
+ * - Used in @[FIPS203, Algorithm 14 (K-PKE.Encrypt), L19]
495
+ *
496
+ **************************************************/
497
+ MLK_INTERNAL_API
498
+ void mlk_polyvec_add(mlk_polyvec *r, const mlk_polyvec *b)
499
+ __contract__(
500
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
501
+ requires(memory_no_alias(b, sizeof(mlk_polyvec)))
502
+ requires(forall(j0, 0, MLKEM_K,
503
+ forall(k0, 0, MLKEM_N,
504
+ (int32_t)r->vec[j0].coeffs[k0] + b->vec[j0].coeffs[k0] <= INT16_MAX)))
505
+ requires(forall(j1, 0, MLKEM_K,
506
+ forall(k1, 0, MLKEM_N,
507
+ (int32_t)r->vec[j1].coeffs[k1] + b->vec[j1].coeffs[k1] >= INT16_MIN)))
508
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
509
+ );
510
+
511
+ #define mlk_polyvec_tomont MLK_NAMESPACE_K(polyvec_tomont)
512
+ /*************************************************
513
+ * Name: mlk_polyvec_tomont
514
+ *
515
+ * Description: Inplace conversion of all coefficients of a polynomial
516
+ * vector from normal domain to Montgomery domain
517
+ *
518
+ * Bounds: Output < q in absolute value.
519
+ *
520
+ *
521
+ * Specification: Internal normalization required in `mlk_indcpa_keypair_derand`
522
+ * as part of matrix-vector multiplication
523
+ * @[FIPS203, Algorithm 13, K-PKE.KeyGen, L18].
524
+ *
525
+ **************************************************/
526
+ MLK_INTERNAL_API
527
+ void mlk_polyvec_tomont(mlk_polyvec *r)
528
+ __contract__(
529
+ requires(memory_no_alias(r, sizeof(mlk_polyvec)))
530
+ assigns(memory_slice(r, sizeof(mlk_polyvec)))
531
+ ensures(forall(j, 0, MLKEM_K,
532
+ array_abs_bound(r->vec[j].coeffs, 0, MLKEM_N, MLKEM_Q)))
533
+ );
534
+
535
+ #define mlk_poly_getnoise_eta1_4x MLK_NAMESPACE_K(poly_getnoise_eta1_4x)
536
+ /*************************************************
537
+ * Name: mlk_poly_getnoise_eta1_4x
538
+ *
539
+ * Description: Batch sample four polynomials deterministically from a seed
540
+ * and nonces, with output polynomials close to centered binomial
541
+ * distribution with parameter MLKEM_ETA1.
542
+ *
543
+ * Arguments: - mlk_poly *r{0,1,2,3}: pointer to output polynomial. The last
544
+ * polynomial pointer may be NULL.
545
+ * - const uint8_t *seed: pointer to input seed
546
+ * (of length MLKEM_SYMBYTES bytes)
547
+ * - uint8_t nonce{0,1,2,3}: one-byte input nonce
548
+ *
549
+ * Specification:
550
+ * Implements 4x `SamplePolyCBD_{eta1} (PRF_{eta1} (sigma, N))`:
551
+ * - @[FIPS203, Algorithm 8, SamplePolyCBD_eta]
552
+ * - @[FIPS203, Eq (4.3), PRF_eta]
553
+ * - `SamplePolyCBD_{eta1} (PRF_{eta1} (sigma, N))` appears in
554
+ * @[FIPS203, Algorithm 13, K-PKE.KeyGen, L{9, 13}]
555
+ * @[FIPS203, Algorithm 14, K-PKE.Encrypt, L10]
556
+ *
557
+ **************************************************/
558
+ MLK_INTERNAL_API
559
+ void mlk_poly_getnoise_eta1_4x(mlk_poly *r0, mlk_poly *r1, mlk_poly *r2,
560
+ mlk_poly *r3, const uint8_t seed[MLKEM_SYMBYTES],
561
+ uint8_t nonce0, uint8_t nonce1, uint8_t nonce2,
562
+ uint8_t nonce3)
563
+ __contract__(
564
+ requires(memory_no_alias(seed, MLKEM_SYMBYTES))
565
+ requires(memory_no_alias(r0, sizeof(mlk_poly)))
566
+ requires(memory_no_alias(r1, sizeof(mlk_poly)))
567
+ requires(memory_no_alias(r2, sizeof(mlk_poly)))
568
+ requires(r3 == NULL || memory_no_alias(r3, sizeof(mlk_poly)))
569
+ assigns(memory_slice(r0, sizeof(mlk_poly)))
570
+ assigns(memory_slice(r1, sizeof(mlk_poly)))
571
+ assigns(memory_slice(r2, sizeof(mlk_poly)))
572
+ assigns(r3 != NULL: memory_slice(r3, sizeof(mlk_poly)))
573
+ ensures(array_abs_bound(r0->coeffs,0, MLKEM_N, MLKEM_ETA1 + 1))
574
+ ensures(array_abs_bound(r1->coeffs,0, MLKEM_N, MLKEM_ETA1 + 1))
575
+ ensures(array_abs_bound(r2->coeffs,0, MLKEM_N, MLKEM_ETA1 + 1))
576
+ ensures(r3 != NULL ==> array_abs_bound(r3->coeffs,0, MLKEM_N, MLKEM_ETA1 + 1))
577
+ );
578
+
579
+ #if MLKEM_ETA1 == MLKEM_ETA2
580
+ /*
581
+ * We only require mlk_poly_getnoise_eta2_4x for ml-kem-768 and ml-kem-1024
582
+ * where MLKEM_ETA2 = MLKEM_ETA1 = 2.
583
+ * For ml-kem-512, mlk_poly_getnoise_eta1122_4x is used instead.
584
+ */
585
+ #define mlk_poly_getnoise_eta2_4x mlk_poly_getnoise_eta1_4x
586
+ #endif /* MLKEM_ETA1 == MLKEM_ETA2 */
587
+
588
+ #if MLKEM_K == 2 || MLKEM_K == 4
589
+ #define mlk_poly_getnoise_eta2 MLK_NAMESPACE_K(poly_getnoise_eta2)
590
+ /*************************************************
591
+ * Name: mlk_poly_getnoise_eta2
592
+ *
593
+ * Description: Sample a polynomial deterministically from a seed and a nonce,
594
+ * with output polynomial close to centered binomial distribution
595
+ * with parameter MLKEM_ETA2
596
+ *
597
+ * Arguments: - mlk_poly *r: pointer to output polynomial
598
+ * - const uint8_t *seed: pointer to input seed
599
+ * (of length MLKEM_SYMBYTES bytes)
600
+ * - uint8_t nonce: one-byte input nonce
601
+ *
602
+ * Specification:
603
+ * Implements `SamplePolyCBD_{eta2} (PRF_{eta2} (sigma, N))`:
604
+ * - @[FIPS203, Algorithm 8, SamplePolyCBD_eta]
605
+ * - @[FIPS203, Eq (4.3), PRF_eta]
606
+ * - `SamplePolyCBD_{eta2} (PRF_{eta2} (sigma, N))` appears in
607
+ * @[FIPS203, Algorithm 14, K-PKE.Encrypt, L14]
608
+ *
609
+ **************************************************/
610
+ MLK_INTERNAL_API
611
+ void mlk_poly_getnoise_eta2(mlk_poly *r, const uint8_t seed[MLKEM_SYMBYTES],
612
+ uint8_t nonce)
613
+ __contract__(
614
+ requires(memory_no_alias(r, sizeof(mlk_poly)))
615
+ requires(memory_no_alias(seed, MLKEM_SYMBYTES))
616
+ assigns(memory_slice(r, sizeof(mlk_poly)))
617
+ ensures(array_abs_bound(r->coeffs, 0, MLKEM_N, MLKEM_ETA2 + 1))
618
+ );
619
+ #endif /* MLKEM_K == 2 || MLKEM_K == 4 */
620
+
621
+ #if MLKEM_K == 2
622
+ #define mlk_poly_getnoise_eta1122_4x MLK_NAMESPACE_K(poly_getnoise_eta1122_4x)
623
+ /*************************************************
624
+ * Name: mlk_poly_getnoise_eta1122_4x
625
+ *
626
+ * Description: Batch sample four polynomials deterministically from a seed
627
+ * and a nonces, with output polynomials close to centered binomial
628
+ * distribution with parameter MLKEM_ETA1 and MLKEM_ETA2
629
+ *
630
+ * Arguments: - mlk_poly *r{0,1,2,3}: pointer to output polynomial
631
+ * - const uint8_t *seed: pointer to input seed
632
+ * (of length MLKEM_SYMBYTES bytes)
633
+ * - uint8_t nonce{0,1,2,3}: one-byte input nonce
634
+ *
635
+ * Specification:
636
+ * Implements two instances each of
637
+ * `SamplePolyCBD_{eta1} (PRF_{eta1} (sigma, N))` and
638
+ * `SamplePolyCBD_{eta2} (PRF_{eta2} (sigma, N))`:
639
+ * - @[FIPS203, Algorithm 8, SamplePolyCBD_eta]
640
+ * - @[FIPS203, Eq (4.3), PRF_eta]
641
+ * - `SamplePolyCBD_{eta2} (PRF_{eta2} (sigma, N))` appears in
642
+ * @[FIPS203, Algorithm 14, K-PKE.Encrypt, L14]
643
+ *
644
+ **************************************************/
645
+ MLK_INTERNAL_API
646
+ void mlk_poly_getnoise_eta1122_4x(mlk_poly *r0, mlk_poly *r1, mlk_poly *r2,
647
+ mlk_poly *r3,
648
+ const uint8_t seed[MLKEM_SYMBYTES],
649
+ uint8_t nonce0, uint8_t nonce1,
650
+ uint8_t nonce2, uint8_t nonce3)
651
+ __contract__(
652
+ requires(memory_no_alias(r0, sizeof(mlk_poly)))
653
+ requires(memory_no_alias(r1, sizeof(mlk_poly)))
654
+ requires(memory_no_alias(r2, sizeof(mlk_poly)))
655
+ requires(memory_no_alias(r3, sizeof(mlk_poly)))
656
+ requires(memory_no_alias(seed, MLKEM_SYMBYTES))
657
+ assigns(memory_slice(r0, sizeof(mlk_poly)))
658
+ assigns(memory_slice(r1, sizeof(mlk_poly)))
659
+ assigns(memory_slice(r2, sizeof(mlk_poly)))
660
+ assigns(memory_slice(r3, sizeof(mlk_poly)))
661
+ ensures(array_abs_bound(r0->coeffs,0, MLKEM_N, MLKEM_ETA1 + 1)
662
+ && array_abs_bound(r1->coeffs,0, MLKEM_N, MLKEM_ETA1 + 1)
663
+ && array_abs_bound(r2->coeffs,0, MLKEM_N, MLKEM_ETA2 + 1)
664
+ && array_abs_bound(r3->coeffs,0, MLKEM_N, MLKEM_ETA2 + 1))
665
+ );
666
+ #endif /* MLKEM_K == 2 */
667
+
668
+ #endif /* !MLK_POLY_K_H */