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,103 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * Copyright (c) The mlkem-native project authors
4
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
+ */
6
+
7
+ /*yaml
8
+ Name: polyz_unpack_17_aarch64_asm
9
+ Description: AArch64 unpacking of 17-bit packed coefficients
10
+ Signature: void mld_polyz_unpack_17_aarch64_asm(int32_t r[256], const uint8_t buf[576], const uint8_t indices[64])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output polynomial (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: 576
24
+ permissions: read-only
25
+ c_parameter: const uint8_t buf[576]
26
+ description: Packed input bytes
27
+ x2:
28
+ type: buffer
29
+ size_bytes: 64
30
+ permissions: read-only
31
+ c_parameter: const uint8_t indices[64]
32
+ description: Permutation index table (64 x uint8_t)
33
+ */
34
+
35
+ #include "../../../common.h"
36
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && \
37
+ (!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)) && \
38
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
39
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44)
40
+
41
+ /*
42
+ * WARNING: This file is auto-derived from the mldsa-native source file
43
+ * dev/aarch64_opt/src/mldsa_polyz_unpack_17_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
44
+ */
45
+
46
+ .text
47
+ .balign 4
48
+ .global MLD_ASM_NAMESPACE(polyz_unpack_17_aarch64_asm)
49
+ MLD_ASM_FN_SYMBOL(polyz_unpack_17_aarch64_asm)
50
+
51
+ .cfi_startproc
52
+ ldr q24, [x2]
53
+ ldr q25, [x2, #0x10]
54
+ ldr q26, [x2, #0x20]
55
+ ldr q27, [x2, #0x30]
56
+ mov x3, #0xfe00000000 // =1090921693184
57
+ mov v28.d[0], x3
58
+ mov x3, #0xfc // =252
59
+ movk x3, #0xfa, lsl #32
60
+ mov v28.d[1], x3
61
+ movi v29.4s, #0x3, msl #16
62
+ movi v30.4s, #0x2, lsl #16
63
+ mov x9, #0x10 // =16
64
+
65
+ Lmld_polyz_unpack_17_loop:
66
+ ld1 { v0.16b, v1.16b }, [x1]
67
+ add x1, x1, #0x14
68
+ ld1 { v2.16b }, [x1], #16
69
+ tbl v4.16b, { v0.16b }, v24.16b
70
+ tbl v5.16b, { v0.16b, v1.16b }, v25.16b
71
+ tbl v6.16b, { v1.16b }, v26.16b
72
+ tbl v7.16b, { v1.16b, v2.16b }, v27.16b
73
+ ushl v4.4s, v4.4s, v28.4s
74
+ and v4.16b, v4.16b, v29.16b
75
+ sub v4.4s, v30.4s, v4.4s
76
+ ushl v5.4s, v5.4s, v28.4s
77
+ and v5.16b, v5.16b, v29.16b
78
+ sub v5.4s, v30.4s, v5.4s
79
+ ushl v6.4s, v6.4s, v28.4s
80
+ and v6.16b, v6.16b, v29.16b
81
+ sub v6.4s, v30.4s, v6.4s
82
+ ushl v7.4s, v7.4s, v28.4s
83
+ and v7.16b, v7.16b, v29.16b
84
+ sub v7.4s, v30.4s, v7.4s
85
+ str q5, [x0, #0x10]
86
+ str q6, [x0, #0x20]
87
+ str q7, [x0, #0x30]
88
+ str q4, [x0], #0x40
89
+ subs x9, x9, #0x1
90
+ b.ne Lmld_polyz_unpack_17_loop
91
+ ret
92
+ .cfi_endproc
93
+
94
+ MLD_ASM_FN_SIZE(polyz_unpack_17_aarch64_asm)
95
+
96
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && (!MLD_CONFIG_NO_SIGN_API || \
97
+ !MLD_CONFIG_NO_VERIFY_API) && !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
98
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 44) \
99
+ */
100
+
101
+ #if defined(__ELF__)
102
+ .section .note.GNU-stack,"",%progbits
103
+ #endif
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * Copyright (c) The mlkem-native project authors
4
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
+ */
6
+
7
+ /*yaml
8
+ Name: polyz_unpack_19_aarch64_asm
9
+ Description: AArch64 unpacking of 19-bit packed coefficients
10
+ Signature: void mld_polyz_unpack_19_aarch64_asm(int32_t r[256], const uint8_t buf[640], const uint8_t indices[64])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output polynomial (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: 640
24
+ permissions: read-only
25
+ c_parameter: const uint8_t buf[640]
26
+ description: Packed input bytes
27
+ x2:
28
+ type: buffer
29
+ size_bytes: 64
30
+ permissions: read-only
31
+ c_parameter: const uint8_t indices[64]
32
+ description: Permutation index table (64 x uint8_t)
33
+ */
34
+
35
+ #include "../../../common.h"
36
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && \
37
+ (!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)) && \
38
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
39
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87))
40
+
41
+ /*
42
+ * WARNING: This file is auto-derived from the mldsa-native source file
43
+ * dev/aarch64_opt/src/mldsa_polyz_unpack_19_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
44
+ */
45
+
46
+ .text
47
+ .balign 4
48
+ .global MLD_ASM_NAMESPACE(polyz_unpack_19_aarch64_asm)
49
+ MLD_ASM_FN_SYMBOL(polyz_unpack_19_aarch64_asm)
50
+
51
+ .cfi_startproc
52
+ ldr q24, [x2]
53
+ ldr q25, [x2, #0x10]
54
+ ldr q26, [x2, #0x20]
55
+ ldr q27, [x2, #0x30]
56
+ mov x3, #0xfc00000000 // =1082331758592
57
+ dup v28.2d, x3
58
+ movi v29.4s, #0xf, msl #16
59
+ movi v30.4s, #0x8, lsl #16
60
+ mov x9, #0x10 // =16
61
+
62
+ Lmld_polyz_unpack_19_loop:
63
+ ld1 { v0.16b, v1.16b }, [x1]
64
+ add x1, x1, #0x18
65
+ ld1 { v2.16b }, [x1], #16
66
+ tbl v4.16b, { v0.16b }, v24.16b
67
+ tbl v5.16b, { v0.16b, v1.16b }, v25.16b
68
+ tbl v6.16b, { v1.16b }, v26.16b
69
+ tbl v7.16b, { v1.16b, v2.16b }, v27.16b
70
+ ushl v4.4s, v4.4s, v28.4s
71
+ and v4.16b, v4.16b, v29.16b
72
+ sub v4.4s, v30.4s, v4.4s
73
+ ushl v5.4s, v5.4s, v28.4s
74
+ and v5.16b, v5.16b, v29.16b
75
+ sub v5.4s, v30.4s, v5.4s
76
+ ushl v6.4s, v6.4s, v28.4s
77
+ and v6.16b, v6.16b, v29.16b
78
+ sub v6.4s, v30.4s, v6.4s
79
+ ushl v7.4s, v7.4s, v28.4s
80
+ and v7.16b, v7.16b, v29.16b
81
+ sub v7.4s, v30.4s, v7.4s
82
+ str q5, [x0, #0x10]
83
+ str q6, [x0, #0x20]
84
+ str q7, [x0, #0x30]
85
+ str q4, [x0], #0x40
86
+ subs x9, x9, #0x1
87
+ b.ne Lmld_polyz_unpack_19_loop
88
+ ret
89
+ .cfi_endproc
90
+
91
+ MLD_ASM_FN_SIZE(polyz_unpack_19_aarch64_asm)
92
+
93
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && (!MLD_CONFIG_NO_SIGN_API || \
94
+ !MLD_CONFIG_NO_VERIFY_API) && !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
95
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLD_CONFIG_PARAMETER_SET == 65 \
96
+ || MLD_CONFIG_PARAMETER_SET == 87) */
97
+
98
+ #if defined(__ELF__)
99
+ .section .note.GNU-stack,"",%progbits
100
+ #endif
@@ -0,0 +1,222 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * Copyright (c) The mlkem-native project authors
4
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
+ */
6
+
7
+ /*yaml
8
+ Name: rej_uniform_aarch64_asm
9
+ Description: AArch64 rejection sampling of uniform coefficients mod q
10
+ Signature: uint64_t mld_rej_uniform_aarch64_asm(int32_t r[256], const uint8_t *buf, unsigned buflen, const uint8_t table[256])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output buffer (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: x2
24
+ permissions: read-only
25
+ c_parameter: const uint8_t *buf
26
+ description: Input buffer
27
+ x2:
28
+ type: scalar
29
+ c_parameter: unsigned buflen
30
+ description: Length of input buffer (must be a multiple of 24)
31
+ test_with: 840 # MLD_POLY_UNIFORM_NBLOCKS * SHAKE128_RATE = 5 * 168
32
+ x3:
33
+ type: buffer
34
+ size_bytes: 256
35
+ permissions: read-only
36
+ c_parameter: const uint8_t table[256]
37
+ description: Lookup table (256 x uint8_t)
38
+ */
39
+
40
+ #include "../../../common.h"
41
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && \
42
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
43
+
44
+ /*
45
+ * WARNING: This file is auto-derived from the mldsa-native source file
46
+ * dev/aarch64_opt/src/mldsa_rej_uniform_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
47
+ */
48
+
49
+ .text
50
+ .balign 4
51
+ .global MLD_ASM_NAMESPACE(rej_uniform_aarch64_asm)
52
+ MLD_ASM_FN_SYMBOL(rej_uniform_aarch64_asm)
53
+
54
+ .cfi_startproc
55
+ sub sp, sp, #0x440
56
+ .cfi_adjust_cfa_offset 0x440
57
+ mov x7, #0x1 // =1
58
+ movk x7, #0x2, lsl #32
59
+ mov v31.d[0], x7
60
+ mov x7, #0x4 // =4
61
+ movk x7, #0x8, lsl #32
62
+ mov v31.d[1], x7
63
+ mov w7, #0xe001 // =57345
64
+ movk w7, #0x7f, lsl #16
65
+ dup v30.4s, w7
66
+ mov x8, sp
67
+ mov x7, x8
68
+ mov x11, #0x0 // =0
69
+ eor v16.16b, v16.16b, v16.16b
70
+
71
+ Lmld_rej_uniform_initial_zero:
72
+ str q16, [x7], #0x40
73
+ stur q16, [x7, #-0x30]
74
+ stur q16, [x7, #-0x20]
75
+ stur q16, [x7, #-0x10]
76
+ add x11, x11, #0x10
77
+ cmp x11, #0x100
78
+ b.lt Lmld_rej_uniform_initial_zero
79
+ mov x7, x8
80
+ mov x9, #0x0 // =0
81
+ mov x4, #0x100 // =256
82
+ cmp x2, #0x30
83
+ b.lo Lmld_rej_uniform_loop48_end
84
+
85
+ Lmld_rej_uniform_loop48:
86
+ cmp x9, x4
87
+ b.hs Lmld_rej_uniform_memory_copy
88
+ sub x2, x2, #0x30
89
+ ld3 { v0.16b, v1.16b, v2.16b }, [x1], #48
90
+ movi v4.16b, #0x80
91
+ bic v2.16b, v2.16b, v4.16b
92
+ zip1 v4.16b, v0.16b, v1.16b
93
+ zip2 v5.16b, v0.16b, v1.16b
94
+ ushll v6.8h, v2.8b, #0x0
95
+ ushll2 v7.8h, v2.16b, #0x0
96
+ zip1 v16.8h, v4.8h, v6.8h
97
+ zip2 v17.8h, v4.8h, v6.8h
98
+ zip1 v18.8h, v5.8h, v7.8h
99
+ zip2 v19.8h, v5.8h, v7.8h
100
+ cmhi v4.4s, v30.4s, v16.4s
101
+ cmhi v5.4s, v30.4s, v17.4s
102
+ cmhi v6.4s, v30.4s, v18.4s
103
+ cmhi v7.4s, v30.4s, v19.4s
104
+ and v4.16b, v4.16b, v31.16b
105
+ and v5.16b, v5.16b, v31.16b
106
+ and v6.16b, v6.16b, v31.16b
107
+ and v7.16b, v7.16b, v31.16b
108
+ uaddlv d20, v4.4s
109
+ uaddlv d21, v5.4s
110
+ uaddlv d22, v6.4s
111
+ uaddlv d23, v7.4s
112
+ fmov x12, d20
113
+ fmov x13, d21
114
+ fmov x14, d22
115
+ fmov x15, d23
116
+ ldr q24, [x3, x12, lsl #4]
117
+ ldr q25, [x3, x13, lsl #4]
118
+ ldr q26, [x3, x14, lsl #4]
119
+ ldr q27, [x3, x15, lsl #4]
120
+ cnt v4.16b, v4.16b
121
+ cnt v5.16b, v5.16b
122
+ cnt v6.16b, v6.16b
123
+ cnt v7.16b, v7.16b
124
+ uaddlv d20, v4.4s
125
+ uaddlv d21, v5.4s
126
+ uaddlv d22, v6.4s
127
+ uaddlv d23, v7.4s
128
+ fmov x12, d20
129
+ fmov x13, d21
130
+ fmov x14, d22
131
+ fmov x15, d23
132
+ tbl v16.16b, { v16.16b }, v24.16b
133
+ tbl v17.16b, { v17.16b }, v25.16b
134
+ tbl v18.16b, { v18.16b }, v26.16b
135
+ tbl v19.16b, { v19.16b }, v27.16b
136
+ st1 { v16.4s }, [x7]
137
+ add x7, x7, x12, lsl #2
138
+ st1 { v17.4s }, [x7]
139
+ add x7, x7, x13, lsl #2
140
+ st1 { v18.4s }, [x7]
141
+ add x7, x7, x14, lsl #2
142
+ st1 { v19.4s }, [x7]
143
+ add x7, x7, x15, lsl #2
144
+ add x12, x12, x13
145
+ add x14, x14, x15
146
+ add x9, x9, x12
147
+ add x9, x9, x14
148
+ cmp x2, #0x30
149
+ b.hs Lmld_rej_uniform_loop48
150
+
151
+ Lmld_rej_uniform_loop48_end:
152
+ cmp x9, x4
153
+ b.hs Lmld_rej_uniform_memory_copy
154
+ cmp x2, #0x18
155
+ b.lo Lmld_rej_uniform_memory_copy
156
+ sub x2, x2, #0x18
157
+ ld3 { v0.8b, v1.8b, v2.8b }, [x1], #24
158
+ movi v4.16b, #0x80
159
+ bic v2.16b, v2.16b, v4.16b
160
+ zip1 v4.16b, v0.16b, v1.16b
161
+ ushll v6.8h, v2.8b, #0x0
162
+ zip1 v16.8h, v4.8h, v6.8h
163
+ zip2 v17.8h, v4.8h, v6.8h
164
+ cmhi v4.4s, v30.4s, v16.4s
165
+ cmhi v5.4s, v30.4s, v17.4s
166
+ and v4.16b, v4.16b, v31.16b
167
+ and v5.16b, v5.16b, v31.16b
168
+ uaddlv d20, v4.4s
169
+ uaddlv d21, v5.4s
170
+ fmov x12, d20
171
+ fmov x13, d21
172
+ ldr q24, [x3, x12, lsl #4]
173
+ ldr q25, [x3, x13, lsl #4]
174
+ cnt v4.16b, v4.16b
175
+ cnt v5.16b, v5.16b
176
+ uaddlv d20, v4.4s
177
+ uaddlv d21, v5.4s
178
+ fmov x12, d20
179
+ fmov x13, d21
180
+ tbl v16.16b, { v16.16b }, v24.16b
181
+ tbl v17.16b, { v17.16b }, v25.16b
182
+ st1 { v16.4s }, [x7]
183
+ add x7, x7, x12, lsl #2
184
+ st1 { v17.4s }, [x7]
185
+ add x7, x7, x13, lsl #2
186
+ add x9, x9, x12
187
+ add x9, x9, x13
188
+
189
+ Lmld_rej_uniform_memory_copy:
190
+ cmp x9, x4
191
+ csel x9, x9, x4, lo
192
+ mov x11, #0x0 // =0
193
+ mov x7, x8
194
+
195
+ Lmld_rej_uniform_final_copy:
196
+ ldr q16, [x7], #0x40
197
+ ldur q17, [x7, #-0x30]
198
+ ldur q18, [x7, #-0x20]
199
+ ldur q19, [x7, #-0x10]
200
+ str q16, [x0], #0x40
201
+ stur q17, [x0, #-0x30]
202
+ stur q18, [x0, #-0x20]
203
+ stur q19, [x0, #-0x10]
204
+ add x11, x11, #0x10
205
+ cmp x11, #0x100
206
+ b.lt Lmld_rej_uniform_final_copy
207
+ mov x0, x9
208
+ b Lmld_rej_uniform_return
209
+
210
+ Lmld_rej_uniform_return:
211
+ add sp, sp, #0x440
212
+ .cfi_adjust_cfa_offset -0x440
213
+ ret
214
+ .cfi_endproc
215
+
216
+ MLD_ASM_FN_SIZE(rej_uniform_aarch64_asm)
217
+
218
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_MULTILEVEL_NO_SHARED */
219
+
220
+ #if defined(__ELF__)
221
+ .section .note.GNU-stack,"",%progbits
222
+ #endif
@@ -0,0 +1,170 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * Copyright (c) The mlkem-native project authors
4
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
+ */
6
+
7
+ /*yaml
8
+ Name: rej_uniform_eta2_aarch64_asm
9
+ Description: AArch64 rejection sampling of eta=2 secret coefficients
10
+ Signature: uint64_t mld_rej_uniform_eta2_aarch64_asm(int32_t r[256], const uint8_t *buf, unsigned buflen, const uint8_t table[4096])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output buffer (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: x2
24
+ permissions: read-only
25
+ c_parameter: const uint8_t *buf
26
+ description: Input buffer
27
+ x2:
28
+ type: scalar
29
+ c_parameter: unsigned buflen
30
+ description: Length of input buffer (must be a multiple of 8)
31
+ test_with: 136 # MLD_AARCH64_REJ_UNIFORM_ETA2_BUFLEN
32
+ x3:
33
+ type: buffer
34
+ size_bytes: 4096
35
+ permissions: read-only
36
+ c_parameter: const uint8_t table[4096]
37
+ description: Lookup table (4096 x uint8_t)
38
+ */
39
+
40
+ #include "../../../common.h"
41
+ #if defined(MLD_ARITH_BACKEND_AARCH64) && \
42
+ !defined(MLD_CONFIG_NO_KEYPAIR_API) && \
43
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
44
+ (defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLDSA_ETA == 2)
45
+
46
+ /*
47
+ * WARNING: This file is auto-derived from the mldsa-native source file
48
+ * dev/aarch64_opt/src/mldsa_rej_uniform_eta2_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
49
+ */
50
+
51
+ .text
52
+ .balign 4
53
+ .global MLD_ASM_NAMESPACE(rej_uniform_eta2_aarch64_asm)
54
+ MLD_ASM_FN_SYMBOL(rej_uniform_eta2_aarch64_asm)
55
+
56
+ .cfi_startproc
57
+ sub sp, sp, #0x240
58
+ .cfi_adjust_cfa_offset 0x240
59
+ mov x7, #0x1 // =1
60
+ movk x7, #0x2, lsl #16
61
+ movk x7, #0x4, lsl #32
62
+ movk x7, #0x8, lsl #48
63
+ mov v31.d[0], x7
64
+ mov x7, #0x10 // =16
65
+ movk x7, #0x20, lsl #16
66
+ movk x7, #0x40, lsl #32
67
+ movk x7, #0x80, lsl #48
68
+ mov v31.d[1], x7
69
+ movi v30.8h, #0xf
70
+ mov x8, sp
71
+ mov x7, x8
72
+ mov x11, #0x0 // =0
73
+ eor v16.16b, v16.16b, v16.16b
74
+
75
+ Lmld_rej_uniform_eta2_initial_zero:
76
+ str q16, [x7], #0x40
77
+ stur q16, [x7, #-0x30]
78
+ stur q16, [x7, #-0x20]
79
+ stur q16, [x7, #-0x10]
80
+ add x11, x11, #0x20
81
+ cmp x11, #0x100
82
+ b.lt Lmld_rej_uniform_eta2_initial_zero
83
+ mov x7, x8
84
+ mov x9, #0x0 // =0
85
+ mov x4, #0x100 // =256
86
+
87
+ Lmld_rej_uniform_eta2_loop8:
88
+ cmp x9, x4
89
+ b.hs Lmld_rej_uniform_eta2_memory_copy
90
+ sub x2, x2, #0x8
91
+ ld1 { v0.8b }, [x1], #8
92
+ movi v26.8b, #0xf
93
+ and v27.8b, v0.8b, v26.8b
94
+ ushr v28.8b, v0.8b, #0x4
95
+ zip1 v26.8b, v27.8b, v28.8b
96
+ zip2 v29.8b, v27.8b, v28.8b
97
+ ushll v16.8h, v26.8b, #0x0
98
+ ushll v17.8h, v29.8b, #0x0
99
+ cmhi v4.8h, v30.8h, v16.8h
100
+ cmhi v5.8h, v30.8h, v17.8h
101
+ and v4.16b, v4.16b, v31.16b
102
+ and v5.16b, v5.16b, v31.16b
103
+ uaddlv s20, v4.8h
104
+ uaddlv s21, v5.8h
105
+ fmov w12, s20
106
+ fmov w13, s21
107
+ ldr q24, [x3, x12, lsl #4]
108
+ ldr q25, [x3, x13, lsl #4]
109
+ cnt v4.16b, v4.16b
110
+ cnt v5.16b, v5.16b
111
+ uaddlv s20, v4.8h
112
+ uaddlv s21, v5.8h
113
+ fmov w12, s20
114
+ fmov w13, s21
115
+ tbl v16.16b, { v16.16b }, v24.16b
116
+ tbl v17.16b, { v17.16b }, v25.16b
117
+ st1 { v16.8h }, [x7]
118
+ add x7, x7, x12, lsl #1
119
+ st1 { v17.8h }, [x7]
120
+ add x7, x7, x13, lsl #1
121
+ add x12, x12, x13
122
+ add x9, x9, x12
123
+ cmp x2, #0x8
124
+ b.hs Lmld_rej_uniform_eta2_loop8
125
+
126
+ Lmld_rej_uniform_eta2_memory_copy:
127
+ cmp x9, x4
128
+ csel x9, x9, x4, lo
129
+ mov w7, #0x199a // =6554
130
+ dup v26.8h, w7
131
+ movi v27.8h, #0x5
132
+ movi v7.8h, #0x2
133
+ mov x11, #0x0 // =0
134
+ mov x7, x8
135
+
136
+ Lmld_rej_uniform_eta2_final_copy:
137
+ ldr q16, [x7], #0x20
138
+ ldur q18, [x7, #-0x10]
139
+ sqdmulh v28.8h, v16.8h, v26.8h
140
+ mls v16.8h, v28.8h, v27.8h
141
+ sqdmulh v28.8h, v18.8h, v26.8h
142
+ mls v18.8h, v28.8h, v27.8h
143
+ sub v16.8h, v7.8h, v16.8h
144
+ sub v18.8h, v7.8h, v18.8h
145
+ sshll2 v17.4s, v16.8h, #0x0
146
+ sshll v16.4s, v16.4h, #0x0
147
+ sshll2 v19.4s, v18.8h, #0x0
148
+ sshll v18.4s, v18.4h, #0x0
149
+ str q16, [x0], #0x40
150
+ stur q17, [x0, #-0x30]
151
+ stur q18, [x0, #-0x20]
152
+ stur q19, [x0, #-0x10]
153
+ add x11, x11, #0x10
154
+ cmp x11, #0x100
155
+ b.lt Lmld_rej_uniform_eta2_final_copy
156
+ mov x0, x9
157
+ add sp, sp, #0x240
158
+ .cfi_adjust_cfa_offset -0x240
159
+ ret
160
+ .cfi_endproc
161
+
162
+ MLD_ASM_FN_SIZE(rej_uniform_eta2_aarch64_asm)
163
+
164
+ #endif /* MLD_ARITH_BACKEND_AARCH64 && !MLD_CONFIG_NO_KEYPAIR_API && \
165
+ !MLD_CONFIG_MULTILEVEL_NO_SHARED && \
166
+ (MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 2) */
167
+
168
+ #if defined(__ELF__)
169
+ .section .note.GNU-stack,"",%progbits
170
+ #endif