puantum 1.2.3__cp312-cp312-manylinux_2_34_x86_64.whl

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.
puantum/__init__.py ADDED
@@ -0,0 +1 @@
1
+ # EMPTY
@@ -0,0 +1,2 @@
1
+ # MAIN
2
+ raise NotImplementedError()
@@ -0,0 +1 @@
1
+ # EMPTY
@@ -0,0 +1,5 @@
1
+ # IMPORT
2
+ from puantum.quantum.dsa.__internal__ import Algorithm, KeyPair
3
+
4
+ # MAIN
5
+ __all__: list[str] = ["Algorithm", "KeyPair"]
@@ -0,0 +1,550 @@
1
+ # IMPORT
2
+ from puantum import __internal__ as _internal # type: ignore
3
+ import typing as _typing
4
+ import enum as _enum
5
+
6
+ # MAIN
7
+ class Algorithm:
8
+ class CROSS(_enum.Enum):
9
+ CROSSR128B = "CrossRsdp128Balanced"
10
+ CROSSR128F = "CrossRsdp128Fast"
11
+ CROSSR128S = "CrossRsdp128Small"
12
+ CROSSR192B = "CrossRsdp192Balanced"
13
+ CROSSR192F = "CrossRsdp192Fast"
14
+ CROSSR192S = "CrossRsdp192Small"
15
+ CROSSR256B = "CrossRsdp256Balanced"
16
+ CROSSR256F = "CrossRsdp256Fast"
17
+ CROSSR256S = "CrossRsdp256Small"
18
+ CROSSRG128B = "CrossRsdpg128Balanced"
19
+ CROSSRG128F = "CrossRsdpg128Fast"
20
+ CROSSRG128S = "CrossRsdpg128Small"
21
+ CROSSRG192B = "CrossRsdpg192Balanced"
22
+ CROSSRG192F = "CrossRsdpg192Fast"
23
+ CROSSRG192S = "CrossRsdpg192Small"
24
+ CROSSRG256B = "CrossRsdpg256Balanced"
25
+ CROSSRG256F = "CrossRsdpg256Fast"
26
+ CROSSRG256S = "CrossRsdpg256Small"
27
+ #
28
+ class DILITHIUM(_enum.Enum):
29
+ DILITHIUM2 = "Dilithium2"
30
+ DILITHIUM3 = "Dilithium3"
31
+ DILITHIUM5 = "Dilithium5"
32
+ #
33
+ class FALCON(_enum.Enum):
34
+ FALCON512 = "Falcon512"
35
+ FALCON1024 = "Falcon1024"
36
+ #
37
+ class MAYO(_enum.Enum):
38
+ MAYO1 = "Mayo1"
39
+ MAYO2 = "Mayo2"
40
+ MAYO3 = "Mayo3"
41
+ MAYO5 = "Mayo5"
42
+ #
43
+ class MLDSA(_enum.Enum):
44
+ MLDSA44 = "MlDsa44"
45
+ MLDSA65 = "MlDsa65"
46
+ MLDSA87 = "MlDsa87"
47
+ #
48
+ class SPHINCS(_enum.Enum):
49
+ SHA2128F = "SphincsSha2128fSimple"
50
+ SHA2128S = "SphincsSha2128sSimple"
51
+ SHA2192F = "SphincsSha2192fSimple"
52
+ SHA2192S = "SphincsSha2192sSimple"
53
+ SHA2256F = "SphincsSha2256fSimple"
54
+ SHA2256S = "SphincsSha2256sSimple"
55
+ SHAKE128F = "SphincsShake128fSimple"
56
+ SHAKE128S = "SphincsShake128sSimple"
57
+ SHAKE192F = "SphincsShake192fSimple"
58
+ SHAKE192S = "SphincsShake192sSimple"
59
+ SHAKE256F = "SphincsShake256fSimple"
60
+ SHAKE256S = "SphincsShake256sSimple"
61
+ #
62
+ class UOV(_enum.Enum):
63
+ UOVOVIII = "UovOvIII"
64
+ UOVOVIIIPKC = "UovOvIIIPkc"
65
+ UOVOVIIIPKCSKC = "UovOvIIIPkcSkc"
66
+ UOVOVIP = "UovOvIp"
67
+ UOVOVIPPKC = "UovOvIpPkc"
68
+ UOVOVIPPKCSKC = "UovOvIpPkcSkc"
69
+ UOVOVIS = "UovOvIs"
70
+ UOVOVISPKC = "UovOvIsPkc"
71
+ UOVOVISPKCSKC = "UovOvIsPkcSkc"
72
+ UOVOVV = "UovOvV"
73
+ UOVOVVPKC = "UovOvVPkc"
74
+ UOVOVVPKCSKC = "UovOvVPkcSkc"
75
+
76
+
77
+
78
+ class PublicKey:
79
+ def __init__(self, publickey: bytes) -> None:
80
+ if not isinstance(publickey, bytes):
81
+ raise TypeError("PublicKey Not Valid")
82
+ #
83
+ self.publickey = publickey
84
+ #
85
+ return None
86
+ #
87
+ def verify(self, signature: _typing.Any, message: _typing.Any) -> _typing.Any:
88
+ raise NotImplementedError()
89
+
90
+
91
+
92
+ class CROSSPublicKey(PublicKey):
93
+ def __init__(self, name: Algorithm.CROSS, publickey: bytes) -> None:
94
+ if not isinstance(name, Algorithm.CROSS):
95
+ raise ValueError(f"Unsupported algorithm: {name}")
96
+ else:
97
+ super().__init__(publickey)
98
+ #
99
+ self._algorithm = name
100
+ #
101
+ return None
102
+ #
103
+ def verify(self, signature: bytes, message: bytes) -> bool:
104
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
105
+ return result # type: ignore
106
+
107
+
108
+
109
+ class DILITHIUMPublicKey(PublicKey):
110
+ def __init__(self, name: Algorithm.DILITHIUM, publickey: bytes) -> None:
111
+ if not isinstance(name, Algorithm.DILITHIUM):
112
+ raise ValueError(f"Unsupported algorithm: {name}")
113
+ else:
114
+ super().__init__(publickey)
115
+ #
116
+ self._algorithm = name
117
+ #
118
+ return None
119
+ #
120
+ def verify(self, signature: bytes, message: bytes) -> bool:
121
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
122
+ return result # type: ignore
123
+
124
+
125
+
126
+ class FALCONPublicKey(PublicKey):
127
+ def __init__(self, name: Algorithm.FALCON, publickey: bytes) -> None:
128
+ if not isinstance(name, Algorithm.FALCON):
129
+ raise ValueError(f"Unsupported algorithm: {name}")
130
+ else:
131
+ super().__init__(publickey)
132
+ #
133
+ self._algorithm = name
134
+ #
135
+ return None
136
+ #
137
+ def verify(self, signature: bytes, message: bytes) -> bool:
138
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
139
+ return result # type: ignore
140
+
141
+
142
+
143
+ class MAYOPublicKey(PublicKey):
144
+ def __init__(self, name: Algorithm.MAYO, publickey: bytes) -> None:
145
+ if not isinstance(name, Algorithm.MAYO):
146
+ raise ValueError(f"Unsupported algorithm: {name}")
147
+ else:
148
+ super().__init__(publickey)
149
+ #
150
+ self._algorithm = name
151
+ #
152
+ return None
153
+ #
154
+ def verify(self, signature: bytes, message: bytes) -> bool:
155
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
156
+ return result # type: ignore
157
+
158
+
159
+
160
+ class MLDSAPublicKey(PublicKey):
161
+ def __init__(self, name: Algorithm.MLDSA, publickey: bytes) -> None:
162
+ if not isinstance(name, Algorithm.MLDSA):
163
+ raise ValueError(f"Unsupported algorithm: {name}")
164
+ else:
165
+ super().__init__(publickey)
166
+ #
167
+ self._algorithm = name
168
+ #
169
+ return None
170
+ #
171
+ def verify(self, signature: bytes, message: bytes) -> bool:
172
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
173
+ return result # type: ignore
174
+
175
+
176
+
177
+ class SPHINCSPublicKey(PublicKey):
178
+ def __init__(self, name: Algorithm.SPHINCS, publickey: bytes) -> None:
179
+ if not isinstance(name, Algorithm.SPHINCS):
180
+ raise ValueError(f"Unsupported algorithm: {name}")
181
+ else:
182
+ super().__init__(publickey)
183
+ #
184
+ self._algorithm = name
185
+ #
186
+ return None
187
+ #
188
+ def verify(self, signature: bytes, message: bytes) -> bool:
189
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
190
+ return result # type: ignore
191
+
192
+
193
+
194
+ class UOVPublicKey(PublicKey):
195
+ def __init__(self, name: Algorithm.UOV, publickey: bytes) -> None:
196
+ if not isinstance(name, Algorithm.UOV):
197
+ raise ValueError(f"Unsupported algorithm: {name}")
198
+ else:
199
+ super().__init__(publickey)
200
+ #
201
+ self._algorithm = name
202
+ #
203
+ return None
204
+ #
205
+ def verify(self, signature: bytes, message: bytes) -> bool:
206
+ result: bool = _internal.sigverify(self._algorithm.value, self.publickey, signature, message) # type: ignore
207
+ return result # type: ignore
208
+
209
+
210
+
211
+ class SecretKey:
212
+ def __init__(self, secretkey: bytes) -> None:
213
+ if not isinstance(secretkey, bytes):
214
+ raise TypeError("SecretKey Not Valid")
215
+ #
216
+ self.secretkey = secretkey
217
+ #
218
+ return None
219
+ #
220
+ def sign(self, message: _typing.Any) -> _typing.Any:
221
+ raise NotImplementedError()
222
+
223
+
224
+
225
+ class CROSSSecretKey(SecretKey):
226
+ def __init__(self, name: Algorithm.CROSS, secretkey: bytes) -> None:
227
+ if not isinstance(name, Algorithm.CROSS):
228
+ raise ValueError(f"Unsupported algorithm: {name}")
229
+ else:
230
+ super().__init__(secretkey)
231
+ #
232
+ self._algorithm = name
233
+ #
234
+ return None
235
+ #
236
+ def sign(self, message: bytes) -> bytes:
237
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
238
+ return signature # type: ignore
239
+
240
+
241
+
242
+ class DILITHIUMSecretKey(SecretKey):
243
+ def __init__(self, name: Algorithm.DILITHIUM, secretkey: bytes) -> None:
244
+ if not isinstance(name, Algorithm.DILITHIUM):
245
+ raise ValueError(f"Unsupported algorithm: {name}")
246
+ else:
247
+ super().__init__(secretkey)
248
+ #
249
+ self._algorithm = name
250
+ #
251
+ return None
252
+ #
253
+ def sign(self, message: bytes) -> bytes:
254
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
255
+ return signature # type: ignore
256
+
257
+
258
+
259
+ class FALCONSecretKey(SecretKey):
260
+ def __init__(self, name: Algorithm.FALCON, secretkey: bytes) -> None:
261
+ if not isinstance(name, Algorithm.FALCON):
262
+ raise ValueError(f"Unsupported algorithm: {name}")
263
+ else:
264
+ super().__init__(secretkey)
265
+ #
266
+ self._algorithm = name
267
+ #
268
+ return None
269
+ #
270
+ def sign(self, message: bytes) -> bytes:
271
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
272
+ return signature # type: ignore
273
+
274
+
275
+
276
+ class MAYOSecretKey(SecretKey):
277
+ def __init__(self, name: Algorithm.MAYO, secretkey: bytes) -> None:
278
+ if not isinstance(name, Algorithm.MAYO):
279
+ raise ValueError(f"Unsupported algorithm: {name}")
280
+ else:
281
+ super().__init__(secretkey)
282
+ #
283
+ self._algorithm = name
284
+ #
285
+ return None
286
+ #
287
+ def sign(self, message: bytes) -> bytes:
288
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
289
+ return signature # type: ignore
290
+
291
+
292
+
293
+ class MLDSASecretKey(SecretKey):
294
+ def __init__(self, name: Algorithm.MLDSA, secretkey: bytes) -> None:
295
+ if not isinstance(name, Algorithm.MLDSA):
296
+ raise ValueError(f"Unsupported algorithm: {name}")
297
+ else:
298
+ super().__init__(secretkey)
299
+ #
300
+ self._algorithm = name
301
+ #
302
+ return None
303
+ #
304
+ def sign(self, message: bytes) -> bytes:
305
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
306
+ return signature # type: ignore
307
+
308
+
309
+
310
+ class SPHINCSSecretKey(SecretKey):
311
+ def __init__(self, name: Algorithm.SPHINCS, secretkey: bytes) -> None:
312
+ if not isinstance(name, Algorithm.SPHINCS):
313
+ raise ValueError(f"Unsupported algorithm: {name}")
314
+ else:
315
+ super().__init__(secretkey)
316
+ #
317
+ self._algorithm = name
318
+ #
319
+ return None
320
+ #
321
+ def sign(self, message: bytes) -> bytes:
322
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
323
+ return signature # type: ignore
324
+
325
+
326
+
327
+ class UOVSecretKey(SecretKey):
328
+ def __init__(self, name: Algorithm.UOV, secretkey: bytes) -> None:
329
+ if not isinstance(name, Algorithm.UOV):
330
+ raise ValueError(f"Unsupported algorithm: {name}")
331
+ else:
332
+ super().__init__(secretkey)
333
+ #
334
+ self._algorithm = name
335
+ #
336
+ return None
337
+ #
338
+ def sign(self, message: bytes) -> bytes:
339
+ signature: bytes = _internal.sigsign(self._algorithm.value, self.secretkey, message) # type: ignore
340
+ return signature # type: ignore
341
+
342
+
343
+
344
+ @_typing.overload
345
+ def KeyPair(
346
+ name: Algorithm,
347
+ *,
348
+ secretkey: bytes, publickey: bytes
349
+ ) -> tuple[SecretKey, PublicKey]: ...
350
+ @_typing.overload
351
+ def KeyPair(name: Algorithm, *, secretkey: bytes) -> SecretKey: ...
352
+ @_typing.overload
353
+ def KeyPair(name: Algorithm, *, publickey: bytes) -> PublicKey: ...
354
+ @_typing.overload
355
+ def KeyPair(name: Algorithm) -> tuple[SecretKey, PublicKey]: ...
356
+
357
+
358
+
359
+ @_typing.overload
360
+ def KeyPair(
361
+ name: Algorithm.CROSS,
362
+ *,
363
+ secretkey: bytes,
364
+ publickey: bytes
365
+ ) -> tuple[CROSSSecretKey, CROSSPublicKey]: ...
366
+ @_typing.overload
367
+ def KeyPair(name: Algorithm.CROSS, *, secretkey: bytes) -> CROSSSecretKey: ...
368
+ @_typing.overload
369
+ def KeyPair(name: Algorithm.CROSS, *, publickey: bytes) -> CROSSPublicKey: ...
370
+ @_typing.overload
371
+ def KeyPair(name: Algorithm.CROSS) -> tuple[CROSSSecretKey, CROSSPublicKey]: ...
372
+
373
+
374
+
375
+ @_typing.overload
376
+ def KeyPair(
377
+ name: Algorithm.DILITHIUM,
378
+ *,
379
+ secretkey: bytes,
380
+ publickey: bytes
381
+ ) -> tuple[DILITHIUMSecretKey, DILITHIUMPublicKey]: ...
382
+ @_typing.overload
383
+ def KeyPair(name: Algorithm.DILITHIUM, *, secretkey: bytes) -> DILITHIUMSecretKey: ...
384
+ @_typing.overload
385
+ def KeyPair(name: Algorithm.DILITHIUM, *, publickey: bytes) -> DILITHIUMPublicKey: ...
386
+ @_typing.overload
387
+ def KeyPair(name: Algorithm.DILITHIUM) -> tuple[DILITHIUMSecretKey, DILITHIUMPublicKey]: ...
388
+
389
+
390
+
391
+ @_typing.overload
392
+ def KeyPair(
393
+ name: Algorithm.FALCON,
394
+ *,
395
+ secretkey: bytes,
396
+ publickey: bytes
397
+ ) -> tuple[FALCONSecretKey, FALCONPublicKey]: ...
398
+ @_typing.overload
399
+ def KeyPair(name: Algorithm.FALCON, *, secretkey: bytes) -> FALCONSecretKey: ...
400
+ @_typing.overload
401
+ def KeyPair(name: Algorithm.FALCON, *, publickey: bytes) -> FALCONPublicKey: ...
402
+ @_typing.overload
403
+ def KeyPair(name: Algorithm.FALCON) -> tuple[FALCONSecretKey, FALCONPublicKey]: ...
404
+
405
+
406
+
407
+ @_typing.overload
408
+ def KeyPair(
409
+ name: Algorithm.MAYO,
410
+ *,
411
+ secretkey: bytes,
412
+ publickey: bytes
413
+ ) -> tuple[MAYOSecretKey, MAYOPublicKey]: ...
414
+ @_typing.overload
415
+ def KeyPair(name: Algorithm.MAYO, *, secretkey: bytes) -> MAYOSecretKey: ...
416
+ @_typing.overload
417
+ def KeyPair(name: Algorithm.MAYO, *, publickey: bytes) -> MAYOPublicKey: ...
418
+ @_typing.overload
419
+ def KeyPair(name: Algorithm.MAYO) -> tuple[MAYOSecretKey, MAYOPublicKey]: ...
420
+
421
+
422
+
423
+ @_typing.overload
424
+ def KeyPair(
425
+ name: Algorithm.MLDSA,
426
+ *,
427
+ secretkey: bytes,
428
+ publickey: bytes
429
+ ) -> tuple[MLDSASecretKey, MLDSAPublicKey]: ...
430
+ @_typing.overload
431
+ def KeyPair(name: Algorithm.MLDSA, *, secretkey: bytes) -> MLDSASecretKey: ...
432
+ @_typing.overload
433
+ def KeyPair(name: Algorithm.MLDSA, *, publickey: bytes) -> MLDSAPublicKey: ...
434
+ @_typing.overload
435
+ def KeyPair(name: Algorithm.MLDSA) -> tuple[MLDSASecretKey, MLDSAPublicKey]: ...
436
+
437
+
438
+
439
+ @_typing.overload
440
+ def KeyPair(
441
+ name: Algorithm.SPHINCS,
442
+ *,
443
+ secretkey: bytes,
444
+ publickey: bytes
445
+ ) -> tuple[SPHINCSSecretKey, SPHINCSPublicKey]: ...
446
+ @_typing.overload
447
+ def KeyPair(name: Algorithm.SPHINCS, *, secretkey: bytes) -> SPHINCSSecretKey: ...
448
+ @_typing.overload
449
+ def KeyPair(name: Algorithm.SPHINCS, *, publickey: bytes) -> SPHINCSPublicKey: ...
450
+ @_typing.overload
451
+ def KeyPair(name: Algorithm.SPHINCS) -> tuple[SPHINCSSecretKey, SPHINCSPublicKey]: ...
452
+
453
+
454
+
455
+ @_typing.overload
456
+ def KeyPair(
457
+ name: Algorithm.UOV,
458
+ *,
459
+ secretkey: bytes,
460
+ publickey: bytes
461
+ ) -> tuple[UOVSecretKey, UOVPublicKey]: ...
462
+ @_typing.overload
463
+ def KeyPair(name: Algorithm.UOV, *, secretkey: bytes) -> UOVSecretKey: ...
464
+ @_typing.overload
465
+ def KeyPair(name: Algorithm.UOV, *, publickey: bytes) -> UOVPublicKey: ...
466
+ @_typing.overload
467
+ def KeyPair(name: Algorithm.UOV) -> tuple[UOVSecretKey, UOVPublicKey]: ...
468
+
469
+
470
+
471
+ Algorithms = Algorithm.CROSS | Algorithm.DILITHIUM | Algorithm.FALCON | Algorithm.MAYO | Algorithm.MLDSA | Algorithm.SPHINCS | Algorithm.UOV
472
+ def KeyPair(
473
+ name: Algorithm | Algorithms,
474
+ *,
475
+ secretkey: bytes | None = None,
476
+ publickey: bytes | None = None
477
+ ) -> tuple[SecretKey, PublicKey] | SecretKey | PublicKey:
478
+ algorithm = name
479
+ if isinstance(algorithm, Algorithm.CROSS):
480
+ if secretkey is not None and publickey is None:
481
+ return CROSSSecretKey(algorithm, secretkey)
482
+ elif publickey is not None and secretkey is None:
483
+ return CROSSPublicKey(algorithm, publickey)
484
+ elif secretkey is not None and publickey is not None:
485
+ return CROSSSecretKey(algorithm, secretkey), CROSSPublicKey(algorithm, publickey)
486
+ else:
487
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
488
+ return CROSSSecretKey(algorithm, secretkey), CROSSPublicKey(algorithm, publickey) # type: ignore
489
+ elif isinstance(algorithm, Algorithm.DILITHIUM):
490
+ if secretkey is not None and publickey is None:
491
+ return DILITHIUMSecretKey(algorithm, secretkey)
492
+ elif publickey is not None and secretkey is None:
493
+ return DILITHIUMPublicKey(algorithm, publickey)
494
+ elif secretkey is not None and publickey is not None:
495
+ return DILITHIUMSecretKey(algorithm, secretkey), DILITHIUMPublicKey(algorithm, publickey)
496
+ else:
497
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
498
+ return DILITHIUMSecretKey(algorithm, secretkey), DILITHIUMPublicKey(algorithm, publickey) # type: ignore
499
+ elif isinstance(algorithm, Algorithm.FALCON):
500
+ if secretkey is not None and publickey is None:
501
+ return FALCONSecretKey(algorithm, secretkey)
502
+ elif publickey is not None and secretkey is None:
503
+ return FALCONPublicKey(algorithm, publickey)
504
+ elif secretkey is not None and publickey is not None:
505
+ return FALCONSecretKey(algorithm, secretkey), FALCONPublicKey(algorithm, publickey)
506
+ else:
507
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
508
+ return FALCONSecretKey(algorithm, secretkey), FALCONPublicKey(algorithm, publickey) # type: ignore
509
+ elif isinstance(algorithm, Algorithm.MAYO):
510
+ if secretkey is not None and publickey is None:
511
+ return MAYOSecretKey(algorithm, secretkey)
512
+ elif publickey is not None and secretkey is None:
513
+ return MAYOPublicKey(algorithm, publickey)
514
+ elif secretkey is not None and publickey is not None:
515
+ return MAYOSecretKey(algorithm, secretkey), MAYOPublicKey(algorithm, publickey)
516
+ else:
517
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
518
+ return MAYOSecretKey(algorithm, secretkey), MAYOPublicKey(algorithm, publickey) # type: ignore
519
+ elif isinstance(algorithm, Algorithm.MLDSA):
520
+ if secretkey is not None and publickey is None:
521
+ return MLDSASecretKey(algorithm, secretkey)
522
+ elif publickey is not None and secretkey is None:
523
+ return MLDSAPublicKey(algorithm, publickey)
524
+ elif secretkey is not None and publickey is not None:
525
+ return MLDSASecretKey(algorithm, secretkey), MLDSAPublicKey(algorithm, publickey)
526
+ else:
527
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
528
+ return MLDSASecretKey(algorithm, secretkey), MLDSAPublicKey(algorithm, publickey) # type: ignore
529
+ elif isinstance(algorithm, Algorithm.SPHINCS):
530
+ if secretkey is not None and publickey is None:
531
+ return SPHINCSSecretKey(algorithm, secretkey)
532
+ elif publickey is not None and secretkey is None:
533
+ return SPHINCSPublicKey(algorithm, publickey)
534
+ elif secretkey is not None and publickey is not None:
535
+ return SPHINCSSecretKey(algorithm, secretkey), SPHINCSPublicKey(algorithm, publickey)
536
+ else:
537
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
538
+ return SPHINCSSecretKey(algorithm, secretkey), SPHINCSPublicKey(algorithm, publickey) # type: ignore
539
+ elif isinstance(algorithm, Algorithm.UOV):
540
+ if secretkey is not None and publickey is None:
541
+ return UOVSecretKey(algorithm, secretkey)
542
+ elif publickey is not None and secretkey is None:
543
+ return UOVPublicKey(algorithm, publickey)
544
+ elif secretkey is not None and publickey is not None:
545
+ return UOVSecretKey(algorithm, secretkey), UOVPublicKey(algorithm, publickey)
546
+ else:
547
+ secretkey, publickey = _internal.sigkeygen(algorithm.value) # type: ignore
548
+ return UOVSecretKey(algorithm, secretkey), UOVPublicKey(algorithm, publickey) # type: ignore
549
+ else:
550
+ raise ValueError(f"Unsupported algorithm: {name}")
@@ -0,0 +1,5 @@
1
+ # IMPORT
2
+ from puantum.quantum.kem.__internal__ import Algorithm, KeyPair
3
+
4
+ # MAIN
5
+ __all__: list[str] = ["Algorithm", "KeyPair"]
@@ -0,0 +1,526 @@
1
+ # IMPORT
2
+ from puantum import __internal__ as _internal # type: ignore
3
+ import typing as _typing
4
+ import enum as _enum
5
+
6
+ # MAIN
7
+ class Algorithm:
8
+ class BIKE(_enum.Enum):
9
+ BIKEL1 = "BikeL1"
10
+ BIKEL3 = "BikeL3"
11
+ BIKEL5 = "BikeL5"
12
+ #
13
+ class CLASSICMCELIECE(_enum.Enum):
14
+ CLASSICMCELIECE348864 = "ClassicMcEliece348864"
15
+ CLASSICMCELIECE348864F = "ClassicMcEliece348864f"
16
+ CLASSICMCELIECE460896 = "ClassicMcEliece460896"
17
+ CLASSICMCELIECE460896F = "ClassicMcEliece460896f"
18
+ CLASSICMCELIECE6688128 = "ClassicMcEliece6688128"
19
+ CLASSICMCELIECE6688128F = "ClassicMcEliece6688128f"
20
+ CLASSICMCELIECE6960119 = "ClassicMcEliece6960119"
21
+ CLASSICMCELIECE6960119F = "ClassicMcEliece6960119f"
22
+ CLASSICMCELIECE8192128 = "ClassicMcEliece8192128"
23
+ CLASSICMCELIECE8192128F = "ClassicMcEliece8192128f"
24
+ #
25
+ class HQC(_enum.Enum):
26
+ HQC128 = "Hqc128"
27
+ HQC192 = "Hqc192"
28
+ HQC256 = "Hqc256"
29
+ #
30
+ class KYBER(_enum.Enum):
31
+ KYBER512 = "Kyber512"
32
+ KYBER768 = "Kyber768"
33
+ KYBER1024 = "Kyber1024"
34
+ #
35
+ class MLKEM(_enum.Enum):
36
+ MLKEM512 = "MlKem512"
37
+ MLKEM768 = "MlKem768"
38
+ MLKEM1024 = "MlKem1024"
39
+ #
40
+ class NTRUPRIME(_enum.Enum):
41
+ NTRUPRIME = "NtruPrimeSntrup761"
42
+ #
43
+ class FRODOKEM(_enum.Enum):
44
+ FRODOKEM640AES = "FrodoKem640Aes"
45
+ FRODOKEM640SHAKE = "FrodoKem640Shake"
46
+ FRODOKEM976AES = "FrodoKem976Aes"
47
+ FRODOKEM976SHAKE = "FrodoKem976Shake"
48
+ FRODOKEM1344AES = "FrodoKem1344Aes"
49
+ FRODOKEM1344SHAKE = "FrodoKem1344Shake"
50
+
51
+
52
+
53
+ class PublicKey:
54
+ def __init__(self, publickey: bytes) -> None:
55
+ if not isinstance(publickey, bytes):
56
+ raise TypeError("PublicKey Not Valid")
57
+ #
58
+ self.publickey = publickey
59
+ #
60
+ return None
61
+ #
62
+ def encapsulate(self) -> tuple[_typing.Any, _typing.Any]:
63
+ raise NotImplementedError()
64
+
65
+
66
+
67
+ class BIKEPublicKey(PublicKey):
68
+ def __init__(self, name: Algorithm.BIKE, publickey: bytes) -> None:
69
+ if not isinstance(name, Algorithm.BIKE):
70
+ raise ValueError(f"Unsupported algorithm: {name}")
71
+ else:
72
+ super().__init__(publickey)
73
+ #
74
+ self._algorithm = name
75
+ #
76
+ return None
77
+ #
78
+ def encapsulate(self) -> tuple[bytes, bytes]:
79
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
80
+ return sharedsecret, ciphertext # type: ignore
81
+
82
+
83
+
84
+ class CLASSICMCELIECEPublicKey(PublicKey):
85
+ def __init__(self, name: Algorithm.CLASSICMCELIECE, publickey: bytes) -> None:
86
+ if not isinstance(name, Algorithm.CLASSICMCELIECE):
87
+ raise ValueError(f"Unsupported algorithm: {name}")
88
+ else:
89
+ super().__init__(publickey)
90
+ #
91
+ self._algorithm = name
92
+ #
93
+ return None
94
+ #
95
+ def encapsulate(self) -> tuple[bytes, bytes]:
96
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
97
+ return sharedsecret, ciphertext # type: ignore
98
+
99
+
100
+
101
+ class HQCPublicKey(PublicKey):
102
+ def __init__(self, name: Algorithm.HQC, publickey: bytes) -> None:
103
+ if not isinstance(name, Algorithm.HQC):
104
+ raise ValueError(f"Unsupported algorithm: {name}")
105
+ else:
106
+ super().__init__(publickey)
107
+ #
108
+ self._algorithm = name
109
+ #
110
+ return None
111
+ #
112
+ def encapsulate(self) -> tuple[bytes, bytes]:
113
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
114
+ return sharedsecret, ciphertext # type: ignore
115
+
116
+
117
+
118
+ class KYBERPublicKey(PublicKey):
119
+ def __init__(self, name: Algorithm.KYBER, publickey: bytes) -> None:
120
+ if not isinstance(name, Algorithm.KYBER):
121
+ raise ValueError(f"Unsupported algorithm: {name}")
122
+ else:
123
+ super().__init__(publickey)
124
+ #
125
+ self._algorithm = name
126
+ #
127
+ return None
128
+ #
129
+ def encapsulate(self) -> tuple[bytes, bytes]:
130
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
131
+ return sharedsecret, ciphertext # type: ignore
132
+
133
+
134
+
135
+ class MLKEMPublicKey(PublicKey):
136
+ def __init__(self, name: Algorithm.MLKEM, publickey: bytes) -> None:
137
+ if not isinstance(name, Algorithm.MLKEM):
138
+ raise ValueError(f"Unsupported algorithm: {name}")
139
+ else:
140
+ super().__init__(publickey)
141
+ #
142
+ self._algorithm = name
143
+ #
144
+ return None
145
+ #
146
+ def encapsulate(self) -> tuple[bytes, bytes]:
147
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
148
+ return sharedsecret, ciphertext # type: ignore
149
+
150
+
151
+
152
+ class NTRUPRIMEPublicKey(PublicKey):
153
+ def __init__(self, name: Algorithm.NTRUPRIME, publickey: bytes) -> None:
154
+ if not isinstance(name, Algorithm.NTRUPRIME):
155
+ raise ValueError(f"Unsupported algorithm: {name}")
156
+ else:
157
+ super().__init__(publickey)
158
+ #
159
+ self._algorithm = name
160
+ #
161
+ return None
162
+ #
163
+ def encapsulate(self) -> tuple[bytes, bytes]:
164
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
165
+ return sharedsecret, ciphertext # type: ignore
166
+
167
+
168
+
169
+ class FRODOKEMPublicKey(PublicKey):
170
+ def __init__(self, name: Algorithm.FRODOKEM, publickey: bytes) -> None:
171
+ if not isinstance(name, Algorithm.FRODOKEM):
172
+ raise ValueError(f"Unsupported algorithm: {name}")
173
+ else:
174
+ super().__init__(publickey)
175
+ #
176
+ self._algorithm = name
177
+ #
178
+ return None
179
+ #
180
+ def encapsulate(self) -> tuple[bytes, bytes]:
181
+ sharedsecret, ciphertext = _internal.kemencapsulate(self._algorithm.value, self.publickey) # type: ignore
182
+ return sharedsecret, ciphertext # type: ignore
183
+
184
+
185
+
186
+ class SecretKey:
187
+ def __init__(self, secretkey: bytes) -> None:
188
+ if not isinstance(secretkey, bytes):
189
+ raise TypeError("SecretKey Not Valid")
190
+ #
191
+ self.secretkey = secretkey
192
+ #
193
+ return None
194
+ #
195
+ def decapsulate(self, ciphertext: _typing.Any) -> _typing.Any:
196
+ raise NotImplementedError()
197
+
198
+
199
+
200
+ class BIKESecretKey(SecretKey):
201
+ def __init__(self, name: Algorithm.BIKE, secretkey: bytes) -> None:
202
+ if not isinstance(name, Algorithm.BIKE):
203
+ raise ValueError(f"Unsupported algorithm: {name}")
204
+ else:
205
+ super().__init__(secretkey)
206
+ #
207
+ self._algorithm = name
208
+ #
209
+ return None
210
+ #
211
+ def decapsulate(self, ciphertext: bytes) -> bytes:
212
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
213
+ return sharedsecret # type: ignore
214
+
215
+
216
+
217
+ class CLASSICMCELIECESecretKey(SecretKey):
218
+ def __init__(self, name: Algorithm.CLASSICMCELIECE, secretkey: bytes) -> None:
219
+ if not isinstance(name, Algorithm.CLASSICMCELIECE):
220
+ raise ValueError(f"Unsupported algorithm: {name}")
221
+ else:
222
+ super().__init__(secretkey)
223
+ #
224
+ self._algorithm = name
225
+ #
226
+ return None
227
+ #
228
+ def decapsulate(self, ciphertext: bytes) -> bytes:
229
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
230
+ return sharedsecret # type: ignore
231
+
232
+
233
+
234
+ class HQCSecretKey(SecretKey):
235
+ def __init__(self, name: Algorithm.HQC, secretkey: bytes) -> None:
236
+ if not isinstance(name, Algorithm.HQC):
237
+ raise ValueError(f"Unsupported algorithm: {name}")
238
+ else:
239
+ super().__init__(secretkey)
240
+ #
241
+ self._algorithm = name
242
+ #
243
+ return None
244
+ #
245
+ def decapsulate(self, ciphertext: bytes) -> bytes:
246
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
247
+ return sharedsecret # type: ignore
248
+
249
+
250
+
251
+ class KYBERSecretKey(SecretKey):
252
+ def __init__(self, name: Algorithm.KYBER, secretkey: bytes) -> None:
253
+ if not isinstance(name, Algorithm.KYBER):
254
+ raise ValueError(f"Unsupported algorithm: {name}")
255
+ else:
256
+ super().__init__(secretkey)
257
+ #
258
+ self._algorithm = name
259
+ #
260
+ return None
261
+ #
262
+ def decapsulate(self, ciphertext: bytes) -> bytes:
263
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
264
+ return sharedsecret # type: ignore
265
+
266
+
267
+
268
+ class MLKEMSecretKey(SecretKey):
269
+ def __init__(self, name: Algorithm.MLKEM, secretkey: bytes) -> None:
270
+ if not isinstance(name, Algorithm.MLKEM):
271
+ raise ValueError(f"Unsupported algorithm: {name}")
272
+ else:
273
+ super().__init__(secretkey)
274
+ #
275
+ self._algorithm = name
276
+ #
277
+ return None
278
+ #
279
+ def decapsulate(self, ciphertext: bytes) -> bytes:
280
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
281
+ return sharedsecret # type: ignore
282
+
283
+
284
+
285
+ class NTRUPRIMESecretKey(SecretKey):
286
+ def __init__(self, name: Algorithm.NTRUPRIME, secretkey: bytes) -> None:
287
+ if not isinstance(name, Algorithm.NTRUPRIME):
288
+ raise ValueError(f"Unsupported algorithm: {name}")
289
+ else:
290
+ super().__init__(secretkey)
291
+ #
292
+ self._algorithm = name
293
+ #
294
+ return None
295
+ #
296
+ def decapsulate(self, ciphertext: bytes) -> bytes:
297
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
298
+ return sharedsecret # type: ignore
299
+
300
+
301
+
302
+ class FRODOKEMSecretKey(SecretKey):
303
+ def __init__(self, name: Algorithm.FRODOKEM, secretkey: bytes) -> None:
304
+ if not isinstance(name, Algorithm.FRODOKEM):
305
+ raise ValueError(f"Unsupported algorithm: {name}")
306
+ else:
307
+ super().__init__(secretkey)
308
+ #
309
+ self._algorithm = name
310
+ #
311
+ return None
312
+ #
313
+ def decapsulate(self, ciphertext: bytes) -> bytes:
314
+ sharedsecret: bytes = _internal.kemdecapsulate(self._algorithm.value, self.secretkey, ciphertext) # type: ignore
315
+ return sharedsecret # type: ignore
316
+
317
+
318
+
319
+ @_typing.overload
320
+ def KeyPair(
321
+ name: Algorithm,
322
+ *,
323
+ secretkey: bytes,
324
+ publickey: bytes
325
+ ) -> tuple[SecretKey, PublicKey]: ...
326
+ @_typing.overload
327
+ def KeyPair(name: Algorithm, *, secretkey: bytes) -> SecretKey: ...
328
+ @_typing.overload
329
+ def KeyPair(name: Algorithm, *, publickey: bytes) -> PublicKey: ...
330
+ @_typing.overload
331
+ def KeyPair(name: Algorithm) -> tuple[SecretKey, PublicKey]: ...
332
+
333
+
334
+
335
+ @_typing.overload
336
+ def KeyPair(
337
+ name: Algorithm.BIKE,
338
+ *,
339
+ secretkey: bytes,
340
+ publickey: bytes
341
+ ) -> tuple[BIKESecretKey, BIKEPublicKey]: ...
342
+ @_typing.overload
343
+ def KeyPair(name: Algorithm.BIKE, *, secretkey: bytes) -> BIKESecretKey: ...
344
+ @_typing.overload
345
+ def KeyPair(name: Algorithm.BIKE, *, publickey: bytes) -> BIKEPublicKey: ...
346
+ @_typing.overload
347
+ def KeyPair(name: Algorithm.BIKE) -> tuple[BIKESecretKey, BIKEPublicKey]: ...
348
+
349
+
350
+
351
+ @_typing.overload
352
+ def KeyPair(
353
+ name: Algorithm.CLASSICMCELIECE,
354
+ *,
355
+ secretkey: bytes,
356
+ publickey: bytes
357
+ ) -> tuple[CLASSICMCELIECESecretKey, CLASSICMCELIECEPublicKey]: ...
358
+ @_typing.overload
359
+ def KeyPair(name: Algorithm.CLASSICMCELIECE, *, secretkey: bytes) -> CLASSICMCELIECESecretKey: ...
360
+ @_typing.overload
361
+ def KeyPair(name: Algorithm.CLASSICMCELIECE, *, publickey: bytes) -> CLASSICMCELIECEPublicKey: ...
362
+ @_typing.overload
363
+ def KeyPair(name: Algorithm.CLASSICMCELIECE) -> tuple[CLASSICMCELIECESecretKey, CLASSICMCELIECEPublicKey]: ...
364
+
365
+
366
+
367
+ @_typing.overload
368
+ def KeyPair(
369
+ name: Algorithm.HQC,
370
+ *,
371
+ secretkey: bytes,
372
+ publickey: bytes
373
+ ) -> tuple[HQCSecretKey, HQCPublicKey]: ...
374
+ @_typing.overload
375
+ def KeyPair(name: Algorithm.HQC, *, secretkey: bytes) -> HQCSecretKey: ...
376
+ @_typing.overload
377
+ def KeyPair(name: Algorithm.HQC, *, publickey: bytes) -> HQCPublicKey: ...
378
+ @_typing.overload
379
+ def KeyPair(name: Algorithm.HQC) -> tuple[HQCSecretKey, HQCPublicKey]: ...
380
+
381
+
382
+
383
+ @_typing.overload
384
+ def KeyPair(
385
+ name: Algorithm.KYBER,
386
+ *,
387
+ secretkey: bytes,
388
+ publickey: bytes
389
+ ) -> tuple[KYBERSecretKey, KYBERPublicKey]: ...
390
+ @_typing.overload
391
+ def KeyPair(name: Algorithm.KYBER, *, secretkey: bytes) -> KYBERSecretKey: ...
392
+ @_typing.overload
393
+ def KeyPair(name: Algorithm.KYBER, *, publickey: bytes) -> KYBERPublicKey: ...
394
+ @_typing.overload
395
+ def KeyPair(name: Algorithm.KYBER) -> tuple[KYBERSecretKey, KYBERPublicKey]: ...
396
+
397
+
398
+
399
+ @_typing.overload
400
+ def KeyPair(
401
+ name: Algorithm.MLKEM,
402
+ *,
403
+ secretkey: bytes,
404
+ publickey: bytes
405
+ ) -> tuple[MLKEMSecretKey, MLKEMPublicKey]: ...
406
+ @_typing.overload
407
+ def KeyPair(name: Algorithm.MLKEM, *, secretkey: bytes) -> MLKEMSecretKey: ...
408
+ @_typing.overload
409
+ def KeyPair(name: Algorithm.MLKEM, *, publickey: bytes) -> MLKEMPublicKey: ...
410
+ @_typing.overload
411
+ def KeyPair(name: Algorithm.MLKEM) -> tuple[MLKEMSecretKey, MLKEMPublicKey]: ...
412
+
413
+
414
+
415
+ @_typing.overload
416
+ def KeyPair(
417
+ name: Algorithm.NTRUPRIME,
418
+ *,
419
+ secretkey: bytes,
420
+ publickey: bytes
421
+ ) -> tuple[NTRUPRIMESecretKey, NTRUPRIMEPublicKey]: ...
422
+ @_typing.overload
423
+ def KeyPair(name: Algorithm.NTRUPRIME, *, secretkey: bytes) -> NTRUPRIMESecretKey: ...
424
+ @_typing.overload
425
+ def KeyPair(name: Algorithm.NTRUPRIME, *, publickey: bytes) -> NTRUPRIMEPublicKey: ...
426
+ @_typing.overload
427
+ def KeyPair(name: Algorithm.NTRUPRIME) -> tuple[NTRUPRIMESecretKey, NTRUPRIMEPublicKey]: ...
428
+
429
+
430
+
431
+ @_typing.overload
432
+ def KeyPair(
433
+ name: Algorithm.FRODOKEM,
434
+ *,
435
+ secretkey: bytes,
436
+ publickey: bytes
437
+ ) -> tuple[FRODOKEMSecretKey, FRODOKEMPublicKey]: ...
438
+ @_typing.overload
439
+ def KeyPair(name: Algorithm.FRODOKEM, *, secretkey: bytes) -> FRODOKEMSecretKey: ...
440
+ @_typing.overload
441
+ def KeyPair(name: Algorithm.FRODOKEM, *, publickey: bytes) -> FRODOKEMPublicKey: ...
442
+ @_typing.overload
443
+ def KeyPair(name: Algorithm.FRODOKEM) -> tuple[FRODOKEMSecretKey, FRODOKEMPublicKey]: ...
444
+
445
+
446
+
447
+ Algorithms = Algorithm.BIKE | Algorithm.CLASSICMCELIECE | Algorithm.HQC | Algorithm.KYBER | Algorithm.MLKEM | Algorithm.NTRUPRIME | Algorithm.FRODOKEM
448
+ def KeyPair(
449
+ name: Algorithm | Algorithms,
450
+ *,
451
+ secretkey: bytes | None = None,
452
+ publickey: bytes | None = None
453
+ ) -> tuple[SecretKey, PublicKey] | SecretKey | PublicKey:
454
+ algorithm = name
455
+ if isinstance(algorithm, Algorithm.BIKE):
456
+ if secretkey is not None and publickey is None:
457
+ return BIKESecretKey(algorithm, secretkey)
458
+ elif publickey is not None and secretkey is None:
459
+ return BIKEPublicKey(algorithm, publickey)
460
+ elif secretkey is not None and publickey is not None:
461
+ return BIKESecretKey(algorithm, secretkey), BIKEPublicKey(algorithm, publickey)
462
+ else:
463
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
464
+ return BIKESecretKey(algorithm, secretkey), BIKEPublicKey(algorithm, publickey) # type: ignore
465
+ elif isinstance(algorithm, Algorithm.CLASSICMCELIECE):
466
+ if secretkey is not None and publickey is None:
467
+ return CLASSICMCELIECESecretKey(algorithm, secretkey)
468
+ elif publickey is not None and secretkey is None:
469
+ return CLASSICMCELIECEPublicKey(algorithm, publickey)
470
+ elif secretkey is not None and publickey is not None:
471
+ return CLASSICMCELIECESecretKey(algorithm, secretkey), CLASSICMCELIECEPublicKey(algorithm, publickey)
472
+ else:
473
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
474
+ return CLASSICMCELIECESecretKey(algorithm, secretkey), CLASSICMCELIECEPublicKey(algorithm, publickey) # type: ignore
475
+ elif isinstance(algorithm, Algorithm.HQC):
476
+ if secretkey is not None and publickey is None:
477
+ return HQCSecretKey(algorithm, secretkey)
478
+ elif publickey is not None and secretkey is None:
479
+ return HQCPublicKey(algorithm, publickey)
480
+ elif secretkey is not None and publickey is not None:
481
+ return HQCSecretKey(algorithm, secretkey), HQCPublicKey(algorithm, publickey)
482
+ else:
483
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
484
+ return HQCSecretKey(algorithm, secretkey), HQCPublicKey(algorithm, publickey) # type: ignore
485
+ elif isinstance(algorithm, Algorithm.KYBER):
486
+ if secretkey is not None and publickey is None:
487
+ return KYBERSecretKey(algorithm, secretkey)
488
+ elif publickey is not None and secretkey is None:
489
+ return KYBERPublicKey(algorithm, publickey)
490
+ elif secretkey is not None and publickey is not None:
491
+ return KYBERSecretKey(algorithm, secretkey), KYBERPublicKey(algorithm, publickey)
492
+ else:
493
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
494
+ return KYBERSecretKey(algorithm, secretkey), KYBERPublicKey(algorithm, publickey) # type: ignore
495
+ elif isinstance(algorithm, Algorithm.MLKEM):
496
+ if secretkey is not None and publickey is None:
497
+ return MLKEMSecretKey(algorithm, secretkey)
498
+ elif publickey is not None and secretkey is None:
499
+ return MLKEMPublicKey(algorithm, publickey)
500
+ elif secretkey is not None and publickey is not None:
501
+ return MLKEMSecretKey(algorithm, secretkey), MLKEMPublicKey(algorithm, publickey)
502
+ else:
503
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
504
+ return MLKEMSecretKey(algorithm, secretkey), MLKEMPublicKey(algorithm, publickey) # type: ignore
505
+ elif isinstance(algorithm, Algorithm.NTRUPRIME):
506
+ if secretkey is not None and publickey is None:
507
+ return NTRUPRIMESecretKey(algorithm, secretkey)
508
+ elif publickey is not None and secretkey is None:
509
+ return NTRUPRIMEPublicKey(algorithm, publickey)
510
+ elif secretkey is not None and publickey is not None:
511
+ return NTRUPRIMESecretKey(algorithm, secretkey), NTRUPRIMEPublicKey(algorithm, publickey)
512
+ else:
513
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
514
+ return NTRUPRIMESecretKey(algorithm, secretkey), NTRUPRIMEPublicKey(algorithm, publickey) # type: ignore
515
+ elif isinstance(algorithm, Algorithm.FRODOKEM):
516
+ if secretkey is not None and publickey is None:
517
+ return FRODOKEMSecretKey(algorithm, secretkey)
518
+ elif publickey is not None and secretkey is None:
519
+ return FRODOKEMPublicKey(algorithm, publickey)
520
+ elif secretkey is not None and publickey is not None:
521
+ return FRODOKEMSecretKey(algorithm, secretkey), FRODOKEMPublicKey(algorithm, publickey)
522
+ else:
523
+ secretkey, publickey = _internal.kemkeygen(algorithm.value) # type: ignore
524
+ return FRODOKEMSecretKey(algorithm, secretkey), FRODOKEMPublicKey(algorithm, publickey) # type: ignore
525
+ else:
526
+ raise ValueError(f"Unsupported algorithm: {name}")
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: puantum
3
+ Version: 1.2.3
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Operating System :: OS Independent
7
+ Classifier: License :: Public Domain
8
+ Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
9
+ License-File: license.md
10
+ Summary: Python Cryptography
11
+ Keywords: python,cryptography,quantum,security
12
+ Author-email: Anonymous <217687495+1xfakebit@users.noreply.github.com>
13
+ License: Unlicense
14
+ Description-Content-Type: text/markdown
15
+ Project-URL: source, https://github.com/1xfakebit/puantum
16
+ Project-URL: x, https://x.com/1xfakebit
17
+
18
+ # 🔐 Python Cryptography
19
+
20
+ A blazing-fast cryptography library for Python, built on Rust.
21
+
22
+ Puantum supports an extensive set of **post-quantum** key encapsulation mechanisms (KEM) and digital signature algorithms (DSA), and will soon support **classic cryptography** as well.
23
+
24
+ ---
25
+ ## ⚡ Features
26
+ - ✅ Dozens of NIST PQC candidates
27
+ - 🦀 Rust core for speed and safety
28
+ - 📦 Easy installation via [`pip`](https://pip.pypa.io)
29
+ ---
30
+
31
+ ### 🧬 Supported Algorithms
32
+
33
+ ### 🛡️ KEM
34
+ - #### Bike
35
+ - #### ClassicMcEliece
36
+ - #### Hqc
37
+ - #### Kyber
38
+ - #### MLKEM
39
+ - #### NtruPrime
40
+ - #### FrodoKem
41
+
42
+ ### ✍️ DSA
43
+ - #### Cross
44
+ - #### Dilithium
45
+ - #### Falcon
46
+ - #### Mayo
47
+ - #### MLDSA
48
+ - #### Sphincs
49
+ - #### Uov
50
+
51
+ ### 🚧 Coming Soon
52
+ - #### AES, ChaCha20, XChaCha20
53
+ - #### RSA, EC
54
+ - #### Argon2, Bcrypt
55
+
56
+ ### 📦 Install
57
+ ```shell
58
+ pip install puantum
59
+ ```
60
+ #### or from source:
61
+ ```shell
62
+ make python
63
+ ```
64
+
65
+ ### 🥳 Enjoy!
66
+
@@ -0,0 +1,12 @@
1
+ puantum-1.2.3.dist-info/METADATA,sha256=IcjYtA9_vDMTDNE7in_Z_rOi7zO7n-CePcjpZFIgeUs,1524
2
+ puantum-1.2.3.dist-info/WHEEL,sha256=IPzRd0nigP4r3GK-lmtM2DKCRPiRfyNhNj4tmNbAOTQ,108
3
+ puantum-1.2.3.dist-info/licenses/license.md,sha256=tQZYOMusRS38hVum5uAxSBrSxoQG9w0h6tkyE3RlPmw,1212
4
+ puantum/__init__.py,sha256=DqzIK80d6ihVj9p2qBPJwBjM0V3kl6MRRjKowVB61Ak,8
5
+ puantum/__internal__.cpython-312-x86_64-linux-gnu.so,sha256=vBEtdfLDAmoj98xYKIbEWH_2FDQn-RxlhRadKngIZzI,8279488
6
+ puantum/classic/__init__.py,sha256=Dlr1m0uJio3HWH8_gkdhnQS87KUZfUw5wX4tXQtbvWQ,35
7
+ puantum/quantum/__init__.py,sha256=DqzIK80d6ihVj9p2qBPJwBjM0V3kl6MRRjKowVB61Ak,8
8
+ puantum/quantum/dsa/__init__.py,sha256=r9eRKYMhU7KC2nwb1hW26KVpwz2XuXDQBzW3m36yCkM,127
9
+ puantum/quantum/dsa/__internal__.py,sha256=HWON0ta7EV09NXbXSh7rNKbUsTdeg9Wf5-oQcRan7Eo,19533
10
+ puantum/quantum/kem/__init__.py,sha256=U3TwWZ7eIYQgPeMXN2pfQvaqdWQimQTP-KDosfFvwk0,127
11
+ puantum/quantum/kem/__internal__.py,sha256=es__oqu6tzaRhXx6x8J5twb3CK-9zXCsPmeNRPMAfow,19144
12
+ puantum-1.2.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-manylinux_2_34_x86_64
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org/>