@pinkparrot/qsafe-mayo-wasm 0.0.3

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 (97) hide show
  1. package/.gitmodules +3 -0
  2. package/.vscode/launch.json +12 -0
  3. package/LICENSE +201 -0
  4. package/bridge/mayo1_bridge.c +26 -0
  5. package/bridge/mayo2_bridge.c +26 -0
  6. package/bridge/randombytes_inject.c +44 -0
  7. package/build_mayo1.ps1 +36 -0
  8. package/build_mayo2.ps1 +36 -0
  9. package/dist/mayo.browser.min.js +216 -0
  10. package/dist/mayo1.js +0 -0
  11. package/dist/mayo2.js +0 -0
  12. package/dist/mayo_api.js +139 -0
  13. package/dist/package.json +1 -0
  14. package/gitignore +2 -0
  15. package/index.mjs +1 -0
  16. package/mayo-c/.astylerc +16 -0
  17. package/mayo-c/.cmake/flags.cmake +45 -0
  18. package/mayo-c/.cmake/sanitizers.cmake +81 -0
  19. package/mayo-c/.cmake/target.cmake +71 -0
  20. package/mayo-c/.github/workflows/ci_clang.yml +61 -0
  21. package/mayo-c/.github/workflows/ci_gcc.yml +60 -0
  22. package/mayo-c/.github/workflows/cmake.yml +160 -0
  23. package/mayo-c/.github/workflows/macos_m1.yml +68 -0
  24. package/mayo-c/CMakeLists.txt +35 -0
  25. package/mayo-c/KAT/PQCsignKAT_24_MAYO_1.req +900 -0
  26. package/mayo-c/KAT/PQCsignKAT_24_MAYO_1.rsp +902 -0
  27. package/mayo-c/KAT/PQCsignKAT_24_MAYO_2.req +900 -0
  28. package/mayo-c/KAT/PQCsignKAT_24_MAYO_2.rsp +902 -0
  29. package/mayo-c/KAT/PQCsignKAT_32_MAYO_3.req +900 -0
  30. package/mayo-c/KAT/PQCsignKAT_32_MAYO_3.rsp +902 -0
  31. package/mayo-c/KAT/PQCsignKAT_40_MAYO_5.req +900 -0
  32. package/mayo-c/KAT/PQCsignKAT_40_MAYO_5.rsp +902 -0
  33. package/mayo-c/LICENSE +202 -0
  34. package/mayo-c/META/MAYO-1_META.yml +52 -0
  35. package/mayo-c/META/MAYO-2_META.yml +52 -0
  36. package/mayo-c/META/MAYO-3_META.yml +52 -0
  37. package/mayo-c/META/MAYO-5_META.yml +52 -0
  38. package/mayo-c/NOTICE +13 -0
  39. package/mayo-c/README.md +183 -0
  40. package/mayo-c/apps/CMakeLists.txt +31 -0
  41. package/mayo-c/apps/PQCgenKAT_sign.c +281 -0
  42. package/mayo-c/apps/example.c +151 -0
  43. package/mayo-c/apps/example_nistapi.c +124 -0
  44. package/mayo-c/include/mayo.h +442 -0
  45. package/mayo-c/include/mem.h +25 -0
  46. package/mayo-c/include/randombytes.h +31 -0
  47. package/mayo-c/scripts/contstants.py +141 -0
  48. package/mayo-c/scripts/find_irred_poly.sage +39 -0
  49. package/mayo-c/src/AVX2/arithmetic_common.h +159 -0
  50. package/mayo-c/src/AVX2/echelon_form.h +91 -0
  51. package/mayo-c/src/AVX2/echelon_form_loop.h +58 -0
  52. package/mayo-c/src/AVX2/shuffle_arithmetic.h +442 -0
  53. package/mayo-c/src/CMakeLists.txt +98 -0
  54. package/mayo-c/src/arithmetic.c +128 -0
  55. package/mayo-c/src/arithmetic.h +124 -0
  56. package/mayo-c/src/common/aes128ctr.c +293 -0
  57. package/mayo-c/src/common/aes_c.c +741 -0
  58. package/mayo-c/src/common/aes_ctr.h +32 -0
  59. package/mayo-c/src/common/aes_neon.c +201 -0
  60. package/mayo-c/src/common/debug_bench_tools.h +69 -0
  61. package/mayo-c/src/common/fips202.c +1093 -0
  62. package/mayo-c/src/common/fips202.h +12 -0
  63. package/mayo-c/src/common/mem.c +19 -0
  64. package/mayo-c/src/common/randombytes_ctrdrbg.c +141 -0
  65. package/mayo-c/src/common/randombytes_system.c +399 -0
  66. package/mayo-c/src/generic/arithmetic_dynamic.h +68 -0
  67. package/mayo-c/src/generic/arithmetic_fixed.h +84 -0
  68. package/mayo-c/src/generic/echelon_form.h +152 -0
  69. package/mayo-c/src/generic/ef_inner_loop.h +56 -0
  70. package/mayo-c/src/generic/generic_arithmetic.h +294 -0
  71. package/mayo-c/src/mayo.c +675 -0
  72. package/mayo-c/src/mayo_1/api.c +46 -0
  73. package/mayo-c/src/mayo_1/api.h +43 -0
  74. package/mayo-c/src/mayo_2/api.c +46 -0
  75. package/mayo-c/src/mayo_2/api.h +43 -0
  76. package/mayo-c/src/mayo_3/api.c +46 -0
  77. package/mayo-c/src/mayo_3/api.h +43 -0
  78. package/mayo-c/src/mayo_5/api.c +46 -0
  79. package/mayo-c/src/mayo_5/api.h +43 -0
  80. package/mayo-c/src/neon/arithmetic_common.h +132 -0
  81. package/mayo-c/src/neon/echelon_form.h +55 -0
  82. package/mayo-c/src/neon/echelon_form_loop.h +58 -0
  83. package/mayo-c/src/neon/shuffle_arithmetic.h +462 -0
  84. package/mayo-c/src/params.c +42 -0
  85. package/mayo-c/src/simple_arithmetic.h +138 -0
  86. package/mayo-c/test/CMakeLists.txt +51 -0
  87. package/mayo-c/test/bench.c +166 -0
  88. package/mayo-c/test/m1cycles.c +155 -0
  89. package/mayo-c/test/m1cycles.h +13 -0
  90. package/mayo-c/test/test_kat.c +271 -0
  91. package/mayo-c/test/test_mayo.c +139 -0
  92. package/mayo-c/test/test_sample_solution.c +75 -0
  93. package/mayo-c/test/test_various.c +680 -0
  94. package/package.json +39 -0
  95. package/publish.bat +22 -0
  96. package/readme.md +80 -0
  97. package/test/test.mjs +42 -0
package/mayo-c/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,52 @@
1
+ name: MAYO-1
2
+ type: signature
3
+ claimed-nist-level: 1
4
+ length-public-key: 1420
5
+ length-secret-key: 24
6
+ length-signature: 454
7
+ nistkat-sha256: 178adb997203ae0512b1bd6fa4a5cfae25805d88aeb0ce5226981423153418ee
8
+ principal-submitters:
9
+ - Ward Beullens
10
+ - Fabio Campos
11
+ - Sofía Celi
12
+ - Basil Hess
13
+ - Matthias J. Kannwischer
14
+ implementations:
15
+ - name: opt
16
+ version: round2
17
+ folder_name: .
18
+ compile_opts: -DMAYO_VARIANT=MAYO_1 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
19
+ signature_keypair: pqmayo_MAYO_1_opt_crypto_sign_keypair
20
+ signature_signature: pqmayo_MAYO_1_opt_crypto_sign_signature
21
+ signature_verify: pqmayo_MAYO_1_opt_crypto_sign_verify
22
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_dynamic.h ./src/generic/arithmetic_fixed.h ./src/generic/echelon_form.h ./src/generic/ef_inner_loop.h ./src/generic/generic_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_1/api.h ./src/mayo_1/api.c
23
+ - name: avx2
24
+ version: round2
25
+ folder_name: .
26
+ compile_opts: -DMAYO_VARIANT=MAYO_1 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL
27
+ signature_keypair: pqmayo_MAYO_1_avx2_crypto_sign_keypair
28
+ signature_signature: pqmayo_MAYO_1_avx2_crypto_sign_signature
29
+ signature_verify: pqmayo_MAYO_1_avx2_crypto_sign_verify
30
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_1/api.h ./src/mayo_1/api.c
31
+ supported_platforms:
32
+ - architecture: x86_64
33
+ operating_systems:
34
+ - Darwin
35
+ - Linux
36
+ required_flags:
37
+ - avx2
38
+ - name: neon
39
+ version: round2
40
+ folder_name: .
41
+ compile_opts: -DMAYO_VARIANT=MAYO_1 -DMAYO_BUILD_TYPE_NEON -DMAYO_NEON -DHAVE_RANDOMBYTES_NORETVAL
42
+ signature_keypair: pqmayo_MAYO_1_neon_crypto_sign_keypair
43
+ signature_signature: pqmayo_MAYO_1_neon_crypto_sign_signature
44
+ signature_verify: pqmayo_MAYO_1_neon_crypto_sign_verify
45
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/neon/arithmetic_common.h ./src/neon/echelon_form.h ./src/neon/echelon_form_loop.h ./src/neon/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_1/api.h ./src/mayo_1/api.c
46
+ supported_platforms:
47
+ - architecture: arm_8
48
+ operating_systems:
49
+ - Darwin
50
+ - Linux
51
+ required_flags:
52
+ - asimd
@@ -0,0 +1,52 @@
1
+ name: MAYO-2
2
+ type: signature
3
+ claimed-nist-level: 1
4
+ length-public-key: 4912
5
+ length-secret-key: 24
6
+ length-signature: 186
7
+ nistkat-sha256: 777df9b41af1a58536ef76d483775b5c8389ff991e70652fa3af803770a5fce3
8
+ principal-submitters:
9
+ - Ward Beullens
10
+ - Fabio Campos
11
+ - Sofía Celi
12
+ - Basil Hess
13
+ - Matthias J. Kannwischer
14
+ implementations:
15
+ - name: opt
16
+ version: round2
17
+ folder_name: .
18
+ compile_opts: -DMAYO_VARIANT=MAYO_2 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL
19
+ signature_keypair: pqmayo_MAYO_2_opt_crypto_sign_keypair
20
+ signature_signature: pqmayo_MAYO_2_opt_crypto_sign_signature
21
+ signature_verify: pqmayo_MAYO_2_opt_crypto_sign_verify
22
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_dynamic.h ./src/generic/arithmetic_fixed.h ./src/generic/echelon_form.h ./src/generic/ef_inner_loop.h ./src/generic/generic_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_2/api.h ./src/mayo_2/api.c
23
+ - name: avx2
24
+ version: round2
25
+ folder_name: .
26
+ compile_opts: -DMAYO_VARIANT=MAYO_2 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL
27
+ signature_keypair: pqmayo_MAYO_2_avx2_crypto_sign_keypair
28
+ signature_signature: pqmayo_MAYO_2_avx2_crypto_sign_signature
29
+ signature_verify: pqmayo_MAYO_2_avx2_crypto_sign_verify
30
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_2/api.h ./src/mayo_2/api.c
31
+ supported_platforms:
32
+ - architecture: x86_64
33
+ operating_systems:
34
+ - Darwin
35
+ - Linux
36
+ required_flags:
37
+ - avx2
38
+ - name: neon
39
+ version: round2
40
+ folder_name: .
41
+ compile_opts: -DMAYO_VARIANT=MAYO_2 -DMAYO_BUILD_TYPE_NEON -DMAYO_NEON -DHAVE_RANDOMBYTES_NORETVAL
42
+ signature_keypair: pqmayo_MAYO_2_neon_crypto_sign_keypair
43
+ signature_signature: pqmayo_MAYO_2_neon_crypto_sign_signature
44
+ signature_verify: pqmayo_MAYO_2_neon_crypto_sign_verify
45
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/neon/arithmetic_common.h ./src/neon/echelon_form.h ./src/neon/echelon_form_loop.h ./src/neon/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_2/api.h ./src/mayo_2/api.c
46
+ supported_platforms:
47
+ - architecture: arm_8
48
+ operating_systems:
49
+ - Darwin
50
+ - Linux
51
+ required_flags:
52
+ - asimd
@@ -0,0 +1,52 @@
1
+ name: MAYO-3
2
+ type: signature
3
+ claimed-nist-level: 3
4
+ length-public-key: 2986
5
+ length-secret-key: 32
6
+ length-signature: 681
7
+ nistkat-sha256: af940f5cd678bde08f452d3ee7e831ec1a2269715579c604ae699069b6fd9c15
8
+ principal-submitters:
9
+ - Ward Beullens
10
+ - Fabio Campos
11
+ - Sofía Celi
12
+ - Basil Hess
13
+ - Matthias J. Kannwischer
14
+ implementations:
15
+ - name: opt
16
+ version: round2
17
+ folder_name: .
18
+ compile_opts: -DMAYO_VARIANT=MAYO_3 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
19
+ signature_keypair: pqmayo_MAYO_3_opt_crypto_sign_keypair
20
+ signature_signature: pqmayo_MAYO_3_opt_crypto_sign_signature
21
+ signature_verify: pqmayo_MAYO_3_opt_crypto_sign_verify
22
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_dynamic.h ./src/generic/arithmetic_fixed.h ./src/generic/echelon_form.h ./src/generic/ef_inner_loop.h ./src/generic/generic_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_3/api.h ./src/mayo_3/api.c
23
+ - name: avx2
24
+ version: round2
25
+ folder_name: .
26
+ compile_opts: -DMAYO_VARIANT=MAYO_3 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL
27
+ signature_keypair: pqmayo_MAYO_3_avx2_crypto_sign_keypair
28
+ signature_signature: pqmayo_MAYO_3_avx2_crypto_sign_signature
29
+ signature_verify: pqmayo_MAYO_3_avx2_crypto_sign_verify
30
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_3/api.h ./src/mayo_3/api.c
31
+ supported_platforms:
32
+ - architecture: x86_64
33
+ operating_systems:
34
+ - Darwin
35
+ - Linux
36
+ required_flags:
37
+ - avx2
38
+ - name: neon
39
+ version: round2
40
+ folder_name: .
41
+ compile_opts: -DMAYO_VARIANT=MAYO_3 -DMAYO_BUILD_TYPE_NEON -DMAYO_NEON -DHAVE_RANDOMBYTES_NORETVAL
42
+ signature_keypair: pqmayo_MAYO_3_neon_crypto_sign_keypair
43
+ signature_signature: pqmayo_MAYO_3_neon_crypto_sign_signature
44
+ signature_verify: pqmayo_MAYO_3_neon_crypto_sign_verify
45
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/neon/arithmetic_common.h ./src/neon/echelon_form.h ./src/neon/echelon_form_loop.h ./src/neon/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_3/api.h ./src/mayo_3/api.c
46
+ supported_platforms:
47
+ - architecture: arm_8
48
+ operating_systems:
49
+ - Darwin
50
+ - Linux
51
+ required_flags:
52
+ - asimd
@@ -0,0 +1,52 @@
1
+ name: MAYO-5
2
+ type: signature
3
+ claimed-nist-level: 5
4
+ length-public-key: 5554
5
+ length-secret-key: 40
6
+ length-signature: 964
7
+ nistkat-sha256: 9a2ede41913131ab479c2581a1a8e86b97222d800aeb16bf67f6163481f2d587
8
+ principal-submitters:
9
+ - Ward Beullens
10
+ - Fabio Campos
11
+ - Sofía Celi
12
+ - Basil Hess
13
+ - Matthias J. Kannwischer
14
+ implementations:
15
+ - name: opt
16
+ version: round2
17
+ folder_name: .
18
+ compile_opts: -DMAYO_VARIANT=MAYO_5 -DMAYO_BUILD_TYPE_OPT -DHAVE_RANDOMBYTES_NORETVAL -DHAVE_STACKEFFICIENT
19
+ signature_keypair: pqmayo_MAYO_5_opt_crypto_sign_keypair
20
+ signature_signature: pqmayo_MAYO_5_opt_crypto_sign_signature
21
+ signature_verify: pqmayo_MAYO_5_opt_crypto_sign_verify
22
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_dynamic.h ./src/generic/arithmetic_fixed.h ./src/generic/echelon_form.h ./src/generic/ef_inner_loop.h ./src/generic/generic_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_5/api.h ./src/mayo_5/api.c
23
+ - name: avx2
24
+ version: round2
25
+ folder_name: .
26
+ compile_opts: -DMAYO_VARIANT=MAYO_5 -DMAYO_BUILD_TYPE_AVX2 -DMAYO_AVX -DHAVE_RANDOMBYTES_NORETVAL
27
+ signature_keypair: pqmayo_MAYO_5_avx2_crypto_sign_keypair
28
+ signature_signature: pqmayo_MAYO_5_avx2_crypto_sign_signature
29
+ signature_verify: pqmayo_MAYO_5_avx2_crypto_sign_verify
30
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/AVX2/arithmetic_common.h ./src/AVX2/echelon_form.h ./src/AVX2/echelon_form_loop.h ./src/AVX2/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_5/api.h ./src/mayo_5/api.c
31
+ supported_platforms:
32
+ - architecture: x86_64
33
+ operating_systems:
34
+ - Darwin
35
+ - Linux
36
+ required_flags:
37
+ - avx2
38
+ - name: neon
39
+ version: round2
40
+ folder_name: .
41
+ compile_opts: -DMAYO_VARIANT=MAYO_5 -DMAYO_BUILD_TYPE_NEON -DMAYO_NEON -DHAVE_RANDOMBYTES_NORETVAL
42
+ signature_keypair: pqmayo_MAYO_5_neon_crypto_sign_keypair
43
+ signature_signature: pqmayo_MAYO_5_neon_crypto_sign_signature
44
+ signature_verify: pqmayo_MAYO_5_neon_crypto_sign_verify
45
+ sources: LICENSE NOTICE ./src/arithmetic.c ./src/arithmetic.h ./src/mayo.c ./src/params.c ./src/simple_arithmetic.h ./src/generic/arithmetic_fixed.h ./src/neon/arithmetic_common.h ./src/neon/echelon_form.h ./src/neon/echelon_form_loop.h ./src/neon/shuffle_arithmetic.h ./include/mayo.h ./include/mem.h ./src/common/aes_ctr.h ./src/mayo_5/api.h ./src/mayo_5/api.c
46
+ supported_platforms:
47
+ - architecture: arm_8
48
+ operating_systems:
49
+ - Darwin
50
+ - Linux
51
+ required_flags:
52
+ - asimd
package/mayo-c/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023-2025 the MAYO team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,183 @@
1
+ # MAYO-C
2
+
3
+ ![MAYO-C workflow](https://github.com/PQCMayo/MAYO-C/actions/workflows/cmake.yml/badge.svg)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+
6
+ ```
7
+ This code is part of a NIST submission for the PQC signatures call.
8
+ ```
9
+
10
+ MAYO-C is a C library implementation of [MAYO](https://pqmayo.org), a multivariate quadratic signature scheme. It implements the following parameter sets:
11
+
12
+ | Parameter Set | NIST Security Level | n | m | o | k | q | sk size | pk size | sig size |
13
+ | --- | ---- | -- | -- | -- | -- | -- | -- | -- | -- |
14
+ | MAYO_1 | 1 | 86 | 78 | 8 | 10 | 16 | 24 B | 1420 B | 454 B |
15
+ | MAYO_2 | 1 | 81 | 64 | 17 | 4 | 16 | 24 B | 4912 B | 186 B |
16
+ | MAYO_3 | 3 | 118 | 108 | 10 | 11 | 16 | 32 B | 2986 B | 681 B |
17
+ | MAYO_5 | 5 | 154 | 142 | 12 | 12 | 16 | 40 B | 5554 B | 964 B |
18
+
19
+ ## Requirements
20
+
21
+ - CMake (version 3.10 or later)
22
+ - C99-compatible compiler
23
+ - Valgrind (for dynamic testing)
24
+ - Clang static analyzer (version 10 or later, for static analysis)
25
+
26
+ ## Build
27
+
28
+ - `mkdir -p build`
29
+ - `cd build`
30
+ - `cmake <Build Options> ..`
31
+ - `make`
32
+
33
+ The following build options have been used to report performance numbers in the specification:
34
+
35
+ 1. Reference: `cmake -DMAYO_BUILD_TYPE=ref -DENABLE_AESNI=OFF ..`
36
+ 2. Optimized (AES-NI enabled): `cmake -DMAYO_BUILD_TYPE=opt -DENABLE_AESNI=ON ..`
37
+ 3. Optimized (AES-NI disabled): `cmake -DMAYO_BUILD_TYPE=opt -DENABLE_AESNI=OFF ..`
38
+ 4. AVX2: `cmake -DMAYO_BUILD_TYPE=avx2 -DENABLE_AESNI=ON ..`
39
+ 5. A64 M1/M2/M3 NEON: `cmake -DMAYO_BUILD_TYPE=neon -DENABLE_AESNEON=ON ..`
40
+ 6. A64 RPi4 Cortex-A72 NEON: `cmake -DMAYO_BUILD_TYPE=neon -DENABLE_AESNEON=OFF ..`
41
+
42
+ ## Build options
43
+
44
+ CMake build options can be specified with `-D<BUILD_OPTION>=<VALUE>`.
45
+
46
+ ### ENABLE_TESTS
47
+
48
+ Builds a test harness for the library, the default value is `ON`.
49
+
50
+ ### ENABLE_CT_TESTING
51
+
52
+ Builds the library with instrumentation for constant-time behavior testing, the default value is `OFF`. Valgrind development files are used for this build option.
53
+
54
+ ### ENABLE_PARAMS_DYNAMIC
55
+
56
+ Builds the library as a single library dynamically supporting all mayo parameter sets. If the option is turned off, multiple libraries for each parameter sets are built, which usually comes with a performance gain. The default value is `OFF`.
57
+
58
+ ### ENABLE_STRICT
59
+
60
+ Builds the library in strict mode: warnings terminate compilation). The default value is `ON`.
61
+
62
+ ### MAYO_BUILD_TYPE
63
+
64
+ Specifies the build type for which Mayo is built. The options are `ref`, `opt` and `avx2`. The effect is the following:
65
+
66
+ - `ref` builds MAYO implemented with portable C code for native target architecture, using run-time parameters.
67
+ - `opt` builds MAYO implemented with optimized portable C code, compiled with `-march=native` (if available) and AES acceleration (if available)
68
+ - `avx2` builds MAYO implemented with optimized AVX2 code, compiled with `-march=native` (if available) and AES acceleration (if available)
69
+ - `neon` builds MAYO implemented with optimized NEON code, compiled with `-march=native` (if available) and AES acceleration (if available)
70
+
71
+ The default build type if none is specified is `opt`.
72
+
73
+ ### CMAKE_BUILD_TYPE
74
+
75
+ Can be used to specify special build types. The options are:
76
+
77
+ - `ASAN`: Builds with AddressSanitizer memory error detector.
78
+ - `MSAN`: Builds with MemorySanitizer detector for uninitialized reads.
79
+ - `LSAN`: Builds with LeakSanitizer for run-time memory leak detection.
80
+ - `UBSAN`: Builds with UndefinedBehaviorSanitizer for undefined behavior detection.
81
+
82
+ The default build type uses `-O3 -Wstrict-prototypes -Wno-error=strict-prototypes -fvisibility=hidden -Wno-error=implicit-function-declaration -Wno-error=attributes`.
83
+
84
+ ## Build artifacts
85
+
86
+ The following artifacts are built:
87
+
88
+ - `libmayo_common_sys.a`: library with common crypto - AES, Keccak and system random number generator.
89
+ - `libmary_common_test.a`: library with common crypto for deterministic tests - AES, Keccak and CTR-DRBG PRNG.
90
+ - `libmayo_<level>.a`: library for `MAYO_<level>`.
91
+ - `libmayo_<level>_test`: library for `MAYO_<level>`, only for test, using the deterministic CTR-DRBG as backend.
92
+ - `libmayo_<level>_nistapi.a`: library for `MAYO_<level>` against the NIST API.
93
+ - `libmayo_<level>_nistapi_test.a`: library for `MAYO_<level>` against the NIST API. Only for test, using the deterministic CTR-DRBG as backend.
94
+ - `mayo_bench_<param>`: Benchmarking suites.
95
+ - `mayo_test_kat_<param>` (`opt`, `avx2` and `neon`), `mayo_test_kat` (`ref`): KAT test suites.
96
+ - `mayo_test_scheme_<param>` (`opt`, `avx2` and `neon`), `mayo_test_scheme` (`ref`): Self-test suites.
97
+ - `PQCgenKAT_sign_<param>`: App for generating NIST KAT.
98
+ - `example_<param>` (`opt`, `avx2` and `neon`), `example_mayo` (`ref`): Example app using the MAYO API.
99
+ - `example_nistapi_<param>`: Example app using the NIST API.
100
+
101
+ ## Test
102
+
103
+ In the `build` directory, run: `make test`.
104
+
105
+ The test harness consists of the following units:
106
+
107
+ - KAT test: tests against the KAT files in the `KAT` folder - `MAYO_<level>_KAT`
108
+ - Self-tests: runs random self-tests (key-generation, signing and verifying) - `MAYO_<level>_SELFTEST`
109
+
110
+ ## Known Answer Tests (KAT)
111
+
112
+ KAT are available in folder `KAT`. They can be generated by running the apps built in the `apps` folder:
113
+
114
+ - `apps/PQCgenKAT_sign_mayo_1`
115
+ - `apps/PQCgenKAT_sign_mayo_2`
116
+ - `apps/PQCgenKAT_sign_mayo_3`
117
+ - `apps/PQCgenKAT_sign_mayo_5`
118
+
119
+ A successful execution will generate the `.req` and `.rsp` files.
120
+
121
+ KAT verification is done as part of the test harness (see previous section).
122
+
123
+ ## Benchmarks
124
+
125
+ A benchmarking suite is built and runs with the following command, where `params` specifies the MAYO parameter set and `runs` the number of benchmark runs:
126
+
127
+ If `MAYO_BUILD_TYPE` is `opt`, `avx2` or `neon`:
128
+ - `test/mayo_bench_<param> <runs>`,
129
+ - On Apple M1/M2/M3 chips, this must be run with root (`sudo`) permission.
130
+
131
+ If `MAYO_BUILD_TYPE` is `ref`:
132
+ - `test/mayo_bench <param> <runs>`,
133
+
134
+ The benchmarks profile the `MAYO.CompactKeyGen`, `MAYO.expandSK`, `MAYO.expandSK`, `MAYO.sign` and `MAYO.verify` functions. The results are reported in CPU cycles if available on the host platform, and timing in nanoseconds otherwise.
135
+
136
+ ## Examples
137
+
138
+ Example code that demonstrates how to use MAYO both via the MAYO API and NIST API are available in the `apps` folder:
139
+
140
+ - `apps/example.c`: Example with the MAYO API.
141
+ - `apps/example_nistapi.c`: Example with the NIST API.
142
+
143
+ ## Project Structure
144
+
145
+ - `apps`: Applications: KAT generation application
146
+ - `include`: MAYO public header files
147
+ - `KAT`: Known Answer Test files
148
+ - `src`: MAYO source code
149
+ - `src/mayo_<x>` MAYO implementation with NIST signature API
150
+ - `src/common`: MAYO common components (RNG, AES, SHAKE)
151
+ - `src/generic`: MAYO generic C source code
152
+ - `src/<arch>`: MAYO <arch> specific source code
153
+ - `test`: MAYO test code
154
+
155
+ ## License
156
+
157
+ MAYO-C is licensed under Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
158
+
159
+ Third party code is used in some test and common code files:
160
+
161
+ - `common/aes_c.c`; MIT: "Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>"
162
+ - `common/aes128ctr.c`: MIT: "Copyright (c) 2016-2021 Open Quantum Safe project" and Public Domain
163
+ - `common/aes_neon.c`: MIT: "Copyright (c) 2024 ChristerKnorborg" and Public Domain
164
+ - `common/fips202.c`: Public Domain
165
+ - `common/randombytes_system.c`: MIT: Copyright (c) 2017 Daan Sprenkels <hello@dsprenkels.com>
166
+ - `apps/PQCgenKAT_sign.c`, `common/randombytes_ctrdrbg.c`, `test/test_kat.c`: by NIST (Public Domain)
167
+ - `test/m1cycles.{c,h}`, Apache 2.0 and Public Domain
168
+
169
+ See also the SPDX License Identifiers in the respective files.
170
+
171
+ ## Citing
172
+
173
+ Bibtext:
174
+
175
+ ```
176
+ @manual{mayo-c,
177
+ title = {MAYO C implementation},
178
+ author = {Ward Beullens and Fabio Campos and Sof\'{i}a Celi and Basil Hess and Matthias J. Kannwischer},
179
+ note = {Available at \url{https://github.com/PQCMayo/MAYO-C}. Accessed June, 2023},
180
+ month = jun,
181
+ year = {2023}
182
+ }
183
+ ```
@@ -0,0 +1,31 @@
1
+ ## NIST KAT generation apps
2
+ foreach(MVARIANT ${MVARIANT_S})
3
+ string(TOLOWER ${MVARIANT} MVARIANT_LOWER)
4
+ add_executable(PQCgenKAT_sign_${MVARIANT_LOWER} PQCgenKAT_sign.c)
5
+ target_link_libraries(PQCgenKAT_sign_${MVARIANT_LOWER} PRIVATE ${MVARIANT_LOWER}_test_nistapi)
6
+ target_include_directories(PQCgenKAT_sign_${MVARIANT_LOWER} PRIVATE ../include)
7
+ endforeach()
8
+
9
+ ## Examples with MAYO API
10
+ if (ENABLE_PARAMS_DYNAMIC)
11
+ add_executable(example_mayo example.c)
12
+ target_link_libraries(example_mayo PRIVATE mayo)
13
+ target_include_directories(example_mayo PRIVATE ../include)
14
+ else()
15
+ foreach(MVARIANT ${MVARIANT_S})
16
+ string(TOLOWER ${MVARIANT} MVARIANT_LOWER)
17
+ add_executable(example_${MVARIANT_LOWER} example.c)
18
+ target_link_libraries(example_${MVARIANT_LOWER} PRIVATE ${MVARIANT_LOWER})
19
+ target_include_directories(example_${MVARIANT_LOWER} PRIVATE ../include)
20
+ target_compile_definitions(example_${MVARIANT_LOWER} PRIVATE MAYO_VARIANT=${MVARIANT})
21
+ endforeach()
22
+ endif()
23
+
24
+ ## Examples with NIST API
25
+ foreach(MVARIANT ${MVARIANT_S})
26
+ string(TOLOWER ${MVARIANT} MVARIANT_LOWER)
27
+ add_executable(example_nistapi_${MVARIANT_LOWER} example_nistapi.c)
28
+ target_link_libraries(example_nistapi_${MVARIANT_LOWER} PRIVATE ${MVARIANT_LOWER}_nistapi)
29
+ target_include_directories(example_nistapi_${MVARIANT_LOWER} PRIVATE ../include ../src/${MVARIANT_LOWER})
30
+ endforeach()
31
+