mldsa_gh 0.1.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 (128) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +88 -0
  4. data/ext/mldsa_gh_native/extconf.rb +14 -0
  5. data/ext/mldsa_gh_native/mldsa_gh_native.c +222 -0
  6. data/ext/mldsa_gh_native/mldsa_gh_native_all.c +24 -0
  7. data/ext/mldsa_gh_native/mldsa_gh_native_all.h +26 -0
  8. data/ext/mldsa_gh_native/vendor/mldsa-native/BUILDING.md +108 -0
  9. data/ext/mldsa_gh_native/vendor/mldsa-native/LICENSE +305 -0
  10. data/ext/mldsa_gh_native/vendor/mldsa-native/README.md +247 -0
  11. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/README.md +23 -0
  12. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.c +803 -0
  13. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.h +956 -0
  14. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_asm.S +830 -0
  15. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_config.h +855 -0
  16. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/cbmc.h +233 -0
  17. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/common.h +301 -0
  18. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/context.h +152 -0
  19. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  20. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.h +373 -0
  21. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.c +75 -0
  22. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.h +125 -0
  23. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.c +270 -0
  24. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.h +224 -0
  25. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +187 -0
  26. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +125 -0
  27. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +510 -0
  28. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +110 -0
  29. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +85 -0
  30. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  31. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +378 -0
  32. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +207 -0
  33. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +262 -0
  34. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1080 -0
  35. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +990 -0
  36. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +47 -0
  37. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +27 -0
  38. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +36 -0
  39. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +40 -0
  40. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +32 -0
  41. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +37 -0
  42. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/api.h +129 -0
  43. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  44. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +67 -0
  45. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +37 -0
  46. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +717 -0
  47. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +42 -0
  48. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +334 -0
  49. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +355 -0
  50. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +53 -0
  51. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +35 -0
  52. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +34 -0
  53. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +45 -0
  54. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +488 -0
  55. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
  56. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +314 -0
  57. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +248 -0
  58. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +367 -0
  59. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +786 -0
  60. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +686 -0
  61. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +106 -0
  62. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +69 -0
  63. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +76 -0
  64. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +108 -0
  65. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +108 -0
  66. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +125 -0
  67. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +133 -0
  68. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +157 -0
  69. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +173 -0
  70. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +205 -0
  71. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +103 -0
  72. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +100 -0
  73. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +222 -0
  74. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +170 -0
  75. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +163 -0
  76. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +52 -0
  77. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +547 -0
  78. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +63 -0
  79. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/api.h +617 -0
  80. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/meta.h +24 -0
  81. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +323 -0
  82. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +330 -0
  83. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  84. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  85. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +2333 -0
  86. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +2405 -0
  87. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +254 -0
  88. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +173 -0
  89. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +189 -0
  90. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +221 -0
  91. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +158 -0
  92. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +199 -0
  93. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
  94. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
  95. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
  96. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
  97. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
  98. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
  99. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
  100. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
  101. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
  102. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
  103. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +161 -0
  104. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.c +213 -0
  105. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.h +277 -0
  106. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/params.h +153 -0
  107. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.c +1066 -0
  108. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.h +464 -0
  109. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.c +910 -0
  110. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.h +367 -0
  111. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.c +509 -0
  112. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.h +435 -0
  113. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +311 -0
  114. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +652 -0
  115. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  116. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/reduce.h +144 -0
  117. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/rounding.h +265 -0
  118. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.c +1720 -0
  119. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.h +850 -0
  120. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  121. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sys.h +327 -0
  122. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  123. data/lib/mldsa/parameter_set.rb +82 -0
  124. data/lib/mldsa/signing_key.rb +147 -0
  125. data/lib/mldsa/verify_key.rb +72 -0
  126. data/lib/mldsa/version.rb +7 -0
  127. data/lib/mldsa_gh.rb +93 -0
  128. metadata +225 -0
@@ -0,0 +1,489 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ *
19
+ * The algorithm for Decompose(r) (more specifically the handling for the
20
+ * wrap-around cases) is modified. See the AVX2 intrinsics version
21
+ * (poly_decompose_88_avx2.c, predecessor of this file) for a more detailed
22
+ * comparison.
23
+ */
24
+
25
+
26
+ /*yaml
27
+ Name: poly_decompose_88_avx2_asm
28
+ Description: x86_64 AVX2 coefficient decomposition (alpha = 2*(Q-1)/88).
29
+ For all coefficients c of the input polynomial, compute high and low bits
30
+ c0, c1 such that c = c1*ALPHA + c0 with -ALPHA/2 < c0 <= ALPHA/2, except if
31
+ c1 = (Q-1)/ALPHA where we set c1 = 0 and -ALPHA/2 <= c0 = c - Q < 0.
32
+ Assumes coefficients to be standard (unsigned canonical) representatives,
33
+ i.e. 0 <= c < Q. For ML-DSA-44 (gamma2 = (Q-1)/88, alpha = 2*gamma2).
34
+ Signature: void mld_poly_decompose_88_avx2_asm(int32_t *a1, int32_t *a0)
35
+ ABI:
36
+ Architecture: x86_64
37
+ CallingConvention: SysV
38
+ Features: [AVX2]
39
+ rdi:
40
+ type: buffer
41
+ size_bytes: 1024
42
+ permissions: write-only
43
+ c_parameter: int32_t *a1
44
+ description: Output high-part polynomial (256 x int32_t)
45
+ rsi:
46
+ type: buffer
47
+ size_bytes: 1024
48
+ permissions: read/write
49
+ c_parameter: int32_t *a0
50
+ description: Input polynomial / output low-part (256 x int32_t)
51
+ */
52
+
53
+ #include "../../../common.h"
54
+
55
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
56
+ !defined(MLD_CONFIG_NO_SIGN_API) && \
57
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
58
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
59
+ MLD_CONFIG_PARAMETER_SET == 44)
60
+
61
+
62
+ /*
63
+ * WARNING: This file is auto-derived from the mldsa-native source file
64
+ * dev/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S using scripts/simpasm. Do not modify it directly.
65
+ */
66
+
67
+ .text
68
+ .balign 4
69
+ .global MLD_ASM_NAMESPACE(poly_decompose_88_avx2_asm)
70
+ MLD_ASM_FN_SYMBOL(poly_decompose_88_avx2_asm)
71
+
72
+ .cfi_startproc
73
+ movl $0x7f, %eax
74
+ vmovd %eax, %xmm10
75
+ vpbroadcastd %xmm10, %ymm10
76
+ movl $0x2c0b, %eax # imm = 0x2C0B
77
+ vmovd %eax, %xmm11
78
+ vpbroadcastd %xmm11, %ymm11
79
+ movl $0x80, %eax
80
+ vmovd %eax, %xmm12
81
+ vpbroadcastd %xmm12, %ymm12
82
+ movl $0x7e6c00, %eax # imm = 0x7E6C00
83
+ vmovd %eax, %xmm13
84
+ vpbroadcastd %xmm13, %ymm13
85
+ movl $0x2e800, %eax # imm = 0x2E800
86
+ vmovd %eax, %xmm14
87
+ vpbroadcastd %xmm14, %ymm14
88
+ vmovdqa (%rsi), %ymm0
89
+ vpaddd %ymm10, %ymm0, %ymm1
90
+ vpsrld $0x7, %ymm1, %ymm1
91
+ vpmulhuw %ymm11, %ymm1, %ymm1
92
+ vpmulhrsw %ymm12, %ymm1, %ymm1
93
+ vpcmpgtd %ymm13, %ymm0, %ymm3
94
+ vpmulld %ymm14, %ymm1, %ymm2
95
+ vpsubd %ymm2, %ymm0, %ymm2
96
+ vpandn %ymm1, %ymm3, %ymm1
97
+ vpaddd %ymm3, %ymm2, %ymm2
98
+ vmovdqa %ymm1, (%rdi)
99
+ vmovdqa %ymm2, (%rsi)
100
+ vmovdqa 0x20(%rsi), %ymm0
101
+ vpaddd %ymm10, %ymm0, %ymm1
102
+ vpsrld $0x7, %ymm1, %ymm1
103
+ vpmulhuw %ymm11, %ymm1, %ymm1
104
+ vpmulhrsw %ymm12, %ymm1, %ymm1
105
+ vpcmpgtd %ymm13, %ymm0, %ymm3
106
+ vpmulld %ymm14, %ymm1, %ymm2
107
+ vpsubd %ymm2, %ymm0, %ymm2
108
+ vpandn %ymm1, %ymm3, %ymm1
109
+ vpaddd %ymm3, %ymm2, %ymm2
110
+ vmovdqa %ymm1, 0x20(%rdi)
111
+ vmovdqa %ymm2, 0x20(%rsi)
112
+ vmovdqa 0x40(%rsi), %ymm0
113
+ vpaddd %ymm10, %ymm0, %ymm1
114
+ vpsrld $0x7, %ymm1, %ymm1
115
+ vpmulhuw %ymm11, %ymm1, %ymm1
116
+ vpmulhrsw %ymm12, %ymm1, %ymm1
117
+ vpcmpgtd %ymm13, %ymm0, %ymm3
118
+ vpmulld %ymm14, %ymm1, %ymm2
119
+ vpsubd %ymm2, %ymm0, %ymm2
120
+ vpandn %ymm1, %ymm3, %ymm1
121
+ vpaddd %ymm3, %ymm2, %ymm2
122
+ vmovdqa %ymm1, 0x40(%rdi)
123
+ vmovdqa %ymm2, 0x40(%rsi)
124
+ vmovdqa 0x60(%rsi), %ymm0
125
+ vpaddd %ymm10, %ymm0, %ymm1
126
+ vpsrld $0x7, %ymm1, %ymm1
127
+ vpmulhuw %ymm11, %ymm1, %ymm1
128
+ vpmulhrsw %ymm12, %ymm1, %ymm1
129
+ vpcmpgtd %ymm13, %ymm0, %ymm3
130
+ vpmulld %ymm14, %ymm1, %ymm2
131
+ vpsubd %ymm2, %ymm0, %ymm2
132
+ vpandn %ymm1, %ymm3, %ymm1
133
+ vpaddd %ymm3, %ymm2, %ymm2
134
+ vmovdqa %ymm1, 0x60(%rdi)
135
+ vmovdqa %ymm2, 0x60(%rsi)
136
+ vmovdqa 0x80(%rsi), %ymm0
137
+ vpaddd %ymm10, %ymm0, %ymm1
138
+ vpsrld $0x7, %ymm1, %ymm1
139
+ vpmulhuw %ymm11, %ymm1, %ymm1
140
+ vpmulhrsw %ymm12, %ymm1, %ymm1
141
+ vpcmpgtd %ymm13, %ymm0, %ymm3
142
+ vpmulld %ymm14, %ymm1, %ymm2
143
+ vpsubd %ymm2, %ymm0, %ymm2
144
+ vpandn %ymm1, %ymm3, %ymm1
145
+ vpaddd %ymm3, %ymm2, %ymm2
146
+ vmovdqa %ymm1, 0x80(%rdi)
147
+ vmovdqa %ymm2, 0x80(%rsi)
148
+ vmovdqa 0xa0(%rsi), %ymm0
149
+ vpaddd %ymm10, %ymm0, %ymm1
150
+ vpsrld $0x7, %ymm1, %ymm1
151
+ vpmulhuw %ymm11, %ymm1, %ymm1
152
+ vpmulhrsw %ymm12, %ymm1, %ymm1
153
+ vpcmpgtd %ymm13, %ymm0, %ymm3
154
+ vpmulld %ymm14, %ymm1, %ymm2
155
+ vpsubd %ymm2, %ymm0, %ymm2
156
+ vpandn %ymm1, %ymm3, %ymm1
157
+ vpaddd %ymm3, %ymm2, %ymm2
158
+ vmovdqa %ymm1, 0xa0(%rdi)
159
+ vmovdqa %ymm2, 0xa0(%rsi)
160
+ vmovdqa 0xc0(%rsi), %ymm0
161
+ vpaddd %ymm10, %ymm0, %ymm1
162
+ vpsrld $0x7, %ymm1, %ymm1
163
+ vpmulhuw %ymm11, %ymm1, %ymm1
164
+ vpmulhrsw %ymm12, %ymm1, %ymm1
165
+ vpcmpgtd %ymm13, %ymm0, %ymm3
166
+ vpmulld %ymm14, %ymm1, %ymm2
167
+ vpsubd %ymm2, %ymm0, %ymm2
168
+ vpandn %ymm1, %ymm3, %ymm1
169
+ vpaddd %ymm3, %ymm2, %ymm2
170
+ vmovdqa %ymm1, 0xc0(%rdi)
171
+ vmovdqa %ymm2, 0xc0(%rsi)
172
+ vmovdqa 0xe0(%rsi), %ymm0
173
+ vpaddd %ymm10, %ymm0, %ymm1
174
+ vpsrld $0x7, %ymm1, %ymm1
175
+ vpmulhuw %ymm11, %ymm1, %ymm1
176
+ vpmulhrsw %ymm12, %ymm1, %ymm1
177
+ vpcmpgtd %ymm13, %ymm0, %ymm3
178
+ vpmulld %ymm14, %ymm1, %ymm2
179
+ vpsubd %ymm2, %ymm0, %ymm2
180
+ vpandn %ymm1, %ymm3, %ymm1
181
+ vpaddd %ymm3, %ymm2, %ymm2
182
+ vmovdqa %ymm1, 0xe0(%rdi)
183
+ vmovdqa %ymm2, 0xe0(%rsi)
184
+ vmovdqa 0x100(%rsi), %ymm0
185
+ vpaddd %ymm10, %ymm0, %ymm1
186
+ vpsrld $0x7, %ymm1, %ymm1
187
+ vpmulhuw %ymm11, %ymm1, %ymm1
188
+ vpmulhrsw %ymm12, %ymm1, %ymm1
189
+ vpcmpgtd %ymm13, %ymm0, %ymm3
190
+ vpmulld %ymm14, %ymm1, %ymm2
191
+ vpsubd %ymm2, %ymm0, %ymm2
192
+ vpandn %ymm1, %ymm3, %ymm1
193
+ vpaddd %ymm3, %ymm2, %ymm2
194
+ vmovdqa %ymm1, 0x100(%rdi)
195
+ vmovdqa %ymm2, 0x100(%rsi)
196
+ vmovdqa 0x120(%rsi), %ymm0
197
+ vpaddd %ymm10, %ymm0, %ymm1
198
+ vpsrld $0x7, %ymm1, %ymm1
199
+ vpmulhuw %ymm11, %ymm1, %ymm1
200
+ vpmulhrsw %ymm12, %ymm1, %ymm1
201
+ vpcmpgtd %ymm13, %ymm0, %ymm3
202
+ vpmulld %ymm14, %ymm1, %ymm2
203
+ vpsubd %ymm2, %ymm0, %ymm2
204
+ vpandn %ymm1, %ymm3, %ymm1
205
+ vpaddd %ymm3, %ymm2, %ymm2
206
+ vmovdqa %ymm1, 0x120(%rdi)
207
+ vmovdqa %ymm2, 0x120(%rsi)
208
+ vmovdqa 0x140(%rsi), %ymm0
209
+ vpaddd %ymm10, %ymm0, %ymm1
210
+ vpsrld $0x7, %ymm1, %ymm1
211
+ vpmulhuw %ymm11, %ymm1, %ymm1
212
+ vpmulhrsw %ymm12, %ymm1, %ymm1
213
+ vpcmpgtd %ymm13, %ymm0, %ymm3
214
+ vpmulld %ymm14, %ymm1, %ymm2
215
+ vpsubd %ymm2, %ymm0, %ymm2
216
+ vpandn %ymm1, %ymm3, %ymm1
217
+ vpaddd %ymm3, %ymm2, %ymm2
218
+ vmovdqa %ymm1, 0x140(%rdi)
219
+ vmovdqa %ymm2, 0x140(%rsi)
220
+ vmovdqa 0x160(%rsi), %ymm0
221
+ vpaddd %ymm10, %ymm0, %ymm1
222
+ vpsrld $0x7, %ymm1, %ymm1
223
+ vpmulhuw %ymm11, %ymm1, %ymm1
224
+ vpmulhrsw %ymm12, %ymm1, %ymm1
225
+ vpcmpgtd %ymm13, %ymm0, %ymm3
226
+ vpmulld %ymm14, %ymm1, %ymm2
227
+ vpsubd %ymm2, %ymm0, %ymm2
228
+ vpandn %ymm1, %ymm3, %ymm1
229
+ vpaddd %ymm3, %ymm2, %ymm2
230
+ vmovdqa %ymm1, 0x160(%rdi)
231
+ vmovdqa %ymm2, 0x160(%rsi)
232
+ vmovdqa 0x180(%rsi), %ymm0
233
+ vpaddd %ymm10, %ymm0, %ymm1
234
+ vpsrld $0x7, %ymm1, %ymm1
235
+ vpmulhuw %ymm11, %ymm1, %ymm1
236
+ vpmulhrsw %ymm12, %ymm1, %ymm1
237
+ vpcmpgtd %ymm13, %ymm0, %ymm3
238
+ vpmulld %ymm14, %ymm1, %ymm2
239
+ vpsubd %ymm2, %ymm0, %ymm2
240
+ vpandn %ymm1, %ymm3, %ymm1
241
+ vpaddd %ymm3, %ymm2, %ymm2
242
+ vmovdqa %ymm1, 0x180(%rdi)
243
+ vmovdqa %ymm2, 0x180(%rsi)
244
+ vmovdqa 0x1a0(%rsi), %ymm0
245
+ vpaddd %ymm10, %ymm0, %ymm1
246
+ vpsrld $0x7, %ymm1, %ymm1
247
+ vpmulhuw %ymm11, %ymm1, %ymm1
248
+ vpmulhrsw %ymm12, %ymm1, %ymm1
249
+ vpcmpgtd %ymm13, %ymm0, %ymm3
250
+ vpmulld %ymm14, %ymm1, %ymm2
251
+ vpsubd %ymm2, %ymm0, %ymm2
252
+ vpandn %ymm1, %ymm3, %ymm1
253
+ vpaddd %ymm3, %ymm2, %ymm2
254
+ vmovdqa %ymm1, 0x1a0(%rdi)
255
+ vmovdqa %ymm2, 0x1a0(%rsi)
256
+ vmovdqa 0x1c0(%rsi), %ymm0
257
+ vpaddd %ymm10, %ymm0, %ymm1
258
+ vpsrld $0x7, %ymm1, %ymm1
259
+ vpmulhuw %ymm11, %ymm1, %ymm1
260
+ vpmulhrsw %ymm12, %ymm1, %ymm1
261
+ vpcmpgtd %ymm13, %ymm0, %ymm3
262
+ vpmulld %ymm14, %ymm1, %ymm2
263
+ vpsubd %ymm2, %ymm0, %ymm2
264
+ vpandn %ymm1, %ymm3, %ymm1
265
+ vpaddd %ymm3, %ymm2, %ymm2
266
+ vmovdqa %ymm1, 0x1c0(%rdi)
267
+ vmovdqa %ymm2, 0x1c0(%rsi)
268
+ vmovdqa 0x1e0(%rsi), %ymm0
269
+ vpaddd %ymm10, %ymm0, %ymm1
270
+ vpsrld $0x7, %ymm1, %ymm1
271
+ vpmulhuw %ymm11, %ymm1, %ymm1
272
+ vpmulhrsw %ymm12, %ymm1, %ymm1
273
+ vpcmpgtd %ymm13, %ymm0, %ymm3
274
+ vpmulld %ymm14, %ymm1, %ymm2
275
+ vpsubd %ymm2, %ymm0, %ymm2
276
+ vpandn %ymm1, %ymm3, %ymm1
277
+ vpaddd %ymm3, %ymm2, %ymm2
278
+ vmovdqa %ymm1, 0x1e0(%rdi)
279
+ vmovdqa %ymm2, 0x1e0(%rsi)
280
+ vmovdqa 0x200(%rsi), %ymm0
281
+ vpaddd %ymm10, %ymm0, %ymm1
282
+ vpsrld $0x7, %ymm1, %ymm1
283
+ vpmulhuw %ymm11, %ymm1, %ymm1
284
+ vpmulhrsw %ymm12, %ymm1, %ymm1
285
+ vpcmpgtd %ymm13, %ymm0, %ymm3
286
+ vpmulld %ymm14, %ymm1, %ymm2
287
+ vpsubd %ymm2, %ymm0, %ymm2
288
+ vpandn %ymm1, %ymm3, %ymm1
289
+ vpaddd %ymm3, %ymm2, %ymm2
290
+ vmovdqa %ymm1, 0x200(%rdi)
291
+ vmovdqa %ymm2, 0x200(%rsi)
292
+ vmovdqa 0x220(%rsi), %ymm0
293
+ vpaddd %ymm10, %ymm0, %ymm1
294
+ vpsrld $0x7, %ymm1, %ymm1
295
+ vpmulhuw %ymm11, %ymm1, %ymm1
296
+ vpmulhrsw %ymm12, %ymm1, %ymm1
297
+ vpcmpgtd %ymm13, %ymm0, %ymm3
298
+ vpmulld %ymm14, %ymm1, %ymm2
299
+ vpsubd %ymm2, %ymm0, %ymm2
300
+ vpandn %ymm1, %ymm3, %ymm1
301
+ vpaddd %ymm3, %ymm2, %ymm2
302
+ vmovdqa %ymm1, 0x220(%rdi)
303
+ vmovdqa %ymm2, 0x220(%rsi)
304
+ vmovdqa 0x240(%rsi), %ymm0
305
+ vpaddd %ymm10, %ymm0, %ymm1
306
+ vpsrld $0x7, %ymm1, %ymm1
307
+ vpmulhuw %ymm11, %ymm1, %ymm1
308
+ vpmulhrsw %ymm12, %ymm1, %ymm1
309
+ vpcmpgtd %ymm13, %ymm0, %ymm3
310
+ vpmulld %ymm14, %ymm1, %ymm2
311
+ vpsubd %ymm2, %ymm0, %ymm2
312
+ vpandn %ymm1, %ymm3, %ymm1
313
+ vpaddd %ymm3, %ymm2, %ymm2
314
+ vmovdqa %ymm1, 0x240(%rdi)
315
+ vmovdqa %ymm2, 0x240(%rsi)
316
+ vmovdqa 0x260(%rsi), %ymm0
317
+ vpaddd %ymm10, %ymm0, %ymm1
318
+ vpsrld $0x7, %ymm1, %ymm1
319
+ vpmulhuw %ymm11, %ymm1, %ymm1
320
+ vpmulhrsw %ymm12, %ymm1, %ymm1
321
+ vpcmpgtd %ymm13, %ymm0, %ymm3
322
+ vpmulld %ymm14, %ymm1, %ymm2
323
+ vpsubd %ymm2, %ymm0, %ymm2
324
+ vpandn %ymm1, %ymm3, %ymm1
325
+ vpaddd %ymm3, %ymm2, %ymm2
326
+ vmovdqa %ymm1, 0x260(%rdi)
327
+ vmovdqa %ymm2, 0x260(%rsi)
328
+ vmovdqa 0x280(%rsi), %ymm0
329
+ vpaddd %ymm10, %ymm0, %ymm1
330
+ vpsrld $0x7, %ymm1, %ymm1
331
+ vpmulhuw %ymm11, %ymm1, %ymm1
332
+ vpmulhrsw %ymm12, %ymm1, %ymm1
333
+ vpcmpgtd %ymm13, %ymm0, %ymm3
334
+ vpmulld %ymm14, %ymm1, %ymm2
335
+ vpsubd %ymm2, %ymm0, %ymm2
336
+ vpandn %ymm1, %ymm3, %ymm1
337
+ vpaddd %ymm3, %ymm2, %ymm2
338
+ vmovdqa %ymm1, 0x280(%rdi)
339
+ vmovdqa %ymm2, 0x280(%rsi)
340
+ vmovdqa 0x2a0(%rsi), %ymm0
341
+ vpaddd %ymm10, %ymm0, %ymm1
342
+ vpsrld $0x7, %ymm1, %ymm1
343
+ vpmulhuw %ymm11, %ymm1, %ymm1
344
+ vpmulhrsw %ymm12, %ymm1, %ymm1
345
+ vpcmpgtd %ymm13, %ymm0, %ymm3
346
+ vpmulld %ymm14, %ymm1, %ymm2
347
+ vpsubd %ymm2, %ymm0, %ymm2
348
+ vpandn %ymm1, %ymm3, %ymm1
349
+ vpaddd %ymm3, %ymm2, %ymm2
350
+ vmovdqa %ymm1, 0x2a0(%rdi)
351
+ vmovdqa %ymm2, 0x2a0(%rsi)
352
+ vmovdqa 0x2c0(%rsi), %ymm0
353
+ vpaddd %ymm10, %ymm0, %ymm1
354
+ vpsrld $0x7, %ymm1, %ymm1
355
+ vpmulhuw %ymm11, %ymm1, %ymm1
356
+ vpmulhrsw %ymm12, %ymm1, %ymm1
357
+ vpcmpgtd %ymm13, %ymm0, %ymm3
358
+ vpmulld %ymm14, %ymm1, %ymm2
359
+ vpsubd %ymm2, %ymm0, %ymm2
360
+ vpandn %ymm1, %ymm3, %ymm1
361
+ vpaddd %ymm3, %ymm2, %ymm2
362
+ vmovdqa %ymm1, 0x2c0(%rdi)
363
+ vmovdqa %ymm2, 0x2c0(%rsi)
364
+ vmovdqa 0x2e0(%rsi), %ymm0
365
+ vpaddd %ymm10, %ymm0, %ymm1
366
+ vpsrld $0x7, %ymm1, %ymm1
367
+ vpmulhuw %ymm11, %ymm1, %ymm1
368
+ vpmulhrsw %ymm12, %ymm1, %ymm1
369
+ vpcmpgtd %ymm13, %ymm0, %ymm3
370
+ vpmulld %ymm14, %ymm1, %ymm2
371
+ vpsubd %ymm2, %ymm0, %ymm2
372
+ vpandn %ymm1, %ymm3, %ymm1
373
+ vpaddd %ymm3, %ymm2, %ymm2
374
+ vmovdqa %ymm1, 0x2e0(%rdi)
375
+ vmovdqa %ymm2, 0x2e0(%rsi)
376
+ vmovdqa 0x300(%rsi), %ymm0
377
+ vpaddd %ymm10, %ymm0, %ymm1
378
+ vpsrld $0x7, %ymm1, %ymm1
379
+ vpmulhuw %ymm11, %ymm1, %ymm1
380
+ vpmulhrsw %ymm12, %ymm1, %ymm1
381
+ vpcmpgtd %ymm13, %ymm0, %ymm3
382
+ vpmulld %ymm14, %ymm1, %ymm2
383
+ vpsubd %ymm2, %ymm0, %ymm2
384
+ vpandn %ymm1, %ymm3, %ymm1
385
+ vpaddd %ymm3, %ymm2, %ymm2
386
+ vmovdqa %ymm1, 0x300(%rdi)
387
+ vmovdqa %ymm2, 0x300(%rsi)
388
+ vmovdqa 0x320(%rsi), %ymm0
389
+ vpaddd %ymm10, %ymm0, %ymm1
390
+ vpsrld $0x7, %ymm1, %ymm1
391
+ vpmulhuw %ymm11, %ymm1, %ymm1
392
+ vpmulhrsw %ymm12, %ymm1, %ymm1
393
+ vpcmpgtd %ymm13, %ymm0, %ymm3
394
+ vpmulld %ymm14, %ymm1, %ymm2
395
+ vpsubd %ymm2, %ymm0, %ymm2
396
+ vpandn %ymm1, %ymm3, %ymm1
397
+ vpaddd %ymm3, %ymm2, %ymm2
398
+ vmovdqa %ymm1, 0x320(%rdi)
399
+ vmovdqa %ymm2, 0x320(%rsi)
400
+ vmovdqa 0x340(%rsi), %ymm0
401
+ vpaddd %ymm10, %ymm0, %ymm1
402
+ vpsrld $0x7, %ymm1, %ymm1
403
+ vpmulhuw %ymm11, %ymm1, %ymm1
404
+ vpmulhrsw %ymm12, %ymm1, %ymm1
405
+ vpcmpgtd %ymm13, %ymm0, %ymm3
406
+ vpmulld %ymm14, %ymm1, %ymm2
407
+ vpsubd %ymm2, %ymm0, %ymm2
408
+ vpandn %ymm1, %ymm3, %ymm1
409
+ vpaddd %ymm3, %ymm2, %ymm2
410
+ vmovdqa %ymm1, 0x340(%rdi)
411
+ vmovdqa %ymm2, 0x340(%rsi)
412
+ vmovdqa 0x360(%rsi), %ymm0
413
+ vpaddd %ymm10, %ymm0, %ymm1
414
+ vpsrld $0x7, %ymm1, %ymm1
415
+ vpmulhuw %ymm11, %ymm1, %ymm1
416
+ vpmulhrsw %ymm12, %ymm1, %ymm1
417
+ vpcmpgtd %ymm13, %ymm0, %ymm3
418
+ vpmulld %ymm14, %ymm1, %ymm2
419
+ vpsubd %ymm2, %ymm0, %ymm2
420
+ vpandn %ymm1, %ymm3, %ymm1
421
+ vpaddd %ymm3, %ymm2, %ymm2
422
+ vmovdqa %ymm1, 0x360(%rdi)
423
+ vmovdqa %ymm2, 0x360(%rsi)
424
+ vmovdqa 0x380(%rsi), %ymm0
425
+ vpaddd %ymm10, %ymm0, %ymm1
426
+ vpsrld $0x7, %ymm1, %ymm1
427
+ vpmulhuw %ymm11, %ymm1, %ymm1
428
+ vpmulhrsw %ymm12, %ymm1, %ymm1
429
+ vpcmpgtd %ymm13, %ymm0, %ymm3
430
+ vpmulld %ymm14, %ymm1, %ymm2
431
+ vpsubd %ymm2, %ymm0, %ymm2
432
+ vpandn %ymm1, %ymm3, %ymm1
433
+ vpaddd %ymm3, %ymm2, %ymm2
434
+ vmovdqa %ymm1, 0x380(%rdi)
435
+ vmovdqa %ymm2, 0x380(%rsi)
436
+ vmovdqa 0x3a0(%rsi), %ymm0
437
+ vpaddd %ymm10, %ymm0, %ymm1
438
+ vpsrld $0x7, %ymm1, %ymm1
439
+ vpmulhuw %ymm11, %ymm1, %ymm1
440
+ vpmulhrsw %ymm12, %ymm1, %ymm1
441
+ vpcmpgtd %ymm13, %ymm0, %ymm3
442
+ vpmulld %ymm14, %ymm1, %ymm2
443
+ vpsubd %ymm2, %ymm0, %ymm2
444
+ vpandn %ymm1, %ymm3, %ymm1
445
+ vpaddd %ymm3, %ymm2, %ymm2
446
+ vmovdqa %ymm1, 0x3a0(%rdi)
447
+ vmovdqa %ymm2, 0x3a0(%rsi)
448
+ vmovdqa 0x3c0(%rsi), %ymm0
449
+ vpaddd %ymm10, %ymm0, %ymm1
450
+ vpsrld $0x7, %ymm1, %ymm1
451
+ vpmulhuw %ymm11, %ymm1, %ymm1
452
+ vpmulhrsw %ymm12, %ymm1, %ymm1
453
+ vpcmpgtd %ymm13, %ymm0, %ymm3
454
+ vpmulld %ymm14, %ymm1, %ymm2
455
+ vpsubd %ymm2, %ymm0, %ymm2
456
+ vpandn %ymm1, %ymm3, %ymm1
457
+ vpaddd %ymm3, %ymm2, %ymm2
458
+ vmovdqa %ymm1, 0x3c0(%rdi)
459
+ vmovdqa %ymm2, 0x3c0(%rsi)
460
+ vmovdqa 0x3e0(%rsi), %ymm0
461
+ vpaddd %ymm10, %ymm0, %ymm1
462
+ vpsrld $0x7, %ymm1, %ymm1
463
+ vpmulhuw %ymm11, %ymm1, %ymm1
464
+ vpmulhrsw %ymm12, %ymm1, %ymm1
465
+ vpcmpgtd %ymm13, %ymm0, %ymm3
466
+ vpmulld %ymm14, %ymm1, %ymm2
467
+ vpsubd %ymm2, %ymm0, %ymm2
468
+ vpandn %ymm1, %ymm3, %ymm1
469
+ vpaddd %ymm3, %ymm2, %ymm2
470
+ vmovdqa %ymm1, 0x3e0(%rdi)
471
+ vmovdqa %ymm2, 0x3e0(%rsi)
472
+ retq
473
+ .cfi_endproc
474
+
475
+ MLD_ASM_FN_SIZE(poly_decompose_88_avx2_asm)
476
+
477
+
478
+ #endif /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_NO_SIGN_API && \
479
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
480
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44) \
481
+ */
482
+
483
+ #if defined(__ELF__)
484
+ .section .note.GNU-stack,"",%progbits
485
+ #endif
486
+
487
+ #if defined(__ELF__)
488
+ .section .note.GNU-stack,"",%progbits
489
+ #endif
@@ -0,0 +1,123 @@
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
+ * - [REF_AVX2]
10
+ * CRYSTALS-Dilithium optimized AVX2 implementation
11
+ * Bai, Ducas, Kiltz, Lepoint, Lyubashevsky, Schwabe, Seiler, Stehlé
12
+ * https://github.com/pq-crystals/dilithium/tree/master/avx2
13
+ */
14
+
15
+ /*
16
+ * This file is derived from the public domain
17
+ * AVX2 Dilithium implementation @[REF_AVX2].
18
+ */
19
+
20
+
21
+ /*yaml
22
+ Name: poly_use_hint_32_avx2_asm
23
+ Description: x86_64 AVX2 hint application (alpha = (Q-1)/32).
24
+ Use the hint polynomial h to correct the high bits of the polynomial a,
25
+ in place. Variant for parameter sets ML-DSA-65 and ML-DSA-87
26
+ (GAMMA2 = (Q-1)/32).
27
+ Signature: void mld_poly_use_hint_32_avx2_asm(int32_t *a, const int32_t *h)
28
+ ABI:
29
+ Architecture: x86_64
30
+ CallingConvention: SysV
31
+ Features: [AVX2]
32
+ rdi:
33
+ type: buffer
34
+ size_bytes: 1024
35
+ permissions: read/write
36
+ c_parameter: int32_t *a
37
+ description: Input/output polynomial (256 x int32_t)
38
+ rsi:
39
+ type: buffer
40
+ size_bytes: 1024
41
+ permissions: read-only
42
+ c_parameter: const int32_t *h
43
+ description: Hint polynomial (256 x int32_t)
44
+ */
45
+
46
+ #include "../../../common.h"
47
+
48
+ #if defined(MLD_ARITH_BACKEND_X86_64_DEFAULT) && \
49
+ !defined(MLD_CONFIG_NO_VERIFY_API) && \
50
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
51
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || \
52
+ (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87))
53
+
54
+
55
+ /*
56
+ * WARNING: This file is auto-derived from the mldsa-native source file
57
+ * dev/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S using scripts/simpasm. Do not modify it directly.
58
+ */
59
+
60
+ .text
61
+ .balign 4
62
+ .global MLD_ASM_NAMESPACE(poly_use_hint_32_avx2_asm)
63
+ MLD_ASM_FN_SYMBOL(poly_use_hint_32_avx2_asm)
64
+
65
+ .cfi_startproc
66
+ movl $0x7f, %ecx
67
+ movl $0x401, %r8d # imm = 0x401
68
+ vmovd %r8d, %xmm8
69
+ vpbroadcastd %xmm8, %ymm8
70
+ xorl %eax, %eax
71
+ vpxor %xmm6, %xmm6, %xmm6
72
+ vmovd %ecx, %xmm5
73
+ movl $0x7be100, %ecx # imm = 0x7BE100
74
+ movl $0x200, %r9d # imm = 0x200
75
+ vmovd %r9d, %xmm7
76
+ vpbroadcastd %xmm7, %ymm7
77
+ vmovd %ecx, %xmm4
78
+ movl $0xf, %ecx
79
+ vpbroadcastd %xmm5, %ymm5
80
+ vmovd %ecx, %xmm3
81
+ vpbroadcastd %xmm4, %ymm4
82
+ vpbroadcastd %xmm3, %ymm3
83
+
84
+ Lmld_poly_use_hint_32_avx2_asm_loop:
85
+ vmovdqa (%rdi), %ymm0
86
+ vmovdqa (%rsi), %ymm2
87
+ vpaddd %ymm0, %ymm5, %ymm1
88
+ vpsrld $0x7, %ymm1, %ymm1
89
+ vpmulhuw %ymm8, %ymm1, %ymm1
90
+ vpmulhrsw %ymm7, %ymm1, %ymm1
91
+ vpcmpgtd %ymm4, %ymm0, %ymm11
92
+ vpandn %ymm1, %ymm11, %ymm9
93
+ vpslld $0xa, %ymm1, %ymm10
94
+ vpsubd %ymm1, %ymm10, %ymm1
95
+ vpslld $0x9, %ymm1, %ymm1
96
+ vpsubd %ymm1, %ymm0, %ymm0
97
+ vpaddd %ymm11, %ymm0, %ymm0
98
+ vpcmpgtd %ymm6, %ymm0, %ymm0
99
+ vpandn %ymm2, %ymm0, %ymm0
100
+ vpslld $0x1, %ymm0, %ymm0
101
+ vpsubd %ymm0, %ymm2, %ymm2
102
+ vpaddd %ymm9, %ymm2, %ymm2
103
+ vpand %ymm3, %ymm2, %ymm2
104
+ vmovdqa %ymm2, (%rdi)
105
+ addq $0x20, %rdi
106
+ addq $0x20, %rsi
107
+ addq $0x20, %rax
108
+ cmpq $0x400, %rax # imm = 0x400
109
+ jne Lmld_poly_use_hint_32_avx2_asm_loop
110
+ retq
111
+ .cfi_endproc
112
+
113
+ MLD_ASM_FN_SIZE(poly_use_hint_32_avx2_asm)
114
+
115
+
116
+ #endif /* MLD_ARITH_BACKEND_X86_64_DEFAULT && !MLD_CONFIG_NO_VERIFY_API && \
117
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
118
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
119
+ || MLD_CONFIG_PARAMETER_SET == 87) */
120
+
121
+ #if defined(__ELF__)
122
+ .section .note.GNU-stack,"",%progbits
123
+ #endif