puantum 1.0.0.0__cp312-cp312-macosx_11_0_arm64.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
puantum/__init__.pyi ADDED
@@ -0,0 +1 @@
1
+ # EMPTY
@@ -0,0 +1,2 @@
1
+ # MAIN
2
+ raise NotImplementedError()
@@ -0,0 +1 @@
1
+ # EMPTY
@@ -0,0 +1 @@
1
+ # EMPTY
@@ -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,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}")