pq_crypto 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/GET_STARTED.md +21 -16
  4. data/README.md +26 -0
  5. data/SECURITY.md +22 -16
  6. data/ext/pqcrypto/extconf.rb +148 -99
  7. data/ext/pqcrypto/mldsa_api.h +1 -118
  8. data/ext/pqcrypto/mlkem_api.h +1 -42
  9. data/ext/pqcrypto/pq_externalmu.c +88 -216
  10. data/ext/pqcrypto/pqcrypto_native_api.h +129 -0
  11. data/ext/pqcrypto/pqcrypto_ruby_secure.c +0 -3
  12. data/ext/pqcrypto/pqcrypto_secure.c +135 -117
  13. data/ext/pqcrypto/pqcrypto_secure.h +1 -42
  14. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  15. data/ext/pqcrypto/randombytes.h +9 -0
  16. data/ext/pqcrypto/vendor/.vendored +10 -5
  17. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +105 -0
  18. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +286 -0
  19. data/ext/pqcrypto/vendor/mldsa-native/META.yml +24 -0
  20. data/ext/pqcrypto/vendor/mldsa-native/README.md +221 -0
  21. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +8 -0
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +721 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +975 -0
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +724 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +723 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +166 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +321 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +385 -0
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +73 -0
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +130 -0
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +277 -0
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +244 -0
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +182 -0
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +117 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +438 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +105 -0
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +71 -0
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +62 -0
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +376 -0
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +204 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +259 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1077 -0
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +987 -0
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +41 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +26 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +35 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +37 -0
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +27 -0
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +36 -0
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +69 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +32 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +20 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +638 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +136 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +52 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +29 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +488 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +16 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/xkcp.h +31 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +247 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +231 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +150 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +753 -0
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +129 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +145 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +177 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +653 -0
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +79 -0
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +53 -0
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +55 -0
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +85 -0
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +85 -0
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +102 -0
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +110 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +72 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +69 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +40 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +189 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +135 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +128 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +543 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +62 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +649 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +23 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +315 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +124 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +2311 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +2383 -0
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +239 -0
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +131 -0
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +139 -0
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +155 -0
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +187 -0
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +61 -0
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +52 -0
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +155 -0
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +155 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +102 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +104 -0
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +91 -0
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +93 -0
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +126 -0
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +155 -0
  108. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +139 -0
  109. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +160 -0
  110. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +293 -0
  111. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +224 -0
  112. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +77 -0
  113. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +991 -0
  114. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +393 -0
  115. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +946 -0
  116. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +360 -0
  117. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +877 -0
  118. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +725 -0
  119. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  120. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +139 -0
  121. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +249 -0
  122. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +1511 -0
  123. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +806 -0
  124. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  125. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +268 -0
  126. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  127. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +104 -0
  128. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +294 -0
  129. data/ext/pqcrypto/vendor/mlkem-native/META.yml +30 -0
  130. data/ext/pqcrypto/vendor/mlkem-native/README.md +223 -0
  131. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +86 -0
  132. data/ext/pqcrypto/vendor/mlkem-native/SECURITY.md +8 -0
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +23 -0
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +660 -0
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +538 -0
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +681 -0
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +709 -0
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +174 -0
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +274 -0
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +717 -0
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +688 -0
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +64 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +128 -0
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +251 -0
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +158 -0
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +208 -0
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +80 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +463 -0
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +98 -0
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +70 -0
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +375 -0
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +203 -0
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +258 -0
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1076 -0
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +986 -0
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +46 -0
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +25 -0
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +34 -0
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +35 -0
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +26 -0
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +35 -0
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +117 -0
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/README.md +10 -0
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +79 -0
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +35 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +667 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +40 -0
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +51 -0
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +290 -0
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +314 -0
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +28 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +33 -0
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +41 -0
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2.S +451 -0
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +51 -0
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +622 -0
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +156 -0
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +446 -0
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +326 -0
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/README.md +16 -0
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +122 -0
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +174 -0
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +177 -0
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/intt.S +628 -0
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/ntt.S +562 -0
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_mulcache_compute_asm.S +127 -0
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_reduce_asm.S +150 -0
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tobytes_asm.S +117 -0
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tomont_asm.S +98 -0
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +261 -0
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +314 -0
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +368 -0
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_asm.S +226 -0
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +542 -0
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +637 -0
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +25 -0
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/README.md +11 -0
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +128 -0
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +45 -0
  201. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +81 -0
  202. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +145 -0
  203. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_izetas.inc +27 -0
  204. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +805 -0
  205. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas.inc +27 -0
  206. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas_basemul.inc +39 -0
  207. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/README.md +4 -0
  208. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +304 -0
  209. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +309 -0
  210. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +94 -0
  211. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +45 -0
  212. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +102 -0
  213. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +25 -0
  214. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/intt.S +719 -0
  215. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mulcache_compute.S +90 -0
  216. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntt.S +639 -0
  217. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttfrombytes.S +193 -0
  218. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntttobytes.S +181 -0
  219. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttunpack.S +174 -0
  220. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d10.S +382 -0
  221. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d11.S +448 -0
  222. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d4.S +163 -0
  223. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d5.S +220 -0
  224. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d10.S +228 -0
  225. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d11.S +277 -0
  226. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d4.S +180 -0
  227. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d5.S +192 -0
  228. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +502 -0
  229. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +750 -0
  230. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +998 -0
  231. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/reduce.S +218 -0
  232. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_asm.S +103 -0
  233. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +544 -0
  234. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/tomont.S +155 -0
  235. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/params.h +76 -0
  236. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +572 -0
  237. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +317 -0
  238. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +502 -0
  239. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +668 -0
  240. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +60 -0
  241. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +362 -0
  242. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +118 -0
  243. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/symmetric.h +70 -0
  244. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +260 -0
  245. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.c +20 -0
  246. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +464 -0
  247. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/zetas.inc +30 -0
  248. data/lib/pq_crypto/version.rb +1 -1
  249. data/lib/pq_crypto.rb +1 -1
  250. data/script/vendor_libs.rb +88 -159
  251. metadata +236 -160
  252. data/ext/pqcrypto/vendor/pqclean/common/aes.c +0 -639
  253. data/ext/pqcrypto/vendor/pqclean/common/aes.h +0 -64
  254. data/ext/pqcrypto/vendor/pqclean/common/compat.h +0 -73
  255. data/ext/pqcrypto/vendor/pqclean/common/crypto_declassify.h +0 -7
  256. data/ext/pqcrypto/vendor/pqclean/common/fips202.c +0 -928
  257. data/ext/pqcrypto/vendor/pqclean/common/fips202.h +0 -166
  258. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/feat.S +0 -168
  259. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.c +0 -684
  260. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.h +0 -60
  261. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SIMD256.c +0 -1028
  262. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SnP.h +0 -50
  263. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-unrolling.macros +0 -198
  264. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile +0 -8
  265. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile.Microsoft_nmake +0 -8
  266. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/SIMD256-config.h +0 -3
  267. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/align.h +0 -34
  268. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/brg_endian.h +0 -142
  269. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.c +0 -101
  270. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.h +0 -39
  271. data/ext/pqcrypto/vendor/pqclean/common/randombytes.c +0 -355
  272. data/ext/pqcrypto/vendor/pqclean/common/randombytes.h +0 -27
  273. data/ext/pqcrypto/vendor/pqclean/common/sha2.c +0 -769
  274. data/ext/pqcrypto/vendor/pqclean/common/sha2.h +0 -173
  275. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.c +0 -156
  276. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.h +0 -27
  277. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/LICENSE +0 -5
  278. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile +0 -19
  279. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile.Microsoft_nmake +0 -23
  280. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/api.h +0 -18
  281. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.c +0 -83
  282. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.h +0 -11
  283. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.c +0 -327
  284. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.h +0 -22
  285. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.c +0 -164
  286. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.h +0 -23
  287. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.c +0 -146
  288. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.h +0 -14
  289. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/params.h +0 -36
  290. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.c +0 -311
  291. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.h +0 -37
  292. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.c +0 -198
  293. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.h +0 -26
  294. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.c +0 -41
  295. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.h +0 -13
  296. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric-shake.c +0 -71
  297. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric.h +0 -30
  298. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.c +0 -67
  299. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.h +0 -13
  300. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/LICENSE +0 -5
  301. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile +0 -19
  302. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile.Microsoft_nmake +0 -23
  303. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/api.h +0 -18
  304. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.c +0 -108
  305. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.h +0 -11
  306. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.c +0 -327
  307. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.h +0 -22
  308. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.c +0 -164
  309. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.h +0 -23
  310. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.c +0 -146
  311. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.h +0 -14
  312. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/params.h +0 -36
  313. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.c +0 -299
  314. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.h +0 -37
  315. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.c +0 -188
  316. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.h +0 -26
  317. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.c +0 -41
  318. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.h +0 -13
  319. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric-shake.c +0 -71
  320. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric.h +0 -30
  321. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.c +0 -67
  322. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.h +0 -13
  323. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/LICENSE +0 -5
  324. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile +0 -19
  325. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile.Microsoft_nmake +0 -23
  326. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/api.h +0 -18
  327. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.c +0 -83
  328. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.h +0 -11
  329. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.c +0 -327
  330. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.h +0 -22
  331. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.c +0 -164
  332. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.h +0 -23
  333. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.c +0 -146
  334. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.h +0 -14
  335. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/params.h +0 -36
  336. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.c +0 -299
  337. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.h +0 -37
  338. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.c +0 -188
  339. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.h +0 -26
  340. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.c +0 -41
  341. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.h +0 -13
  342. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric-shake.c +0 -71
  343. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric.h +0 -30
  344. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.c +0 -67
  345. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.h +0 -13
  346. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/LICENSE +0 -5
  347. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile +0 -19
  348. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile.Microsoft_nmake +0 -23
  349. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/api.h +0 -50
  350. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.c +0 -98
  351. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.h +0 -10
  352. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.c +0 -261
  353. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.h +0 -31
  354. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/params.h +0 -44
  355. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.c +0 -848
  356. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.h +0 -52
  357. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.c +0 -415
  358. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.h +0 -65
  359. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.c +0 -69
  360. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.h +0 -17
  361. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.c +0 -98
  362. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.h +0 -14
  363. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.c +0 -407
  364. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.h +0 -47
  365. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric-shake.c +0 -26
  366. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric.h +0 -34
  367. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/LICENSE +0 -5
  368. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile +0 -19
  369. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile.Microsoft_nmake +0 -23
  370. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/api.h +0 -50
  371. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.c +0 -98
  372. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.h +0 -10
  373. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.c +0 -261
  374. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.h +0 -31
  375. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/params.h +0 -44
  376. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.c +0 -799
  377. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.h +0 -52
  378. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.c +0 -415
  379. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.h +0 -65
  380. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.c +0 -69
  381. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.h +0 -17
  382. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.c +0 -92
  383. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.h +0 -14
  384. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.c +0 -407
  385. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.h +0 -47
  386. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric-shake.c +0 -26
  387. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric.h +0 -34
  388. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/LICENSE +0 -5
  389. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile +0 -19
  390. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile.Microsoft_nmake +0 -23
  391. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/api.h +0 -50
  392. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.c +0 -98
  393. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.h +0 -10
  394. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.c +0 -261
  395. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.h +0 -31
  396. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/params.h +0 -44
  397. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.c +0 -823
  398. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.h +0 -52
  399. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.c +0 -415
  400. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.h +0 -65
  401. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.c +0 -69
  402. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.h +0 -17
  403. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.c +0 -92
  404. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.h +0 -14
  405. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.c +0 -407
  406. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.h +0 -47
  407. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric-shake.c +0 -26
  408. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric.h +0 -34
@@ -1,327 +0,0 @@
1
- #include "indcpa.h"
2
- #include "ntt.h"
3
- #include "params.h"
4
- #include "poly.h"
5
- #include "polyvec.h"
6
- #include "randombytes.h"
7
- #include "symmetric.h"
8
- #include <stddef.h>
9
- #include <stdint.h>
10
- #include <string.h>
11
-
12
- /*************************************************
13
- * Name: pack_pk
14
- *
15
- * Description: Serialize the public key as concatenation of the
16
- * serialized vector of polynomials pk
17
- * and the public seed used to generate the matrix A.
18
- *
19
- * Arguments: uint8_t *r: pointer to the output serialized public key
20
- * polyvec *pk: pointer to the input public-key polyvec
21
- * const uint8_t *seed: pointer to the input public seed
22
- **************************************************/
23
- static void pack_pk(uint8_t r[KYBER_INDCPA_PUBLICKEYBYTES],
24
- polyvec *pk,
25
- const uint8_t seed[KYBER_SYMBYTES]) {
26
- PQCLEAN_MLKEM1024_CLEAN_polyvec_tobytes(r, pk);
27
- memcpy(r + KYBER_POLYVECBYTES, seed, KYBER_SYMBYTES);
28
- }
29
-
30
- /*************************************************
31
- * Name: unpack_pk
32
- *
33
- * Description: De-serialize public key from a byte array;
34
- * approximate inverse of pack_pk
35
- *
36
- * Arguments: - polyvec *pk: pointer to output public-key polynomial vector
37
- * - uint8_t *seed: pointer to output seed to generate matrix A
38
- * - const uint8_t *packedpk: pointer to input serialized public key
39
- **************************************************/
40
- static void unpack_pk(polyvec *pk,
41
- uint8_t seed[KYBER_SYMBYTES],
42
- const uint8_t packedpk[KYBER_INDCPA_PUBLICKEYBYTES]) {
43
- PQCLEAN_MLKEM1024_CLEAN_polyvec_frombytes(pk, packedpk);
44
- memcpy(seed, packedpk + KYBER_POLYVECBYTES, KYBER_SYMBYTES);
45
- }
46
-
47
- /*************************************************
48
- * Name: pack_sk
49
- *
50
- * Description: Serialize the secret key
51
- *
52
- * Arguments: - uint8_t *r: pointer to output serialized secret key
53
- * - polyvec *sk: pointer to input vector of polynomials (secret key)
54
- **************************************************/
55
- static void pack_sk(uint8_t r[KYBER_INDCPA_SECRETKEYBYTES], polyvec *sk) {
56
- PQCLEAN_MLKEM1024_CLEAN_polyvec_tobytes(r, sk);
57
- }
58
-
59
- /*************************************************
60
- * Name: unpack_sk
61
- *
62
- * Description: De-serialize the secret key; inverse of pack_sk
63
- *
64
- * Arguments: - polyvec *sk: pointer to output vector of polynomials (secret key)
65
- * - const uint8_t *packedsk: pointer to input serialized secret key
66
- **************************************************/
67
- static void unpack_sk(polyvec *sk, const uint8_t packedsk[KYBER_INDCPA_SECRETKEYBYTES]) {
68
- PQCLEAN_MLKEM1024_CLEAN_polyvec_frombytes(sk, packedsk);
69
- }
70
-
71
- /*************************************************
72
- * Name: pack_ciphertext
73
- *
74
- * Description: Serialize the ciphertext as concatenation of the
75
- * compressed and serialized vector of polynomials b
76
- * and the compressed and serialized polynomial v
77
- *
78
- * Arguments: uint8_t *r: pointer to the output serialized ciphertext
79
- * poly *pk: pointer to the input vector of polynomials b
80
- * poly *v: pointer to the input polynomial v
81
- **************************************************/
82
- static void pack_ciphertext(uint8_t r[KYBER_INDCPA_BYTES], polyvec *b, poly *v) {
83
- PQCLEAN_MLKEM1024_CLEAN_polyvec_compress(r, b);
84
- PQCLEAN_MLKEM1024_CLEAN_poly_compress(r + KYBER_POLYVECCOMPRESSEDBYTES, v);
85
- }
86
-
87
- /*************************************************
88
- * Name: unpack_ciphertext
89
- *
90
- * Description: De-serialize and decompress ciphertext from a byte array;
91
- * approximate inverse of pack_ciphertext
92
- *
93
- * Arguments: - polyvec *b: pointer to the output vector of polynomials b
94
- * - poly *v: pointer to the output polynomial v
95
- * - const uint8_t *c: pointer to the input serialized ciphertext
96
- **************************************************/
97
- static void unpack_ciphertext(polyvec *b, poly *v, const uint8_t c[KYBER_INDCPA_BYTES]) {
98
- PQCLEAN_MLKEM1024_CLEAN_polyvec_decompress(b, c);
99
- PQCLEAN_MLKEM1024_CLEAN_poly_decompress(v, c + KYBER_POLYVECCOMPRESSEDBYTES);
100
- }
101
-
102
- /*************************************************
103
- * Name: rej_uniform
104
- *
105
- * Description: Run rejection sampling on uniform random bytes to generate
106
- * uniform random integers mod q
107
- *
108
- * Arguments: - int16_t *r: pointer to output buffer
109
- * - unsigned int len: requested number of 16-bit integers (uniform mod q)
110
- * - const uint8_t *buf: pointer to input buffer (assumed to be uniformly random bytes)
111
- * - unsigned int buflen: length of input buffer in bytes
112
- *
113
- * Returns number of sampled 16-bit integers (at most len)
114
- **************************************************/
115
- static unsigned int rej_uniform(int16_t *r,
116
- unsigned int len,
117
- const uint8_t *buf,
118
- unsigned int buflen) {
119
- unsigned int ctr, pos;
120
- uint16_t val0, val1;
121
-
122
- ctr = pos = 0;
123
- while (ctr < len && pos + 3 <= buflen) {
124
- val0 = ((buf[pos + 0] >> 0) | ((uint16_t)buf[pos + 1] << 8)) & 0xFFF;
125
- val1 = ((buf[pos + 1] >> 4) | ((uint16_t)buf[pos + 2] << 4)) & 0xFFF;
126
- pos += 3;
127
-
128
- if (val0 < KYBER_Q) {
129
- r[ctr++] = val0;
130
- }
131
- if (ctr < len && val1 < KYBER_Q) {
132
- r[ctr++] = val1;
133
- }
134
- }
135
-
136
- return ctr;
137
- }
138
-
139
- #define gen_a(A,B) PQCLEAN_MLKEM1024_CLEAN_gen_matrix(A,B,0)
140
- #define gen_at(A,B) PQCLEAN_MLKEM1024_CLEAN_gen_matrix(A,B,1)
141
-
142
- /*************************************************
143
- * Name: PQCLEAN_MLKEM1024_CLEAN_gen_matrix
144
- *
145
- * Description: Deterministically generate matrix A (or the transpose of A)
146
- * from a seed. Entries of the matrix are polynomials that look
147
- * uniformly random. Performs rejection sampling on output of
148
- * a XOF
149
- *
150
- * Arguments: - polyvec *a: pointer to ouptput matrix A
151
- * - const uint8_t *seed: pointer to input seed
152
- * - int transposed: boolean deciding whether A or A^T is generated
153
- **************************************************/
154
-
155
- #define GEN_MATRIX_NBLOCKS ((12*KYBER_N/8*(1 << 12)/KYBER_Q + XOF_BLOCKBYTES)/XOF_BLOCKBYTES)
156
- // Not static for benchmarking
157
- void PQCLEAN_MLKEM1024_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYMBYTES], int transposed) {
158
- unsigned int ctr, i, j;
159
- unsigned int buflen;
160
- uint8_t buf[GEN_MATRIX_NBLOCKS * XOF_BLOCKBYTES];
161
- xof_state state;
162
-
163
- for (i = 0; i < KYBER_K; i++) {
164
- for (j = 0; j < KYBER_K; j++) {
165
- if (transposed) {
166
- xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j);
167
- } else {
168
- xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i);
169
- }
170
-
171
- xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state);
172
- buflen = GEN_MATRIX_NBLOCKS * XOF_BLOCKBYTES;
173
- ctr = rej_uniform(a[i].vec[j].coeffs, KYBER_N, buf, buflen);
174
-
175
- while (ctr < KYBER_N) {
176
- xof_squeezeblocks(buf, 1, &state);
177
- buflen = XOF_BLOCKBYTES;
178
- ctr += rej_uniform(a[i].vec[j].coeffs + ctr, KYBER_N - ctr, buf, buflen);
179
- }
180
- xof_ctx_release(&state);
181
- }
182
- }
183
- }
184
-
185
- /*************************************************
186
- * Name: PQCLEAN_MLKEM1024_CLEAN_indcpa_keypair_derand
187
- *
188
- * Description: Generates public and private key for the CPA-secure
189
- * public-key encryption scheme underlying Kyber
190
- *
191
- * Arguments: - uint8_t *pk: pointer to output public key
192
- * (of length KYBER_INDCPA_PUBLICKEYBYTES bytes)
193
- * - uint8_t *sk: pointer to output private key
194
- * (of length KYBER_INDCPA_SECRETKEYBYTES bytes)
195
- * - const uint8_t *coins: pointer to input randomness
196
- * (of length KYBER_SYMBYTES bytes)
197
- **************************************************/
198
- void PQCLEAN_MLKEM1024_CLEAN_indcpa_keypair_derand(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES],
199
- uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES],
200
- const uint8_t coins[KYBER_SYMBYTES]) {
201
- unsigned int i;
202
- uint8_t buf[2 * KYBER_SYMBYTES];
203
- const uint8_t *publicseed = buf;
204
- const uint8_t *noiseseed = buf + KYBER_SYMBYTES;
205
- uint8_t nonce = 0;
206
- polyvec a[KYBER_K], e, pkpv, skpv;
207
-
208
- memcpy(buf, coins, KYBER_SYMBYTES);
209
- buf[KYBER_SYMBYTES] = KYBER_K;
210
- hash_g(buf, buf, KYBER_SYMBYTES + 1);
211
-
212
- gen_a(a, publicseed);
213
-
214
- for (i = 0; i < KYBER_K; i++) {
215
- PQCLEAN_MLKEM1024_CLEAN_poly_getnoise_eta1(&skpv.vec[i], noiseseed, nonce++);
216
- }
217
- for (i = 0; i < KYBER_K; i++) {
218
- PQCLEAN_MLKEM1024_CLEAN_poly_getnoise_eta1(&e.vec[i], noiseseed, nonce++);
219
- }
220
-
221
- PQCLEAN_MLKEM1024_CLEAN_polyvec_ntt(&skpv);
222
- PQCLEAN_MLKEM1024_CLEAN_polyvec_ntt(&e);
223
-
224
- // matrix-vector multiplication
225
- for (i = 0; i < KYBER_K; i++) {
226
- PQCLEAN_MLKEM1024_CLEAN_polyvec_basemul_acc_montgomery(&pkpv.vec[i], &a[i], &skpv);
227
- PQCLEAN_MLKEM1024_CLEAN_poly_tomont(&pkpv.vec[i]);
228
- }
229
-
230
- PQCLEAN_MLKEM1024_CLEAN_polyvec_add(&pkpv, &pkpv, &e);
231
- PQCLEAN_MLKEM1024_CLEAN_polyvec_reduce(&pkpv);
232
-
233
- pack_sk(sk, &skpv);
234
- pack_pk(pk, &pkpv, publicseed);
235
- }
236
-
237
-
238
- /*************************************************
239
- * Name: PQCLEAN_MLKEM1024_CLEAN_indcpa_enc
240
- *
241
- * Description: Encryption function of the CPA-secure
242
- * public-key encryption scheme underlying Kyber.
243
- *
244
- * Arguments: - uint8_t *c: pointer to output ciphertext
245
- * (of length KYBER_INDCPA_BYTES bytes)
246
- * - const uint8_t *m: pointer to input message
247
- * (of length KYBER_INDCPA_MSGBYTES bytes)
248
- * - const uint8_t *pk: pointer to input public key
249
- * (of length KYBER_INDCPA_PUBLICKEYBYTES)
250
- * - const uint8_t *coins: pointer to input random coins used as seed
251
- * (of length KYBER_SYMBYTES) to deterministically
252
- * generate all randomness
253
- **************************************************/
254
- void PQCLEAN_MLKEM1024_CLEAN_indcpa_enc(uint8_t c[KYBER_INDCPA_BYTES],
255
- const uint8_t m[KYBER_INDCPA_MSGBYTES],
256
- const uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES],
257
- const uint8_t coins[KYBER_SYMBYTES]) {
258
- unsigned int i;
259
- uint8_t seed[KYBER_SYMBYTES];
260
- uint8_t nonce = 0;
261
- polyvec sp, pkpv, ep, at[KYBER_K], b;
262
- poly v, k, epp;
263
-
264
- unpack_pk(&pkpv, seed, pk);
265
- PQCLEAN_MLKEM1024_CLEAN_poly_frommsg(&k, m);
266
- gen_at(at, seed);
267
-
268
- for (i = 0; i < KYBER_K; i++) {
269
- PQCLEAN_MLKEM1024_CLEAN_poly_getnoise_eta1(sp.vec + i, coins, nonce++);
270
- }
271
- for (i = 0; i < KYBER_K; i++) {
272
- PQCLEAN_MLKEM1024_CLEAN_poly_getnoise_eta2(ep.vec + i, coins, nonce++);
273
- }
274
- PQCLEAN_MLKEM1024_CLEAN_poly_getnoise_eta2(&epp, coins, nonce++);
275
-
276
- PQCLEAN_MLKEM1024_CLEAN_polyvec_ntt(&sp);
277
-
278
- // matrix-vector multiplication
279
- for (i = 0; i < KYBER_K; i++) {
280
- PQCLEAN_MLKEM1024_CLEAN_polyvec_basemul_acc_montgomery(&b.vec[i], &at[i], &sp);
281
- }
282
-
283
- PQCLEAN_MLKEM1024_CLEAN_polyvec_basemul_acc_montgomery(&v, &pkpv, &sp);
284
-
285
- PQCLEAN_MLKEM1024_CLEAN_polyvec_invntt_tomont(&b);
286
- PQCLEAN_MLKEM1024_CLEAN_poly_invntt_tomont(&v);
287
-
288
- PQCLEAN_MLKEM1024_CLEAN_polyvec_add(&b, &b, &ep);
289
- PQCLEAN_MLKEM1024_CLEAN_poly_add(&v, &v, &epp);
290
- PQCLEAN_MLKEM1024_CLEAN_poly_add(&v, &v, &k);
291
- PQCLEAN_MLKEM1024_CLEAN_polyvec_reduce(&b);
292
- PQCLEAN_MLKEM1024_CLEAN_poly_reduce(&v);
293
-
294
- pack_ciphertext(c, &b, &v);
295
- }
296
-
297
- /*************************************************
298
- * Name: PQCLEAN_MLKEM1024_CLEAN_indcpa_dec
299
- *
300
- * Description: Decryption function of the CPA-secure
301
- * public-key encryption scheme underlying Kyber.
302
- *
303
- * Arguments: - uint8_t *m: pointer to output decrypted message
304
- * (of length KYBER_INDCPA_MSGBYTES)
305
- * - const uint8_t *c: pointer to input ciphertext
306
- * (of length KYBER_INDCPA_BYTES)
307
- * - const uint8_t *sk: pointer to input secret key
308
- * (of length KYBER_INDCPA_SECRETKEYBYTES)
309
- **************************************************/
310
- void PQCLEAN_MLKEM1024_CLEAN_indcpa_dec(uint8_t m[KYBER_INDCPA_MSGBYTES],
311
- const uint8_t c[KYBER_INDCPA_BYTES],
312
- const uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES]) {
313
- polyvec b, skpv;
314
- poly v, mp;
315
-
316
- unpack_ciphertext(&b, &v, c);
317
- unpack_sk(&skpv, sk);
318
-
319
- PQCLEAN_MLKEM1024_CLEAN_polyvec_ntt(&b);
320
- PQCLEAN_MLKEM1024_CLEAN_polyvec_basemul_acc_montgomery(&mp, &skpv, &b);
321
- PQCLEAN_MLKEM1024_CLEAN_poly_invntt_tomont(&mp);
322
-
323
- PQCLEAN_MLKEM1024_CLEAN_poly_sub(&mp, &v, &mp);
324
- PQCLEAN_MLKEM1024_CLEAN_poly_reduce(&mp);
325
-
326
- PQCLEAN_MLKEM1024_CLEAN_poly_tomsg(m, &mp);
327
- }
@@ -1,22 +0,0 @@
1
- #ifndef PQCLEAN_MLKEM1024_CLEAN_INDCPA_H
2
- #define PQCLEAN_MLKEM1024_CLEAN_INDCPA_H
3
- #include "params.h"
4
- #include "polyvec.h"
5
- #include <stdint.h>
6
-
7
- void PQCLEAN_MLKEM1024_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYMBYTES], int transposed);
8
-
9
- void PQCLEAN_MLKEM1024_CLEAN_indcpa_keypair_derand(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES],
10
- uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES],
11
- const uint8_t coins[KYBER_SYMBYTES]);
12
-
13
- void PQCLEAN_MLKEM1024_CLEAN_indcpa_enc(uint8_t c[KYBER_INDCPA_BYTES],
14
- const uint8_t m[KYBER_INDCPA_MSGBYTES],
15
- const uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES],
16
- const uint8_t coins[KYBER_SYMBYTES]);
17
-
18
- void PQCLEAN_MLKEM1024_CLEAN_indcpa_dec(uint8_t m[KYBER_INDCPA_MSGBYTES],
19
- const uint8_t c[KYBER_INDCPA_BYTES],
20
- const uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES]);
21
-
22
- #endif
@@ -1,164 +0,0 @@
1
- #include "indcpa.h"
2
- #include "kem.h"
3
- #include "params.h"
4
- #include "randombytes.h"
5
- #include "symmetric.h"
6
- #include "verify.h"
7
- #include <stddef.h>
8
- #include <stdint.h>
9
- #include <string.h>
10
- /*************************************************
11
- * Name: PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair_derand
12
- *
13
- * Description: Generates public and private key
14
- * for CCA-secure Kyber key encapsulation mechanism
15
- *
16
- * Arguments: - uint8_t *pk: pointer to output public key
17
- * (an already allocated array of KYBER_PUBLICKEYBYTES bytes)
18
- * - uint8_t *sk: pointer to output private key
19
- * (an already allocated array of KYBER_SECRETKEYBYTES bytes)
20
- * - uint8_t *coins: pointer to input randomness
21
- * (an already allocated array filled with 2*KYBER_SYMBYTES random bytes)
22
- **
23
- * Returns 0 (success)
24
- **************************************************/
25
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair_derand(uint8_t *pk,
26
- uint8_t *sk,
27
- const uint8_t *coins) {
28
- PQCLEAN_MLKEM1024_CLEAN_indcpa_keypair_derand(pk, sk, coins);
29
- memcpy(sk + KYBER_INDCPA_SECRETKEYBYTES, pk, KYBER_PUBLICKEYBYTES);
30
- hash_h(sk + KYBER_SECRETKEYBYTES - 2 * KYBER_SYMBYTES, pk, KYBER_PUBLICKEYBYTES);
31
- /* Value z for pseudo-random output on reject */
32
- memcpy(sk + KYBER_SECRETKEYBYTES - KYBER_SYMBYTES, coins + KYBER_SYMBYTES, KYBER_SYMBYTES);
33
- return 0;
34
- }
35
-
36
- /*************************************************
37
- * Name: PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair
38
- *
39
- * Description: Generates public and private key
40
- * for CCA-secure Kyber key encapsulation mechanism
41
- *
42
- * Arguments: - uint8_t *pk: pointer to output public key
43
- * (an already allocated array of KYBER_PUBLICKEYBYTES bytes)
44
- * - uint8_t *sk: pointer to output private key
45
- * (an already allocated array of KYBER_SECRETKEYBYTES bytes)
46
- *
47
- * Returns 0 (success)
48
- **************************************************/
49
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair(uint8_t *pk,
50
- uint8_t *sk) {
51
- uint8_t coins[2 * KYBER_SYMBYTES];
52
- randombytes(coins, 2 * KYBER_SYMBYTES);
53
- PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair_derand(pk, sk, coins);
54
- return 0;
55
- }
56
-
57
- /*************************************************
58
- * Name: PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc_derand
59
- *
60
- * Description: Generates cipher text and shared
61
- * secret for given public key
62
- *
63
- * Arguments: - uint8_t *ct: pointer to output cipher text
64
- * (an already allocated array of KYBER_CIPHERTEXTBYTES bytes)
65
- * - uint8_t *ss: pointer to output shared secret
66
- * (an already allocated array of KYBER_SSBYTES bytes)
67
- * - const uint8_t *pk: pointer to input public key
68
- * (an already allocated array of KYBER_PUBLICKEYBYTES bytes)
69
- * - const uint8_t *coins: pointer to input randomness
70
- * (an already allocated array filled with KYBER_SYMBYTES random bytes)
71
- **
72
- * Returns 0 (success)
73
- **************************************************/
74
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc_derand(uint8_t *ct,
75
- uint8_t *ss,
76
- const uint8_t *pk,
77
- const uint8_t *coins) {
78
- uint8_t buf[2 * KYBER_SYMBYTES];
79
- /* Will contain key, coins */
80
- uint8_t kr[2 * KYBER_SYMBYTES];
81
-
82
- memcpy(buf, coins, KYBER_SYMBYTES);
83
-
84
- /* Multitarget countermeasure for coins + contributory KEM */
85
- hash_h(buf + KYBER_SYMBYTES, pk, KYBER_PUBLICKEYBYTES);
86
- hash_g(kr, buf, 2 * KYBER_SYMBYTES);
87
-
88
- /* coins are in kr+KYBER_SYMBYTES */
89
- PQCLEAN_MLKEM1024_CLEAN_indcpa_enc(ct, buf, pk, kr + KYBER_SYMBYTES);
90
-
91
- memcpy(ss, kr, KYBER_SYMBYTES);
92
- return 0;
93
- }
94
-
95
- /*************************************************
96
- * Name: PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc
97
- *
98
- * Description: Generates cipher text and shared
99
- * secret for given public key
100
- *
101
- * Arguments: - uint8_t *ct: pointer to output cipher text
102
- * (an already allocated array of KYBER_CIPHERTEXTBYTES bytes)
103
- * - uint8_t *ss: pointer to output shared secret
104
- * (an already allocated array of KYBER_SSBYTES bytes)
105
- * - const uint8_t *pk: pointer to input public key
106
- * (an already allocated array of KYBER_PUBLICKEYBYTES bytes)
107
- *
108
- * Returns 0 (success)
109
- **************************************************/
110
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc(uint8_t *ct,
111
- uint8_t *ss,
112
- const uint8_t *pk) {
113
- uint8_t coins[KYBER_SYMBYTES];
114
- randombytes(coins, KYBER_SYMBYTES);
115
- PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc_derand(ct, ss, pk, coins);
116
- return 0;
117
- }
118
-
119
- /*************************************************
120
- * Name: PQCLEAN_MLKEM1024_CLEAN_crypto_kem_dec
121
- *
122
- * Description: Generates shared secret for given
123
- * cipher text and private key
124
- *
125
- * Arguments: - uint8_t *ss: pointer to output shared secret
126
- * (an already allocated array of KYBER_SSBYTES bytes)
127
- * - const uint8_t *ct: pointer to input cipher text
128
- * (an already allocated array of KYBER_CIPHERTEXTBYTES bytes)
129
- * - const uint8_t *sk: pointer to input private key
130
- * (an already allocated array of KYBER_SECRETKEYBYTES bytes)
131
- *
132
- * Returns 0.
133
- *
134
- * On failure, ss will contain a pseudo-random value.
135
- **************************************************/
136
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_dec(uint8_t *ss,
137
- const uint8_t *ct,
138
- const uint8_t *sk) {
139
- int fail;
140
- uint8_t buf[2 * KYBER_SYMBYTES];
141
- /* Will contain key, coins */
142
- uint8_t kr[2 * KYBER_SYMBYTES];
143
- uint8_t cmp[KYBER_CIPHERTEXTBYTES + KYBER_SYMBYTES];
144
- const uint8_t *pk = sk + KYBER_INDCPA_SECRETKEYBYTES;
145
-
146
- PQCLEAN_MLKEM1024_CLEAN_indcpa_dec(buf, ct, sk);
147
-
148
- /* Multitarget countermeasure for coins + contributory KEM */
149
- memcpy(buf + KYBER_SYMBYTES, sk + KYBER_SECRETKEYBYTES - 2 * KYBER_SYMBYTES, KYBER_SYMBYTES);
150
- hash_g(kr, buf, 2 * KYBER_SYMBYTES);
151
-
152
- /* coins are in kr+KYBER_SYMBYTES */
153
- PQCLEAN_MLKEM1024_CLEAN_indcpa_enc(cmp, buf, pk, kr + KYBER_SYMBYTES);
154
-
155
- fail = PQCLEAN_MLKEM1024_CLEAN_verify(ct, cmp, KYBER_CIPHERTEXTBYTES);
156
-
157
- /* Compute rejection key */
158
- rkprf(ss, sk + KYBER_SECRETKEYBYTES - KYBER_SYMBYTES, ct);
159
-
160
- /* Copy true key to return buffer if fail is false */
161
- PQCLEAN_MLKEM1024_CLEAN_cmov(ss, kr, KYBER_SYMBYTES, (uint8_t) (1 - fail));
162
-
163
- return 0;
164
- }
@@ -1,23 +0,0 @@
1
- #ifndef PQCLEAN_MLKEM1024_CLEAN_KEM_H
2
- #define PQCLEAN_MLKEM1024_CLEAN_KEM_H
3
- #include "params.h"
4
- #include <stdint.h>
5
-
6
- #define PQCLEAN_MLKEM1024_CLEAN_CRYPTO_SECRETKEYBYTES KYBER_SECRETKEYBYTES
7
- #define PQCLEAN_MLKEM1024_CLEAN_CRYPTO_PUBLICKEYBYTES KYBER_PUBLICKEYBYTES
8
- #define PQCLEAN_MLKEM1024_CLEAN_CRYPTO_CIPHERTEXTBYTES KYBER_CIPHERTEXTBYTES
9
- #define PQCLEAN_MLKEM1024_CLEAN_CRYPTO_BYTES KYBER_SSBYTES
10
-
11
- #define PQCLEAN_MLKEM1024_CLEAN_CRYPTO_ALGNAME "ML-KEM-1024"
12
-
13
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair_derand(uint8_t *pk, uint8_t *sk, const uint8_t *coins);
14
-
15
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk);
16
-
17
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc_derand(uint8_t *ct, uint8_t *ss, const uint8_t *pk, const uint8_t *coins);
18
-
19
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);
20
-
21
- int PQCLEAN_MLKEM1024_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);
22
-
23
- #endif
@@ -1,146 +0,0 @@
1
- #include "ntt.h"
2
- #include "params.h"
3
- #include "reduce.h"
4
- #include <stdint.h>
5
-
6
- /* Code to generate PQCLEAN_MLKEM1024_CLEAN_zetas and zetas_inv used in the number-theoretic transform:
7
-
8
- #define KYBER_ROOT_OF_UNITY 17
9
-
10
- static const uint8_t tree[128] = {
11
- 0, 64, 32, 96, 16, 80, 48, 112, 8, 72, 40, 104, 24, 88, 56, 120,
12
- 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124,
13
- 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122,
14
- 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 126,
15
- 1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121,
16
- 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125,
17
- 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123,
18
- 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 127
19
- };
20
-
21
- void init_ntt() {
22
- unsigned int i;
23
- int16_t tmp[128];
24
-
25
- tmp[0] = MONT;
26
- for(i=1;i<128;i++)
27
- tmp[i] = fqmul(tmp[i-1],MONT*KYBER_ROOT_OF_UNITY % KYBER_Q);
28
-
29
- for(i=0;i<128;i++) {
30
- PQCLEAN_MLKEM1024_CLEAN_zetas[i] = tmp[tree[i]];
31
- if(PQCLEAN_MLKEM1024_CLEAN_zetas[i] > KYBER_Q/2)
32
- PQCLEAN_MLKEM1024_CLEAN_zetas[i] -= KYBER_Q;
33
- if(PQCLEAN_MLKEM1024_CLEAN_zetas[i] < -KYBER_Q/2)
34
- PQCLEAN_MLKEM1024_CLEAN_zetas[i] += KYBER_Q;
35
- }
36
- }
37
- */
38
-
39
- const int16_t PQCLEAN_MLKEM1024_CLEAN_zetas[128] = {
40
- -1044, -758, -359, -1517, 1493, 1422, 287, 202,
41
- -171, 622, 1577, 182, 962, -1202, -1474, 1468,
42
- 573, -1325, 264, 383, -829, 1458, -1602, -130,
43
- -681, 1017, 732, 608, -1542, 411, -205, -1571,
44
- 1223, 652, -552, 1015, -1293, 1491, -282, -1544,
45
- 516, -8, -320, -666, -1618, -1162, 126, 1469,
46
- -853, -90, -271, 830, 107, -1421, -247, -951,
47
- -398, 961, -1508, -725, 448, -1065, 677, -1275,
48
- -1103, 430, 555, 843, -1251, 871, 1550, 105,
49
- 422, 587, 177, -235, -291, -460, 1574, 1653,
50
- -246, 778, 1159, -147, -777, 1483, -602, 1119,
51
- -1590, 644, -872, 349, 418, 329, -156, -75,
52
- 817, 1097, 603, 610, 1322, -1285, -1465, 384,
53
- -1215, -136, 1218, -1335, -874, 220, -1187, -1659,
54
- -1185, -1530, -1278, 794, -1510, -854, -870, 478,
55
- -108, -308, 996, 991, 958, -1460, 1522, 1628
56
- };
57
-
58
- /*************************************************
59
- * Name: fqmul
60
- *
61
- * Description: Multiplication followed by Montgomery reduction
62
- *
63
- * Arguments: - int16_t a: first factor
64
- * - int16_t b: second factor
65
- *
66
- * Returns 16-bit integer congruent to a*b*R^{-1} mod q
67
- **************************************************/
68
- static int16_t fqmul(int16_t a, int16_t b) {
69
- return PQCLEAN_MLKEM1024_CLEAN_montgomery_reduce((int32_t)a * b);
70
- }
71
-
72
- /*************************************************
73
- * Name: PQCLEAN_MLKEM1024_CLEAN_ntt
74
- *
75
- * Description: Inplace number-theoretic transform (NTT) in Rq.
76
- * input is in standard order, output is in bitreversed order
77
- *
78
- * Arguments: - int16_t r[256]: pointer to input/output vector of elements of Zq
79
- **************************************************/
80
- void PQCLEAN_MLKEM1024_CLEAN_ntt(int16_t r[256]) {
81
- unsigned int len, start, j, k;
82
- int16_t t, zeta;
83
-
84
- k = 1;
85
- for (len = 128; len >= 2; len >>= 1) {
86
- for (start = 0; start < 256; start = j + len) {
87
- zeta = PQCLEAN_MLKEM1024_CLEAN_zetas[k++];
88
- for (j = start; j < start + len; j++) {
89
- t = fqmul(zeta, r[j + len]);
90
- r[j + len] = r[j] - t;
91
- r[j] = r[j] + t;
92
- }
93
- }
94
- }
95
- }
96
-
97
- /*************************************************
98
- * Name: invntt_tomont
99
- *
100
- * Description: Inplace inverse number-theoretic transform in Rq and
101
- * multiplication by Montgomery factor 2^16.
102
- * Input is in bitreversed order, output is in standard order
103
- *
104
- * Arguments: - int16_t r[256]: pointer to input/output vector of elements of Zq
105
- **************************************************/
106
- void PQCLEAN_MLKEM1024_CLEAN_invntt(int16_t r[256]) {
107
- unsigned int start, len, j, k;
108
- int16_t t, zeta;
109
- const int16_t f = 1441; // mont^2/128
110
-
111
- k = 127;
112
- for (len = 2; len <= 128; len <<= 1) {
113
- for (start = 0; start < 256; start = j + len) {
114
- zeta = PQCLEAN_MLKEM1024_CLEAN_zetas[k--];
115
- for (j = start; j < start + len; j++) {
116
- t = r[j];
117
- r[j] = PQCLEAN_MLKEM1024_CLEAN_barrett_reduce(t + r[j + len]);
118
- r[j + len] = r[j + len] - t;
119
- r[j + len] = fqmul(zeta, r[j + len]);
120
- }
121
- }
122
- }
123
-
124
- for (j = 0; j < 256; j++) {
125
- r[j] = fqmul(r[j], f);
126
- }
127
- }
128
-
129
- /*************************************************
130
- * Name: PQCLEAN_MLKEM1024_CLEAN_basemul
131
- *
132
- * Description: Multiplication of polynomials in Zq[X]/(X^2-zeta)
133
- * used for multiplication of elements in Rq in NTT domain
134
- *
135
- * Arguments: - int16_t r[2]: pointer to the output polynomial
136
- * - const int16_t a[2]: pointer to the first factor
137
- * - const int16_t b[2]: pointer to the second factor
138
- * - int16_t zeta: integer defining the reduction polynomial
139
- **************************************************/
140
- void PQCLEAN_MLKEM1024_CLEAN_basemul(int16_t r[2], const int16_t a[2], const int16_t b[2], int16_t zeta) {
141
- r[0] = fqmul(a[1], b[1]);
142
- r[0] = fqmul(r[0], zeta);
143
- r[0] += fqmul(a[0], b[0]);
144
- r[1] = fqmul(a[0], b[1]);
145
- r[1] += fqmul(a[1], b[0]);
146
- }