pq_crypto 0.6.3 → 0.6.5

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +149 -17
  3. data/CHANGELOG.md +73 -0
  4. data/GET_STARTED.md +1 -1
  5. data/README.md +7 -2
  6. data/ext/pqcrypto/extconf.rb +264 -24
  7. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  8. data/ext/pqcrypto/vendor/.vendored +4 -4
  9. data/ext/pqcrypto/vendor/mlkem-native/README.md +2 -4
  10. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +98 -0
  11. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +8 -7
  12. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +21 -1
  13. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +45 -44
  14. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +36 -0
  15. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +13 -30
  16. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
  17. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
  18. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +42 -0
  19. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
  20. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
  21. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
  22. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
  23. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
  24. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
  25. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +2 -1
  26. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +2 -1
  27. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +5 -0
  28. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +2 -1
  29. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +5 -19
  30. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  31. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  32. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  33. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  34. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
  35. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +6 -0
  36. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +11 -0
  37. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +25 -1
  38. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
  39. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
  40. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
  41. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
  42. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
  43. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_aarch64_asm.S → mlkem_poly_mulcache_compute_aarch64_asm.S} +6 -3
  44. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
  45. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
  46. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
  47. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +6 -3
  48. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +6 -3
  49. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +6 -3
  50. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
  51. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
  52. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
  53. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
  54. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
  55. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
  56. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
  57. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
  58. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
  59. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
  60. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
  61. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +25 -5
  62. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
  63. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
  64. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
  65. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
  66. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
  67. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
  68. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
  69. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
  70. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10_avx2_asm.S → mlkem_poly_compress_d10_avx2_asm.S} +34 -3
  71. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11_avx2_asm.S → mlkem_poly_compress_d11_avx2_asm.S} +33 -2
  72. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4_avx2_asm.S → mlkem_poly_compress_d4_avx2_asm.S} +34 -3
  73. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5_avx2_asm.S → mlkem_poly_compress_d5_avx2_asm.S} +33 -2
  74. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10_avx2_asm.S → mlkem_poly_decompress_d10_avx2_asm.S} +32 -3
  75. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11_avx2_asm.S → mlkem_poly_decompress_d11_avx2_asm.S} +32 -2
  76. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4_avx2_asm.S → mlkem_poly_decompress_d4_avx2_asm.S} +32 -3
  77. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5_avx2_asm.S → mlkem_poly_decompress_d5_avx2_asm.S} +32 -2
  78. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_mulcache_compute_avx2_asm.S → mlkem_poly_mulcache_compute_avx2_asm.S} +29 -1
  79. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +35 -1
  80. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +35 -1
  81. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +35 -1
  82. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
  83. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_avx2_asm.S → mlkem_rej_uniform_avx2_asm.S} +40 -7
  84. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
  85. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
  86. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
  87. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
  88. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
  89. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
  90. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
  91. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +19 -1
  92. data/lib/pq_crypto/version.rb +1 -1
  93. data/script/vendor_libs.rb +3 -3
  94. metadata +41 -43
@@ -78,8 +78,8 @@ static MLK_INLINE vint16m1_t fq_barrett(vint16m1_t a, size_t vl)
78
78
  * masked ops, and Zvkt's DIEL guarantee does not cover the v0 mask
79
79
  * register. Using an arithmetic-shift sign mask keeps all operands in the
80
80
  * Zvkt-covered set and matches the idiom used in the portable C
81
- * (mlk_ct_cmask_neg_i16, verify.h) and AArch64 (poly_reduce_aarch64_asm.S)
82
- * implementations. */
81
+ * (mlk_ct_cmask_neg_i16, verify.h) and AArch64
82
+ * (mlkem_poly_reduce_aarch64_asm.S) implementations. */
83
83
 
84
84
  static MLK_INLINE vint16m1_t fq_cadd(vint16m1_t rx, size_t vl)
85
85
  {
@@ -324,6 +324,7 @@ void mlk_rv64v_poly_ntt(int16_t *r)
324
324
  &r[0xe0], mlk_rv64v_ntt2(__riscv_vcreate_v_i16m1_i16m2(ve, vf), ze), vl2);
325
325
  }
326
326
 
327
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
327
328
  /* Reverse / Gentleman-Sande butterfly operation */
328
329
 
329
330
  #define MLK_RVV_GS_BFLY_RX(u0, u1, ut, uc, vl) \
@@ -604,6 +605,7 @@ void mlk_rv64v_poly_invntt_tomont(int16_t *r)
604
605
  __riscv_vse16_v_i16m1(&r[0xe0], ve, vl);
605
606
  __riscv_vse16_v_i16m1(&r[0xf0], vf, vl);
606
607
  }
608
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
607
609
 
608
610
  /* ML-KEM's middle field GF(3329)[X]/(X^2) multiplication */
609
611
 
@@ -682,6 +684,7 @@ void mlk_rv64v_poly_basemul_mont_add_k4(int16_t *r, const int16_t *a,
682
684
  }
683
685
  #endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
684
686
 
687
+ #if !defined(MLK_CONFIG_NO_KEYPAIR_API)
685
688
  /**
686
689
  * In-place conversion of all coefficients of a polynomial from the normal
687
690
  * domain to the Montgomery domain.
@@ -700,6 +703,7 @@ void mlk_rv64v_poly_tomont(int16_t *r)
700
703
  __riscv_vse16_v_i16m1(&r[i], vec, vl);
701
704
  }
702
705
  }
706
+ #endif /* !MLK_CONFIG_NO_KEYPAIR_API */
703
707
 
704
708
  /**
705
709
  * Apply Barrett reduction to all coefficients of a polynomial. For details
@@ -68,6 +68,7 @@ static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
68
68
  return MLK_NATIVE_FUNC_SUCCESS;
69
69
  }
70
70
 
71
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
71
72
  MLK_MUST_CHECK_RETURN_VALUE
72
73
  static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
73
74
  {
@@ -79,6 +80,7 @@ static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
79
80
  mlk_invntt_avx2_asm(data, mlk_qdata);
80
81
  return MLK_NATIVE_FUNC_SUCCESS;
81
82
  }
83
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
82
84
 
83
85
  MLK_MUST_CHECK_RETURN_VALUE
84
86
  static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
@@ -92,6 +94,7 @@ static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
92
94
  return MLK_NATIVE_FUNC_SUCCESS;
93
95
  }
94
96
 
97
+ #if !defined(MLK_CONFIG_NO_KEYPAIR_API)
95
98
  MLK_MUST_CHECK_RETURN_VALUE
96
99
  static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
97
100
  {
@@ -103,6 +106,7 @@ static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
103
106
  mlk_tomont_avx2_asm(data);
104
107
  return MLK_NATIVE_FUNC_SUCCESS;
105
108
  }
109
+ #endif /* !MLK_CONFIG_NO_KEYPAIR_API */
106
110
 
107
111
  MLK_MUST_CHECK_RETURN_VALUE
108
112
  static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
@@ -165,6 +169,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
165
169
  }
166
170
  #endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
167
171
 
172
+ #if !defined(MLK_CONFIG_NO_KEYPAIR_API) || !defined(MLK_CONFIG_NO_ENCAPS_API)
168
173
  MLK_MUST_CHECK_RETURN_VALUE
169
174
  static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
170
175
  const int16_t a[MLKEM_N])
@@ -177,7 +182,9 @@ static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
177
182
  mlk_ntttobytes_avx2_asm(r, a);
178
183
  return MLK_NATIVE_FUNC_SUCCESS;
179
184
  }
185
+ #endif /* !MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API */
180
186
 
187
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
181
188
  MLK_MUST_CHECK_RETURN_VALUE
182
189
  static MLK_INLINE int mlk_poly_frombytes_native(
183
190
  int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYBYTES])
@@ -190,8 +197,12 @@ static MLK_INLINE int mlk_poly_frombytes_native(
190
197
  mlk_nttfrombytes_avx2_asm(r, a);
191
198
  return MLK_NATIVE_FUNC_SUCCESS;
192
199
  }
200
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
193
201
 
194
- #if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || (MLKEM_K == 2 || MLKEM_K == 3)
202
+ #if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
203
+ !defined(MLK_CONFIG_NO_DECAPS_API)) && \
204
+ (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || \
205
+ MLKEM_K == 3)
195
206
  MLK_MUST_CHECK_RETURN_VALUE
196
207
  static MLK_INLINE int mlk_poly_compress_d4_native(
197
208
  uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4], const int16_t a[MLKEM_N])
@@ -218,6 +229,7 @@ static MLK_INLINE int mlk_poly_compress_d10_native(
218
229
  return MLK_NATIVE_FUNC_SUCCESS;
219
230
  }
220
231
 
232
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
221
233
  MLK_MUST_CHECK_RETURN_VALUE
222
234
  static MLK_INLINE int mlk_poly_decompress_d4_native(
223
235
  int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4])
@@ -243,9 +255,14 @@ static MLK_INLINE int mlk_poly_decompress_d10_native(
243
255
  mlk_poly_decompress_d10_avx2_asm(r, a, mlk_decompress_d10_data);
244
256
  return MLK_NATIVE_FUNC_SUCCESS;
245
257
  }
246
- #endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3 */
247
-
248
- #if defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4
258
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
259
+ #endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
260
+ (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3) \
261
+ */
262
+
263
+ #if (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
264
+ !defined(MLK_CONFIG_NO_DECAPS_API)) && \
265
+ (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
249
266
  MLK_MUST_CHECK_RETURN_VALUE
250
267
  static MLK_INLINE int mlk_poly_compress_d5_native(
251
268
  uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5], const int16_t a[MLKEM_N])
@@ -272,6 +289,7 @@ static MLK_INLINE int mlk_poly_compress_d11_native(
272
289
  return MLK_NATIVE_FUNC_SUCCESS;
273
290
  }
274
291
 
292
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
275
293
  MLK_MUST_CHECK_RETURN_VALUE
276
294
  static MLK_INLINE int mlk_poly_decompress_d5_native(
277
295
  int16_t r[MLKEM_N], const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5])
@@ -297,7 +315,9 @@ static MLK_INLINE int mlk_poly_decompress_d11_native(
297
315
  mlk_poly_decompress_d11_avx2_asm(r, a, mlk_decompress_d11_data);
298
316
  return MLK_NATIVE_FUNC_SUCCESS;
299
317
  }
300
- #endif /* MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4 */
318
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
319
+ #endif /* (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
320
+ (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
301
321
 
302
322
  #endif /* !__ASSEMBLER__ */
303
323
 
@@ -22,7 +22,7 @@ MLK_MUST_CHECK_RETURN_VALUE MLK_SYSV_ABI
22
22
  uint64_t mlk_rej_uniform_avx2_asm(int16_t *r, const uint8_t *buf,
23
23
  unsigned buflen, const uint8_t *table)
24
24
  /* This must be kept in sync with the HOL-Light specification
25
- * in proofs/hol_light/x86_64/proofs/rej_uniform_avx2_asm.ml. */
25
+ * in proofs/hol_light/x86_64/proofs/mlkem_rej_uniform_avx2_asm.ml. */
26
26
  __contract__(
27
27
  requires(buflen % 12 == 0)
28
28
  requires(memory_no_alias(buf, buflen))
@@ -37,7 +37,7 @@ __contract__(
37
37
  MLK_SYSV_ABI
38
38
  void mlk_ntt_avx2_asm(int16_t *r, const int16_t *qdata)
39
39
  /* This must be kept in sync with the HOL-Light specification
40
- * in proofs/hol_light/x86_64/proofs/ntt_avx2_asm.ml */
40
+ * in proofs/hol_light/x86_64/proofs/mlkem_ntt_avx2_asm.ml */
41
41
  __contract__(
42
42
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
43
43
  requires(array_abs_bound(r, 0, MLKEM_N, 8192))
@@ -52,7 +52,7 @@ __contract__(
52
52
  MLK_SYSV_ABI
53
53
  void mlk_invntt_avx2_asm(int16_t *r, const int16_t *qdata)
54
54
  /* This must be kept in sync with the HOL-Light specification
55
- * in proofs/hol_light/x86_64/proofs/intt_avx2_asm.ml */
55
+ * in proofs/hol_light/x86_64/proofs/mlkem_intt_avx2_asm.ml */
56
56
  __contract__(
57
57
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
58
58
  requires(qdata == mlk_qdata)
@@ -66,7 +66,7 @@ __contract__(
66
66
  MLK_SYSV_ABI
67
67
  void mlk_nttunpack_avx2_asm(int16_t *r)
68
68
  /* This must be kept in sync with the HOL-Light specification
69
- * in proofs/hol_light/x86_64/proofs/nttunpack_avx2_asm.ml */
69
+ * in proofs/hol_light/x86_64/proofs/mlkem_nttunpack_avx2_asm.ml */
70
70
  __contract__(
71
71
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
72
72
  requires(array_bound(r, 0, MLKEM_N, 0, MLKEM_Q))
@@ -81,7 +81,7 @@ __contract__(
81
81
  MLK_SYSV_ABI
82
82
  void mlk_reduce_avx2_asm(int16_t *r)
83
83
  /* This must be kept in sync with the HOL-Light specification
84
- * in proofs/hol_light/x86_64/proofs/reduce_avx2_asm.ml */
84
+ * in proofs/hol_light/x86_64/proofs/mlkem_reduce_avx2_asm.ml */
85
85
  __contract__(
86
86
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
87
87
  assigns(memory_slice(r, sizeof(int16_t) * MLKEM_N))
@@ -94,7 +94,7 @@ MLK_SYSV_ABI
94
94
  void mlk_poly_mulcache_compute_avx2_asm(int16_t *out, const int16_t *in,
95
95
  const int16_t *qdata)
96
96
  /* This must be kept in sync with the HOL-Light specification
97
- * in proofs/hol_light/x86_64/proofs/poly_mulcache_compute_avx2_asm.ml */
97
+ * in proofs/hol_light/x86_64/proofs/mlkem_poly_mulcache_compute_avx2_asm.ml */
98
98
  __contract__(
99
99
  requires(memory_no_alias(out, sizeof(int16_t) * (MLKEM_N / 2)))
100
100
  requires(memory_no_alias(in, sizeof(int16_t) * MLKEM_N))
@@ -109,7 +109,7 @@ MLK_SYSV_ABI
109
109
  void mlk_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm(
110
110
  int16_t *r, const int16_t *a, const int16_t *b, const int16_t *b_cache)
111
111
  /* This must be kept in sync with the HOL-Light specification in
112
- * proofs/hol_light/x86_64/proofs/polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.ml.
112
+ * proofs/hol_light/x86_64/proofs/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.ml.
113
113
  */
114
114
  __contract__(
115
115
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -126,7 +126,7 @@ MLK_SYSV_ABI
126
126
  void mlk_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm(
127
127
  int16_t *r, const int16_t *a, const int16_t *b, const int16_t *b_cache)
128
128
  /* This must be kept in sync with the HOL-Light specification in
129
- * proofs/hol_light/x86_64/proofs/polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.ml.
129
+ * proofs/hol_light/x86_64/proofs/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.ml.
130
130
  */
131
131
  __contract__(
132
132
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -143,7 +143,7 @@ MLK_SYSV_ABI
143
143
  void mlk_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm(
144
144
  int16_t *r, const int16_t *a, const int16_t *b, const int16_t *b_cache)
145
145
  /* This must be kept in sync with the HOL-Light specification in
146
- * proofs/hol_light/x86_64/proofs/polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.ml.
146
+ * proofs/hol_light/x86_64/proofs/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.ml.
147
147
  */
148
148
  __contract__(
149
149
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -158,7 +158,7 @@ __contract__(
158
158
  MLK_SYSV_ABI
159
159
  void mlk_ntttobytes_avx2_asm(uint8_t *r, const int16_t *a)
160
160
  /* This must be kept in sync with the HOL-Light specification in
161
- * proofs/hol_light/x86_64/proofs/ntttobytes_avx2_asm.ml.
161
+ * proofs/hol_light/x86_64/proofs/mlkem_ntttobytes_avx2_asm.ml.
162
162
  */
163
163
  __contract__(
164
164
  requires(memory_no_alias(r, MLKEM_POLYBYTES))
@@ -171,7 +171,7 @@ __contract__(
171
171
  MLK_SYSV_ABI
172
172
  void mlk_nttfrombytes_avx2_asm(int16_t *r, const uint8_t *a)
173
173
  /* This must be kept in sync with the HOL-Light specification in
174
- * proofs/hol_light/x86_64/proofs/nttfrombytes_avx2_asm.ml.
174
+ * proofs/hol_light/x86_64/proofs/mlkem_nttfrombytes_avx2_asm.ml.
175
175
  */
176
176
  __contract__(
177
177
  requires(memory_no_alias(a, MLKEM_POLYBYTES))
@@ -184,7 +184,7 @@ __contract__(
184
184
  MLK_SYSV_ABI
185
185
  void mlk_tomont_avx2_asm(int16_t *r)
186
186
  /* This must be kept in sync with the HOL-Light specification in
187
- * proofs/hol_light/x86_64/proofs/tomont_avx2_asm.ml.
187
+ * proofs/hol_light/x86_64/proofs/mlkem_tomont_avx2_asm.ml.
188
188
  */
189
189
  __contract__(
190
190
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -198,7 +198,7 @@ void mlk_poly_compress_d4_avx2_asm(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D4],
198
198
  const int16_t *MLK_RESTRICT a,
199
199
  const uint8_t *data)
200
200
  /* This must be kept in sync with the HOL-Light specification in
201
- * proofs/hol_light/x86_64/proofs/poly_compress_d4_avx2_asm.ml.
201
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d4_avx2_asm.ml.
202
202
  */
203
203
  __contract__(
204
204
  requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D4))
@@ -215,7 +215,7 @@ void mlk_poly_decompress_d4_avx2_asm(
215
215
  int16_t *MLK_RESTRICT r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D4],
216
216
  const uint8_t *data)
217
217
  /* This must be kept in sync with the HOL-Light specification in
218
- * proofs/hol_light/x86_64/proofs/poly_decompress_d4_avx2_asm.ml.
218
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d4_avx2_asm.ml.
219
219
  */
220
220
  __contract__(
221
221
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -231,7 +231,7 @@ void mlk_poly_compress_d10_avx2_asm(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D10],
231
231
  const int16_t *MLK_RESTRICT a,
232
232
  const uint8_t *data)
233
233
  /* This must be kept in sync with the HOL-Light specification in
234
- * proofs/hol_light/x86_64/proofs/poly_compress_d10_avx2_asm.ml.
234
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d10_avx2_asm.ml.
235
235
  */
236
236
  __contract__(
237
237
  requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D10))
@@ -248,7 +248,7 @@ void mlk_poly_decompress_d10_avx2_asm(
248
248
  int16_t *MLK_RESTRICT r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D10],
249
249
  const uint8_t *data)
250
250
  /* This must be kept in sync with the HOL-Light specification in
251
- * proofs/hol_light/x86_64/proofs/poly_decompress_d10_avx2_asm.ml.
251
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d10_avx2_asm.ml.
252
252
  */
253
253
  __contract__(
254
254
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -264,7 +264,7 @@ void mlk_poly_compress_d5_avx2_asm(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D5],
264
264
  const int16_t *MLK_RESTRICT a,
265
265
  const uint8_t *data)
266
266
  /* This must be kept in sync with the HOL-Light specification in
267
- * proofs/hol_light/x86_64/proofs/poly_compress_d5_avx2_asm.ml.
267
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d5_avx2_asm.ml.
268
268
  */
269
269
  __contract__(
270
270
  requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D5))
@@ -281,7 +281,7 @@ void mlk_poly_decompress_d5_avx2_asm(
281
281
  int16_t *MLK_RESTRICT r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D5],
282
282
  const uint8_t *data)
283
283
  /* This must be kept in sync with the HOL-Light specification in
284
- * proofs/hol_light/x86_64/proofs/poly_decompress_d5_avx2_asm.ml.
284
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d5_avx2_asm.ml.
285
285
  */
286
286
  __contract__(
287
287
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -297,7 +297,7 @@ void mlk_poly_compress_d11_avx2_asm(uint8_t r[MLKEM_POLYCOMPRESSEDBYTES_D11],
297
297
  const int16_t *MLK_RESTRICT a,
298
298
  const uint8_t *data)
299
299
  /* This must be kept in sync with the HOL-Light specification in
300
- * proofs/hol_light/x86_64/proofs/poly_compress_d11_avx2_asm.ml.
300
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_compress_d11_avx2_asm.ml.
301
301
  */
302
302
  __contract__(
303
303
  requires(memory_no_alias(r, MLKEM_POLYCOMPRESSEDBYTES_D11))
@@ -314,7 +314,7 @@ void mlk_poly_decompress_d11_avx2_asm(
314
314
  int16_t *MLK_RESTRICT r, const uint8_t a[MLKEM_POLYCOMPRESSEDBYTES_D11],
315
315
  const uint8_t *data)
316
316
  /* This must be kept in sync with the HOL-Light specification in
317
- * proofs/hol_light/x86_64/proofs/poly_decompress_d11_avx2_asm.ml.
317
+ * proofs/hol_light/x86_64/proofs/mlkem_poly_decompress_d11_avx2_asm.ml.
318
318
  */
319
319
  __contract__(
320
320
  requires(memory_no_alias(r, sizeof(int16_t) * MLKEM_N))
@@ -11,7 +11,8 @@
11
11
 
12
12
  #include "../../../common.h"
13
13
 
14
- #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT)
14
+ #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
15
+ (!defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API))
15
16
 
16
17
  #include "compress_consts.h"
17
18
 
@@ -25,11 +26,13 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
25
26
  2, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0, /* permdidx */
26
27
  };
27
28
 
29
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
28
30
  MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
29
31
  mlk_decompress_d4_data[32] = {
30
32
  0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
31
33
  4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, /* shufbidx */
32
34
  };
35
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
33
36
 
34
37
  MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
35
38
  mlk_compress_d10_data[32] = {
@@ -38,11 +41,13 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
38
41
  255, 255, 255, 255, 0, 1, 2, 3, 4, 8, /* shufbidx */
39
42
  };
40
43
 
44
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
41
45
  MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
42
46
  mlk_decompress_d10_data[32] = {
43
47
  0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9,
44
48
  2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, /* shufbidx */
45
49
  };
50
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
46
51
 
47
52
  #endif /* !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
48
53
  (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == 3) \
@@ -58,6 +63,7 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
58
63
  1, 2, 3, 4, 255, 255, 255, 255, 255, 8, /* shufbidx */
59
64
  };
60
65
 
66
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
61
67
  /* shufbidx[0:32], mask[32:64], shift[64:96] */
62
68
  MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
63
69
  mlk_decompress_d5_data[96] = {
@@ -68,6 +74,7 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
68
74
  0, 4, 32, 0, 0, 1, 8, 0, 64, 0, 0, 2, 16, 0, 128, 0, 0, 4,
69
75
  32, 0, 0, 1, 8, 0, 64, 0, 0, 2, 16, 0, 128, 0, /* shift */
70
76
  };
77
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
71
78
 
72
79
  /* srlvqidx[0:32], shufbidx[32:64] */
73
80
  MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
@@ -81,6 +88,7 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
81
88
  255, 255, 255, 255, 0, 0, 1, 2, 3, 4, /* shufbidx */
82
89
  };
83
90
 
91
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
84
92
  /* shufbidx[0:32], srlvdidx[32:64], srlvqidx[64:96], shift[96:128] */
85
93
  MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
86
94
  mlk_decompress_d11_data[128] = {
@@ -93,12 +101,15 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const uint8_t
93
101
  32, 0, 4, 0, 1, 0, 32, 0, 8, 0, 1, 0, 32, 0, 4, 0,
94
102
  32, 0, 4, 0, 1, 0, 32, 0, 8, 0, 1, 0, 32, 0, 4, 0, /* shift */
95
103
  };
104
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
96
105
 
97
106
  #endif /* !MLK_CONFIG_MULTILEVEL_NO_SHARED && \
98
107
  (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
99
108
 
100
- #else /* MLK_ARITH_BACKEND_X86_64_DEFAULT */
109
+ #else /* MLK_ARITH_BACKEND_X86_64_DEFAULT && (!MLK_CONFIG_NO_ENCAPS_API || \
110
+ !MLK_CONFIG_NO_DECAPS_API) */
101
111
 
102
112
  MLK_EMPTY_CU(avx2_compress_consts)
103
113
 
104
- #endif /* !MLK_ARITH_BACKEND_X86_64_DEFAULT */
114
+ #endif /* !(MLK_ARITH_BACKEND_X86_64_DEFAULT && (!MLK_CONFIG_NO_ENCAPS_API || \
115
+ !MLK_CONFIG_NO_DECAPS_API)) */
@@ -19,26 +19,34 @@
19
19
  #define mlk_compress_d4_data MLK_NAMESPACE(compress_d4_data)
20
20
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_compress_d4_data[32];
21
21
 
22
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
22
23
  #define mlk_decompress_d4_data MLK_NAMESPACE(decompress_d4_data)
23
24
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_decompress_d4_data[32];
25
+ #endif
24
26
 
25
27
  #define mlk_compress_d10_data MLK_NAMESPACE(compress_d10_data)
26
28
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_compress_d10_data[32];
27
29
 
30
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
28
31
  #define mlk_decompress_d10_data MLK_NAMESPACE(decompress_d10_data)
29
32
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_decompress_d10_data[32];
33
+ #endif
30
34
 
31
35
  #define mlk_compress_d5_data MLK_NAMESPACE(compress_d5_data)
32
36
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_compress_d5_data[32];
33
37
 
38
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
34
39
  #define mlk_decompress_d5_data MLK_NAMESPACE(decompress_d5_data)
35
40
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_decompress_d5_data[96];
41
+ #endif
36
42
 
37
43
  #define mlk_compress_d11_data MLK_NAMESPACE(compress_d11_data)
38
44
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_compress_d11_data[64];
39
45
 
46
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
40
47
  #define mlk_decompress_d11_data MLK_NAMESPACE(decompress_d11_data)
41
48
  MLK_INTERNAL_DATA_DECLARATION const uint8_t mlk_decompress_d11_data[128];
49
+ #endif
42
50
 
43
51
  #endif /* !__ASSEMBLER__ */
44
52
 
@@ -30,11 +30,35 @@
30
30
 
31
31
  #include "../../../common.h"
32
32
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
33
- !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
33
+ !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
34
+ (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
35
+ !defined(MLK_CONFIG_NO_DECAPS_API))
36
+ /*yaml
37
+ Name: invntt_avx2_asm
38
+ Description: x86_64 AVX2 inverse NTT
39
+ Signature: void mlk_invntt_avx2_asm(int16_t *r, const int16_t *qdata)
40
+ ABI:
41
+ Architecture: x86_64
42
+ CallingConvention: SysV
43
+ Features: [AVX2]
44
+ rdi:
45
+ type: buffer
46
+ size_bytes: 512
47
+ permissions: read/write
48
+ c_parameter: int16_t *r
49
+ description: Input/output polynomial (256 x int16_t)
50
+ rsi:
51
+ type: buffer
52
+ size_bytes: 1248
53
+ permissions: read-only
54
+ c_parameter: const int16_t *qdata
55
+ description: Precomputed constants (624 x int16_t)
56
+ */
57
+
34
58
 
35
59
  /*
36
60
  * WARNING: This file is auto-derived from the mlkem-native source file
37
- * dev/x86_64/src/intt_avx2_asm.S using scripts/simpasm. Do not modify it directly.
61
+ * dev/x86_64/src/mlkem_intt_avx2_asm.S using scripts/simpasm. Do not modify it directly.
38
62
  */
39
63
 
40
64
  .text
@@ -712,7 +736,7 @@ MLK_ASM_FN_SYMBOL(invntt_avx2_asm)
712
736
  MLK_ASM_FN_SIZE(invntt_avx2_asm)
713
737
 
714
738
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
715
- */
739
+ && (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) */
716
740
 
717
741
  #if defined(__ELF__)
718
742
  .section .note.GNU-stack,"",%progbits
@@ -27,10 +27,32 @@
27
27
  #include "../../../common.h"
28
28
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
29
29
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
30
+ /*yaml
31
+ Name: ntt_avx2_asm
32
+ Description: x86_64 AVX2 forward NTT
33
+ Signature: void mlk_ntt_avx2_asm(int16_t *r, const int16_t *qdata)
34
+ ABI:
35
+ Architecture: x86_64
36
+ CallingConvention: SysV
37
+ Features: [AVX2]
38
+ rdi:
39
+ type: buffer
40
+ size_bytes: 512
41
+ permissions: read/write
42
+ c_parameter: int16_t *r
43
+ description: Input/output polynomial (256 x int16_t)
44
+ rsi:
45
+ type: buffer
46
+ size_bytes: 1248
47
+ permissions: read-only
48
+ c_parameter: const int16_t *qdata
49
+ description: Precomputed constants (624 x int16_t)
50
+ */
51
+
30
52
 
31
53
  /*
32
54
  * WARNING: This file is auto-derived from the mlkem-native source file
33
- * dev/x86_64/src/ntt_avx2_asm.S using scripts/simpasm. Do not modify it directly.
55
+ * dev/x86_64/src/mlkem_ntt_avx2_asm.S using scripts/simpasm. Do not modify it directly.
34
56
  */
35
57
 
36
58
  .text
@@ -20,11 +20,35 @@
20
20
  #include "../../../common.h"
21
21
 
22
22
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
23
- !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
23
+ !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
25
+ !defined(MLK_CONFIG_NO_DECAPS_API))
26
+ /*yaml
27
+ Name: nttfrombytes_avx2_asm
28
+ Description: x86_64 AVX2 polynomial deserialization in NTT domain
29
+ Signature: void mlk_nttfrombytes_avx2_asm(int16_t *r, const uint8_t *a)
30
+ ABI:
31
+ Architecture: x86_64
32
+ CallingConvention: SysV
33
+ Features: [AVX2]
34
+ rdi:
35
+ type: buffer
36
+ size_bytes: 512
37
+ permissions: write-only
38
+ c_parameter: int16_t *r
39
+ description: Output polynomial (256 x int16_t)
40
+ rsi:
41
+ type: buffer
42
+ size_bytes: 384
43
+ permissions: read-only
44
+ c_parameter: const uint8_t *a
45
+ description: Input byte array (MLKEM_POLYBYTES = 384)
46
+ */
47
+
24
48
 
25
49
  /*
26
50
  * WARNING: This file is auto-derived from the mlkem-native source file
27
- * dev/x86_64/src/nttfrombytes_avx2_asm.S using scripts/simpasm. Do not modify it directly.
51
+ * dev/x86_64/src/mlkem_nttfrombytes_avx2_asm.S using scripts/simpasm. Do not modify it directly.
28
52
  */
29
53
 
30
54
  .text
@@ -186,7 +210,7 @@ MLK_ASM_FN_SYMBOL(nttfrombytes_avx2_asm)
186
210
  MLK_ASM_FN_SIZE(nttfrombytes_avx2_asm)
187
211
 
188
212
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
189
- */
213
+ && (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) */
190
214
 
191
215
  #if defined(__ELF__)
192
216
  .section .note.GNU-stack,"",%progbits
@@ -20,11 +20,35 @@
20
20
  #include "../../../common.h"
21
21
 
22
22
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
23
- !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
23
+ !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
24
+ (!defined(MLK_CONFIG_NO_KEYPAIR_API) || \
25
+ !defined(MLK_CONFIG_NO_ENCAPS_API))
26
+ /*yaml
27
+ Name: ntttobytes_avx2_asm
28
+ Description: x86_64 AVX2 polynomial serialization in NTT domain
29
+ Signature: void mlk_ntttobytes_avx2_asm(uint8_t *r, const int16_t *a)
30
+ ABI:
31
+ Architecture: x86_64
32
+ CallingConvention: SysV
33
+ Features: [AVX2]
34
+ rdi:
35
+ type: buffer
36
+ size_bytes: 384
37
+ permissions: write-only
38
+ c_parameter: uint8_t *r
39
+ description: Output byte array (MLKEM_POLYBYTES = 384)
40
+ rsi:
41
+ type: buffer
42
+ size_bytes: 512
43
+ permissions: read-only
44
+ c_parameter: const int16_t *a
45
+ description: Input polynomial (256 x int16_t)
46
+ */
47
+
24
48
 
25
49
  /*
26
50
  * WARNING: This file is auto-derived from the mlkem-native source file
27
- * dev/x86_64/src/ntttobytes_avx2_asm.S using scripts/simpasm. Do not modify it directly.
51
+ * dev/x86_64/src/mlkem_ntttobytes_avx2_asm.S using scripts/simpasm. Do not modify it directly.
28
52
  */
29
53
 
30
54
  .text
@@ -174,7 +198,7 @@ MLK_ASM_FN_SYMBOL(ntttobytes_avx2_asm)
174
198
  MLK_ASM_FN_SIZE(ntttobytes_avx2_asm)
175
199
 
176
200
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
177
- */
201
+ && (!MLK_CONFIG_NO_KEYPAIR_API || !MLK_CONFIG_NO_ENCAPS_API) */
178
202
 
179
203
  #if defined(__ELF__)
180
204
  .section .note.GNU-stack,"",%progbits
@@ -21,10 +21,26 @@
21
21
 
22
22
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
23
23
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
24
+ /*yaml
25
+ Name: nttunpack_avx2_asm
26
+ Description: x86_64 AVX2 NTT unpack from custom to bitreversed order
27
+ Signature: void mlk_nttunpack_avx2_asm(int16_t *r)
28
+ ABI:
29
+ Architecture: x86_64
30
+ CallingConvention: SysV
31
+ Features: [AVX2]
32
+ rdi:
33
+ type: buffer
34
+ size_bytes: 512
35
+ permissions: read/write
36
+ c_parameter: int16_t *r
37
+ description: Input/output polynomial (256 x int16_t)
38
+ */
39
+
24
40
 
25
41
  /*
26
42
  * WARNING: This file is auto-derived from the mlkem-native source file
27
- * dev/x86_64/src/nttunpack_avx2_asm.S using scripts/simpasm. Do not modify it directly.
43
+ * dev/x86_64/src/mlkem_nttunpack_avx2_asm.S using scripts/simpasm. Do not modify it directly.
28
44
  */
29
45
 
30
46
  .text