mirror of https://github.com/nucypher/nucypher.git
Separating creation of decryption request from the actual retrieval flow, so that pre-serialized decryption requests can be used.
parent
e1dcaab7fb
commit
469ffc3e1e
|
@ -562,23 +562,14 @@ class Bob(Character):
|
||||||
|
|
||||||
return cohort
|
return cohort
|
||||||
|
|
||||||
def gather_decryption_shares(
|
def make_decryption_request(
|
||||||
self,
|
self,
|
||||||
ritual_id: int,
|
ritual_id: int,
|
||||||
cohort: List["Ursula"],
|
ciphertext: Ciphertext,
|
||||||
ciphertext: Ciphertext,
|
lingo: LingoList,
|
||||||
lingo: LingoList,
|
variant: FerveoVariant,
|
||||||
threshold: int,
|
context: Optional[dict] = None,
|
||||||
variant: FerveoVariant,
|
) -> ThresholdDecryptionRequest:
|
||||||
context: Optional[dict] = None,
|
|
||||||
) -> Dict[
|
|
||||||
ChecksumAddress, Union[DecryptionShareSimple, DecryptionSharePrecomputed]
|
|
||||||
]:
|
|
||||||
if variant == FerveoVariant.PRECOMPUTED:
|
|
||||||
share_type = DecryptionSharePrecomputed
|
|
||||||
elif variant == FerveoVariant.SIMPLE:
|
|
||||||
share_type = DecryptionShareSimple
|
|
||||||
|
|
||||||
conditions = Conditions(json.dumps(lingo))
|
conditions = Conditions(json.dumps(lingo))
|
||||||
if context:
|
if context:
|
||||||
context = Context(json.dumps(context))
|
context = Context(json.dumps(context))
|
||||||
|
@ -589,6 +580,18 @@ class Bob(Character):
|
||||||
conditions=conditions,
|
conditions=conditions,
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
return decryption_request
|
||||||
|
|
||||||
|
def get_decryption_shares_using_existing_decryption_request(self,
|
||||||
|
decryption_request: ThresholdDecryptionRequest,
|
||||||
|
variant: FerveoVariant,
|
||||||
|
cohort: List["Ursula"],
|
||||||
|
threshold: int,
|
||||||
|
):
|
||||||
|
if variant == FerveoVariant.PRECOMPUTED:
|
||||||
|
share_type = DecryptionSharePrecomputed
|
||||||
|
elif variant == FerveoVariant.SIMPLE:
|
||||||
|
share_type = DecryptionShareSimple
|
||||||
|
|
||||||
decryption_request_mapping = {}
|
decryption_request_mapping = {}
|
||||||
for ursula in cohort:
|
for ursula in cohort:
|
||||||
|
@ -614,6 +617,27 @@ class Bob(Character):
|
||||||
gathered_shares[provider_address] = decryption_share
|
gathered_shares[provider_address] = decryption_share
|
||||||
return gathered_shares
|
return gathered_shares
|
||||||
|
|
||||||
|
def gather_decryption_shares(
|
||||||
|
self,
|
||||||
|
ritual_id: int,
|
||||||
|
cohort: List["Ursula"],
|
||||||
|
ciphertext: Ciphertext,
|
||||||
|
lingo: LingoList,
|
||||||
|
threshold: int,
|
||||||
|
variant: FerveoVariant,
|
||||||
|
context: Optional[dict] = None,
|
||||||
|
) -> Dict[
|
||||||
|
ChecksumAddress, Union[DecryptionShareSimple, DecryptionSharePrecomputed]
|
||||||
|
]:
|
||||||
|
|
||||||
|
decryption_request = self.make_decryption_request(ritual_id=ritual_id,
|
||||||
|
ciphertext=ciphertext,
|
||||||
|
lingo=lingo,
|
||||||
|
variant=variant,
|
||||||
|
context=context)
|
||||||
|
return self.get_decryption_shares_using_existing_decryption_request(decryption_request, variant, cohort,
|
||||||
|
threshold)
|
||||||
|
|
||||||
def threshold_decrypt(self,
|
def threshold_decrypt(self,
|
||||||
ritual_id: int,
|
ritual_id: int,
|
||||||
ciphertext: Ciphertext,
|
ciphertext: Ciphertext,
|
||||||
|
|
Loading…
Reference in New Issue