Utilize efficiency improvements to ThresholdMessageKit that ensures that Ciphertext is not needlessly copied between python layer and Rust later.

Allow ciphertext header to be directly obtained without needing to first get the Ciphertext.
Move decryption of ferveo encrypted data into a method on ThresholdMessageKit so that the Ciphertext data can be used directly in Rust layer, and not pulled into python to then pass
it back into the Rust layer for decryption.
pull/3194/head
derekpierre 2023-08-22 16:22:17 -04:00 committed by Kieran Prasch
parent 62b4ed7940
commit 03ca66b561
3 changed files with 4 additions and 10 deletions

View File

@ -57,7 +57,6 @@ from nucypher_core.ferveo import (
Validator,
combine_decryption_shares_precomputed,
combine_decryption_shares_simple,
decrypt_with_shared_secret,
)
from nucypher_core.umbral import (
PublicKey,
@ -638,7 +637,7 @@ class Bob(Character):
decryption_request = ThresholdDecryptionRequest(
ritual_id=ritual_id,
variant=variant,
ciphertext_header=threshold_message_kit.ciphertext.header,
ciphertext_header=threshold_message_kit.ciphertext_header,
acp=threshold_message_kit.acp,
context=context,
)
@ -775,13 +774,8 @@ class Bob(Character):
shared_secret = combine_decryption_shares_simple(shares)
else:
raise ValueError(f"Invalid variant: {variant}.")
aad = threshold_message_kit.acp.aad()
cleartext = decrypt_with_shared_secret(
threshold_message_kit.ciphertext,
aad, # aad
shared_secret,
)
cleartext = threshold_message_kit.decrypt_with_shared_secret(shared_secret)
return cleartext

View File

@ -55,7 +55,7 @@ msgpack==1.0.5
msgpack-python==0.5.6
multidict==5.2.0 ; python_version >= '3.6'
mypy-extensions==0.4.4 ; python_version >= '2.7'
nucypher-core @ git+https://github.com/derekpierre/nucypher-core.git@e8602c63d645a2643de5b25fa95eb408d259440e#subdirectory=nucypher-core-python
nucypher-core @ git+https://github.com/derekpierre/nucypher-core.git@5ed307f57ad6e0c02ae065baac494a4028f8f729#subdirectory=nucypher-core-python
packaging==23.1 ; python_version >= '3.7'
parsimonious==0.9.0
pendulum==3.0.0a1 ; python_version >= '3.7' and python_version < '4.0'

View File

@ -194,7 +194,7 @@ def test_ritualist(temp_dir_path, testerchain, dkg_public_key):
decryption_request = ThresholdDecryptionRequest(
ritual_id=ritual_id,
variant=FerveoVariant.Simple,
ciphertext_header=threshold_message_kit.ciphertext.header,
ciphertext_header=threshold_message_kit.ciphertext_header,
acp=threshold_message_kit.acp,
)