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,106 @@
1
+ /* Copyright (c) The mldsa-native project authors
2
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3
+ */
4
+
5
+ /*yaml
6
+ Name: poly_pointwise_montgomery_aarch64_asm
7
+ Description: AArch64 pointwise Montgomery multiplication of two polynomials
8
+ Signature: void mld_poly_pointwise_montgomery_aarch64_asm(int32_t a[256], const int32_t b[256])
9
+ ABI:
10
+ Architecture: aarch64
11
+ CallingConvention: AAPCS64
12
+ Features: [NEON]
13
+ x0:
14
+ type: buffer
15
+ size_bytes: 1024
16
+ permissions: read/write
17
+ c_parameter: int32_t a[256]
18
+ description: Input/output polynomial (256 x int32_t)
19
+ x1:
20
+ type: buffer
21
+ size_bytes: 1024
22
+ permissions: read-only
23
+ c_parameter: const int32_t b[256]
24
+ description: Input polynomial (256 x int32_t)
25
+ */
26
+
27
+ #include "../../../common.h"
28
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && \
29
+ (!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API) || \
30
+ defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)) && \
31
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
32
+
33
+ /*
34
+ * WARNING: This file is auto-derived from the mldsa-native source file
35
+ * dev/aarch64_opt/src/mldsa_pointwise_montgomery_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
36
+ */
37
+
38
+ .text
39
+ .balign 4
40
+ .global MLD_ASM_NAMESPACE(poly_pointwise_montgomery_aarch64_asm)
41
+ MLD_ASM_FN_SYMBOL(poly_pointwise_montgomery_aarch64_asm)
42
+
43
+ .cfi_startproc
44
+ mov w3, #0xe001 // =57345
45
+ movk w3, #0x7f, lsl #16
46
+ dup v0.4s, w3
47
+ mov w3, #0x2001 // =8193
48
+ movk w3, #0x380, lsl #16
49
+ dup v1.4s, w3
50
+ mov x3, #0x40 // =64
51
+
52
+ Lmld_poly_pointwise_montgomery_loop_start:
53
+ ldr q16, [x0]
54
+ ldr q17, [x0, #0x10]
55
+ ldr q18, [x0, #0x20]
56
+ ldr q19, [x0, #0x30]
57
+ ldr q21, [x1, #0x10]
58
+ ldr q22, [x1, #0x20]
59
+ ldr q23, [x1, #0x30]
60
+ ldr q20, [x1], #0x40
61
+ smull v24.2d, v16.2s, v20.2s
62
+ smull2 v25.2d, v16.4s, v20.4s
63
+ smull v26.2d, v17.2s, v21.2s
64
+ smull2 v27.2d, v17.4s, v21.4s
65
+ smull v28.2d, v18.2s, v22.2s
66
+ smull2 v29.2d, v18.4s, v22.4s
67
+ smull v30.2d, v19.2s, v23.2s
68
+ smull2 v31.2d, v19.4s, v23.4s
69
+ uzp1 v16.4s, v24.4s, v25.4s
70
+ mul v16.4s, v16.4s, v1.4s
71
+ smlsl v24.2d, v16.2s, v0.2s
72
+ smlsl2 v25.2d, v16.4s, v0.4s
73
+ uzp2 v16.4s, v24.4s, v25.4s
74
+ uzp1 v17.4s, v26.4s, v27.4s
75
+ mul v17.4s, v17.4s, v1.4s
76
+ smlsl v26.2d, v17.2s, v0.2s
77
+ smlsl2 v27.2d, v17.4s, v0.4s
78
+ uzp2 v17.4s, v26.4s, v27.4s
79
+ uzp1 v18.4s, v28.4s, v29.4s
80
+ mul v18.4s, v18.4s, v1.4s
81
+ smlsl v28.2d, v18.2s, v0.2s
82
+ smlsl2 v29.2d, v18.4s, v0.4s
83
+ uzp2 v18.4s, v28.4s, v29.4s
84
+ uzp1 v19.4s, v30.4s, v31.4s
85
+ mul v19.4s, v19.4s, v1.4s
86
+ smlsl v30.2d, v19.2s, v0.2s
87
+ smlsl2 v31.2d, v19.4s, v0.4s
88
+ uzp2 v19.4s, v30.4s, v31.4s
89
+ str q17, [x0, #0x10]
90
+ str q18, [x0, #0x20]
91
+ str q19, [x0, #0x30]
92
+ str q16, [x0], #0x40
93
+ subs x3, x3, #0x4
94
+ cbnz x3, Lmld_poly_pointwise_montgomery_loop_start
95
+ ret
96
+ .cfi_endproc
97
+
98
+ MLD_ASM_FN_SIZE(poly_pointwise_montgomery_aarch64_asm)
99
+
100
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && (!MLD_CONFIG_NO_SIGN_API || \
101
+ !MLD_CONFIG_NO_VERIFY_API || MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST) \
102
+ && !MLD_CONFIG_MULTILEVEL_NO_SHARED */
103
+
104
+ #if defined(__ELF__)
105
+ .section .note.GNU-stack,"",%progbits
106
+ #endif
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ /*yaml
6
+ Name: poly_caddq_aarch64_asm
7
+ Description: AArch64 conditional addition of q to each coefficient
8
+ Signature: void mld_poly_caddq_aarch64_asm(int32_t a[256])
9
+ ABI:
10
+ Architecture: aarch64
11
+ CallingConvention: AAPCS64
12
+ Features: [NEON]
13
+ x0:
14
+ type: buffer
15
+ size_bytes: 1024
16
+ permissions: read/write
17
+ c_parameter: int32_t a[256]
18
+ description: Input/output polynomial (256 x int32_t)
19
+ */
20
+
21
+ #include "../../../common.h"
22
+
23
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
24
+
25
+ /*
26
+ * WARNING: This file is auto-derived from the mldsa-native source file
27
+ * dev/aarch64_opt/src/mldsa_poly_caddq_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
28
+ */
29
+
30
+ .text
31
+ .balign 4
32
+ .global MLD_ASM_NAMESPACE(poly_caddq_aarch64_asm)
33
+ MLD_ASM_FN_SYMBOL(poly_caddq_aarch64_asm)
34
+
35
+ .cfi_startproc
36
+ mov w9, #0xe001 // =57345
37
+ movk w9, #0x7f, lsl #16
38
+ dup v4.4s, w9
39
+ mov x1, #0x10 // =16
40
+
41
+ Lmld_poly_caddq_loop:
42
+ ldr q0, [x0]
43
+ ldr q1, [x0, #0x10]
44
+ ldr q2, [x0, #0x20]
45
+ ldr q3, [x0, #0x30]
46
+ ushr v5.4s, v0.4s, #0x1f
47
+ mla v0.4s, v5.4s, v4.4s
48
+ ushr v5.4s, v1.4s, #0x1f
49
+ mla v1.4s, v5.4s, v4.4s
50
+ ushr v5.4s, v2.4s, #0x1f
51
+ mla v2.4s, v5.4s, v4.4s
52
+ ushr v5.4s, v3.4s, #0x1f
53
+ mla v3.4s, v5.4s, v4.4s
54
+ str q1, [x0, #0x10]
55
+ str q2, [x0, #0x20]
56
+ str q3, [x0, #0x30]
57
+ str q0, [x0], #0x40
58
+ subs x1, x1, #0x1
59
+ b.ne Lmld_poly_caddq_loop
60
+ ret
61
+ .cfi_endproc
62
+
63
+ MLD_ASM_FN_SIZE(poly_caddq_aarch64_asm)
64
+
65
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_MULTILEVEL_NO_SHARED */
66
+
67
+ #if defined(__ELF__)
68
+ .section .note.GNU-stack,"",%progbits
69
+ #endif
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ /*yaml
6
+ Name: poly_chknorm_aarch64_asm
7
+ Description: AArch64 infinity-norm bound check on polynomial coefficients
8
+ Signature: int mld_poly_chknorm_aarch64_asm(const int32_t a[256], int32_t B)
9
+ ABI:
10
+ Architecture: aarch64
11
+ CallingConvention: AAPCS64
12
+ Features: [NEON]
13
+ x0:
14
+ type: buffer
15
+ size_bytes: 1024
16
+ permissions: read-only
17
+ c_parameter: const int32_t a[256]
18
+ description: Input polynomial (256 x int32_t)
19
+ x1:
20
+ type: scalar
21
+ c_parameter: int32_t B
22
+ description: Norm bound
23
+ test_with: 131072 # representative non-negative bound (1 << 17)
24
+ */
25
+
26
+ #include "../../../common.h"
27
+
28
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
29
+
30
+ /*
31
+ * WARNING: This file is auto-derived from the mldsa-native source file
32
+ * dev/aarch64_opt/src/mldsa_poly_chknorm_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
33
+ */
34
+
35
+ .text
36
+ .balign 4
37
+ .global MLD_ASM_NAMESPACE(poly_chknorm_aarch64_asm)
38
+ MLD_ASM_FN_SYMBOL(poly_chknorm_aarch64_asm)
39
+
40
+ .cfi_startproc
41
+ dup v20.4s, w1
42
+ eor v21.16b, v21.16b, v21.16b
43
+ mov x2, #0x10 // =16
44
+
45
+ Lmld_poly_chknorm_loop:
46
+ ldr q1, [x0, #0x10]
47
+ ldr q2, [x0, #0x20]
48
+ ldr q3, [x0, #0x30]
49
+ ldr q0, [x0], #0x40
50
+ abs v1.4s, v1.4s
51
+ cmge v1.4s, v1.4s, v20.4s
52
+ orr v21.16b, v21.16b, v1.16b
53
+ abs v2.4s, v2.4s
54
+ cmge v2.4s, v2.4s, v20.4s
55
+ orr v21.16b, v21.16b, v2.16b
56
+ abs v3.4s, v3.4s
57
+ cmge v3.4s, v3.4s, v20.4s
58
+ orr v21.16b, v21.16b, v3.16b
59
+ abs v0.4s, v0.4s
60
+ cmge v0.4s, v0.4s, v20.4s
61
+ orr v21.16b, v21.16b, v0.16b
62
+ subs x2, x2, #0x1
63
+ b.ne Lmld_poly_chknorm_loop
64
+ umaxv s21, v21.4s
65
+ fmov w0, s21
66
+ and w0, w0, #0x1
67
+ ret
68
+ .cfi_endproc
69
+
70
+ MLD_ASM_FN_SIZE(poly_chknorm_aarch64_asm)
71
+
72
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_MULTILEVEL_NO_SHARED */
73
+
74
+ #if defined(__ELF__)
75
+ .section .note.GNU-stack,"",%progbits
76
+ #endif
@@ -0,0 +1,108 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ /*yaml
6
+ Name: poly_decompose_32_aarch64_asm
7
+ Description: AArch64 coefficient decomposition (alpha = (Q-1)/32)
8
+ Signature: void mld_poly_decompose_32_aarch64_asm(int32_t a1[256], int32_t a0[256])
9
+ ABI:
10
+ Architecture: aarch64
11
+ CallingConvention: AAPCS64
12
+ Features: [NEON]
13
+ x0:
14
+ type: buffer
15
+ size_bytes: 1024
16
+ permissions: write-only
17
+ c_parameter: int32_t a1[256]
18
+ description: Output high-part polynomial (256 x int32_t)
19
+ x1:
20
+ type: buffer
21
+ size_bytes: 1024
22
+ permissions: read/write
23
+ c_parameter: int32_t a0[256]
24
+ description: Input polynomial / output low-part (256 x int32_t)
25
+ */
26
+
27
+ #include "../../../common.h"
28
+
29
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && !defined(MLD_CONFIG_NO_SIGN_API) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
30
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87))
31
+
32
+ /*
33
+ * WARNING: This file is auto-derived from the mldsa-native source file
34
+ * dev/aarch64_opt/src/mldsa_poly_decompose_32_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
35
+ */
36
+
37
+ .text
38
+ .balign 4
39
+ .global MLD_ASM_NAMESPACE(poly_decompose_32_aarch64_asm)
40
+ MLD_ASM_FN_SYMBOL(poly_decompose_32_aarch64_asm)
41
+
42
+ .cfi_startproc
43
+ mov w4, #0xe001 // =57345
44
+ movk w4, #0x7f, lsl #16
45
+ dup v20.4s, w4
46
+ mov w5, #0xe100 // =57600
47
+ movk w5, #0x7b, lsl #16
48
+ dup v21.4s, w5
49
+ mov w7, #0xfe00 // =65024
50
+ movk w7, #0x7, lsl #16
51
+ dup v22.4s, w7
52
+ mov w11, #0x401 // =1025
53
+ movk w11, #0x4010, lsl #16
54
+ dup v23.4s, w11
55
+ mov x3, #0x10 // =16
56
+
57
+ Lmld_poly_decompose_32_loop:
58
+ ldr q0, [x1]
59
+ ldr q1, [x1, #0x10]
60
+ ldr q2, [x1, #0x20]
61
+ ldr q3, [x1, #0x30]
62
+ sqdmulh v5.4s, v1.4s, v23.4s
63
+ srshr v5.4s, v5.4s, #0x12
64
+ cmgt v24.4s, v1.4s, v21.4s
65
+ mls v1.4s, v5.4s, v22.4s
66
+ bic v5.16b, v5.16b, v24.16b
67
+ add v1.4s, v1.4s, v24.4s
68
+ sqdmulh v6.4s, v2.4s, v23.4s
69
+ srshr v6.4s, v6.4s, #0x12
70
+ cmgt v24.4s, v2.4s, v21.4s
71
+ mls v2.4s, v6.4s, v22.4s
72
+ bic v6.16b, v6.16b, v24.16b
73
+ add v2.4s, v2.4s, v24.4s
74
+ sqdmulh v7.4s, v3.4s, v23.4s
75
+ srshr v7.4s, v7.4s, #0x12
76
+ cmgt v24.4s, v3.4s, v21.4s
77
+ mls v3.4s, v7.4s, v22.4s
78
+ bic v7.16b, v7.16b, v24.16b
79
+ add v3.4s, v3.4s, v24.4s
80
+ sqdmulh v4.4s, v0.4s, v23.4s
81
+ srshr v4.4s, v4.4s, #0x12
82
+ cmgt v24.4s, v0.4s, v21.4s
83
+ mls v0.4s, v4.4s, v22.4s
84
+ bic v4.16b, v4.16b, v24.16b
85
+ add v0.4s, v0.4s, v24.4s
86
+ str q5, [x0, #0x10]
87
+ str q6, [x0, #0x20]
88
+ str q7, [x0, #0x30]
89
+ str q4, [x0], #0x40
90
+ str q1, [x1, #0x10]
91
+ str q2, [x1, #0x20]
92
+ str q3, [x1, #0x30]
93
+ str q0, [x1], #0x40
94
+ subs x3, x3, #0x1
95
+ b.ne Lmld_poly_decompose_32_loop
96
+ ret
97
+ .cfi_endproc
98
+
99
+ MLD_ASM_FN_SIZE(poly_decompose_32_aarch64_asm)
100
+
101
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_NO_SIGN_API && \
102
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
103
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
104
+ || MLD_CONFIG_PARAMETER_SET == 87) */
105
+
106
+ #if defined(__ELF__)
107
+ .section .note.GNU-stack,"",%progbits
108
+ #endif
@@ -0,0 +1,108 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ /*yaml
6
+ Name: poly_decompose_88_aarch64_asm
7
+ Description: AArch64 coefficient decomposition (alpha = (Q-1)/88)
8
+ Signature: void mld_poly_decompose_88_aarch64_asm(int32_t a1[256], int32_t a0[256])
9
+ ABI:
10
+ Architecture: aarch64
11
+ CallingConvention: AAPCS64
12
+ Features: [NEON]
13
+ x0:
14
+ type: buffer
15
+ size_bytes: 1024
16
+ permissions: write-only
17
+ c_parameter: int32_t a1[256]
18
+ description: Output high-part polynomial (256 x int32_t)
19
+ x1:
20
+ type: buffer
21
+ size_bytes: 1024
22
+ permissions: read/write
23
+ c_parameter: int32_t a0[256]
24
+ description: Input polynomial / output low-part (256 x int32_t)
25
+ */
26
+
27
+ #include "../../../common.h"
28
+
29
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && !defined(MLD_CONFIG_NO_SIGN_API) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
30
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44)
31
+
32
+ /*
33
+ * WARNING: This file is auto-derived from the mldsa-native source file
34
+ * dev/aarch64_opt/src/mldsa_poly_decompose_88_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
35
+ */
36
+
37
+ .text
38
+ .balign 4
39
+ .global MLD_ASM_NAMESPACE(poly_decompose_88_aarch64_asm)
40
+ MLD_ASM_FN_SYMBOL(poly_decompose_88_aarch64_asm)
41
+
42
+ .cfi_startproc
43
+ mov w4, #0xe001 // =57345
44
+ movk w4, #0x7f, lsl #16
45
+ dup v20.4s, w4
46
+ mov w5, #0x6c00 // =27648
47
+ movk w5, #0x7e, lsl #16
48
+ dup v21.4s, w5
49
+ mov w7, #0xe800 // =59392
50
+ movk w7, #0x2, lsl #16
51
+ dup v22.4s, w7
52
+ mov w11, #0x581 // =1409
53
+ movk w11, #0x5816, lsl #16
54
+ dup v23.4s, w11
55
+ mov x3, #0x10 // =16
56
+
57
+ Lmld_poly_decompose_88_loop:
58
+ ldr q0, [x1]
59
+ ldr q1, [x1, #0x10]
60
+ ldr q2, [x1, #0x20]
61
+ ldr q3, [x1, #0x30]
62
+ sqdmulh v5.4s, v1.4s, v23.4s
63
+ srshr v5.4s, v5.4s, #0x11
64
+ cmgt v24.4s, v1.4s, v21.4s
65
+ mls v1.4s, v5.4s, v22.4s
66
+ bic v5.16b, v5.16b, v24.16b
67
+ add v1.4s, v1.4s, v24.4s
68
+ sqdmulh v6.4s, v2.4s, v23.4s
69
+ srshr v6.4s, v6.4s, #0x11
70
+ cmgt v24.4s, v2.4s, v21.4s
71
+ mls v2.4s, v6.4s, v22.4s
72
+ bic v6.16b, v6.16b, v24.16b
73
+ add v2.4s, v2.4s, v24.4s
74
+ sqdmulh v7.4s, v3.4s, v23.4s
75
+ srshr v7.4s, v7.4s, #0x11
76
+ cmgt v24.4s, v3.4s, v21.4s
77
+ mls v3.4s, v7.4s, v22.4s
78
+ bic v7.16b, v7.16b, v24.16b
79
+ add v3.4s, v3.4s, v24.4s
80
+ sqdmulh v4.4s, v0.4s, v23.4s
81
+ srshr v4.4s, v4.4s, #0x11
82
+ cmgt v24.4s, v0.4s, v21.4s
83
+ mls v0.4s, v4.4s, v22.4s
84
+ bic v4.16b, v4.16b, v24.16b
85
+ add v0.4s, v0.4s, v24.4s
86
+ str q5, [x0, #0x10]
87
+ str q6, [x0, #0x20]
88
+ str q7, [x0, #0x30]
89
+ str q4, [x0], #0x40
90
+ str q1, [x1, #0x10]
91
+ str q2, [x1, #0x20]
92
+ str q3, [x1, #0x30]
93
+ str q0, [x1], #0x40
94
+ subs x3, x3, #0x1
95
+ b.ne Lmld_poly_decompose_88_loop
96
+ ret
97
+ .cfi_endproc
98
+
99
+ MLD_ASM_FN_SIZE(poly_decompose_88_aarch64_asm)
100
+
101
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_NO_SIGN_API && \
102
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
103
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44) \
104
+ */
105
+
106
+ #if defined(__ELF__)
107
+ .section .note.GNU-stack,"",%progbits
108
+ #endif
@@ -0,0 +1,125 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ /*yaml
6
+ Name: poly_use_hint_32_aarch64_asm
7
+ Description: AArch64 hint application (alpha = (Q-1)/32)
8
+ Signature: void mld_poly_use_hint_32_aarch64_asm(int32_t a[256], const int32_t h[256])
9
+ ABI:
10
+ Architecture: aarch64
11
+ CallingConvention: AAPCS64
12
+ Features: [NEON]
13
+ x0:
14
+ type: buffer
15
+ size_bytes: 1024
16
+ permissions: read/write
17
+ c_parameter: int32_t a[256]
18
+ description: Input/output polynomial (256 x int32_t)
19
+ x1:
20
+ type: buffer
21
+ size_bytes: 1024
22
+ permissions: read-only
23
+ c_parameter: const int32_t h[256]
24
+ description: Hint polynomial (256 x int32_t)
25
+ */
26
+
27
+ #include "../../../common.h"
28
+
29
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && !defined(MLD_CONFIG_NO_VERIFY_API) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
30
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87))
31
+
32
+ /*
33
+ * WARNING: This file is auto-derived from the mldsa-native source file
34
+ * dev/aarch64_opt/src/mldsa_poly_use_hint_32_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
35
+ */
36
+
37
+ .text
38
+ .balign 4
39
+ .global MLD_ASM_NAMESPACE(poly_use_hint_32_aarch64_asm)
40
+ MLD_ASM_FN_SYMBOL(poly_use_hint_32_aarch64_asm)
41
+
42
+ .cfi_startproc
43
+ mov w4, #0xe001 // =57345
44
+ movk w4, #0x7f, lsl #16
45
+ dup v20.4s, w4
46
+ mov w5, #0xe100 // =57600
47
+ movk w5, #0x7b, lsl #16
48
+ dup v21.4s, w5
49
+ mov w7, #0xfe00 // =65024
50
+ movk w7, #0x7, lsl #16
51
+ dup v22.4s, w7
52
+ mov w11, #0x401 // =1025
53
+ movk w11, #0x4010, lsl #16
54
+ dup v23.4s, w11
55
+ movi v24.4s, #0xf
56
+ mov x3, #0x10 // =16
57
+
58
+ Lmld_poly_use_hint_32_loop:
59
+ ldr q1, [x0, #0x10]
60
+ ldr q2, [x0, #0x20]
61
+ ldr q3, [x0, #0x30]
62
+ ldr q0, [x0]
63
+ ldr q5, [x1, #0x10]
64
+ ldr q6, [x1, #0x20]
65
+ ldr q7, [x1, #0x30]
66
+ ldr q4, [x1], #0x40
67
+ sqdmulh v17.4s, v1.4s, v23.4s
68
+ srshr v17.4s, v17.4s, #0x12
69
+ cmgt v25.4s, v1.4s, v21.4s
70
+ mls v1.4s, v17.4s, v22.4s
71
+ bic v17.16b, v17.16b, v25.16b
72
+ add v1.4s, v1.4s, v25.4s
73
+ cmle v1.4s, v1.4s, #0
74
+ orr v1.4s, #0x1
75
+ mla v17.4s, v1.4s, v5.4s
76
+ and v17.16b, v17.16b, v24.16b
77
+ sqdmulh v18.4s, v2.4s, v23.4s
78
+ srshr v18.4s, v18.4s, #0x12
79
+ cmgt v25.4s, v2.4s, v21.4s
80
+ mls v2.4s, v18.4s, v22.4s
81
+ bic v18.16b, v18.16b, v25.16b
82
+ add v2.4s, v2.4s, v25.4s
83
+ cmle v2.4s, v2.4s, #0
84
+ orr v2.4s, #0x1
85
+ mla v18.4s, v2.4s, v6.4s
86
+ and v18.16b, v18.16b, v24.16b
87
+ sqdmulh v19.4s, v3.4s, v23.4s
88
+ srshr v19.4s, v19.4s, #0x12
89
+ cmgt v25.4s, v3.4s, v21.4s
90
+ mls v3.4s, v19.4s, v22.4s
91
+ bic v19.16b, v19.16b, v25.16b
92
+ add v3.4s, v3.4s, v25.4s
93
+ cmle v3.4s, v3.4s, #0
94
+ orr v3.4s, #0x1
95
+ mla v19.4s, v3.4s, v7.4s
96
+ and v19.16b, v19.16b, v24.16b
97
+ sqdmulh v16.4s, v0.4s, v23.4s
98
+ srshr v16.4s, v16.4s, #0x12
99
+ cmgt v25.4s, v0.4s, v21.4s
100
+ mls v0.4s, v16.4s, v22.4s
101
+ bic v16.16b, v16.16b, v25.16b
102
+ add v0.4s, v0.4s, v25.4s
103
+ cmle v0.4s, v0.4s, #0
104
+ orr v0.4s, #0x1
105
+ mla v16.4s, v0.4s, v4.4s
106
+ and v16.16b, v16.16b, v24.16b
107
+ str q17, [x0, #0x10]
108
+ str q18, [x0, #0x20]
109
+ str q19, [x0, #0x30]
110
+ str q16, [x0], #0x40
111
+ subs x3, x3, #0x1
112
+ b.ne Lmld_poly_use_hint_32_loop
113
+ ret
114
+ .cfi_endproc
115
+
116
+ MLD_ASM_FN_SIZE(poly_use_hint_32_aarch64_asm)
117
+
118
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_NO_VERIFY_API && \
119
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
120
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
121
+ || MLD_CONFIG_PARAMETER_SET == 87) */
122
+
123
+ #if defined(__ELF__)
124
+ .section .note.GNU-stack,"",%progbits
125
+ #endif