-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove FIPS202_NAMESPACE_PREFIX configuration option #672
Conversation
119fc71
to
ca92329
Compare
Previously, the namespace for FIPS202 symbols could be separately defined from the namespace for MLKEM-specific symbols. This was primarily to allow for a multi-level build where FIPS202 code is shared. Now that multi-level builds are possible even with sharing of all level-independent code (not merely FIPS202), there is no longer a use of a separate FIPS202 namespace. Note also that when a custom FIPS202 implementation is used, the user is in full control of namespacing since they are expected to replace the FIPS202 headers. In light of the above, this commit merges the FIPS202_NAMESPACE_PREFIX configuration option into MLKEM_NAMESPACE_PREFIX. The latter now controls prefixing of _all_ global symbols in an mlkem-native build. If users want to share common code in a multilevel build, this should be done by setting MLKEM_NAMESPACE_PREFIX_ADD_LEVEL, and dropping the level from the MLKEM_NAMESPACE_PREFIX; all this is already demonstrated in the example `example/multilevel_build`. It is therefore no longer necessary to demonstrate a shared-FIPS202 build in the `Makefile`, which was done so far. Instead, the default build can be simplified to three independent builds of libmlkem{512,768,1024}, each with their own FIPS202. Again, usage examples are now provided in `examples/*`, while the user should not need to inspect the test Makefiles. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
ca92329
to
cb6b7a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arm Cortex-A76 (Raspberry Pi 5) benchmarks
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
29052 cycles |
29080 cycles |
1.00 |
ML-KEM-512 encaps |
35415 cycles |
35434 cycles |
1.00 |
ML-KEM-512 decaps |
45889 cycles |
45903 cycles |
1.00 |
ML-KEM-768 keypair |
49307 cycles |
49300 cycles |
1.00 |
ML-KEM-768 encaps |
55610 cycles |
55591 cycles |
1.00 |
ML-KEM-768 decaps |
70376 cycles |
70356 cycles |
1.00 |
ML-KEM-1024 keypair |
72088 cycles |
72019 cycles |
1.00 |
ML-KEM-1024 encaps |
80839 cycles |
80739 cycles |
1.00 |
ML-KEM-1024 decaps |
100712 cycles |
100646 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intel Xeon 4th gen (c7i)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
13522 cycles |
13517 cycles |
1.00 |
ML-KEM-512 encaps |
17302 cycles |
17266 cycles |
1.00 |
ML-KEM-512 decaps |
22852 cycles |
22791 cycles |
1.00 |
ML-KEM-768 keypair |
22545 cycles |
22537 cycles |
1.00 |
ML-KEM-768 encaps |
24569 cycles |
24540 cycles |
1.00 |
ML-KEM-768 decaps |
32589 cycles |
32550 cycles |
1.00 |
ML-KEM-1024 keypair |
31497 cycles |
31535 cycles |
1.00 |
ML-KEM-1024 encaps |
34843 cycles |
34867 cycles |
1.00 |
ML-KEM-1024 decaps |
45712 cycles |
45809 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intel Xeon 4th gen (c7i) (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
33224 cycles |
33267 cycles |
1.00 |
ML-KEM-512 encaps |
38674 cycles |
38680 cycles |
1.00 |
ML-KEM-512 decaps |
50006 cycles |
50063 cycles |
1.00 |
ML-KEM-768 keypair |
54076 cycles |
54067 cycles |
1.00 |
ML-KEM-768 encaps |
61043 cycles |
61066 cycles |
1.00 |
ML-KEM-768 decaps |
75807 cycles |
75782 cycles |
1.00 |
ML-KEM-1024 keypair |
82361 cycles |
82432 cycles |
1.00 |
ML-KEM-1024 encaps |
92965 cycles |
92941 cycles |
1.00 |
ML-KEM-1024 decaps |
111567 cycles |
111525 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arm Cortex-A55 (Snapdragon 888) benchmarks
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
58324 cycles |
58337 cycles |
1.00 |
ML-KEM-512 encaps |
65743 cycles |
65750 cycles |
1.00 |
ML-KEM-512 decaps |
84550 cycles |
84524 cycles |
1.00 |
ML-KEM-768 keypair |
98953 cycles |
98954 cycles |
1.00 |
ML-KEM-768 encaps |
110401 cycles |
110343 cycles |
1.00 |
ML-KEM-768 decaps |
136581 cycles |
136523 cycles |
1.00 |
ML-KEM-1024 keypair |
150123 cycles |
150162 cycles |
1.00 |
ML-KEM-1024 encaps |
166448 cycles |
166157 cycles |
1.00 |
ML-KEM-1024 decaps |
202115 cycles |
202263 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AMD EPYC 3rd gen (c6a)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
18170 cycles |
18110 cycles |
1.00 |
ML-KEM-512 encaps |
22996 cycles |
22994 cycles |
1.00 |
ML-KEM-512 decaps |
30233 cycles |
30314 cycles |
1.00 |
ML-KEM-768 keypair |
31114 cycles |
31107 cycles |
1.00 |
ML-KEM-768 encaps |
33904 cycles |
33885 cycles |
1.00 |
ML-KEM-768 decaps |
44538 cycles |
44610 cycles |
1.00 |
ML-KEM-1024 keypair |
44515 cycles |
44396 cycles |
1.00 |
ML-KEM-1024 encaps |
49788 cycles |
49543 cycles |
1.00 |
ML-KEM-1024 decaps |
64301 cycles |
64077 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intel Xeon 3rd gen (c6i)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
20348 cycles |
20354 cycles |
1.00 |
ML-KEM-512 encaps |
27160 cycles |
26922 cycles |
1.01 |
ML-KEM-512 decaps |
35750 cycles |
35737 cycles |
1.00 |
ML-KEM-768 keypair |
34878 cycles |
34903 cycles |
1.00 |
ML-KEM-768 encaps |
38160 cycles |
38190 cycles |
1.00 |
ML-KEM-768 decaps |
50942 cycles |
50956 cycles |
1.00 |
ML-KEM-1024 keypair |
48070 cycles |
48037 cycles |
1.00 |
ML-KEM-1024 encaps |
53930 cycles |
53872 cycles |
1.00 |
ML-KEM-1024 decaps |
71417 cycles |
71418 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graviton4
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
18121 cycles |
18116 cycles |
1.00 |
ML-KEM-512 encaps |
22176 cycles |
22180 cycles |
1.00 |
ML-KEM-512 decaps |
28836 cycles |
28845 cycles |
1.00 |
ML-KEM-768 keypair |
30544 cycles |
30552 cycles |
1.00 |
ML-KEM-768 encaps |
33631 cycles |
33635 cycles |
1.00 |
ML-KEM-768 decaps |
43171 cycles |
43159 cycles |
1.00 |
ML-KEM-1024 keypair |
44173 cycles |
44155 cycles |
1.00 |
ML-KEM-1024 encaps |
49651 cycles |
49644 cycles |
1.00 |
ML-KEM-1024 decaps |
62611 cycles |
62630 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graviton2
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
29053 cycles |
29079 cycles |
1.00 |
ML-KEM-512 encaps |
35404 cycles |
35455 cycles |
1.00 |
ML-KEM-512 decaps |
45901 cycles |
45897 cycles |
1.00 |
ML-KEM-768 keypair |
49315 cycles |
49316 cycles |
1.00 |
ML-KEM-768 encaps |
55625 cycles |
55598 cycles |
1.00 |
ML-KEM-768 decaps |
70409 cycles |
70388 cycles |
1.00 |
ML-KEM-1024 keypair |
72172 cycles |
72026 cycles |
1.00 |
ML-KEM-1024 encaps |
80955 cycles |
80761 cycles |
1.00 |
ML-KEM-1024 decaps |
100872 cycles |
100670 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AMD EPYC 3rd gen (c6a) (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
43322 cycles |
43442 cycles |
1.00 |
ML-KEM-512 encaps |
51410 cycles |
51406 cycles |
1.00 |
ML-KEM-512 decaps |
66726 cycles |
66702 cycles |
1.00 |
ML-KEM-768 keypair |
71799 cycles |
71827 cycles |
1.00 |
ML-KEM-768 encaps |
83396 cycles |
83304 cycles |
1.00 |
ML-KEM-768 decaps |
103878 cycles |
103667 cycles |
1.00 |
ML-KEM-1024 keypair |
107204 cycles |
107138 cycles |
1.00 |
ML-KEM-1024 encaps |
122026 cycles |
122109 cycles |
1.00 |
ML-KEM-1024 decaps |
148130 cycles |
147886 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intel Xeon 3rd gen (c6i) (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
51611 cycles |
51538 cycles |
1.00 |
ML-KEM-512 encaps |
59740 cycles |
59634 cycles |
1.00 |
ML-KEM-512 decaps |
76677 cycles |
76544 cycles |
1.00 |
ML-KEM-768 keypair |
84336 cycles |
84288 cycles |
1.00 |
ML-KEM-768 encaps |
95629 cycles |
95641 cycles |
1.00 |
ML-KEM-768 decaps |
117703 cycles |
117943 cycles |
1.00 |
ML-KEM-1024 keypair |
125339 cycles |
125363 cycles |
1.00 |
ML-KEM-1024 encaps |
139520 cycles |
139482 cycles |
1.00 |
ML-KEM-1024 decaps |
168167 cycles |
168180 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graviton4 (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
37960 cycles |
38052 cycles |
1.00 |
ML-KEM-512 encaps |
43322 cycles |
43371 cycles |
1.00 |
ML-KEM-512 decaps |
55508 cycles |
55552 cycles |
1.00 |
ML-KEM-768 keypair |
63010 cycles |
63038 cycles |
1.00 |
ML-KEM-768 encaps |
70538 cycles |
70440 cycles |
1.00 |
ML-KEM-768 decaps |
87021 cycles |
86908 cycles |
1.00 |
ML-KEM-1024 keypair |
94585 cycles |
94539 cycles |
1.00 |
ML-KEM-1024 encaps |
105393 cycles |
105314 cycles |
1.00 |
ML-KEM-1024 decaps |
126667 cycles |
126986 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AMD EPYC 4th gen (c7a)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
14871 cycles |
14893 cycles |
1.00 |
ML-KEM-512 encaps |
19687 cycles |
19708 cycles |
1.00 |
ML-KEM-512 decaps |
26365 cycles |
26576 cycles |
0.99 |
ML-KEM-768 keypair |
25588 cycles |
25613 cycles |
1.00 |
ML-KEM-768 encaps |
28099 cycles |
28157 cycles |
1.00 |
ML-KEM-768 decaps |
37821 cycles |
37835 cycles |
1.00 |
ML-KEM-1024 keypair |
35935 cycles |
35590 cycles |
1.01 |
ML-KEM-1024 encaps |
40640 cycles |
40336 cycles |
1.01 |
ML-KEM-1024 decaps |
54079 cycles |
53879 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graviton2 (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
60767 cycles |
60638 cycles |
1.00 |
ML-KEM-512 encaps |
69735 cycles |
69777 cycles |
1.00 |
ML-KEM-512 decaps |
88805 cycles |
88704 cycles |
1.00 |
ML-KEM-768 keypair |
101999 cycles |
101743 cycles |
1.00 |
ML-KEM-768 encaps |
115220 cycles |
115005 cycles |
1.00 |
ML-KEM-768 decaps |
140658 cycles |
140654 cycles |
1.00 |
ML-KEM-1024 keypair |
154699 cycles |
154323 cycles |
1.00 |
ML-KEM-1024 encaps |
171813 cycles |
171473 cycles |
1.00 |
ML-KEM-1024 decaps |
204390 cycles |
203985 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AMD EPYC 4th gen (c7a) (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
39366 cycles |
39396 cycles |
1.00 |
ML-KEM-512 encaps |
45577 cycles |
45598 cycles |
1.00 |
ML-KEM-512 decaps |
59039 cycles |
59080 cycles |
1.00 |
ML-KEM-768 keypair |
64880 cycles |
64918 cycles |
1.00 |
ML-KEM-768 encaps |
73199 cycles |
73199 cycles |
1 |
ML-KEM-768 decaps |
91307 cycles |
91533 cycles |
1.00 |
ML-KEM-1024 keypair |
96668 cycles |
96607 cycles |
1.00 |
ML-KEM-1024 encaps |
107833 cycles |
107897 cycles |
1.00 |
ML-KEM-1024 decaps |
131430 cycles |
131224 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graviton3
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
18953 cycles |
18950 cycles |
1.00 |
ML-KEM-512 encaps |
23560 cycles |
23573 cycles |
1.00 |
ML-KEM-512 decaps |
30706 cycles |
30675 cycles |
1.00 |
ML-KEM-768 keypair |
32335 cycles |
32341 cycles |
1.00 |
ML-KEM-768 encaps |
35897 cycles |
35900 cycles |
1.00 |
ML-KEM-768 decaps |
46041 cycles |
46041 cycles |
1 |
ML-KEM-1024 keypair |
46566 cycles |
46586 cycles |
1.00 |
ML-KEM-1024 encaps |
52439 cycles |
52470 cycles |
1.00 |
ML-KEM-1024 decaps |
66267 cycles |
66239 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graviton3 (no-opt)
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
39335 cycles |
39349 cycles |
1.00 |
ML-KEM-512 encaps |
45371 cycles |
45352 cycles |
1.00 |
ML-KEM-512 decaps |
57270 cycles |
57395 cycles |
1.00 |
ML-KEM-768 keypair |
65884 cycles |
65864 cycles |
1.00 |
ML-KEM-768 encaps |
73706 cycles |
73715 cycles |
1.00 |
ML-KEM-768 decaps |
89714 cycles |
89700 cycles |
1.00 |
ML-KEM-1024 keypair |
99009 cycles |
98984 cycles |
1.00 |
ML-KEM-1024 encaps |
109964 cycles |
109964 cycles |
1 |
ML-KEM-1024 decaps |
130717 cycles |
130729 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bananapi bpi-f3 benchmarks
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
331562 cycles |
331562 cycles |
1 |
ML-KEM-512 encaps |
440572 cycles |
440510 cycles |
1.00 |
ML-KEM-512 decaps |
588957 cycles |
588870 cycles |
1.00 |
ML-KEM-768 keypair |
548498 cycles |
548593 cycles |
1.00 |
ML-KEM-768 encaps |
687574 cycles |
687637 cycles |
1.00 |
ML-KEM-768 decaps |
880175 cycles |
879374 cycles |
1.00 |
ML-KEM-1024 keypair |
809121 cycles |
809108 cycles |
1.00 |
ML-KEM-1024 encaps |
981241 cycles |
981068 cycles |
1.00 |
ML-KEM-1024 decaps |
1215321 cycles |
1215369 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arm Cortex-A72 (Raspberry Pi 4) benchmarks
Benchmark suite | Current: cb6b7a8 | Previous: 412ff2d | Ratio |
---|---|---|---|
ML-KEM-512 keypair |
51554 cycles |
52445 cycles |
0.98 |
ML-KEM-512 encaps |
57852 cycles |
58898 cycles |
0.98 |
ML-KEM-512 decaps |
74440 cycles |
75192 cycles |
0.99 |
ML-KEM-768 keypair |
87698 cycles |
88768 cycles |
0.99 |
ML-KEM-768 encaps |
96499 cycles |
96913 cycles |
1.00 |
ML-KEM-768 decaps |
120558 cycles |
119344 cycles |
1.01 |
ML-KEM-1024 keypair |
131611 cycles |
132166 cycles |
1.00 |
ML-KEM-1024 encaps |
144488 cycles |
144492 cycles |
1.00 |
ML-KEM-1024 decaps |
176069 cycles |
175903 cycles |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Previously, the namespace for FIPS202 symbols could be separately defined from the namespace for MLKEM-specific symbols. This was primarily to allow for a multi-level build where FIPS202 code is shared.
Now that multi-level builds are possible even with sharing of all level-independent code (not merely FIPS202), there is no longer a use of a separate FIPS202 namespace. Note also that when a custom FIPS202 implementation is used, the user is in full control of namespacing since they are expected to replace the FIPS202 headers.
In light of the above, this commit merges the FIPS202_NAMESPACE_PREFIX configuration option into MLKEM_NAMESPACE_PREFIX. The latter now controls prefixing of all global symbols in an mlkem-native build.
If users want to share common code in a multilevel build, this should be done by setting MLKEM_NAMESPACE_PREFIX_ADD_LEVEL, and dropping the level from the MLKEM_NAMESPACE_PREFIX; all this is already demonstrated in the example
example/multilevel_build
. It is therefore no longer necessary to demonstrate a shared-FIPS202 build in theMakefile
, which was done so far. Instead, the default build can be simplified to three independent builds of libmlkem{512,768,1024}, each with their own FIPS202. Again, usage examples are now provided inexamples/*
, while the user should not need to inspect the test Makefiles.