pq_crypto 0.6.4 → 0.6.6

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 (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +180 -0
  3. data/README.md +7 -0
  4. data/ext/pqcrypto/extconf.rb +4 -1
  5. data/ext/pqcrypto/pq_externalmu.c +35 -0
  6. data/ext/pqcrypto/pqcrypto_native_api.h +85 -75
  7. data/ext/pqcrypto/pqcrypto_ruby_secure.c +16 -9
  8. data/ext/pqcrypto/pqcrypto_secure.c +43 -33
  9. data/ext/pqcrypto/pqcrypto_secure.h +52 -47
  10. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  11. data/ext/pqcrypto/vendor/.vendored +7 -7
  12. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +5 -2
  13. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +21 -2
  14. data/ext/pqcrypto/vendor/mldsa-native/README.md +20 -7
  15. data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +160 -0
  16. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +1 -1
  17. data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +2 -2
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +85 -59
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +292 -348
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +122 -76
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +184 -86
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +49 -4
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +49 -81
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +152 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +25 -12
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +2 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +2 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +2 -2
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +9 -11
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +19 -11
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +6 -4
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +7 -4
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +7 -4
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +12 -9
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +12 -9
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +1 -1
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +3 -2
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +3 -2
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +11 -11
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +9 -22
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +1 -0
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +5 -4
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +1 -0
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +62 -4
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +87 -54
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{intt_aarch64_asm.S → mldsa_intt_aarch64_asm.S} +39 -6
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{ntt_aarch64_asm.S → mldsa_ntt_aarch64_asm.S} +39 -6
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{pointwise_montgomery_aarch64_asm.S → mldsa_pointwise_montgomery_aarch64_asm.S} +25 -3
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_caddq_aarch64_asm.S → mldsa_poly_caddq_aarch64_asm.S} +19 -3
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_chknorm_aarch64_asm.S → mldsa_poly_chknorm_aarch64_asm.S} +24 -3
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_32_aarch64_asm.S → mldsa_poly_decompose_32_aarch64_asm.S} +25 -3
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_88_aarch64_asm.S → mldsa_poly_decompose_88_aarch64_asm.S} +25 -3
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_32_aarch64_asm.S → mldsa_poly_use_hint_32_aarch64_asm.S} +25 -3
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_88_aarch64_asm.S → mldsa_poly_use_hint_88_aarch64_asm.S} +25 -3
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S} +31 -3
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S} +31 -3
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S} +31 -3
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_17_aarch64_asm.S → mldsa_polyz_unpack_17_aarch64_asm.S} +31 -3
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_19_aarch64_asm.S → mldsa_polyz_unpack_19_aarch64_asm.S} +31 -3
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mldsa_rej_uniform_aarch64_asm.S} +48 -15
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta2_aarch64_asm.S → mldsa_rej_uniform_eta2_aarch64_asm.S} +42 -9
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta4_aarch64_asm.S → mldsa_rej_uniform_eta4_aarch64_asm.S} +42 -9
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +11 -3
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +3 -2
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +28 -28
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +171 -49
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{intt_avx2_asm.S → mldsa_intt_avx2_asm.S} +23 -1
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{ntt_avx2_asm.S → mldsa_ntt_avx2_asm.S} +23 -1
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{nttunpack_avx2_asm.S → mldsa_nttunpack_avx2_asm.S} +17 -1
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l4_avx2_asm.S → mldsa_pointwise_acc_l4_avx2_asm.S} +37 -3
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l5_avx2_asm.S → mldsa_pointwise_acc_l5_avx2_asm.S} +37 -3
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l7_avx2_asm.S → mldsa_pointwise_acc_l7_avx2_asm.S} +37 -3
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_avx2_asm.S → mldsa_pointwise_avx2_asm.S} +31 -3
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{poly_caddq_avx2_asm.S → mldsa_poly_caddq_avx2_asm.S} +18 -9
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +27 -36
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +42 -8
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +93 -17
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +74 -15
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +97 -11
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +7 -38
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +49 -7
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +16 -17
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +26 -9
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +3 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +18 -19
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +15 -3
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +28 -6
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +311 -246
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +245 -240
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +64 -5
  108. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +5 -2
  109. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +21 -3
  110. data/ext/pqcrypto/vendor/mlkem-native/README.md +4 -6
  111. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +211 -0
  112. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +2 -2
  113. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +25 -34
  114. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +79 -142
  115. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +62 -71
  116. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +77 -39
  117. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +25 -0
  118. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +48 -34
  119. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
  120. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
  121. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +51 -0
  122. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +2 -2
  123. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -8
  124. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
  125. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
  126. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
  127. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
  128. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
  129. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
  130. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +1 -1
  131. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +3 -2
  132. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +3 -2
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +11 -11
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +8 -22
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +20 -11
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +39 -11
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +64 -15
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_aarch64_asm.S → mlkem_poly_mulcache_compute_aarch64_asm.S} +6 -3
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +6 -3
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +6 -3
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +6 -3
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +45 -25
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10_avx2_asm.S → mlkem_poly_compress_d10_avx2_asm.S} +34 -3
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11_avx2_asm.S → mlkem_poly_compress_d11_avx2_asm.S} +33 -2
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4_avx2_asm.S → mlkem_poly_compress_d4_avx2_asm.S} +34 -3
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5_avx2_asm.S → mlkem_poly_compress_d5_avx2_asm.S} +33 -2
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10_avx2_asm.S → mlkem_poly_decompress_d10_avx2_asm.S} +32 -3
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11_avx2_asm.S → mlkem_poly_decompress_d11_avx2_asm.S} +32 -2
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4_avx2_asm.S → mlkem_poly_decompress_d4_avx2_asm.S} +32 -3
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5_avx2_asm.S → mlkem_poly_decompress_d5_avx2_asm.S} +32 -2
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_mulcache_compute_avx2_asm.S → mlkem_poly_mulcache_compute_avx2_asm.S} +29 -1
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +35 -1
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +35 -1
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +35 -1
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_avx2_asm.S → mlkem_rej_uniform_avx2_asm.S} +40 -7
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +21 -3
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +11 -10
  201. data/lib/pq_crypto/version.rb +1 -1
  202. data/script/vendor_libs.rb +6 -6
  203. metadata +79 -79
  204. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +0 -52
  205. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +0 -157
  206. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +0 -157
  207. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +0 -103
  208. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +0 -105
  209. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +0 -94
  210. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +0 -96
  211. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +0 -126
  212. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +0 -157
  213. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +0 -141
@@ -16,14 +16,15 @@
16
16
  #include "aarch64/auto.h"
17
17
  #endif
18
18
 
19
- #if defined(MLD_SYS_X86_64) && defined(MLD_SYS_X86_64_AVX2) && \
19
+ /* The x86_64 backend requires toolchain support for the SysV ABI */
20
+ #if defined(MLD_SYS_X86_64_AVX2) && defined(MLD_SYSV_ABI_SUPPORTED) && \
20
21
  (!defined(MLD_CONFIG_NO_KEYPAIR_API) || \
21
22
  !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_REDUCE_RAM)) && \
22
23
  !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
23
24
  #include "x86_64/keccak_f1600_x4_avx2.h"
24
- #endif /* MLD_SYS_X86_64 && MLD_SYS_X86_64_AVX2 && (!MLD_CONFIG_NO_KEYPAIR_API \
25
- || !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_REDUCE_RAM) && \
26
- !MLD_CONFIG_SERIAL_FIPS202_ONLY */
25
+ #endif /* MLD_SYS_X86_64_AVX2 && MLD_SYSV_ABI_SUPPORTED && \
26
+ (!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_NO_SIGN_API || \
27
+ !MLD_CONFIG_REDUCE_RAM) && !MLD_CONFIG_SERIAL_FIPS202_ONLY */
27
28
 
28
29
  /* We do not yet include the FIPS202 backend for Armv8.1-M+MVE by default
29
30
  * as it is still experimental and undergoing review. */
@@ -12,7 +12,7 @@
12
12
  #define MLD_FIPS202_X86_64_NEED_X4_AVX2
13
13
 
14
14
  /* Part of backend API */
15
- #define MLD_USE_FIPS202_X4_NATIVE
15
+ #define MLD_USE_NATIVE_FIPS202_X4
16
16
 
17
17
  #if !defined(__ASSEMBLER__)
18
18
  #include "../api.h"
@@ -20,7 +20,7 @@
20
20
  MLD_MUST_CHECK_RETURN_VALUE
21
21
  static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
22
22
  {
23
- if (!mld_sys_check_capability(MLD_SYS_CAP_AVX2))
23
+ if (!mld_sys_check_capability(MLD_SYS_CAP_X86_64_AVX2))
24
24
  {
25
25
  return MLD_NATIVE_FUNC_FALLBACK;
26
26
  }
@@ -28,6 +28,7 @@ MLD_INTERNAL_DATA_DECLARATION const uint64_t mld_keccak_rho8[4];
28
28
  MLD_INTERNAL_DATA_DECLARATION const uint64_t mld_keccak_rho56[4];
29
29
 
30
30
  #define mld_keccak_f1600_x4_avx2_asm MLD_NAMESPACE(keccak_f1600_x4_avx2_asm)
31
+ MLD_SYSV_ABI
31
32
  void mld_keccak_f1600_x4_avx2_asm(uint64_t states[100], const uint64_t rc[24],
32
33
  const uint64_t rho8[4],
33
34
  const uint64_t rho56[4])
@@ -3,6 +3,40 @@
3
3
  * Copyright (c) The mldsa-native project authors
4
4
  * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
5
  */
6
+ /*yaml
7
+ Name: keccak_f1600_x4_avx2_asm
8
+ Description: x86_64 AVX2 Keccak-f[1600] permutation for four sequential states
9
+ Signature: void mld_keccak_f1600_x4_avx2_asm(uint64_t states[100], const uint64_t rc[24], const uint64_t rho8[4], const uint64_t rho56[4])
10
+ ABI:
11
+ Architecture: x86_64
12
+ CallingConvention: SysV
13
+ Features: [AVX2]
14
+ rdi:
15
+ type: buffer
16
+ size_bytes: 800
17
+ permissions: read/write
18
+ c_parameter: uint64_t states[100]
19
+ description: Four sequential Keccak states (4 x 25 x uint64_t)
20
+ rsi:
21
+ type: buffer
22
+ size_bytes: 192
23
+ permissions: read-only
24
+ c_parameter: const uint64_t rc[24]
25
+ description: Round constants (24 x uint64_t)
26
+ rdx:
27
+ type: buffer
28
+ size_bytes: 32
29
+ permissions: read-only
30
+ c_parameter: const uint64_t rho8[4]
31
+ description: Rotation constant rho8 (4 x uint64_t)
32
+ rcx:
33
+ type: buffer
34
+ size_bytes: 32
35
+ permissions: read-only
36
+ c_parameter: const uint64_t rho56[4]
37
+ description: Rotation constant rho56 (4 x uint64_t)
38
+ */
39
+
6
40
  #include "../../../../common.h"
7
41
 
8
42
  #if defined(MLD_FIPS202_X86_64_NEED_X4_AVX2) && \
@@ -120,7 +154,7 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_avx2_asm)
120
154
  vinserti128 $0x1, %xmm0, %ymm1, %ymm2
121
155
  movq $0x0, %r10
122
156
 
123
- LLkeccak_f1600_x4_avx2_asm:
157
+ LLmld_keccak_f1600_x4_avx2_asm:
124
158
  vmovdqu 0xa0(%rsp), %ymm4
125
159
  vpxor 0x1c0(%rsp), %ymm9, %ymm0
126
160
  vmovdqu %ymm9, 0x200(%rsp)
@@ -344,7 +378,7 @@ LLkeccak_f1600_x4_avx2_asm:
344
378
  addq $0x8, %rsi
345
379
  addq $0x1, %r10
346
380
  cmpq $0x18, %r10
347
- jne LLkeccak_f1600_x4_avx2_asm
381
+ jne LLmld_keccak_f1600_x4_avx2_asm
348
382
  vmovdqu (%rsp), %ymm4
349
383
  vmovdqu 0x40(%rsp), %ymm5
350
384
  vmovdqu 0x20(%rsp), %ymm0
@@ -38,6 +38,10 @@
38
38
  MLD_MUST_CHECK_RETURN_VALUE
39
39
  static MLD_INLINE int mld_ntt_native(int32_t data[MLDSA_N])
40
40
  {
41
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
42
+ {
43
+ return MLD_NATIVE_FUNC_FALLBACK;
44
+ }
41
45
  mld_ntt_aarch64_asm(data, mld_aarch64_ntt_zetas_layer123456,
42
46
  mld_aarch64_ntt_zetas_layer78);
43
47
  return MLD_NATIVE_FUNC_SUCCESS;
@@ -46,6 +50,10 @@ static MLD_INLINE int mld_ntt_native(int32_t data[MLDSA_N])
46
50
  MLD_MUST_CHECK_RETURN_VALUE
47
51
  static MLD_INLINE int mld_intt_native(int32_t data[MLDSA_N])
48
52
  {
53
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
54
+ {
55
+ return MLD_NATIVE_FUNC_FALLBACK;
56
+ }
49
57
  mld_intt_aarch64_asm(data, mld_aarch64_intt_zetas_layer78,
50
58
  mld_aarch64_intt_zetas_layer123456);
51
59
  return MLD_NATIVE_FUNC_SUCCESS;
@@ -56,8 +64,8 @@ static MLD_INLINE int mld_rej_uniform_native(int32_t *r, unsigned len,
56
64
  const uint8_t *buf,
57
65
  unsigned buflen)
58
66
  {
59
- if (len != MLDSA_N ||
60
- buflen % 24 != 0) /* NEON support is mandatory for AArch64 */
67
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON) || len != MLDSA_N ||
68
+ buflen % 24 != 0)
61
69
  {
62
70
  return MLD_NATIVE_FUNC_FALLBACK;
63
71
  }
@@ -76,7 +84,8 @@ static MLD_INLINE int mld_rej_uniform_eta2_native(int32_t *r, unsigned len,
76
84
  {
77
85
  uint64_t outlen;
78
86
  /* AArch64 implementation assumes specific buffer lengths */
79
- if (len != MLDSA_N || buflen != MLD_AARCH64_REJ_UNIFORM_ETA2_BUFLEN)
87
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON) || len != MLDSA_N ||
88
+ buflen != MLD_AARCH64_REJ_UNIFORM_ETA2_BUFLEN)
80
89
  {
81
90
  return MLD_NATIVE_FUNC_FALLBACK;
82
91
  }
@@ -104,7 +113,8 @@ static MLD_INLINE int mld_rej_uniform_eta4_native(int32_t *r, unsigned len,
104
113
  {
105
114
  uint64_t outlen;
106
115
  /* AArch64 implementation assumes specific buffer lengths */
107
- if (len != MLDSA_N || buflen != MLD_AARCH64_REJ_UNIFORM_ETA4_BUFLEN)
116
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON) || len != MLDSA_N ||
117
+ buflen != MLD_AARCH64_REJ_UNIFORM_ETA4_BUFLEN)
108
118
  {
109
119
  return MLD_NATIVE_FUNC_FALLBACK;
110
120
  }
@@ -131,6 +141,10 @@ static MLD_INLINE int mld_rej_uniform_eta4_native(int32_t *r, unsigned len,
131
141
  MLD_MUST_CHECK_RETURN_VALUE
132
142
  static MLD_INLINE int mld_poly_decompose_32_native(int32_t *a1, int32_t *a0)
133
143
  {
144
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
145
+ {
146
+ return MLD_NATIVE_FUNC_FALLBACK;
147
+ }
134
148
  mld_poly_decompose_32_aarch64_asm(a1, a0);
135
149
  return MLD_NATIVE_FUNC_SUCCESS;
136
150
  }
@@ -141,6 +155,10 @@ static MLD_INLINE int mld_poly_decompose_32_native(int32_t *a1, int32_t *a0)
141
155
  MLD_MUST_CHECK_RETURN_VALUE
142
156
  static MLD_INLINE int mld_poly_decompose_88_native(int32_t *a1, int32_t *a0)
143
157
  {
158
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
159
+ {
160
+ return MLD_NATIVE_FUNC_FALLBACK;
161
+ }
144
162
  mld_poly_decompose_88_aarch64_asm(a1, a0);
145
163
  return MLD_NATIVE_FUNC_SUCCESS;
146
164
  }
@@ -151,6 +169,10 @@ static MLD_INLINE int mld_poly_decompose_88_native(int32_t *a1, int32_t *a0)
151
169
  MLD_MUST_CHECK_RETURN_VALUE
152
170
  static MLD_INLINE int mld_poly_caddq_native(int32_t a[MLDSA_N])
153
171
  {
172
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
173
+ {
174
+ return MLD_NATIVE_FUNC_FALLBACK;
175
+ }
154
176
  mld_poly_caddq_aarch64_asm(a);
155
177
  return MLD_NATIVE_FUNC_SUCCESS;
156
178
  }
@@ -161,6 +183,10 @@ static MLD_INLINE int mld_poly_caddq_native(int32_t a[MLDSA_N])
161
183
  MLD_MUST_CHECK_RETURN_VALUE
162
184
  static MLD_INLINE int mld_poly_use_hint_32_native(int32_t *a, const int32_t *h)
163
185
  {
186
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
187
+ {
188
+ return MLD_NATIVE_FUNC_FALLBACK;
189
+ }
164
190
  mld_poly_use_hint_32_aarch64_asm(a, h);
165
191
  return MLD_NATIVE_FUNC_SUCCESS;
166
192
  }
@@ -171,6 +197,10 @@ static MLD_INLINE int mld_poly_use_hint_32_native(int32_t *a, const int32_t *h)
171
197
  MLD_MUST_CHECK_RETURN_VALUE
172
198
  static MLD_INLINE int mld_poly_use_hint_88_native(int32_t *a, const int32_t *h)
173
199
  {
200
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
201
+ {
202
+ return MLD_NATIVE_FUNC_FALLBACK;
203
+ }
174
204
  mld_poly_use_hint_88_aarch64_asm(a, h);
175
205
  return MLD_NATIVE_FUNC_SUCCESS;
176
206
  }
@@ -181,6 +211,10 @@ static MLD_INLINE int mld_poly_use_hint_88_native(int32_t *a, const int32_t *h)
181
211
  MLD_MUST_CHECK_RETURN_VALUE
182
212
  static MLD_INLINE int mld_poly_chknorm_native(const int32_t *a, int32_t B)
183
213
  {
214
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
215
+ {
216
+ return MLD_NATIVE_FUNC_FALLBACK;
217
+ }
184
218
  return mld_poly_chknorm_aarch64_asm(a, B);
185
219
  }
186
220
 
@@ -189,6 +223,10 @@ static MLD_INLINE int mld_poly_chknorm_native(const int32_t *a, int32_t B)
189
223
  MLD_MUST_CHECK_RETURN_VALUE
190
224
  static MLD_INLINE int mld_polyz_unpack_17_native(int32_t *r, const uint8_t *buf)
191
225
  {
226
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
227
+ {
228
+ return MLD_NATIVE_FUNC_FALLBACK;
229
+ }
192
230
  mld_polyz_unpack_17_aarch64_asm(r, buf, mld_polyz_unpack_17_indices);
193
231
  return MLD_NATIVE_FUNC_SUCCESS;
194
232
  }
@@ -200,6 +238,10 @@ static MLD_INLINE int mld_polyz_unpack_17_native(int32_t *r, const uint8_t *buf)
200
238
  MLD_MUST_CHECK_RETURN_VALUE
201
239
  static MLD_INLINE int mld_polyz_unpack_19_native(int32_t *r, const uint8_t *buf)
202
240
  {
241
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
242
+ {
243
+ return MLD_NATIVE_FUNC_FALLBACK;
244
+ }
203
245
  mld_polyz_unpack_19_aarch64_asm(r, buf, mld_polyz_unpack_19_indices);
204
246
  return MLD_NATIVE_FUNC_SUCCESS;
205
247
  }
@@ -213,6 +255,10 @@ MLD_MUST_CHECK_RETURN_VALUE
213
255
  static MLD_INLINE int mld_poly_pointwise_montgomery_native(
214
256
  int32_t a[MLDSA_N], const int32_t b[MLDSA_N])
215
257
  {
258
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
259
+ {
260
+ return MLD_NATIVE_FUNC_FALLBACK;
261
+ }
216
262
  mld_poly_pointwise_montgomery_aarch64_asm(a, b);
217
263
  return MLD_NATIVE_FUNC_SUCCESS;
218
264
  }
@@ -225,6 +271,10 @@ static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l4_native(
225
271
  int32_t w[MLDSA_N], const int32_t u[4][MLDSA_N],
226
272
  const int32_t v[4][MLDSA_N])
227
273
  {
274
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
275
+ {
276
+ return MLD_NATIVE_FUNC_FALLBACK;
277
+ }
228
278
  mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm(w, u, v);
229
279
  return MLD_NATIVE_FUNC_SUCCESS;
230
280
  }
@@ -236,6 +286,10 @@ static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l5_native(
236
286
  int32_t w[MLDSA_N], const int32_t u[5][MLDSA_N],
237
287
  const int32_t v[5][MLDSA_N])
238
288
  {
289
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
290
+ {
291
+ return MLD_NATIVE_FUNC_FALLBACK;
292
+ }
239
293
  mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm(w, u, v);
240
294
  return MLD_NATIVE_FUNC_SUCCESS;
241
295
  }
@@ -247,6 +301,10 @@ static MLD_INLINE int mld_polyvecl_pointwise_acc_montgomery_l7_native(
247
301
  int32_t w[MLDSA_N], const int32_t u[7][MLDSA_N],
248
302
  const int32_t v[7][MLDSA_N])
249
303
  {
304
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
305
+ {
306
+ return MLD_NATIVE_FUNC_FALLBACK;
307
+ }
250
308
  mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm(w, u, v);
251
309
  return MLD_NATIVE_FUNC_SUCCESS;
252
310
  }
@@ -61,12 +61,13 @@ MLD_INTERNAL_DATA_DECLARATION const uint8_t mld_polyz_unpack_19_indices[64];
61
61
  #define MLD_AARCH64_REJ_UNIFORM_ETA4_BUFLEN (2 * 136)
62
62
 
63
63
  #define mld_ntt_aarch64_asm MLD_NAMESPACE(ntt_aarch64_asm)
64
- void mld_ntt_aarch64_asm(int32_t *r, const int32_t *zetas_l123456,
65
- const int32_t *zetas_l78)
64
+ void mld_ntt_aarch64_asm(int32_t r[MLDSA_N], const int32_t zetas_l123456[144],
65
+ const int32_t zetas_l78[384])
66
66
  /* This must be kept in sync with the HOL-Light specification
67
- * in proofs/hol_light/aarch64/proofs/ntt_aarch64_asm.ml */
67
+ * in proofs/hol_light/aarch64/proofs/mldsa_ntt_aarch64_asm.ml */
68
68
  __contract__(
69
69
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
70
+ /* check-magic: 8380417 == MLDSA_Q */
70
71
  requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
71
72
  requires(zetas_l123456 == mld_aarch64_ntt_zetas_layer123456)
72
73
  requires(zetas_l78 == mld_aarch64_ntt_zetas_layer78)
@@ -77,10 +78,10 @@ __contract__(
77
78
  );
78
79
 
79
80
  #define mld_intt_aarch64_asm MLD_NAMESPACE(intt_aarch64_asm)
80
- void mld_intt_aarch64_asm(int32_t *r, const int32_t *zetas_l78,
81
- const int32_t *zetas_l123456)
81
+ void mld_intt_aarch64_asm(int32_t r[MLDSA_N], const int32_t zetas_l78[384],
82
+ const int32_t zetas_l123456[160])
82
83
  /* This must be kept in sync with the HOL-Light specification
83
- * in proofs/hol_light/aarch64/proofs/intt_aarch64_asm.ml */
84
+ * in proofs/hol_light/aarch64/proofs/mldsa_intt_aarch64_asm.ml */
84
85
  __contract__(
85
86
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
86
87
  requires(array_abs_bound(r, 0, MLDSA_N, 8380417))
@@ -94,10 +95,10 @@ __contract__(
94
95
 
95
96
  #define mld_rej_uniform_aarch64_asm MLD_NAMESPACE(rej_uniform_aarch64_asm)
96
97
  MLD_MUST_CHECK_RETURN_VALUE
97
- uint64_t mld_rej_uniform_aarch64_asm(int32_t *r, const uint8_t *buf,
98
- unsigned buflen, const uint8_t *table)
98
+ uint64_t mld_rej_uniform_aarch64_asm(int32_t r[MLDSA_N], const uint8_t *buf,
99
+ unsigned buflen, const uint8_t table[256])
99
100
  /* This must be kept in sync with the HOL-Light specification
100
- * in proofs/hol_light/aarch64/proofs/rej_uniform_aarch64_asm.ml. */
101
+ * in proofs/hol_light/aarch64/proofs/mldsa_rej_uniform_aarch64_asm.ml. */
101
102
  __contract__(
102
103
  requires(buflen % 24 == 0)
103
104
  requires(memory_no_alias(buf, buflen))
@@ -112,24 +113,50 @@ __contract__(
112
113
  #define mld_rej_uniform_eta2_aarch64_asm \
113
114
  MLD_NAMESPACE(rej_uniform_eta2_aarch64_asm)
114
115
  MLD_MUST_CHECK_RETURN_VALUE
115
- uint64_t mld_rej_uniform_eta2_aarch64_asm(int32_t *r, const uint8_t *buf,
116
- unsigned buflen,
117
- const uint8_t *table);
116
+ uint64_t mld_rej_uniform_eta2_aarch64_asm(int32_t r[MLDSA_N],
117
+ const uint8_t *buf, unsigned buflen,
118
+ const uint8_t table[4096])
119
+ /* This must be kept in sync with the HOL-Light specification
120
+ * in proofs/hol_light/aarch64/proofs/mldsa_rej_uniform_eta2_aarch64_asm.ml */
121
+ __contract__(
122
+ requires(buflen % 8 == 0)
123
+ requires(buflen >= 8)
124
+ requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
125
+ requires(memory_no_alias(buf, buflen))
126
+ requires(table == mld_rej_uniform_eta_table)
127
+ assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
128
+ ensures(return_value <= MLDSA_N)
129
+ /* check-magic: 3 == 2 + 1 (asm is eta=2-specific) */
130
+ ensures(array_abs_bound(r, 0, return_value, 3))
131
+ );
118
132
 
119
133
  #define mld_rej_uniform_eta4_aarch64_asm \
120
134
  MLD_NAMESPACE(rej_uniform_eta4_aarch64_asm)
121
135
  MLD_MUST_CHECK_RETURN_VALUE
122
- uint64_t mld_rej_uniform_eta4_aarch64_asm(int32_t *r, const uint8_t *buf,
123
- unsigned buflen,
124
- const uint8_t *table);
136
+ uint64_t mld_rej_uniform_eta4_aarch64_asm(int32_t r[MLDSA_N],
137
+ const uint8_t *buf, unsigned buflen,
138
+ const uint8_t table[4096])
139
+ /* This must be kept in sync with the HOL-Light specification
140
+ * in proofs/hol_light/aarch64/proofs/mldsa_rej_uniform_eta4_aarch64_asm.ml */
141
+ __contract__(
142
+ requires(buflen % 8 == 0)
143
+ requires(buflen >= 8)
144
+ requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
145
+ requires(memory_no_alias(buf, buflen))
146
+ requires(table == mld_rej_uniform_eta_table)
147
+ assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
148
+ ensures(return_value <= MLDSA_N)
149
+ /* check-magic: 5 == 4 + 1 (asm is eta=4-specific) */
150
+ ensures(array_abs_bound(r, 0, return_value, 5))
151
+ );
125
152
  #endif /* !MLD_CONFIG_NO_KEYPAIR_API */
126
153
 
127
154
  #if !defined(MLD_CONFIG_NO_SIGN_API)
128
155
  #define mld_poly_decompose_32_aarch64_asm \
129
156
  MLD_NAMESPACE(poly_decompose_32_aarch64_asm)
130
- void mld_poly_decompose_32_aarch64_asm(int32_t *a1, int32_t *a0)
157
+ void mld_poly_decompose_32_aarch64_asm(int32_t a1[MLDSA_N], int32_t a0[MLDSA_N])
131
158
  /* This must be kept in sync with the HOL-Light specification
132
- * in proofs/hol_light/aarch64/proofs/poly_decompose_32_aarch64_asm.ml */
159
+ * in proofs/hol_light/aarch64/proofs/mldsa_poly_decompose_32_aarch64_asm.ml */
133
160
  __contract__(
134
161
  requires(memory_no_alias(a1, sizeof(int32_t) * MLDSA_N))
135
162
  requires(memory_no_alias(a0, sizeof(int32_t) * MLDSA_N))
@@ -144,9 +171,9 @@ __contract__(
144
171
 
145
172
  #define mld_poly_decompose_88_aarch64_asm \
146
173
  MLD_NAMESPACE(poly_decompose_88_aarch64_asm)
147
- void mld_poly_decompose_88_aarch64_asm(int32_t *a1, int32_t *a0)
174
+ void mld_poly_decompose_88_aarch64_asm(int32_t a1[MLDSA_N], int32_t a0[MLDSA_N])
148
175
  /* This must be kept in sync with the HOL-Light specification
149
- * in proofs/hol_light/aarch64/proofs/poly_decompose_88_aarch64_asm.ml */
176
+ * in proofs/hol_light/aarch64/proofs/mldsa_poly_decompose_88_aarch64_asm.ml */
150
177
  __contract__(
151
178
  requires(memory_no_alias(a1, sizeof(int32_t) * MLDSA_N))
152
179
  requires(memory_no_alias(a0, sizeof(int32_t) * MLDSA_N))
@@ -161,9 +188,9 @@ __contract__(
161
188
  #endif /* !MLD_CONFIG_NO_SIGN_API */
162
189
 
163
190
  #define mld_poly_caddq_aarch64_asm MLD_NAMESPACE(poly_caddq_aarch64_asm)
164
- void mld_poly_caddq_aarch64_asm(int32_t *a)
191
+ void mld_poly_caddq_aarch64_asm(int32_t a[MLDSA_N])
165
192
  /* This must be kept in sync with the HOL-Light specification
166
- * in proofs/hol_light/aarch64/proofs/poly_caddq_aarch64_asm.ml */
193
+ * in proofs/hol_light/aarch64/proofs/mldsa_poly_caddq_aarch64_asm.ml */
167
194
  __contract__(
168
195
  requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
169
196
  requires(array_abs_bound(a, 0, MLDSA_N, MLDSA_Q))
@@ -174,9 +201,10 @@ __contract__(
174
201
  #if !defined(MLD_CONFIG_NO_VERIFY_API)
175
202
  #define mld_poly_use_hint_32_aarch64_asm \
176
203
  MLD_NAMESPACE(poly_use_hint_32_aarch64_asm)
177
- void mld_poly_use_hint_32_aarch64_asm(int32_t *a, const int32_t *h)
204
+ void mld_poly_use_hint_32_aarch64_asm(int32_t a[MLDSA_N],
205
+ const int32_t h[MLDSA_N])
178
206
  /* This must be kept in sync with the HOL-Light specification
179
- * in proofs/hol_light/aarch64/proofs/poly_use_hint_32_aarch64_asm.ml */
207
+ * in proofs/hol_light/aarch64/proofs/mldsa_poly_use_hint_32_aarch64_asm.ml */
180
208
  __contract__(
181
209
  requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
182
210
  requires(memory_no_alias(h, sizeof(int32_t) * MLDSA_N))
@@ -188,9 +216,10 @@ __contract__(
188
216
 
189
217
  #define mld_poly_use_hint_88_aarch64_asm \
190
218
  MLD_NAMESPACE(poly_use_hint_88_aarch64_asm)
191
- void mld_poly_use_hint_88_aarch64_asm(int32_t *a, const int32_t *h)
219
+ void mld_poly_use_hint_88_aarch64_asm(int32_t a[MLDSA_N],
220
+ const int32_t h[MLDSA_N])
192
221
  /* This must be kept in sync with the HOL-Light specification
193
- * in proofs/hol_light/aarch64/proofs/poly_use_hint_88_aarch64_asm.ml */
222
+ * in proofs/hol_light/aarch64/proofs/mldsa_poly_use_hint_88_aarch64_asm.ml */
194
223
  __contract__(
195
224
  requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
196
225
  requires(memory_no_alias(h, sizeof(int32_t) * MLDSA_N))
@@ -203,9 +232,9 @@ __contract__(
203
232
 
204
233
  #define mld_poly_chknorm_aarch64_asm MLD_NAMESPACE(poly_chknorm_aarch64_asm)
205
234
  MLD_MUST_CHECK_RETURN_VALUE
206
- int mld_poly_chknorm_aarch64_asm(const int32_t *a, int32_t B)
235
+ int mld_poly_chknorm_aarch64_asm(const int32_t a[MLDSA_N], int32_t B)
207
236
  /* This must be kept in sync with the HOL-Light specification
208
- * in proofs/hol_light/aarch64/proofs/poly_chknorm_aarch64_asm.ml */
237
+ * in proofs/hol_light/aarch64/proofs/mldsa_poly_chknorm_aarch64_asm.ml */
209
238
  __contract__(
210
239
  requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
211
240
  /* HOL Light precondition: abs(ival(x i)) < 2^31, i.e., a[i] != INT32_MIN */
@@ -218,10 +247,10 @@ __contract__(
218
247
  #if defined(MLD_CONFIG_MULTILEVEL_WITH_SHARED) || MLD_CONFIG_PARAMETER_SET == 44
219
248
  #define mld_polyz_unpack_17_aarch64_asm \
220
249
  MLD_NAMESPACE(polyz_unpack_17_aarch64_asm)
221
- void mld_polyz_unpack_17_aarch64_asm(int32_t *r, const uint8_t *buf,
222
- const uint8_t *indices)
250
+ void mld_polyz_unpack_17_aarch64_asm(int32_t r[MLDSA_N], const uint8_t buf[576],
251
+ const uint8_t indices[64])
223
252
  /* This must be kept in sync with the HOL-Light specification
224
- * in proofs/hol_light/aarch64/proofs/polyz_unpack_17_aarch64_asm.ml */
253
+ * in proofs/hol_light/aarch64/proofs/mldsa_polyz_unpack_17_aarch64_asm.ml */
225
254
  __contract__(
226
255
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
227
256
  requires(memory_no_alias(buf, 576))
@@ -236,10 +265,10 @@ __contract__(
236
265
  (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87)
237
266
  #define mld_polyz_unpack_19_aarch64_asm \
238
267
  MLD_NAMESPACE(polyz_unpack_19_aarch64_asm)
239
- void mld_polyz_unpack_19_aarch64_asm(int32_t *r, const uint8_t *buf,
240
- const uint8_t *indices)
268
+ void mld_polyz_unpack_19_aarch64_asm(int32_t r[MLDSA_N], const uint8_t buf[640],
269
+ const uint8_t indices[64])
241
270
  /* This must be kept in sync with the HOL-Light specification
242
- * in proofs/hol_light/aarch64/proofs/polyz_unpack_19_aarch64_asm.ml */
271
+ * in proofs/hol_light/aarch64/proofs/mldsa_polyz_unpack_19_aarch64_asm.ml */
243
272
  __contract__(
244
273
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
245
274
  requires(memory_no_alias(buf, 640))
@@ -255,18 +284,22 @@ __contract__(
255
284
  defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)
256
285
  #define mld_poly_pointwise_montgomery_aarch64_asm \
257
286
  MLD_NAMESPACE(poly_pointwise_montgomery_aarch64_asm)
258
- void mld_poly_pointwise_montgomery_aarch64_asm(int32_t *a, const int32_t *b)
287
+ void mld_poly_pointwise_montgomery_aarch64_asm(int32_t a[MLDSA_N],
288
+ const int32_t b[MLDSA_N])
259
289
  /* This must be kept in sync with the HOL-Light specification
260
- * in proofs/hol_light/aarch64/proofs/pointwise_montgomery_aarch64_asm.ml */
290
+ * in proofs/hol_light/aarch64/proofs/mldsa_pointwise_montgomery_aarch64_asm.ml
291
+ */
261
292
  __contract__(
262
293
  requires(memory_no_alias(a, sizeof(int32_t) * MLDSA_N))
263
294
  requires(memory_no_alias(b, sizeof(int32_t) * MLDSA_N))
264
- /* check-magic: off */
265
- requires(array_abs_bound(a, 0, MLDSA_N, 75423753))
266
- requires(array_abs_bound(b, 0, MLDSA_N, 75423753))
295
+ /* Input bound MLD_NTT_BOUND = 9 * MLD_FQMUL_BOUND, the guaranteed bound of
296
+ * any forward NTT implementation. Hardcoded here to keep this header free
297
+ * of poly.h. */
298
+ /* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
299
+ requires(array_abs_bound(a, 0, MLDSA_N, 94279698))
300
+ requires(array_abs_bound(b, 0, MLDSA_N, 94279698))
267
301
  assigns(memory_slice(a, sizeof(int32_t) * MLDSA_N))
268
302
  ensures(array_abs_bound(a, 0, MLDSA_N, 8380417))
269
- /* check-magic: on */
270
303
  );
271
304
  #endif /* !MLD_CONFIG_NO_SIGN_API || !MLD_CONFIG_NO_VERIFY_API || \
272
305
  MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
@@ -274,61 +307,61 @@ __contract__(
274
307
  #define mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm \
275
308
  MLD_NAMESPACE(polyvecl_pointwise_acc_montgomery_l4_aarch64_asm)
276
309
  void mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm(
277
- int32_t *r, const int32_t a[4][MLDSA_N], const int32_t b[4][MLDSA_N])
310
+ int32_t r[MLDSA_N], const int32_t a[4][MLDSA_N],
311
+ const int32_t b[4][MLDSA_N])
278
312
  /* This must be kept in sync with the HOL-Light specification
279
313
  * in
280
- * proofs/hol_light/aarch64/proofs/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.ml
314
+ * proofs/hol_light/aarch64/proofs/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.ml
281
315
  */
282
316
  __contract__(
283
317
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
284
318
  requires(memory_no_alias(a, sizeof(int32_t) * 4 * MLDSA_N))
285
319
  requires(memory_no_alias(b, sizeof(int32_t) * 4 * MLDSA_N))
286
- /* check-magic: off */
287
320
  requires(forall(l0, 0, 4, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
288
- requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
321
+ /* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
322
+ requires(forall(l1, 0, 4, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
289
323
  assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
290
324
  ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
291
- /* check-magic: on */
292
325
  );
293
326
 
294
327
  #define mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm \
295
328
  MLD_NAMESPACE(polyvecl_pointwise_acc_montgomery_l5_aarch64_asm)
296
329
  void mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm(
297
- int32_t *r, const int32_t a[5][MLDSA_N], const int32_t b[5][MLDSA_N])
330
+ int32_t r[MLDSA_N], const int32_t a[5][MLDSA_N],
331
+ const int32_t b[5][MLDSA_N])
298
332
  /* This must be kept in sync with the HOL-Light specification
299
333
  * in
300
- * proofs/hol_light/aarch64/proofs/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.ml
334
+ * proofs/hol_light/aarch64/proofs/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.ml
301
335
  */
302
336
  __contract__(
303
337
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
304
338
  requires(memory_no_alias(a, sizeof(int32_t) * 5 * MLDSA_N))
305
339
  requires(memory_no_alias(b, sizeof(int32_t) * 5 * MLDSA_N))
306
- /* check-magic: off */
307
340
  requires(forall(l0, 0, 5, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
308
- requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
341
+ /* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
342
+ requires(forall(l1, 0, 5, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
309
343
  assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
310
344
  ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
311
- /* check-magic: on */
312
345
  );
313
346
 
314
347
  #define mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm \
315
348
  MLD_NAMESPACE(polyvecl_pointwise_acc_montgomery_l7_aarch64_asm)
316
349
  void mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm(
317
- int32_t *r, const int32_t a[7][MLDSA_N], const int32_t b[7][MLDSA_N])
350
+ int32_t r[MLDSA_N], const int32_t a[7][MLDSA_N],
351
+ const int32_t b[7][MLDSA_N])
318
352
  /* This must be kept in sync with the HOL-Light specification
319
353
  * in
320
- * proofs/hol_light/aarch64/proofs/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.ml
354
+ * proofs/hol_light/aarch64/proofs/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.ml
321
355
  */
322
356
  __contract__(
323
357
  requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N))
324
358
  requires(memory_no_alias(a, sizeof(int32_t) * 7 * MLDSA_N))
325
359
  requires(memory_no_alias(b, sizeof(int32_t) * 7 * MLDSA_N))
326
- /* check-magic: off */
327
360
  requires(forall(l0, 0, 7, array_abs_bound(a[l0], 0, MLDSA_N, 8380417)))
328
- requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 75423753)))
361
+ /* check-magic: 94279698 == 9 * ((5 * MLDSA_Q + 3) / 4) */
362
+ requires(forall(l1, 0, 7, array_abs_bound(b[l1], 0, MLDSA_N, 94279698)))
329
363
  assigns(memory_slice(r, sizeof(int32_t) * MLDSA_N))
330
364
  ensures(array_abs_bound(r, 0, MLDSA_N, 8380417))
331
- /* check-magic: on */
332
365
  );
333
366
 
334
367
  #endif /* !MLD_NATIVE_AARCH64_SRC_ARITH_NATIVE_AARCH64_H */
@@ -14,20 +14,53 @@
14
14
  * Becker, Hwang, Kannwischer, Yang, Yang
15
15
  * https://eprint.iacr.org/2021/986
16
16
  *
17
+ * - [NeonNTT_Autoformalised]
18
+ * Neon NTT - (Auto)formalised
19
+ * Hanno Becker
20
+ * https://eprint.iacr.org/2026/1223
21
+ *
17
22
  * - [SLOTHY_Paper]
18
23
  * Fast and Clean: Auditable high-performance assembly via constraint solving
19
24
  * Abdulrahman, Becker, Kannwischer, Klein
20
25
  * https://eprint.iacr.org/2022/1303
21
26
  */
22
27
 
23
- /* AArch64 ML-DSA inverse NTT following @[NeonNTT] and @[SLOTHY_Paper] */
28
+ /* AArch64 ML-DSA inverse NTT following @[NeonNTT], @[SLOTHY_Paper], and @[NeonNTT_Autoformalised] */
29
+
30
+ /*yaml
31
+ Name: intt_aarch64_asm
32
+ Description: AArch64 ML-DSA inverse NTT
33
+ Signature: void mld_intt_aarch64_asm(int32_t r[256], const int32_t zetas_l78[384], const int32_t zetas_l123456[160])
34
+ ABI:
35
+ Architecture: aarch64
36
+ CallingConvention: AAPCS64
37
+ Features: [NEON]
38
+ x0:
39
+ type: buffer
40
+ size_bytes: 1024
41
+ permissions: read/write
42
+ c_parameter: int32_t r[256]
43
+ description: Input/output polynomial (256 x int32_t)
44
+ x1:
45
+ type: buffer
46
+ size_bytes: 1536
47
+ permissions: read-only
48
+ c_parameter: const int32_t zetas_l78[384]
49
+ description: Twiddle factors for layers 7-8 (384 x int32_t)
50
+ x2:
51
+ type: buffer
52
+ size_bytes: 640
53
+ permissions: read-only
54
+ c_parameter: const int32_t zetas_l123456[160]
55
+ description: Twiddle factors for layers 1-6 (160 x int32_t)
56
+ */
24
57
 
25
58
  #include "../../../common.h"
26
59
  #if defined(MLD_ARITH_BACKEND_AARCH64) && !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
27
60
 
28
61
  /*
29
62
  * WARNING: This file is auto-derived from the mldsa-native source file
30
- * dev/aarch64_opt/src/intt_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
63
+ * dev/aarch64_opt/src/mldsa_intt_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
31
64
  */
32
65
 
33
66
  .text
@@ -156,7 +189,7 @@ MLD_ASM_FN_SYMBOL(intt_aarch64_asm)
156
189
  ldr q17, [x1], #0x60
157
190
  sub x4, x4, #0x2
158
191
 
159
- Lintt_layer5678_start:
192
+ Lmld_intt_layer5678_start:
160
193
  ldr d4, [x2], #0x20
161
194
  mul v0.4s, v21.4s, v17.4s
162
195
  ldr q7, [x3, #0xa0]
@@ -230,7 +263,7 @@ Lintt_layer5678_start:
230
263
  mul v8.4s, v19.4s, v4.s[0]
231
264
  sqrdmulh v24.4s, v21.4s, v2.4s
232
265
  subs x4, x4, #0x1
233
- cbnz x4, Lintt_layer5678_start
266
+ cbnz x4, Lmld_intt_layer5678_start
234
267
  sqrdmulh v19.4s, v3.4s, v2.4s
235
268
  trn2 v0.4s, v14.4s, v26.4s
236
269
  str q15, [x3], #0x40
@@ -400,7 +433,7 @@ Lintt_layer5678_start:
400
433
  mul v25.4s, v9.4s, v2.s[0]
401
434
  sub x4, x4, #0x1
402
435
 
403
- Lintt_layer1234_start:
436
+ Lmld_intt_layer1234_start:
404
437
  sub v22.4s, v21.4s, v16.4s
405
438
  mls v25.4s, v12.4s, v31.s[0]
406
439
  add v12.4s, v21.4s, v16.4s
@@ -618,7 +651,7 @@ Lintt_layer1234_start:
618
651
  sqrdmulh v8.4s, v24.4s, v0.s[3]
619
652
  mul v25.4s, v22.4s, v2.s[0]
620
653
  subs x4, x4, #0x1
621
- cbnz x4, Lintt_layer1234_start
654
+ cbnz x4, Lmld_intt_layer1234_start
622
655
  mul v22.4s, v24.4s, v0.s[2]
623
656
  sqrdmulh v9.4s, v23.4s, v30.4s
624
657
  mls v25.4s, v12.4s, v31.s[0]