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
@@ -0,0 +1,806 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [FIPS204]
10
+ * FIPS 204 Module-Lattice-Based Digital Signature Standard
11
+ * National Institute of Standards and Technology
12
+ * https://csrc.nist.gov/pubs/fips/204/final
13
+ */
14
+
15
+ #ifndef MLD_SIGN_H
16
+ #define MLD_SIGN_H
17
+
18
+ #include <stddef.h>
19
+ #include "cbmc.h"
20
+ #include "common.h"
21
+ #include "poly.h"
22
+ #include "polyvec.h"
23
+ #include "sys.h"
24
+
25
+ #if defined(MLD_CHECK_APIS)
26
+ /* Include to ensure consistency between internal sign.h
27
+ * and external mldsa_native.h. */
28
+ #include "mldsa_native.h"
29
+
30
+ #if MLDSA_CRYPTO_SECRETKEYBYTES != \
31
+ MLDSA_SECRETKEYBYTES(MLD_CONFIG_PARAMETER_SET)
32
+ #error Mismatch for SECRETKEYBYTES between sign.h and mldsa_native.h
33
+ #endif
34
+
35
+ #if MLDSA_CRYPTO_PUBLICKEYBYTES != \
36
+ MLDSA_PUBLICKEYBYTES(MLD_CONFIG_PARAMETER_SET)
37
+ #error Mismatch for PUBLICKEYBYTES between sign.h and mldsa_native.h
38
+ #endif
39
+
40
+ #if MLDSA_CRYPTO_BYTES != MLDSA_BYTES(MLD_CONFIG_PARAMETER_SET)
41
+ #error Mismatch for CRYPTO_BYTES between sign.h and mldsa_native.h
42
+ #endif
43
+
44
+ #endif /* MLD_CHECK_APIS */
45
+
46
+ #define mld_sign_keypair_internal \
47
+ MLD_NAMESPACE_KL(keypair_internal) MLD_CONTEXT_PARAMETERS_3
48
+ #define mld_sign_keypair MLD_NAMESPACE_KL(keypair) MLD_CONTEXT_PARAMETERS_2
49
+ #define mld_sign_signature_internal \
50
+ MLD_NAMESPACE_KL(signature_internal) MLD_CONTEXT_PARAMETERS_9
51
+ #define mld_sign_signature MLD_NAMESPACE_KL(signature) MLD_CONTEXT_PARAMETERS_7
52
+ #define mld_sign_signature_extmu \
53
+ MLD_NAMESPACE_KL(signature_extmu) MLD_CONTEXT_PARAMETERS_4
54
+ #define mld_sign MLD_NAMESPACE_KL(sign) MLD_CONTEXT_PARAMETERS_7
55
+ #define mld_sign_verify_internal \
56
+ MLD_NAMESPACE_KL(verify_internal) MLD_CONTEXT_PARAMETERS_8
57
+ #define mld_sign_verify MLD_NAMESPACE_KL(verify) MLD_CONTEXT_PARAMETERS_7
58
+ #define mld_sign_verify_extmu \
59
+ MLD_NAMESPACE_KL(verify_extmu) MLD_CONTEXT_PARAMETERS_4
60
+ #define mld_sign_open MLD_NAMESPACE_KL(open) MLD_CONTEXT_PARAMETERS_7
61
+ #define mld_sign_signature_pre_hash_internal \
62
+ MLD_NAMESPACE_KL(signature_pre_hash_internal) MLD_CONTEXT_PARAMETERS_9
63
+ #define mld_sign_verify_pre_hash_internal \
64
+ MLD_NAMESPACE_KL(verify_pre_hash_internal) MLD_CONTEXT_PARAMETERS_8
65
+ #define mld_sign_signature_pre_hash_shake256 \
66
+ MLD_NAMESPACE_KL(signature_pre_hash_shake256) MLD_CONTEXT_PARAMETERS_8
67
+ #define mld_sign_verify_pre_hash_shake256 \
68
+ MLD_NAMESPACE_KL(verify_pre_hash_shake256) MLD_CONTEXT_PARAMETERS_7
69
+ #define mld_prepare_domain_separation_prefix \
70
+ MLD_NAMESPACE_KL(prepare_domain_separation_prefix)
71
+ #define mld_sign_pk_from_sk \
72
+ MLD_NAMESPACE_KL(pk_from_sk) MLD_CONTEXT_PARAMETERS_2
73
+
74
+ /*************************************************
75
+ * Hash algorithm constants for domain separation
76
+ **************************************************/
77
+ #define MLD_PREHASH_NONE 0
78
+ #define MLD_PREHASH_SHA2_224 1
79
+ #define MLD_PREHASH_SHA2_256 2
80
+ #define MLD_PREHASH_SHA2_384 3
81
+ #define MLD_PREHASH_SHA2_512 4
82
+ #define MLD_PREHASH_SHA2_512_224 5
83
+ #define MLD_PREHASH_SHA2_512_256 6
84
+ #define MLD_PREHASH_SHA3_224 7
85
+ #define MLD_PREHASH_SHA3_256 8
86
+ #define MLD_PREHASH_SHA3_384 9
87
+ #define MLD_PREHASH_SHA3_512 10
88
+ #define MLD_PREHASH_SHAKE_128 11
89
+ #define MLD_PREHASH_SHAKE_256 12
90
+
91
+ /*************************************************
92
+ * Name: mld_sign_keypair_internal
93
+ *
94
+ * Description: Generates public and private key. Internal API.
95
+ * When MLD_CONFIG_KEYGEN_PCT is set, performs a Pairwise
96
+ * Consistency Test (PCT) as required by FIPS 140-3 IG.
97
+ *
98
+ * Arguments: - uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]: output public key
99
+ * - uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]: output private key
100
+ * - const uint8_t seed[MLDSA_SEEDBYTES]: input random seed
101
+ *
102
+ * Returns: - 0: Success
103
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
104
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
105
+ * - MLD_ERR_RNG_FAIL: Random number generation failed.
106
+ * - MLD_ERR_FAIL: Other kinds of failure, incl. PCT failure
107
+ * if MLD_CONFIG_KEYGEN_PCT is enabled.
108
+ *
109
+ * Specification: Implements @[FIPS204 Algorithm 6 (ML-DSA.KeyGen_internal)]
110
+ *
111
+ **************************************************/
112
+ MLD_MUST_CHECK_RETURN_VALUE
113
+ MLD_EXTERNAL_API
114
+ int mld_sign_keypair_internal(uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
115
+ uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
116
+ const uint8_t seed[MLDSA_SEEDBYTES],
117
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
118
+ __contract__(
119
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
120
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
121
+ requires(memory_no_alias(seed, MLDSA_SEEDBYTES))
122
+ assigns(object_whole(pk))
123
+ assigns(object_whole(sk))
124
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL ||
125
+ return_value == MLD_ERR_OUT_OF_MEMORY || return_value == MLD_ERR_RNG_FAIL)
126
+ );
127
+
128
+ /*************************************************
129
+ * Name: mld_sign_keypair
130
+ *
131
+ * Description: Generates public and private key.
132
+ * When MLD_CONFIG_KEYGEN_PCT is set, performs a Pairwise
133
+ * Consistency Test (PCT) as required by FIPS 140-3 IG.
134
+ *
135
+ * Arguments: - uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]: output public key
136
+ * - uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]: output private key
137
+ *
138
+ * Returns: - 0: Success
139
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
140
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
141
+ * - MLD_ERR_RNG_FAIL: Random number generation failed.
142
+ * - MLD_ERR_FAIL: Other kinds of failure, incl. PCT failure
143
+ * if MLD_CONFIG_KEYGEN_PCT is enabled.
144
+ *
145
+ * Specification: Implements @[FIPS204 Algorithm 1 (ML-DSA.KeyGen)]
146
+ *
147
+ **************************************************/
148
+ MLD_MUST_CHECK_RETURN_VALUE
149
+ MLD_EXTERNAL_API
150
+ int mld_sign_keypair(uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
151
+ uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
152
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
153
+ __contract__(
154
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
155
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
156
+ assigns(object_whole(pk))
157
+ assigns(object_whole(sk))
158
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL ||
159
+ return_value == MLD_ERR_OUT_OF_MEMORY || return_value == MLD_ERR_RNG_FAIL)
160
+ );
161
+
162
+ /*************************************************
163
+ * Name: mld_sign_signature_internal
164
+ *
165
+ * Description: Computes signature. Internal API.
166
+ *
167
+ * Arguments: - uint8_t sig[MLDSA_CRYPTO_BYTES]: output signature
168
+ * - size_t *siglen: pointer to output length of
169
+ * signature
170
+ * - const uint8_t *m: pointer to message to be signed
171
+ * - size_t mlen: length of message
172
+ * - const uint8_t *pre: pointer to prefix string
173
+ * - size_t prelen: length of prefix string
174
+ * - const uint8_t rnd[MLDSA_RNDBYTES]:
175
+ * random seed
176
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]:
177
+ * bit-packed secret key
178
+ * - int externalmu: indicates input message m is
179
+ * processed as mu
180
+ *
181
+ * Returns: - 0: Success
182
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
183
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
184
+ * - MLD_ERR_FAIL: Other kinds of failure
185
+ *
186
+ * If the returned value is non-zero, then the values of *sig and
187
+ * *siglen should not be referenced.
188
+ *
189
+ * Reference: This code differs from the reference implementation
190
+ * in that it adds an explicit check for nonce exhaustion
191
+ * and can return MLD_ERR_FAIL in that case.
192
+ **************************************************/
193
+ MLD_MUST_CHECK_RETURN_VALUE
194
+ MLD_EXTERNAL_API
195
+ int mld_sign_signature_internal(uint8_t sig[MLDSA_CRYPTO_BYTES], size_t *siglen,
196
+ const uint8_t *m, size_t mlen,
197
+ const uint8_t *pre, size_t prelen,
198
+ const uint8_t rnd[MLDSA_RNDBYTES],
199
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
200
+ int externalmu,
201
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
202
+ __contract__(
203
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
204
+ requires(prelen <= MLD_MAX_BUFFER_SIZE)
205
+ requires(memory_no_alias(sig, MLDSA_CRYPTO_BYTES))
206
+ requires(memory_no_alias(siglen, sizeof(size_t)))
207
+ requires(memory_no_alias(m, mlen))
208
+ requires(memory_no_alias(rnd, MLDSA_RNDBYTES))
209
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
210
+ requires((externalmu == 0 && (prelen == 0 || memory_no_alias(pre, prelen))) ||
211
+ (externalmu == 1 && mlen == MLDSA_CRHBYTES))
212
+ assigns(memory_slice(sig, MLDSA_CRYPTO_BYTES))
213
+ assigns(object_whole(siglen))
214
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL ||
215
+ return_value == MLD_ERR_OUT_OF_MEMORY)
216
+ ensures(return_value == 0 ==> *siglen == MLDSA_CRYPTO_BYTES)
217
+ ensures(return_value != 0 ==> *siglen == 0)
218
+ );
219
+
220
+ /*************************************************
221
+ * Name: mld_sign_signature
222
+ *
223
+ * Description: Computes signature. This function implements the randomized
224
+ * variant of ML-DSA. If you require the deterministic variant,
225
+ * use mld_sign_signature_internal directly.
226
+ *
227
+ * Arguments: - uint8_t sig[MLDSA_CRYPTO_BYTES]: output signature
228
+ * - size_t *siglen: pointer to output length of
229
+ * signature
230
+ * - const uint8_t *m: pointer to message to be signed
231
+ * - size_t mlen: length of message
232
+ * - uint8_t *ctx: pointer to context string.
233
+ * May be NULL if ctxlen == 0.
234
+ * - size_t ctxlen: length of context string.
235
+ * Should be <= 255.
236
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]:
237
+ * bit-packed secret key
238
+ *
239
+ * Returns: - 0: Success
240
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
241
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
242
+ * - MLD_ERR_RNG_FAIL: Random number generation failed.
243
+ * - MLD_ERR_FAIL: Other kinds of failure.
244
+ *
245
+ * Specification: Implements @[FIPS204 Algorithm 2 (ML-DSA.Sign)].
246
+ *
247
+ **************************************************/
248
+ MLD_MUST_CHECK_RETURN_VALUE
249
+ MLD_EXTERNAL_API
250
+ int mld_sign_signature(uint8_t sig[MLDSA_CRYPTO_BYTES], size_t *siglen,
251
+ const uint8_t *m, size_t mlen, const uint8_t *ctx,
252
+ size_t ctxlen,
253
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
254
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
255
+ __contract__(
256
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
257
+ requires(memory_no_alias(sig, MLDSA_CRYPTO_BYTES))
258
+ requires(memory_no_alias(siglen, sizeof(size_t)))
259
+ requires(memory_no_alias(m, mlen))
260
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE)
261
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
262
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
263
+ assigns(memory_slice(sig, MLDSA_CRYPTO_BYTES))
264
+ assigns(object_whole(siglen))
265
+ ensures((return_value == 0 && *siglen == MLDSA_CRYPTO_BYTES) ||
266
+ ((return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY || return_value == MLD_ERR_RNG_FAIL) && *siglen == 0))
267
+ );
268
+
269
+ /*************************************************
270
+ * Name: mld_sign_signature_extmu
271
+ *
272
+ * Description: Computes signature. This function implements the randomized
273
+ * variant of ML-DSA. If you require the deterministic variant,
274
+ * use mld_sign_signature_internal directly.
275
+ *
276
+ * Arguments: - uint8_t sig[MLDSA_CRYPTO_BYTES]: output signature
277
+ * - size_t *siglen: pointer to output length of
278
+ * signature
279
+ * - const uint8_t mu[MLDSA_CRHBYTES]:
280
+ * input mu to be signed
281
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]:
282
+ * bit-packed secret key
283
+ *
284
+ * Returns: - 0: Success
285
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
286
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
287
+ * - MLD_ERR_RNG_FAIL: Random number generation failed.
288
+ * - MLD_ERR_FAIL: Other kinds of failure.
289
+ *
290
+ * Specification: Implements @[FIPS204 Algorithm 2 (ML-DSA.Sign external mu
291
+ * variant)]
292
+ *
293
+ **************************************************/
294
+ MLD_MUST_CHECK_RETURN_VALUE
295
+ MLD_EXTERNAL_API
296
+ int mld_sign_signature_extmu(uint8_t sig[MLDSA_CRYPTO_BYTES], size_t *siglen,
297
+ const uint8_t mu[MLDSA_CRHBYTES],
298
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
299
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
300
+ __contract__(
301
+ requires(memory_no_alias(sig, MLDSA_CRYPTO_BYTES))
302
+ requires(memory_no_alias(siglen, sizeof(size_t)))
303
+ requires(memory_no_alias(mu, MLDSA_CRHBYTES))
304
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
305
+ assigns(memory_slice(sig, MLDSA_CRYPTO_BYTES))
306
+ assigns(object_whole(siglen))
307
+ ensures((return_value == 0 && *siglen == MLDSA_CRYPTO_BYTES) ||
308
+ ((return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY || return_value == MLD_ERR_RNG_FAIL) && *siglen == 0))
309
+ );
310
+
311
+ /*************************************************
312
+ * Name: mld_sign
313
+ *
314
+ * Description: Compute signed message.
315
+ *
316
+ * Arguments: - uint8_t *sm: pointer to output signed message
317
+ * (allocated array with MLDSA_CRYPTO_BYTES +
318
+ *mlen bytes), can be equal to m
319
+ * - size_t *smlen: pointer to output length of signed message
320
+ * - const uint8_t *m: pointer to message to be signed
321
+ * - size_t mlen: length of message
322
+ * - const uint8_t *ctx: pointer to context string
323
+ * - size_t ctxlen: length of context string
324
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]:
325
+ * bit-packed secret key
326
+ *
327
+ * Returns: - 0: Success
328
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
329
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
330
+ * - MLD_ERR_FAIL: Other kinds of failure
331
+ *
332
+ **************************************************/
333
+ MLD_MUST_CHECK_RETURN_VALUE
334
+ MLD_EXTERNAL_API
335
+ int mld_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
336
+ const uint8_t *ctx, size_t ctxlen,
337
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
338
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
339
+ __contract__(
340
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
341
+ requires(memory_no_alias(sm, MLDSA_CRYPTO_BYTES + mlen))
342
+ requires(memory_no_alias(smlen, sizeof(size_t)))
343
+ requires(m == sm || memory_no_alias(m, mlen))
344
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE)
345
+ requires(memory_no_alias(ctx, ctxlen))
346
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
347
+ assigns(memory_slice(sm, MLDSA_CRYPTO_BYTES + mlen))
348
+ assigns(object_whole(smlen))
349
+ ensures((return_value == 0 && *smlen == MLDSA_CRYPTO_BYTES + mlen) ||
350
+ (return_value == MLD_ERR_FAIL
351
+ || return_value == MLD_ERR_OUT_OF_MEMORY
352
+ || return_value == MLD_ERR_RNG_FAIL))
353
+ );
354
+
355
+ /*************************************************
356
+ * Name: mld_sign_verify_internal
357
+ *
358
+ * Description: Verifies signature. Internal API.
359
+ *
360
+ * Arguments: - const uint8_t *sig: pointer to input signature
361
+ * - size_t siglen: length of signature
362
+ * - const uint8_t *m: pointer to message
363
+ * - size_t mlen: length of message
364
+ * - const uint8_t *pre: pointer to prefix string
365
+ * - size_t prelen: length of prefix string
366
+ * - const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]:
367
+ * bit-packed public key
368
+ * - int externalmu: indicates input message m is processed as
369
+ * mu
370
+ *
371
+ * Returns: - 0: Success
372
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
373
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
374
+ * - MLD_ERR_FAIL: Signature verification failed
375
+ *
376
+ * Specification: Implements @[FIPS204 Algorithm 8 (ML-DSA.Verify_internal)]
377
+ *
378
+ **************************************************/
379
+ MLD_MUST_CHECK_RETURN_VALUE
380
+ MLD_EXTERNAL_API
381
+ int mld_sign_verify_internal(const uint8_t *sig, size_t siglen,
382
+ const uint8_t *m, size_t mlen, const uint8_t *pre,
383
+ size_t prelen,
384
+ const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
385
+ int externalmu,
386
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
387
+ __contract__(
388
+ requires(prelen <= MLD_MAX_BUFFER_SIZE)
389
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
390
+ requires(siglen <= MLD_MAX_BUFFER_SIZE)
391
+ requires(memory_no_alias(sig, siglen))
392
+ requires(memory_no_alias(m, mlen))
393
+ requires(externalmu == 0 || (externalmu == 1 && mlen == MLDSA_CRHBYTES))
394
+ requires(externalmu == 1 || prelen == 0 || memory_no_alias(pre, prelen))
395
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
396
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
397
+ );
398
+
399
+ /*************************************************
400
+ * Name: mld_sign_verify
401
+ *
402
+ * Description: Verifies signature.
403
+ *
404
+ * Arguments: - const uint8_t *sig: pointer to input signature
405
+ * - size_t siglen: length of signature
406
+ * - const uint8_t *m: pointer to message
407
+ * - size_t mlen: length of message
408
+ * - const uint8_t *ctx: pointer to context string.
409
+ * May be NULL if ctxlen == 0.
410
+ * - size_t ctxlen: length of context string
411
+ * - const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]:
412
+ * bit-packed public key
413
+ *
414
+ * Returns: - 0: Success
415
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
416
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
417
+ * - MLD_ERR_FAIL: Signature verification failed
418
+ *
419
+ * Specification: Implements @[FIPS204 Algorithm 3 (ML-DSA.Verify)]
420
+ *
421
+ **************************************************/
422
+ MLD_MUST_CHECK_RETURN_VALUE
423
+ MLD_EXTERNAL_API
424
+ int mld_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m,
425
+ size_t mlen, const uint8_t *ctx, size_t ctxlen,
426
+ const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
427
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
428
+ __contract__(
429
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
430
+ requires(siglen <= MLD_MAX_BUFFER_SIZE)
431
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE)
432
+ requires(memory_no_alias(sig, siglen))
433
+ requires(memory_no_alias(m, mlen))
434
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
435
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
436
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
437
+ );
438
+
439
+ /*************************************************
440
+ * Name: mld_sign_verify_extmu
441
+ *
442
+ * Description: Verifies signature.
443
+ *
444
+ * Arguments: - const uint8_t *sig: pointer to input signature
445
+ * - size_t siglen: length of signature
446
+ * - const uint8_t mu[MLDSA_CRHBYTES]:
447
+ * input mu
448
+ * - const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]:
449
+ * bit-packed public key
450
+ *
451
+ * Returns: - 0: Success
452
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
453
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
454
+ * - MLD_ERR_FAIL: Signature verification failed
455
+ *
456
+ * Specification: Implements @[FIPS204 Algorithm 3 (ML-DSA.Verify external mu
457
+ * variant)]
458
+ *
459
+ **************************************************/
460
+ MLD_MUST_CHECK_RETURN_VALUE
461
+ MLD_EXTERNAL_API
462
+ int mld_sign_verify_extmu(const uint8_t *sig, size_t siglen,
463
+ const uint8_t mu[MLDSA_CRHBYTES],
464
+ const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
465
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
466
+ __contract__(
467
+ requires(siglen <= MLD_MAX_BUFFER_SIZE)
468
+ requires(memory_no_alias(sig, siglen))
469
+ requires(memory_no_alias(mu, MLDSA_CRHBYTES))
470
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
471
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
472
+ );
473
+
474
+ /*************************************************
475
+ * Name: mld_sign_open
476
+ *
477
+ * Description: Verify signed message.
478
+ *
479
+ * Arguments: - uint8_t *m: pointer to output message (allocated array
480
+ * with smlen bytes), can be equal to sm
481
+ * - size_t *mlen: pointer to output length of message
482
+ * - const uint8_t *sm: pointer to signed message
483
+ * - size_t smlen: length of signed message
484
+ * - const uint8_t *ctx: pointer to context tring
485
+ * - size_t ctxlen: length of context string
486
+ * - const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]:
487
+ * bit-packed public key
488
+ *
489
+ * Returns: - 0: Success
490
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
491
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
492
+ * - MLD_ERR_FAIL: Signature verification failed
493
+ *
494
+ **************************************************/
495
+ MLD_MUST_CHECK_RETURN_VALUE
496
+ MLD_EXTERNAL_API
497
+ int mld_sign_open(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen,
498
+ const uint8_t *ctx, size_t ctxlen,
499
+ const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
500
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
501
+ __contract__(
502
+ requires(smlen <= MLD_MAX_BUFFER_SIZE)
503
+ requires(memory_no_alias(m, smlen))
504
+ requires(memory_no_alias(mlen, sizeof(size_t)))
505
+ requires(m == sm || memory_no_alias(sm, smlen))
506
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE)
507
+ requires(memory_no_alias(ctx, ctxlen))
508
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
509
+ assigns(memory_slice(m, smlen))
510
+ assigns(memory_slice(mlen, sizeof(size_t)))
511
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
512
+ );
513
+
514
+ /*************************************************
515
+ * Name: mld_sign_signature_pre_hash_internal
516
+ *
517
+ * Description: FIPS 204: Algorithm 4 HashML-DSA.Sign.
518
+ * Computes signature with pre-hashed message.
519
+ *
520
+ * Arguments: - uint8_t sig[MLDSA_CRYPTO_BYTES]:
521
+ * output signature
522
+ * - size_t *siglen: pointer to output length of signature
523
+ * - const uint8_t *ph: pointer to pre-hashed message
524
+ * - size_t phlen: length of pre-hashed message
525
+ * - const uint8_t *ctx: pointer to context string
526
+ * - size_t ctxlen: length of context string
527
+ * - const uint8_t rnd[MLDSA_RNDBYTES]:
528
+ * random seed
529
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]:
530
+ * bit-packed secret key
531
+ * - int hashalg: hash algorithm constant (one of
532
+ * MLD_PREHASH_*)
533
+ *
534
+ * Returns: - 0: Success
535
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
536
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
537
+ * - MLD_ERR_FAIL: Other kinds of failure
538
+ *
539
+ * Supported hash algorithm constants:
540
+ * MLD_PREHASH_SHA2_224, MLD_PREHASH_SHA2_256, MLD_PREHASH_SHA2_384,
541
+ * MLD_PREHASH_SHA2_512, MLD_PREHASH_SHA2_512_224, MLD_PREHASH_SHA2_512_256,
542
+ * MLD_PREHASH_SHA3_224, MLD_PREHASH_SHA3_256, MLD_PREHASH_SHA3_384,
543
+ * MLD_PREHASH_SHA3_512, MLD_PREHASH_SHAKE_128, MLD_PREHASH_SHAKE_256
544
+ *
545
+ * Warning: This is an unstable API that may change in the future. If you need
546
+ * a stable API use mld_sign_signature_pre_hash_shake256.
547
+ **************************************************/
548
+ MLD_MUST_CHECK_RETURN_VALUE
549
+ MLD_EXTERNAL_API
550
+ int mld_sign_signature_pre_hash_internal(
551
+ uint8_t sig[MLDSA_CRYPTO_BYTES], size_t *siglen, const uint8_t *ph,
552
+ size_t phlen, const uint8_t *ctx, size_t ctxlen,
553
+ const uint8_t rnd[MLDSA_RNDBYTES],
554
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES], int hashalg,
555
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
556
+ __contract__(
557
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE)
558
+ requires(phlen <= MLD_MAX_BUFFER_SIZE)
559
+ requires(memory_no_alias(sig, MLDSA_CRYPTO_BYTES))
560
+ requires(memory_no_alias(siglen, sizeof(size_t)))
561
+ requires(memory_no_alias(ph, phlen))
562
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
563
+ requires(memory_no_alias(rnd, MLDSA_RNDBYTES))
564
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
565
+ assigns(memory_slice(sig, MLDSA_CRYPTO_BYTES))
566
+ assigns(object_whole(siglen))
567
+ ensures((return_value == 0 && *siglen == MLDSA_CRYPTO_BYTES) ||
568
+ ((return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY) && *siglen == 0))
569
+ );
570
+
571
+ /*************************************************
572
+ * Name: mld_sign_verify_pre_hash_internal
573
+ *
574
+ * Description: FIPS 204: Algorithm 5 HashML-DSA.Verify.
575
+ * Verifies signature with pre-hashed message.
576
+ *
577
+ * Arguments: - const uint8_t *sig: pointer to input signature
578
+ * - size_t siglen: length of signature
579
+ * - const uint8_t *ph: pointer to pre-hashed message
580
+ * - size_t phlen: length of pre-hashed message
581
+ * - const uint8_t *ctx: pointer to context string
582
+ * - size_t ctxlen: length of context string
583
+ * - const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]:
584
+ * bit-packed public key
585
+ * - int hashalg: hash algorithm constant (one of
586
+ * MLD_PREHASH_*)
587
+ *
588
+ * Returns: - 0: Success
589
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
590
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
591
+ * - MLD_ERR_FAIL: Signature verification failed
592
+ *
593
+ * Supported hash algorithm constants:
594
+ * MLD_PREHASH_SHA2_224, MLD_PREHASH_SHA2_256, MLD_PREHASH_SHA2_384,
595
+ * MLD_PREHASH_SHA2_512, MLD_PREHASH_SHA2_512_224, MLD_PREHASH_SHA2_512_256,
596
+ * MLD_PREHASH_SHA3_224, MLD_PREHASH_SHA3_256, MLD_PREHASH_SHA3_384,
597
+ * MLD_PREHASH_SHA3_512, MLD_PREHASH_SHAKE_128, MLD_PREHASH_SHAKE_256
598
+ *
599
+ * Warning: This is an unstable API that may change in the future. If you need
600
+ * a stable API use mld_sign_verify_pre_hash_shake256.
601
+ **************************************************/
602
+ MLD_MUST_CHECK_RETURN_VALUE
603
+ MLD_EXTERNAL_API
604
+ int mld_sign_verify_pre_hash_internal(
605
+ const uint8_t *sig, size_t siglen, const uint8_t *ph, size_t phlen,
606
+ const uint8_t *ctx, size_t ctxlen,
607
+ const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES], int hashalg,
608
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
609
+ __contract__(
610
+ requires(phlen <= MLD_MAX_BUFFER_SIZE)
611
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE - 77)
612
+ requires(siglen <= MLD_MAX_BUFFER_SIZE)
613
+ requires(memory_no_alias(sig, siglen))
614
+ requires(memory_no_alias(ph, phlen))
615
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
616
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
617
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
618
+ );
619
+
620
+ /*************************************************
621
+ * Name: mld_sign_signature_pre_hash_shake256
622
+ *
623
+ * Description: FIPS 204: Algorithm 4 HashML-DSA.Sign with SHAKE256.
624
+ * Computes signature with pre-hashed message using SHAKE256.
625
+ * This function computes the SHAKE256 hash of the message
626
+ *internally.
627
+ *
628
+ * Arguments: - uint8_t sig[MLDSA_CRYPTO_BYTES]:
629
+ * output signature
630
+ * - size_t *siglen: pointer to output length of signature
631
+ * - const uint8_t *m: pointer to message to be hashed and signed
632
+ * - size_t mlen: length of message
633
+ * - const uint8_t *ctx: pointer to context string
634
+ * - size_t ctxlen: length of context string
635
+ * - const uint8_t rnd[MLDSA_RNDBYTES]:
636
+ * random seed
637
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]:
638
+ * bit-packed secret key
639
+ *
640
+ * Returns: - 0: Success
641
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
642
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
643
+ * - MLD_ERR_FAIL: Other kinds of failure
644
+ *
645
+ **************************************************/
646
+ MLD_MUST_CHECK_RETURN_VALUE
647
+ MLD_EXTERNAL_API
648
+ int mld_sign_signature_pre_hash_shake256(
649
+ uint8_t sig[MLDSA_CRYPTO_BYTES], size_t *siglen, const uint8_t *m,
650
+ size_t mlen, const uint8_t *ctx, size_t ctxlen,
651
+ const uint8_t rnd[MLDSA_RNDBYTES],
652
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
653
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
654
+ __contract__(
655
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
656
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE)
657
+ requires(memory_no_alias(sig, MLDSA_CRYPTO_BYTES))
658
+ requires(memory_no_alias(siglen, sizeof(size_t)))
659
+ requires(memory_no_alias(m, mlen))
660
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
661
+ requires(memory_no_alias(rnd, MLDSA_RNDBYTES))
662
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
663
+ assigns(memory_slice(sig, MLDSA_CRYPTO_BYTES))
664
+ assigns(object_whole(siglen))
665
+ ensures((return_value == 0 && *siglen == MLDSA_CRYPTO_BYTES) ||
666
+ ((return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY) && *siglen == 0))
667
+ );
668
+
669
+ /*************************************************
670
+ * Name: mld_sign_verify_pre_hash_shake256
671
+ *
672
+ * Description: FIPS 204: Algorithm 5 HashML-DSA.Verify with SHAKE256.
673
+ * Verifies signature with pre-hashed message using SHAKE256.
674
+ * This function computes the SHAKE256 hash of the message
675
+ * internally.
676
+ *
677
+ * Arguments: - const uint8_t *sig: pointer to input signature
678
+ * - size_t siglen: length of signature
679
+ * - const uint8_t *m: pointer to message to be hashed and
680
+ * verified
681
+ * - size_t mlen: length of message
682
+ * - const uint8_t *ctx: pointer to context string
683
+ * - size_t ctxlen: length of context string
684
+ * - const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]:
685
+ * bit-packed public key
686
+ *
687
+ * Returns: - 0: Success
688
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
689
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
690
+ * - MLD_ERR_FAIL: Signature verification failed
691
+ *
692
+ **************************************************/
693
+ MLD_MUST_CHECK_RETURN_VALUE
694
+ MLD_EXTERNAL_API
695
+ int mld_sign_verify_pre_hash_shake256(
696
+ const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen,
697
+ const uint8_t *ctx, size_t ctxlen,
698
+ const uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
699
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
700
+ __contract__(
701
+ requires(mlen <= MLD_MAX_BUFFER_SIZE)
702
+ requires(ctxlen <= MLD_MAX_BUFFER_SIZE - 77)
703
+ requires(siglen <= MLD_MAX_BUFFER_SIZE)
704
+ requires(memory_no_alias(sig, siglen))
705
+ requires(memory_no_alias(m, mlen))
706
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
707
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
708
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
709
+ );
710
+
711
+ /* Maximum formatted domain separation message length:
712
+ * - Pure ML-DSA: 0x00 || ctxlen || ctx (max 255)
713
+ * - HashML-DSA: 0x01 || ctxlen || ctx (max 255) || oid (11) || ph (max 64) */
714
+ #define MLD_DOMAIN_SEPARATION_MAX_BYTES (2 + 255 + 11 + 64)
715
+
716
+ /*************************************************
717
+ * Name: mld_prepare_domain_separation_prefix
718
+ *
719
+ * Description: Prepares domain separation prefix for ML-DSA signing.
720
+ * For pure ML-DSA (hashalg == MLD_PREHASH_NONE):
721
+ * Format: 0x00 || ctxlen (1 byte) || ctx
722
+ * For HashML-DSA (hashalg != MLD_PREHASH_NONE):
723
+ * Format: 0x01 || ctxlen (1 byte) || ctx || oid (11 bytes) || ph
724
+ *
725
+ * Arguments: - uint8_t prefix[MLD_DOMAIN_SEPARATION_MAX_BYTES]:
726
+ * output domain separation prefix buffer
727
+ * - const uint8_t *ph: pointer to pre-hashed message
728
+ * (ignored for pure ML-DSA)
729
+ * - size_t phlen: length of pre-hashed message
730
+ * (ignored for pure ML-DSA)
731
+ * - const uint8_t *ctx: pointer to context string (may be NULL)
732
+ * - size_t ctxlen: length of context string
733
+ * - int hashalg: hash algorithm constant
734
+ * (MLD_PREHASH_NONE for pure ML-DSA, or MLD_PREHASH_* for
735
+ * HashML-DSA)
736
+ *
737
+ * Returns the total length of the formatted prefix, or 0 on error.
738
+ *
739
+ * This function is useful for building incremental signing APIs.
740
+ *
741
+ * Specification:
742
+ * - For HashML-DSA (hashalg != MLD_PREHASH_NONE), implements
743
+ * @[FIPS204, Algorithm 4, L23]
744
+ * - For Pure ML-DSA (hashalg == MLD_PREHASH_NONE), implements
745
+ * ```
746
+ * M' <- BytesToBits(IntegerToBytes(0, 1)
747
+ * || IntegerToBytes(|ctx|, 1)
748
+ * || ctx
749
+ * ```
750
+ * which is part of @[FIPS204, Algorithm 2 (ML-DSA.Sign), L10] and
751
+ * @[FIPS204, Algorithm 3 (ML-DSA.Verify), L5].
752
+ *
753
+ **************************************************/
754
+ MLD_MUST_CHECK_RETURN_VALUE
755
+ MLD_EXTERNAL_API
756
+ size_t mld_prepare_domain_separation_prefix(
757
+ uint8_t prefix[MLD_DOMAIN_SEPARATION_MAX_BYTES], const uint8_t *ph,
758
+ size_t phlen, const uint8_t *ctx, size_t ctxlen, int hashalg)
759
+ __contract__(
760
+ requires(ctxlen <= 255)
761
+ requires(phlen <= MLD_MAX_BUFFER_SIZE)
762
+ requires(ctxlen == 0 || memory_no_alias(ctx, ctxlen))
763
+ requires(hashalg == MLD_PREHASH_NONE || memory_no_alias(ph, phlen))
764
+ requires(memory_no_alias(prefix, MLD_DOMAIN_SEPARATION_MAX_BYTES))
765
+ assigns(memory_slice(prefix, MLD_DOMAIN_SEPARATION_MAX_BYTES))
766
+ ensures(return_value <= MLD_DOMAIN_SEPARATION_MAX_BYTES)
767
+ );
768
+
769
+ /*************************************************
770
+ * Name: mld_sign_pk_from_sk
771
+ *
772
+ * Description: Performs basic validity checks on secret key, and derives
773
+ * public key.
774
+ *
775
+ * Referring to the decoding of the secret key
776
+ * `sk=(rho, K, tr, s1, s2, t0)`
777
+ * (cf. [@FIPS204, Algorithm 25 skDecode]),
778
+ * the following checks are performed:
779
+ * - Check that s1 and s2 have coefficients in
780
+ * [-MLDSA_ETA, MLDSA_ETA]
781
+ * - Check that t0 and tr stored in sk match recomputed values.
782
+ *
783
+ * Arguments: - uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES]: output public key
784
+ * - const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES]: input secret
785
+ * key
786
+ *
787
+ * Returns: - 0: Success
788
+ * - MLD_ERR_OUT_OF_MEMORY: If MLD_CONFIG_CUSTOM_ALLOC_FREE is
789
+ * used and an allocation via MLD_CUSTOM_ALLOC returned NULL.
790
+ * - MLD_ERR_FAIL: Secret key validation failed
791
+ *
792
+ * Note: This function leaks whether the secret key is valid or invalid
793
+ * through its return value and timing.
794
+ **************************************************/
795
+ MLD_MUST_CHECK_RETURN_VALUE
796
+ MLD_EXTERNAL_API
797
+ int mld_sign_pk_from_sk(uint8_t pk[MLDSA_CRYPTO_PUBLICKEYBYTES],
798
+ const uint8_t sk[MLDSA_CRYPTO_SECRETKEYBYTES],
799
+ MLD_CONFIG_CONTEXT_PARAMETER_TYPE context)
800
+ __contract__(
801
+ requires(memory_no_alias(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
802
+ requires(memory_no_alias(sk, MLDSA_CRYPTO_SECRETKEYBYTES))
803
+ assigns(memory_slice(pk, MLDSA_CRYPTO_PUBLICKEYBYTES))
804
+ ensures(return_value == 0 || return_value == MLD_ERR_FAIL || return_value == MLD_ERR_OUT_OF_MEMORY)
805
+ );
806
+ #endif /* !MLD_SIGN_H */