@@ -266,11 +266,10 @@ def generate_keypair(self):
266
266
rv = native ().OQS_KEM_keypair (
267
267
self ._kem , ct .byref (public_key ), ct .byref (self .secret_key )
268
268
)
269
- return (
270
- bytes (public_key )
271
- if rv == OQS_SUCCESS
272
- else RuntimeError ("Can not generate keypair" )
273
- )
269
+ if rv == OQS_SUCCESS :
270
+ return bytes (public_key )
271
+ else :
272
+ raise RuntimeError ("Can not generate keypair" )
274
273
275
274
def export_secret_key (self ):
276
275
"""Exports the secret key."""
@@ -290,11 +289,10 @@ def encap_secret(self, public_key):
290
289
rv = native ().OQS_KEM_encaps (
291
290
self ._kem , ct .byref (ciphertext ), ct .byref (shared_secret ), c_public_key
292
291
)
293
- return bytes (ciphertext ), (
294
- bytes (shared_secret )
295
- if rv == OQS_SUCCESS
296
- else RuntimeError ("Can not encapsulate secret" )
297
- )
292
+ if rv == OQS_SUCCESS :
293
+ return bytes (ciphertext ), bytes (shared_secret )
294
+ else :
295
+ raise RuntimeError ("Can not encapsulate secret" )
298
296
299
297
def decap_secret (self , ciphertext ):
300
298
"""
@@ -309,11 +307,10 @@ def decap_secret(self, ciphertext):
309
307
rv = native ().OQS_KEM_decaps (
310
308
self ._kem , ct .byref (shared_secret ), c_ciphertext , self .secret_key
311
309
)
312
- return (
313
- bytes (shared_secret )
314
- if rv == OQS_SUCCESS
315
- else RuntimeError ("Can not decapsulate secret" )
316
- )
310
+ if rv == OQS_SUCCESS :
311
+ return bytes (shared_secret )
312
+ else :
313
+ raise RuntimeError ("Can not decapsulate secret" )
317
314
318
315
def free (self ):
319
316
"""Releases the native resources."""
@@ -435,11 +432,10 @@ def generate_keypair(self):
435
432
rv = native ().OQS_SIG_keypair (
436
433
self ._sig , ct .byref (public_key ), ct .byref (self .secret_key )
437
434
)
438
- return (
439
- bytes (public_key )
440
- if rv == OQS_SUCCESS
441
- else RuntimeError ("Can not generate keypair" )
442
- )
435
+ if rv == OQS_SUCCESS :
436
+ return bytes (public_key )
437
+ else :
438
+ raise RuntimeError ("Can not generate keypair" )
443
439
444
440
def export_secret_key (self ):
445
441
"""Exports the secret key."""
@@ -467,11 +463,10 @@ def sign(self, message):
467
463
message_len ,
468
464
self .secret_key ,
469
465
)
470
- return (
471
- bytes (c_signature [: signature_len .value ])
472
- if rv == OQS_SUCCESS
473
- else RuntimeError ("Can not sign message" )
474
- )
466
+ if rv == OQS_SUCCESS :
467
+ return bytes (c_signature [: signature_len .value ])
468
+ else :
469
+ raise RuntimeError ("Can not sign message" )
475
470
476
471
def verify (self , message , signature , public_key ):
477
472
"""
@@ -527,11 +522,10 @@ def sign_with_ctx_str(self, message, context):
527
522
context_len ,
528
523
self .secret_key ,
529
524
)
530
- return (
531
- bytes (c_signature [: signature_len .value ])
532
- if rv == OQS_SUCCESS
533
- else RuntimeError ("Can not sign message with context string" )
534
- )
525
+ if rv == OQS_SUCCESS :
526
+ return bytes (c_signature [: signature_len .value ])
527
+ else :
528
+ raise RuntimeError ("Can not sign message with context string" )
535
529
536
530
def verify_with_ctx_str (self , message , signature , context , public_key ):
537
531
"""
0 commit comments