-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #619 from pq-code-package/kem_h
Introduce header for mlkem-native's public API
- Loading branch information
Showing
28 changed files
with
3,539 additions
and
2,943 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../mlkem/mlkem_native.h |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include <kem.h> | ||
#include <mlkem_native.h> | ||
|
||
int main(void) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright (c) 2024 The mlkem-native project authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef MLKEM_NATIVE_CONFIG_H | ||
#define MLKEM_NATIVE_CONFIG_H | ||
|
||
/****************************************************************************** | ||
* Name: MLKEM_K | ||
* | ||
* Description: Determines the security level for ML-KEM | ||
* - MLKEM_K=2 corresponds to ML-KEM-512 | ||
* - MLKEM_K=3 corresponds to ML-KEM-768 | ||
* - MLKEM_K=4 corresponds to ML-KEM-1024 | ||
* | ||
* This can also be set using CFLAGS. | ||
* | ||
*****************************************************************************/ | ||
#ifndef MLKEM_K | ||
#define MLKEM_K 2 /* Change this for different security strengths */ | ||
#endif | ||
|
||
/****************************************************************************** | ||
* Name: MLKEM_NATIVE_CONFIG_FILE | ||
* | ||
* Description: If defined, this is a header that will be included instead | ||
* of mlkem/config.h. | ||
* | ||
* This _must_ be set on the command line using | ||
* `-DMLKEM_NATIVE_CONFIG_FILE="..."`. | ||
* | ||
* When you need to build mlkem-native in multiple configurations, | ||
* using varying MLKEM_NATIE_CONFIG_FILE can be more convenient | ||
* then configuring everything through CFLAGS. | ||
* | ||
*****************************************************************************/ | ||
/* #define MLKEM_NATIVE_CONFIG_FILE "config.h" */ | ||
|
||
/****************************************************************************** | ||
* Name: MLKEM_NAMESPACE | ||
* | ||
* Description: The macros to use to namespace global symbols | ||
* from mlkem/. | ||
*****************************************************************************/ | ||
#define CONCAT(a, b) a##b | ||
#define MLKEM_NAMESPACE(sym) CONCAT(mlkem512_, sym) | ||
|
||
/****************************************************************************** | ||
* Name: FIPS202_NAMESPACE | ||
* | ||
* Description: The macros to use to namespace global symbols | ||
* from mlkem/fips202/. | ||
*****************************************************************************/ | ||
#define FIPS202_NAMESPACE(sym) CONCAT(mlkem512_, sym) | ||
|
||
/****************************************************************************** | ||
* Name: MLKEM_USE_NATIVE | ||
* | ||
* Description: Determines whether a native backend should | ||
* be used, if available. | ||
* | ||
* This can also be set using CFLAGS. | ||
* | ||
*****************************************************************************/ | ||
/* #define MLKEM_USE_NATIVE */ | ||
|
||
/****************************************************************************** | ||
* Name: MLKEM_NATIVE_ARITH_BACKEND | ||
* | ||
* Description: The arithmetic backend to use. | ||
* | ||
* This must be the filename of an arithmetic backend. | ||
* See the existing backends for examples. | ||
* | ||
* This can be set using CFLAGS. | ||
* | ||
*****************************************************************************/ | ||
#if defined(MLKEM_USE_NATIVE) && !defined(MLKEM_NATIVE_ARITH_BACKEND) | ||
#define MLKEM_NATIVE_ARITH_BACKEND "native/default.h" | ||
#endif /* MLKEM_NATIVE_ARITH_BACKEND */ | ||
|
||
/****************************************************************************** | ||
* Name: MLKEM_NATIVE_FIPS202_BACKEND | ||
* | ||
* Description: The FIPS-202 backend to use. | ||
* | ||
* This must be the filename of an FIPS-202 backend. | ||
* | ||
* This can be set using CFLAGS. | ||
* | ||
*****************************************************************************/ | ||
#if defined(MLKEM_USE_NATIVE) && !defined(MLKEM_NATIVE_FIPS202_BACKEND) | ||
#define MLKEM_NATIVE_FIPS202_BACKEND "fips202/native/default.h" | ||
#endif /* MLKEM_NATIVE_FIPS202_BACKEND */ | ||
|
||
#endif /* MLkEM_NATIVE_CONFIG_H */ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
dc3d0cd
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
ML-KEM-512 keypair
29062
cycles29061
cycles1.00
ML-KEM-512 encaps
35383
cycles35384
cycles1.00
ML-KEM-512 decaps
45860
cycles45860
cycles1
ML-KEM-768 keypair
49395
cycles49388
cycles1.00
ML-KEM-768 encaps
55568
cycles55566
cycles1.00
ML-KEM-768 decaps
70311
cycles70304
cycles1.00
ML-KEM-1024 keypair
72048
cycles72050
cycles1.00
ML-KEM-1024 encaps
80821
cycles80825
cycles1.00
ML-KEM-1024 decaps
100697
cycles100700
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
13911
cycles13522
cycles1.03
ML-KEM-512 encaps
17239
cycles17307
cycles1.00
ML-KEM-512 decaps
23069
cycles22850
cycles1.01
ML-KEM-768 keypair
22563
cycles22521
cycles1.00
ML-KEM-768 encaps
24501
cycles24448
cycles1.00
ML-KEM-768 decaps
32532
cycles32387
cycles1.00
ML-KEM-1024 keypair
31369
cycles31386
cycles1.00
ML-KEM-1024 encaps
34920
cycles34920
cycles1
ML-KEM-1024 decaps
45821
cycles45791
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
18127
cycles18123
cycles1.00
ML-KEM-512 encaps
23200
cycles23219
cycles1.00
ML-KEM-512 decaps
30491
cycles30517
cycles1.00
ML-KEM-768 keypair
31076
cycles31112
cycles1.00
ML-KEM-768 encaps
34166
cycles34158
cycles1.00
ML-KEM-768 decaps
44731
cycles44736
cycles1.00
ML-KEM-1024 keypair
44615
cycles44735
cycles1.00
ML-KEM-1024 encaps
49907
cycles49899
cycles1.00
ML-KEM-1024 decaps
64356
cycles64342
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
20336
cycles20329
cycles1.00
ML-KEM-512 encaps
27016
cycles27016
cycles1
ML-KEM-512 decaps
35814
cycles35820
cycles1.00
ML-KEM-768 keypair
34895
cycles34903
cycles1.00
ML-KEM-768 encaps
38146
cycles38130
cycles1.00
ML-KEM-768 decaps
50971
cycles50970
cycles1.00
ML-KEM-1024 keypair
47950
cycles47958
cycles1.00
ML-KEM-1024 encaps
54107
cycles54119
cycles1.00
ML-KEM-1024 decaps
71636
cycles71659
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
34853
cycles34896
cycles1.00
ML-KEM-512 encaps
45050
cycles45026
cycles1.00
ML-KEM-512 decaps
58927
cycles58961
cycles1.00
ML-KEM-768 keypair
59275
cycles59186
cycles1.00
ML-KEM-768 encaps
71891
cycles71842
cycles1.00
ML-KEM-768 decaps
89446
cycles89371
cycles1.00
ML-KEM-1024 keypair
87544
cycles87532
cycles1.00
ML-KEM-1024 encaps
104559
cycles104588
cycles1.00
ML-KEM-1024 decaps
127643
cycles127572
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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
ML-KEM-512 keypair
18965
cycles18965
cycles1
ML-KEM-512 encaps
23587
cycles23590
cycles1.00
ML-KEM-512 decaps
30671
cycles30673
cycles1.00
ML-KEM-768 keypair
32288
cycles32290
cycles1.00
ML-KEM-768 encaps
35873
cycles35872
cycles1.00
ML-KEM-768 decaps
46039
cycles46043
cycles1.00
ML-KEM-1024 keypair
46611
cycles46612
cycles1.00
ML-KEM-1024 encaps
52445
cycles52449
cycles1.00
ML-KEM-1024 decaps
66245
cycles66245
cycles1
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
15060
cycles15058
cycles1.00
ML-KEM-512 encaps
19672
cycles19653
cycles1.00
ML-KEM-512 decaps
26313
cycles26288
cycles1.00
ML-KEM-768 keypair
25624
cycles25469
cycles1.01
ML-KEM-768 encaps
28174
cycles28135
cycles1.00
ML-KEM-768 decaps
37871
cycles37833
cycles1.00
ML-KEM-1024 keypair
35627
cycles35647
cycles1.00
ML-KEM-1024 encaps
40994
cycles40999
cycles1.00
ML-KEM-1024 decaps
54621
cycles54506
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
52168
cycles52177
cycles1.00
ML-KEM-512 encaps
65776
cycles65785
cycles1.00
ML-KEM-512 decaps
88405
cycles88423
cycles1.00
ML-KEM-768 keypair
84751
cycles84786
cycles1.00
ML-KEM-768 encaps
101453
cycles101479
cycles1.00
ML-KEM-768 decaps
132106
cycles132101
cycles1.00
ML-KEM-1024 keypair
124354
cycles124028
cycles1.00
ML-KEM-1024 encaps
145704
cycles145920
cycles1.00
ML-KEM-1024 decaps
183673
cycles183661
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
56637
cycles56667
cycles1.00
ML-KEM-512 encaps
69483
cycles69506
cycles1.00
ML-KEM-512 decaps
91396
cycles91492
cycles1.00
ML-KEM-768 keypair
91863
cycles91911
cycles1.00
ML-KEM-768 encaps
107820
cycles107825
cycles1.00
ML-KEM-768 decaps
136371
cycles136585
cycles1.00
ML-KEM-1024 keypair
134966
cycles134891
cycles1.00
ML-KEM-1024 encaps
155230
cycles155385
cycles1.00
ML-KEM-1024 decaps
191729
cycles191709
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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
ML-KEM-512 keypair
18135
cycles18133
cycles1.00
ML-KEM-512 encaps
22162
cycles22162
cycles1
ML-KEM-512 decaps
28771
cycles28770
cycles1.00
ML-KEM-768 keypair
30561
cycles30563
cycles1.00
ML-KEM-768 encaps
33620
cycles33618
cycles1.00
ML-KEM-768 decaps
43142
cycles43146
cycles1.00
ML-KEM-1024 keypair
44197
cycles44194
cycles1.00
ML-KEM-1024 encaps
49663
cycles49660
cycles1.00
ML-KEM-1024 decaps
62653
cycles62656
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
45388
cycles45387
cycles1.00
ML-KEM-512 encaps
54248
cycles54245
cycles1.00
ML-KEM-512 decaps
71154
cycles71158
cycles1.00
ML-KEM-768 keypair
74891
cycles74901
cycles1.00
ML-KEM-768 encaps
86130
cycles86136
cycles1.00
ML-KEM-768 decaps
108637
cycles108642
cycles1.00
ML-KEM-1024 keypair
111102
cycles111104
cycles1.00
ML-KEM-1024 encaps
125931
cycles125939
cycles1.00
ML-KEM-1024 decaps
154635
cycles154645
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
45761
cycles45715
cycles1.00
ML-KEM-512 encaps
56859
cycles56922
cycles1.00
ML-KEM-512 decaps
76275
cycles76247
cycles1.00
ML-KEM-768 keypair
74521
cycles74437
cycles1.00
ML-KEM-768 encaps
88579
cycles88528
cycles1.00
ML-KEM-768 decaps
114399
cycles114300
cycles1.00
ML-KEM-1024 keypair
109415
cycles109359
cycles1.00
ML-KEM-1024 encaps
127265
cycles127198
cycles1.00
ML-KEM-1024 decaps
159982
cycles159905
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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
ML-KEM-512 keypair
29061
cycles29059
cycles1.00
ML-KEM-512 encaps
35382
cycles35380
cycles1.00
ML-KEM-512 decaps
45899
cycles45897
cycles1.00
ML-KEM-768 keypair
49424
cycles49421
cycles1.00
ML-KEM-768 encaps
55577
cycles55568
cycles1.00
ML-KEM-768 decaps
70321
cycles70321
cycles1
ML-KEM-1024 keypair
72051
cycles72049
cycles1.00
ML-KEM-1024 encaps
80854
cycles80859
cycles1.00
ML-KEM-1024 decaps
100735
cycles100729
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
41960
cycles41962
cycles1.00
ML-KEM-512 encaps
50107
cycles50107
cycles1
ML-KEM-512 decaps
66081
cycles66079
cycles1.00
ML-KEM-768 keypair
69189
cycles69183
cycles1.00
ML-KEM-768 encaps
79961
cycles79958
cycles1.00
ML-KEM-768 decaps
101149
cycles101142
cycles1.00
ML-KEM-1024 keypair
102498
cycles102501
cycles1.00
ML-KEM-1024 encaps
117442
cycles117438
cycles1.00
ML-KEM-1024 decaps
143369
cycles143375
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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)
ML-KEM-512 keypair
71199
cycles71184
cycles1.00
ML-KEM-512 encaps
85130
cycles85120
cycles1.00
ML-KEM-512 decaps
112553
cycles112558
cycles1.00
ML-KEM-768 keypair
117671
cycles117715
cycles1.00
ML-KEM-768 encaps
135261
cycles135306
cycles1.00
ML-KEM-768 decaps
172112
cycles172149
cycles1.00
ML-KEM-1024 keypair
175078
cycles175075
cycles1.00
ML-KEM-1024 encaps
197185
cycles197201
cycles1.00
ML-KEM-1024 decaps
243470
cycles243455
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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
ML-KEM-512 keypair
335087
cycles335241
cycles1.00
ML-KEM-512 encaps
445805
cycles445831
cycles1.00
ML-KEM-512 decaps
593954
cycles594090
cycles1.00
ML-KEM-768 keypair
556239
cycles556387
cycles1.00
ML-KEM-768 encaps
698057
cycles698350
cycles1.00
ML-KEM-768 decaps
889707
cycles890991
cycles1.00
ML-KEM-1024 keypair
821844
cycles821999
cycles1.00
ML-KEM-1024 encaps
998487
cycles998751
cycles1.00
ML-KEM-1024 decaps
1230866
cycles1231111
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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
ML-KEM-512 keypair
58343
cycles58372
cycles1.00
ML-KEM-512 encaps
65770
cycles65796
cycles1.00
ML-KEM-512 decaps
84524
cycles84559
cycles1.00
ML-KEM-768 keypair
98995
cycles98974
cycles1.00
ML-KEM-768 encaps
110314
cycles110630
cycles1.00
ML-KEM-768 decaps
136985
cycles136899
cycles1.00
ML-KEM-1024 keypair
150232
cycles150000
cycles1.00
ML-KEM-1024 encaps
166387
cycles166967
cycles1.00
ML-KEM-1024 decaps
202309
cycles203193
cycles1.00
This comment was automatically generated by workflow using github-action-benchmark.
dc3d0cd
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
ML-KEM-512 keypair
51744
cycles51700
cycles1.00
ML-KEM-512 encaps
58301
cycles57994
cycles1.01
ML-KEM-512 decaps
74881
cycles73992
cycles1.01
ML-KEM-768 keypair
87697
cycles87545
cycles1.00
ML-KEM-768 encaps
96202
cycles96486
cycles1.00
ML-KEM-768 decaps
120042
cycles119532
cycles1.00
ML-KEM-1024 keypair
131795
cycles131846
cycles1.00
ML-KEM-1024 encaps
144424
cycles144831
cycles1.00
ML-KEM-1024 decaps
176003
cycles177016
cycles0.99
This comment was automatically generated by workflow using github-action-benchmark.