Using custom client to produce shares as side channel, etc.

pull/3143/head
jMyles 2023-06-13 17:08:31 +02:00
parent c9262a33c8
commit 9c290820a9
2 changed files with 34 additions and 2 deletions

View File

@ -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

View File

@ -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
)