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
|
||||
|
||||
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]
|
||||
]:
|
||||
if variant == FerveoVariant.PRECOMPUTED:
|
||||
share_type = DecryptionSharePrecomputed
|
||||
elif variant == FerveoVariant.SIMPLE:
|
||||
share_type = DecryptionShareSimple
|
||||
|
||||
def make_decryption_request(
|
||||
self,
|
||||
ritual_id: int,
|
||||
ciphertext: Ciphertext,
|
||||
lingo: LingoList,
|
||||
variant: FerveoVariant,
|
||||
context: Optional[dict] = None,
|
||||
) -> ThresholdDecryptionRequest:
|
||||
conditions = Conditions(json.dumps(lingo))
|
||||
if context:
|
||||
context = Context(json.dumps(context))
|
||||
|
@ -589,6 +580,18 @@ class Bob(Character):
|
|||
conditions=conditions,
|
||||
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 = {}
|
||||
for ursula in cohort:
|
||||
|
@ -614,6 +617,27 @@ class Bob(Character):
|
|||
gathered_shares[provider_address] = decryption_share
|
||||
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,
|
||||
ritual_id: int,
|
||||
ciphertext: Ciphertext,
|
||||
|
|
Loading…
Reference in New Issue