From 9c290820a9243f8225f75760185e3a3d42e7eb17 Mon Sep 17 00:00:00 2001 From: jMyles Date: Tue, 13 Jun 2023 17:08:31 +0200 Subject: [PATCH] Using custom client to produce shares as side channel, etc. --- nucypher/characters/chaotic.py | 33 ++++++++++++++++++++++++++++++++- nucypher/characters/lawful.py | 3 ++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/nucypher/characters/chaotic.py b/nucypher/characters/chaotic.py index 728cf2411..42dd26051 100644 --- a/nucypher/characters/chaotic.py +++ b/nucypher/characters/chaotic.py @@ -1,8 +1,11 @@ import json +from typing import Dict, Tuple -from nucypher_core import ferveo +from nucypher_core import EncryptedThresholdDecryptionResponse, ferveo from nucypher.characters.lawful import Bob, Enrico +from nucypher.cli.types import ChecksumAddress +from nucypher.network.decryption import ThresholdDecryptionClient from nucypher.policy.conditions.types import LingoList from nucypher.policy.conditions.utils import validate_condition_lingo @@ -98,6 +101,34 @@ class BobGonnaBob(Bob, DKGOmniscient): After all, Bob gonna Bob. """ + class DKGOmniscientDecryptionClient(ThresholdDecryptionClient): + def gather_encrypted_decryption_shares( + self, + *args, + **kwargs, + ) -> Tuple[ + Dict[ChecksumAddress, EncryptedThresholdDecryptionResponse], + Dict[ChecksumAddress, str], + ]: + assert ( + False # This is where DKGomniscent just knows the shares in question. + ) + + _threshold_decryption_client_class = DKGOmniscientDecryptionClient + + @property + def done_seeding(self, *args, **kwargs): + return True + + @done_seeding.setter + def done_seeding(self, *args, **kwargs): + return True # We were done seeding before we started. + + def ensure_ursula_availability_is_of_no_conern_to_anyone(self, *args, **kwargs): + pass + + _ensure_ursula_availability = ensure_ursula_availability_is_of_no_conern_to_anyone + def threshold_decrypt(self, ciphertext, *args, **kwargs) -> bytes: """ https://imgflip.com/i/7o0q5d # Copilot gonns copilot diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index 974d289ff..b8af0f766 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -440,6 +440,7 @@ class Bob(Character): banner = BOB_BANNER default_dkg_variant = FerveoVariant.PRECOMPUTED _default_crypto_powerups = [SigningPower, DecryptingPower] + _threshold_decryption_client_class = ThresholdDecryptionClient class IncorrectCFragsReceived(Exception): """ @@ -676,7 +677,7 @@ class Bob(Character): ursula_checksum_address ] = encrypted_decryption_request - decryption_client = ThresholdDecryptionClient(learner=self) + decryption_client = self._threshold_decryption_client_class(learner=self) successes, failures = decryption_client.gather_encrypted_decryption_shares( encrypted_requests=decryption_request_mapping, threshold=threshold )