mirror of https://github.com/nucypher/nucypher.git
Don't cache derived decryption shares - what in the hell was I thinking, they are ciphertext specific at the moment.
parent
f5eb270e90
commit
611445f80e
|
@ -595,10 +595,6 @@ class Operator(BaseActor):
|
|||
if not self.coordinator_agent.is_ritual_active(ritual_id=ritual_id):
|
||||
raise self.ActorError(f"Ritual #{ritual_id} is not active.")
|
||||
|
||||
decryption_share = self.dkg_storage.get_decryption_share(ritual_id)
|
||||
if decryption_share:
|
||||
return decryption_share
|
||||
|
||||
ritual = self.coordinator_agent.get_ritual(ritual_id)
|
||||
|
||||
validators = self._resolve_validators(ritual)
|
||||
|
@ -623,7 +619,6 @@ class Operator(BaseActor):
|
|||
aad=aad,
|
||||
variant=variant
|
||||
)
|
||||
self.dkg_storage.store_decryption_share(ritual_id, decryption_share)
|
||||
return decryption_share
|
||||
|
||||
def decrypt_threshold_decryption_request(
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
from collections import defaultdict
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Optional
|
||||
|
||||
from hexbytes import HexBytes
|
||||
from nucypher_core.ferveo import (
|
||||
AggregatedTranscript,
|
||||
DecryptionSharePrecomputed,
|
||||
DecryptionShareSimple,
|
||||
Validator,
|
||||
)
|
||||
|
||||
|
@ -19,15 +17,12 @@ class DKGStorage:
|
|||
# round 2
|
||||
KEY_AGGREGATED_TXS = "aggregation_tx_hashes"
|
||||
KEY_AGGREGATED_TRANSCRIPTS = "aggregated_transcripts"
|
||||
# active rituals
|
||||
KEY_DECRYPTION_SHARE = "decryption_share"
|
||||
|
||||
_KEYS = [
|
||||
KEY_TRANSCRIPT_TXS,
|
||||
KEY_VALIDATORS,
|
||||
KEY_AGGREGATED_TXS,
|
||||
KEY_AGGREGATED_TRANSCRIPTS,
|
||||
KEY_DECRYPTION_SHARE,
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
|
@ -96,18 +91,3 @@ class DKGStorage:
|
|||
|
||||
def get_aggregation_txhash(self, ritual_id: int) -> Optional[HexBytes]:
|
||||
return self.data[self.KEY_AGGREGATED_TXS].get(ritual_id)
|
||||
|
||||
#
|
||||
# Active Rituals
|
||||
#
|
||||
def store_decryption_share(
|
||||
self,
|
||||
ritual_id: int,
|
||||
decryption_share: Union[DecryptionShareSimple, DecryptionSharePrecomputed],
|
||||
) -> None:
|
||||
self.data[self.KEY_DECRYPTION_SHARE][ritual_id] = decryption_share
|
||||
|
||||
def get_decryption_share(
|
||||
self, ritual_id: int
|
||||
) -> Optional[Union[DecryptionShareSimple, DecryptionSharePrecomputed]]:
|
||||
return self.data[self.KEY_DECRYPTION_SHARE].get(ritual_id)
|
||||
|
|
|
@ -312,16 +312,10 @@ def test_ursula_ritualist(
|
|||
0
|
||||
].dkg_storage.get_aggregated_transcript(RITUAL_ID)
|
||||
|
||||
original_decryption_shares = []
|
||||
for ursula in cohort:
|
||||
original_decryption_shares.append(
|
||||
ursula.dkg_storage.get_decryption_share(RITUAL_ID)
|
||||
)
|
||||
|
||||
ursula.dkg_storage.clear(RITUAL_ID)
|
||||
assert ursula.dkg_storage.get_validators(RITUAL_ID) is None
|
||||
assert ursula.dkg_storage.get_aggregated_transcript(RITUAL_ID) is None
|
||||
assert ursula.dkg_storage.get_decryption_share(RITUAL_ID) is None
|
||||
|
||||
bob.start_learning_loop(now=True)
|
||||
cleartext = bob.threshold_decrypt(
|
||||
|
@ -348,11 +342,6 @@ def test_ursula_ritualist(
|
|||
original_aggregated_transcript
|
||||
)
|
||||
assert bytes(cached_aggregated_transcript) == ritual.aggregated_transcript
|
||||
|
||||
assert ursula.dkg_storage.get_decryption_share(RITUAL_ID)
|
||||
|
||||
# TODO not working for some reason
|
||||
# assert bytes(ursula.dkg_storage.get_decryption_share(ritual_id)) == bytes(original_decryption_shares[ursula_index])
|
||||
assert num_used_ursulas >= ritual.threshold
|
||||
print("===================== DECRYPTION SUCCESSFUL =====================")
|
||||
|
||||
|
|
|
@ -300,16 +300,10 @@ def test_ursula_ritualist(
|
|||
0
|
||||
].dkg_storage.get_aggregated_transcript(ritual_id)
|
||||
|
||||
original_decryption_shares = []
|
||||
for ursula in cohort:
|
||||
original_decryption_shares.append(
|
||||
ursula.dkg_storage.get_decryption_share(ritual_id)
|
||||
)
|
||||
|
||||
ursula.dkg_storage.clear(ritual_id)
|
||||
assert ursula.dkg_storage.get_validators(ritual_id) is None
|
||||
assert ursula.dkg_storage.get_aggregated_transcript(ritual_id) is None
|
||||
assert ursula.dkg_storage.get_decryption_share(ritual_id) is None
|
||||
|
||||
bob.start_learning_loop(now=True)
|
||||
cleartext = bob.threshold_decrypt(
|
||||
|
@ -338,11 +332,6 @@ def test_ursula_ritualist(
|
|||
assert (
|
||||
bytes(cached_aggregated_transcript) == ritual.aggregated_transcript
|
||||
)
|
||||
|
||||
assert ursula.dkg_storage.get_decryption_share(ritual_id)
|
||||
|
||||
# TODO not working for some reason
|
||||
# assert bytes(ursula.dkg_storage.get_decryption_share(ritual_id)) == bytes(original_decryption_shares[ursula_index])
|
||||
assert num_used_ursulas >= threshold
|
||||
print("===================== DECRYPTION SUCCESSFUL =====================")
|
||||
|
||||
|
|
Loading…
Reference in New Issue