pq_crypto 0.6.4 → 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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/README.md +5 -0
  4. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  5. data/ext/pqcrypto/vendor/.vendored +4 -4
  6. data/ext/pqcrypto/vendor/mlkem-native/README.md +2 -4
  7. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +98 -0
  8. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +8 -7
  9. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +21 -1
  10. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +45 -44
  11. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +36 -0
  12. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +13 -30
  13. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
  14. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
  15. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +42 -0
  16. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
  17. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
  18. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
  19. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
  20. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
  21. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
  22. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +2 -1
  23. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +2 -1
  24. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +5 -0
  25. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +2 -1
  26. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +5 -19
  27. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  28. 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
  29. 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
  30. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  31. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
  32. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +6 -0
  33. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +11 -0
  34. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +25 -1
  35. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
  36. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
  37. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
  38. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
  39. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
  40. 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
  41. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
  42. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
  43. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
  44. 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
  45. 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
  46. 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
  47. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
  48. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
  49. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
  50. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
  51. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
  52. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
  53. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
  54. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
  55. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
  56. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
  57. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
  58. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +25 -5
  59. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
  60. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
  61. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
  62. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
  63. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
  64. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
  65. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
  66. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
  67. 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
  68. 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
  69. 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
  70. 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
  71. 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
  72. 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
  73. 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
  74. 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
  75. 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
  76. 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
  77. 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
  78. 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
  79. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
  80. 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
  81. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
  82. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
  83. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
  84. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
  85. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
  86. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
  87. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
  88. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +19 -1
  89. data/lib/pq_crypto/version.rb +1 -1
  90. data/script/vendor_libs.rb +3 -3
  91. metadata +40 -42
@@ -31,11 +31,41 @@
31
31
  #include "../../../common.h"
32
32
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
33
33
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
34
+ (!defined(MLK_CONFIG_NO_ENCAPS_API) || \
35
+ !defined(MLK_CONFIG_NO_DECAPS_API)) && \
34
36
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
37
+ /*yaml
38
+ Name: poly_compress_d5_avx2_asm
39
+ Description: x86_64 AVX2 polynomial compression (d=5)
40
+ Signature: void mlk_poly_compress_d5_avx2_asm(uint8_t *r, const int16_t *a, const uint8_t *data)
41
+ ABI:
42
+ Architecture: x86_64
43
+ CallingConvention: SysV
44
+ Features: [AVX2]
45
+ rdi:
46
+ type: buffer
47
+ size_bytes: 160
48
+ permissions: write-only
49
+ c_parameter: uint8_t *r
50
+ description: Output compressed polynomial
51
+ rsi:
52
+ type: buffer
53
+ size_bytes: 512
54
+ permissions: read-only
55
+ c_parameter: const int16_t *a
56
+ description: Input polynomial (256 x int16_t)
57
+ rdx:
58
+ type: buffer
59
+ size_bytes: 32
60
+ permissions: read-only
61
+ c_parameter: const uint8_t *data
62
+ description: Precomputed compression constants
63
+ */
64
+
35
65
 
36
66
  /*
37
67
  * WARNING: This file is auto-derived from the mlkem-native source file
38
- * dev/x86_64/src/poly_compress_d5_avx2_asm.S using scripts/simpasm. Do not modify it directly.
68
+ * dev/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S using scripts/simpasm. Do not modify it directly.
39
69
  */
40
70
 
41
71
  .text
@@ -213,7 +243,8 @@ MLK_ASM_FN_SYMBOL(poly_compress_d5_avx2_asm)
213
243
  MLK_ASM_FN_SIZE(poly_compress_d5_avx2_asm)
214
244
 
215
245
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
216
- && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
246
+ && (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) && \
247
+ (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
217
248
 
218
249
  #if defined(__ELF__)
219
250
  .section .note.GNU-stack,"",%progbits
@@ -31,11 +31,40 @@
31
31
  #include "../../../common.h"
32
32
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
33
33
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
34
+ !defined(MLK_CONFIG_NO_DECAPS_API) && \
34
35
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || MLKEM_K == 3)
36
+ /*yaml
37
+ Name: poly_decompress_d10_avx2_asm
38
+ Description: x86_64 AVX2 polynomial decompression (d=10)
39
+ Signature: void mlk_poly_decompress_d10_avx2_asm(int16_t *r, const uint8_t *a, const uint8_t *data)
40
+ ABI:
41
+ Architecture: x86_64
42
+ CallingConvention: SysV
43
+ Features: [AVX2]
44
+ rdi:
45
+ type: buffer
46
+ size_bytes: 512
47
+ permissions: write-only
48
+ c_parameter: int16_t *r
49
+ description: Output polynomial (256 x int16_t)
50
+ rsi:
51
+ type: buffer
52
+ size_bytes: 320
53
+ permissions: read-only
54
+ c_parameter: const uint8_t *a
55
+ description: Input compressed polynomial
56
+ rdx:
57
+ type: buffer
58
+ size_bytes: 32
59
+ permissions: read-only
60
+ c_parameter: const uint8_t *data
61
+ description: Precomputed decompression constants
62
+ */
63
+
35
64
 
36
65
  /*
37
66
  * WARNING: This file is auto-derived from the mlkem-native source file
38
- * dev/x86_64/src/poly_decompress_d10_avx2_asm.S using scripts/simpasm. Do not modify it directly.
67
+ * dev/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S using scripts/simpasm. Do not modify it directly.
39
68
  */
40
69
 
41
70
  .text
@@ -220,8 +249,8 @@ MLK_ASM_FN_SYMBOL(poly_decompress_d10_avx2_asm)
220
249
  MLK_ASM_FN_SIZE(poly_decompress_d10_avx2_asm)
221
250
 
222
251
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
223
- && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == \
224
- 3) */
252
+ && !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
253
+ MLKEM_K == 2 || MLKEM_K == 3) */
225
254
 
226
255
  #if defined(__ELF__)
227
256
  .section .note.GNU-stack,"",%progbits
@@ -33,11 +33,40 @@
33
33
  #include "../../../common.h"
34
34
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
35
35
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
36
+ !defined(MLK_CONFIG_NO_DECAPS_API) && \
36
37
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
38
+ /*yaml
39
+ Name: poly_decompress_d11_avx2_asm
40
+ Description: x86_64 AVX2 polynomial decompression (d=11)
41
+ Signature: void mlk_poly_decompress_d11_avx2_asm(int16_t *r, const uint8_t *a, const uint8_t *data)
42
+ ABI:
43
+ Architecture: x86_64
44
+ CallingConvention: SysV
45
+ Features: [AVX2]
46
+ rdi:
47
+ type: buffer
48
+ size_bytes: 512
49
+ permissions: write-only
50
+ c_parameter: int16_t *r
51
+ description: Output polynomial (256 x int16_t)
52
+ rsi:
53
+ type: buffer
54
+ size_bytes: 352
55
+ permissions: read-only
56
+ c_parameter: const uint8_t *a
57
+ description: Input compressed polynomial
58
+ rdx:
59
+ type: buffer
60
+ size_bytes: 128
61
+ permissions: read-only
62
+ c_parameter: const uint8_t *data
63
+ description: Precomputed decompression constants
64
+ */
65
+
37
66
 
38
67
  /*
39
68
  * WARNING: This file is auto-derived from the mlkem-native source file
40
- * dev/x86_64/src/poly_decompress_d11_avx2_asm.S using scripts/simpasm. Do not modify it directly.
69
+ * dev/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S using scripts/simpasm. Do not modify it directly.
41
70
  */
42
71
 
43
72
  .text
@@ -270,7 +299,8 @@ MLK_ASM_FN_SYMBOL(poly_decompress_d11_avx2_asm)
270
299
  MLK_ASM_FN_SIZE(poly_decompress_d11_avx2_asm)
271
300
 
272
301
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
273
- && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
302
+ && !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
303
+ MLKEM_K == 4) */
274
304
 
275
305
  #if defined(__ELF__)
276
306
  .section .note.GNU-stack,"",%progbits
@@ -31,11 +31,40 @@
31
31
  #include "../../../common.h"
32
32
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
33
33
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
34
+ !defined(MLK_CONFIG_NO_DECAPS_API) && \
34
35
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2 || MLKEM_K == 3)
36
+ /*yaml
37
+ Name: poly_decompress_d4_avx2_asm
38
+ Description: x86_64 AVX2 polynomial decompression (d=4)
39
+ Signature: void mlk_poly_decompress_d4_avx2_asm(int16_t *r, const uint8_t *a, const uint8_t *data)
40
+ ABI:
41
+ Architecture: x86_64
42
+ CallingConvention: SysV
43
+ Features: [AVX2]
44
+ rdi:
45
+ type: buffer
46
+ size_bytes: 512
47
+ permissions: write-only
48
+ c_parameter: int16_t *r
49
+ description: Output polynomial (256 x int16_t)
50
+ rsi:
51
+ type: buffer
52
+ size_bytes: 128
53
+ permissions: read-only
54
+ c_parameter: const uint8_t *a
55
+ description: Input compressed polynomial
56
+ rdx:
57
+ type: buffer
58
+ size_bytes: 32
59
+ permissions: read-only
60
+ c_parameter: const uint8_t *data
61
+ description: Precomputed decompression constants
62
+ */
63
+
35
64
 
36
65
  /*
37
66
  * WARNING: This file is auto-derived from the mlkem-native source file
38
- * dev/x86_64/src/poly_decompress_d4_avx2_asm.S using scripts/simpasm. Do not modify it directly.
67
+ * dev/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S using scripts/simpasm. Do not modify it directly.
39
68
  */
40
69
 
41
70
  .text
@@ -172,8 +201,8 @@ MLK_ASM_FN_SYMBOL(poly_decompress_d4_avx2_asm)
172
201
  MLK_ASM_FN_SIZE(poly_decompress_d4_avx2_asm)
173
202
 
174
203
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
175
- && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 2 || MLKEM_K == \
176
- 3) */
204
+ && !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
205
+ MLKEM_K == 2 || MLKEM_K == 3) */
177
206
 
178
207
  #if defined(__ELF__)
179
208
  .section .note.GNU-stack,"",%progbits
@@ -32,11 +32,40 @@
32
32
  #include "../../../common.h"
33
33
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
34
34
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
35
+ !defined(MLK_CONFIG_NO_DECAPS_API) && \
35
36
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
37
+ /*yaml
38
+ Name: poly_decompress_d5_avx2_asm
39
+ Description: x86_64 AVX2 polynomial decompression (d=5)
40
+ Signature: void mlk_poly_decompress_d5_avx2_asm(int16_t *r, const uint8_t *a, const uint8_t *data)
41
+ ABI:
42
+ Architecture: x86_64
43
+ CallingConvention: SysV
44
+ Features: [AVX2]
45
+ rdi:
46
+ type: buffer
47
+ size_bytes: 512
48
+ permissions: write-only
49
+ c_parameter: int16_t *r
50
+ description: Output polynomial (256 x int16_t)
51
+ rsi:
52
+ type: buffer
53
+ size_bytes: 160
54
+ permissions: read-only
55
+ c_parameter: const uint8_t *a
56
+ description: Input compressed polynomial
57
+ rdx:
58
+ type: buffer
59
+ size_bytes: 96
60
+ permissions: read-only
61
+ c_parameter: const uint8_t *data
62
+ description: Precomputed decompression constants
63
+ */
64
+
36
65
 
37
66
  /*
38
67
  * WARNING: This file is auto-derived from the mlkem-native source file
39
- * dev/x86_64/src/poly_decompress_d5_avx2_asm.S using scripts/simpasm. Do not modify it directly.
68
+ * dev/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S using scripts/simpasm. Do not modify it directly.
40
69
  */
41
70
 
42
71
  .text
@@ -185,7 +214,8 @@ MLK_ASM_FN_SYMBOL(poly_decompress_d5_avx2_asm)
185
214
  MLK_ASM_FN_SIZE(poly_decompress_d5_avx2_asm)
186
215
 
187
216
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
188
- && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || MLKEM_K == 4) */
217
+ && !MLK_CONFIG_NO_DECAPS_API && (MLK_CONFIG_MULTILEVEL_WITH_SHARED || \
218
+ MLKEM_K == 4) */
189
219
 
190
220
  #if defined(__ELF__)
191
221
  .section .note.GNU-stack,"",%progbits
@@ -6,10 +6,38 @@
6
6
  #include "../../../common.h"
7
7
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
8
8
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
9
+ /*yaml
10
+ Name: poly_mulcache_compute_avx2_asm
11
+ Description: x86_64 AVX2 mulcache computation
12
+ Signature: void mlk_poly_mulcache_compute_avx2_asm(int16_t *out, const int16_t *in, const int16_t *qdata)
13
+ ABI:
14
+ Architecture: x86_64
15
+ CallingConvention: SysV
16
+ Features: [AVX2]
17
+ rdi:
18
+ type: buffer
19
+ size_bytes: 256
20
+ permissions: write-only
21
+ c_parameter: int16_t *out
22
+ description: Output mulcache (128 x int16_t)
23
+ rsi:
24
+ type: buffer
25
+ size_bytes: 512
26
+ permissions: read-only
27
+ c_parameter: const int16_t *in
28
+ description: Input polynomial (256 x int16_t)
29
+ rdx:
30
+ type: buffer
31
+ size_bytes: 1248
32
+ permissions: read-only
33
+ c_parameter: const int16_t *qdata
34
+ description: Precomputed constants (624 x int16_t)
35
+ */
36
+
9
37
 
10
38
  /*
11
39
  * WARNING: This file is auto-derived from the mlkem-native source file
12
- * dev/x86_64/src/poly_mulcache_compute_avx2_asm.S using scripts/simpasm. Do not modify it directly.
40
+ * dev/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S using scripts/simpasm. Do not modify it directly.
13
41
  */
14
42
 
15
43
  .text
@@ -7,10 +7,44 @@
7
7
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
8
8
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
9
9
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 2)
10
+ /*yaml
11
+ Name: polyvec_basemul_acc_montgomery_cached_k2_avx2_asm
12
+ Description: x86_64 AVX2 base multiplication with accumulation (k=2)
13
+ Signature: void mlk_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm(int16_t *r, const int16_t *a, const int16_t *b, const int16_t *b_cache)
14
+ ABI:
15
+ Architecture: x86_64
16
+ CallingConvention: SysV
17
+ Features: [AVX2]
18
+ rdi:
19
+ type: buffer
20
+ size_bytes: 512
21
+ permissions: read/write
22
+ c_parameter: int16_t *r
23
+ description: Output polynomial (256 x int16_t)
24
+ rsi:
25
+ type: buffer
26
+ size_bytes: 1024
27
+ permissions: read-only
28
+ c_parameter: const int16_t *a
29
+ description: Input polyvec a (2 x 256 x int16_t)
30
+ rdx:
31
+ type: buffer
32
+ size_bytes: 1024
33
+ permissions: read-only
34
+ c_parameter: const int16_t *b
35
+ description: Input polyvec b (2 x 256 x int16_t)
36
+ rcx:
37
+ type: buffer
38
+ size_bytes: 512
39
+ permissions: read-only
40
+ c_parameter: const int16_t *b_cache
41
+ description: Mulcache for b (2 x 128 x int16_t)
42
+ */
43
+
10
44
 
11
45
  /*
12
46
  * WARNING: This file is auto-derived from the mlkem-native source file
13
- * dev/x86_64/src/polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S using scripts/simpasm. Do not modify it directly.
47
+ * dev/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S using scripts/simpasm. Do not modify it directly.
14
48
  */
15
49
 
16
50
  .text
@@ -7,10 +7,44 @@
7
7
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
8
8
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
9
9
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 3)
10
+ /*yaml
11
+ Name: polyvec_basemul_acc_montgomery_cached_k3_avx2_asm
12
+ Description: x86_64 AVX2 base multiplication with accumulation (k=3)
13
+ Signature: void mlk_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm(int16_t *r, const int16_t *a, const int16_t *b, const int16_t *b_cache)
14
+ ABI:
15
+ Architecture: x86_64
16
+ CallingConvention: SysV
17
+ Features: [AVX2]
18
+ rdi:
19
+ type: buffer
20
+ size_bytes: 512
21
+ permissions: read/write
22
+ c_parameter: int16_t *r
23
+ description: Output polynomial (256 x int16_t)
24
+ rsi:
25
+ type: buffer
26
+ size_bytes: 1536
27
+ permissions: read-only
28
+ c_parameter: const int16_t *a
29
+ description: Input polyvec a (3 x 256 x int16_t)
30
+ rdx:
31
+ type: buffer
32
+ size_bytes: 1536
33
+ permissions: read-only
34
+ c_parameter: const int16_t *b
35
+ description: Input polyvec b (3 x 256 x int16_t)
36
+ rcx:
37
+ type: buffer
38
+ size_bytes: 768
39
+ permissions: read-only
40
+ c_parameter: const int16_t *b_cache
41
+ description: Mulcache for b (3 x 128 x int16_t)
42
+ */
43
+
10
44
 
11
45
  /*
12
46
  * WARNING: This file is auto-derived from the mlkem-native source file
13
- * dev/x86_64/src/polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S using scripts/simpasm. Do not modify it directly.
47
+ * dev/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S using scripts/simpasm. Do not modify it directly.
14
48
  */
15
49
 
16
50
  .text
@@ -7,10 +7,44 @@
7
7
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
8
8
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
9
9
  (defined(MLK_CONFIG_MULTILEVEL_WITH_SHARED) || MLKEM_K == 4)
10
+ /*yaml
11
+ Name: polyvec_basemul_acc_montgomery_cached_k4_avx2_asm
12
+ Description: x86_64 AVX2 base multiplication with accumulation (k=4)
13
+ Signature: void mlk_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm(int16_t *r, const int16_t *a, const int16_t *b, const int16_t *b_cache)
14
+ ABI:
15
+ Architecture: x86_64
16
+ CallingConvention: SysV
17
+ Features: [AVX2]
18
+ rdi:
19
+ type: buffer
20
+ size_bytes: 512
21
+ permissions: read/write
22
+ c_parameter: int16_t *r
23
+ description: Output polynomial (256 x int16_t)
24
+ rsi:
25
+ type: buffer
26
+ size_bytes: 2048
27
+ permissions: read-only
28
+ c_parameter: const int16_t *a
29
+ description: Input polyvec a (4 x 256 x int16_t)
30
+ rdx:
31
+ type: buffer
32
+ size_bytes: 2048
33
+ permissions: read-only
34
+ c_parameter: const int16_t *b
35
+ description: Input polyvec b (4 x 256 x int16_t)
36
+ rcx:
37
+ type: buffer
38
+ size_bytes: 1024
39
+ permissions: read-only
40
+ c_parameter: const int16_t *b_cache
41
+ description: Mulcache for b (4 x 128 x int16_t)
42
+ */
43
+
10
44
 
11
45
  /*
12
46
  * WARNING: This file is auto-derived from the mlkem-native source file
13
- * dev/x86_64/src/polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S using scripts/simpasm. Do not modify it directly.
47
+ * dev/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S using scripts/simpasm. Do not modify it directly.
14
48
  */
15
49
 
16
50
  .text
@@ -27,10 +27,26 @@
27
27
 
28
28
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
29
29
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
30
+ /*yaml
31
+ Name: reduce_avx2_asm
32
+ Description: x86_64 AVX2 modular reduction
33
+ Signature: void mlk_reduce_avx2_asm(int16_t *r)
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
+ */
45
+
30
46
 
31
47
  /*
32
48
  * WARNING: This file is auto-derived from the mlkem-native source file
33
- * dev/x86_64/src/reduce_avx2_asm.S using scripts/simpasm. Do not modify it directly.
49
+ * dev/x86_64/src/mlkem_reduce_avx2_asm.S using scripts/simpasm. Do not modify it directly.
34
50
  */
35
51
 
36
52
  .text
@@ -22,10 +22,43 @@
22
22
 
23
23
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
24
24
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
25
+ /*yaml
26
+ Name: rej_uniform_avx2_asm
27
+ Description: x86_64 AVX2 rejection sampling
28
+ Signature: uint64_t mlk_rej_uniform_avx2_asm(int16_t *r, const uint8_t *buf, unsigned buflen, const uint8_t *table)
29
+ ABI:
30
+ Architecture: x86_64
31
+ CallingConvention: SysV
32
+ Features: [AVX2]
33
+ rdi:
34
+ type: buffer
35
+ size_bytes: 512
36
+ permissions: write-only
37
+ c_parameter: int16_t *r
38
+ description: Output buffer (256 x int16_t)
39
+ rsi:
40
+ type: buffer
41
+ size_bytes: rdx
42
+ permissions: read-only
43
+ c_parameter: const uint8_t *buf
44
+ description: Input buffer
45
+ rdx:
46
+ type: scalar
47
+ c_parameter: unsigned buflen
48
+ description: Length of input buffer (must be multiple of 12)
49
+ test_with: 504 # MLKEM_GEN_MATRIX_NBLOCKS * MLK_XOF_RATE
50
+ rcx:
51
+ type: buffer
52
+ size_bytes: 4096
53
+ permissions: read-only
54
+ c_parameter: const uint8_t *table
55
+ description: Lookup table
56
+ */
57
+
25
58
 
26
59
  /*
27
60
  * WARNING: This file is auto-derived from the mlkem-native source file
28
- * dev/x86_64/src/rej_uniform_avx2_asm.S using scripts/simpasm. Do not modify it directly.
61
+ * dev/x86_64/src/mlkem_rej_uniform_avx2_asm.S using scripts/simpasm. Do not modify it directly.
29
62
  */
30
63
 
31
64
  .text
@@ -38,7 +71,7 @@ MLK_ASM_FN_SYMBOL(rej_uniform_avx2_asm)
38
71
  .cfi_adjust_cfa_offset 0x210
39
72
  xorl %eax, %eax
40
73
  testq %rdx, %rdx
41
- je Lrej_uniform_asm_end
74
+ je Lmlk_rej_uniform_asm_end
42
75
  movabsq $0xd010d010d010d01, %rax # imm = 0xD010D010D010D01
43
76
  movq %rax, %xmm0
44
77
  pinsrq $0x1, %rax, %xmm0
@@ -53,7 +86,7 @@ MLK_ASM_FN_SYMBOL(rej_uniform_avx2_asm)
53
86
  movq $0x0, %r8
54
87
  movq $0x5555, %r9 # imm = 0x5555
55
88
 
56
- Lrej_uniform_asm_loop_start:
89
+ Lmlk_rej_uniform_asm_loop_start:
57
90
  movq (%rsi,%r8), %xmm2
58
91
  pinsrd $0x2, 0x8(%rsi,%r8), %xmm2
59
92
  pshufb %xmm4, %xmm2
@@ -73,12 +106,12 @@ Lrej_uniform_asm_loop_start:
73
106
  popcntq %r11, %r11
74
107
  addq %r11, %rax
75
108
  cmpq $0x100, %rax # imm = 0x100
76
- jae Lrej_uniform_asm_final_copy
109
+ jae Lmlk_rej_uniform_asm_final_copy
77
110
  addq $0xc, %r8
78
111
  cmpq %r8, %rdx
79
- ja Lrej_uniform_asm_loop_start
112
+ ja Lmlk_rej_uniform_asm_loop_start
80
113
 
81
- Lrej_uniform_asm_final_copy:
114
+ Lmlk_rej_uniform_asm_final_copy:
82
115
  movq $0x100, %rcx # imm = 0x100
83
116
  cmpq $0x100, %rax # imm = 0x100
84
117
  cmovaq %rcx, %rax
@@ -87,7 +120,7 @@ Lrej_uniform_asm_final_copy:
87
120
  shlq %rcx
88
121
  rep movsb (%rsi), %es:(%rdi)
89
122
 
90
- Lrej_uniform_asm_end:
123
+ Lmlk_rej_uniform_asm_end:
91
124
  addq $0x210, %rsp # imm = 0x210
92
125
  .cfi_adjust_cfa_offset -0x210
93
126
  retq
@@ -24,11 +24,28 @@
24
24
 
25
25
  #include "../../../common.h"
26
26
  #if defined(MLK_ARITH_BACKEND_X86_64_DEFAULT) && \
27
- !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
27
+ !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
28
+ !defined(MLK_CONFIG_NO_KEYPAIR_API)
29
+ /*yaml
30
+ Name: tomont_avx2_asm
31
+ Description: x86_64 AVX2 Montgomery conversion
32
+ Signature: void mlk_tomont_avx2_asm(int16_t *r)
33
+ ABI:
34
+ Architecture: x86_64
35
+ CallingConvention: SysV
36
+ Features: [AVX2]
37
+ rdi:
38
+ type: buffer
39
+ size_bytes: 512
40
+ permissions: read/write
41
+ c_parameter: int16_t *r
42
+ description: Input/output polynomial (256 x int16_t)
43
+ */
44
+
28
45
 
29
46
  /*
30
47
  * WARNING: This file is auto-derived from the mlkem-native source file
31
- * dev/x86_64/src/tomont_avx2_asm.S using scripts/simpasm. Do not modify it directly.
48
+ * dev/x86_64/src/mlkem_tomont_avx2_asm.S using scripts/simpasm. Do not modify it directly.
32
49
  */
33
50
 
34
51
  .text
@@ -148,7 +165,7 @@ MLK_ASM_FN_SYMBOL(tomont_avx2_asm)
148
165
  MLK_ASM_FN_SIZE(tomont_avx2_asm)
149
166
 
150
167
  #endif /* MLK_ARITH_BACKEND_X86_64_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
151
- */
168
+ && !MLK_CONFIG_NO_KEYPAIR_API */
152
169
 
153
170
  #if defined(__ELF__)
154
171
  .section .note.GNU-stack,"",%progbits
@@ -105,6 +105,7 @@ __contract__(
105
105
  return res;
106
106
  }
107
107
 
108
+ #if !defined(MLK_CONFIG_NO_KEYPAIR_API)
108
109
  /* Reference: `poly_tomont()` in the reference implementation @[REF]. */
109
110
  MLK_STATIC_TESTABLE void mlk_poly_tomont_c(mlk_poly *r)
110
111
  __contract__(
@@ -142,6 +143,7 @@ void mlk_poly_tomont(mlk_poly *r)
142
143
 
143
144
  mlk_poly_tomont_c(r);
144
145
  }
146
+ #endif /* !MLK_CONFIG_NO_KEYPAIR_API */
145
147
 
146
148
  /**
147
149
  * Constant-time conversion of signed representatives modulo MLKEM_Q within
@@ -241,6 +243,7 @@ void mlk_poly_add(mlk_poly *r, const mlk_poly *b)
241
243
  }
242
244
  }
243
245
 
246
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
244
247
  /* Reference: `poly_sub()` in the reference implementation @[REF].
245
248
  * - We use destructive version (output=first input) to avoid
246
249
  * reasoning about aliasing in the CBMC specification */
@@ -259,6 +262,7 @@ void mlk_poly_sub(mlk_poly *r, const mlk_poly *b)
259
262
  r->coeffs[i] = (int16_t)(r->coeffs[i] - b->coeffs[i]);
260
263
  }
261
264
  }
265
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
262
266
 
263
267
  #include "zetas.inc"
264
268
 
@@ -470,6 +474,7 @@ void mlk_poly_ntt(mlk_poly *r)
470
474
  }
471
475
 
472
476
 
477
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
473
478
  /* Compute one layer of inverse NTT */
474
479
 
475
480
  /* Reference: Embedded into `invntt()` in the reference implementation @[REF] */
@@ -568,8 +573,8 @@ void mlk_poly_invntt_tomont(mlk_poly *r)
568
573
 
569
574
  mlk_poly_invntt_tomont_c(r);
570
575
  }
571
-
572
- #else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED */
576
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */
577
+ #else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED */
573
578
 
574
579
  MLK_EMPTY_CU(mlk_poly)
575
580