mirror of https://github.com/nucypher/nucypher.git
Remove "enrico" as a parameter to Bob.retrieve(); make "policy_encrypting_key" mandatory.
parent
0f85435ac7
commit
da816586fa
|
@ -362,7 +362,7 @@ Then Bob can retrieve and decrypt the message kit:
|
|||
|
||||
cleartexts = bob.retrieve(
|
||||
message_kits=[message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=policy.public_key,
|
||||
alice_verifying_key=alice_public_key,
|
||||
encrypted_treasure_map=policy.treasure_map,
|
||||
)
|
||||
|
|
|
@ -97,18 +97,12 @@ treasure_map = EncryptedTreasureMap.from_bytes(base64.b64decode(policy_data["tre
|
|||
data = msgpack.load(open("heart_data.msgpack", "rb"), raw=False)
|
||||
message_kits = (MessageKit.from_bytes(k) for k in data['kits'])
|
||||
|
||||
# The doctor also needs to create a view of the Data Source from its public keys
|
||||
data_source = Enrico.from_public_keys(
|
||||
verifying_key=data['data_source'],
|
||||
policy_encrypting_key=policy_pubkey
|
||||
)
|
||||
|
||||
# Now he can ask the NuCypher network to get a re-encrypted version of each MessageKit.
|
||||
for message_kit in message_kits:
|
||||
start = timer()
|
||||
retrieved_plaintexts = doctor.retrieve(
|
||||
[message_kit],
|
||||
enrico=data_source,
|
||||
policy_encrypting_key=policy_pubkey,
|
||||
alice_verifying_key=alices_sig_pubkey,
|
||||
encrypted_treasure_map=treasure_map
|
||||
)
|
||||
|
|
|
@ -176,9 +176,6 @@ class BobInterface(CharacterPublicInterface):
|
|||
alice_verifying_key = PublicKey.from_bytes(alice_verifying_key)
|
||||
message_kit = MessageKit.from_bytes(message_kit) # TODO #846: May raise UnknownOpenSSLError and InvalidTag.
|
||||
|
||||
enrico = Enrico.from_public_keys(verifying_key=message_kit.sender_verifying_key,
|
||||
policy_encrypting_key=policy_encrypting_key)
|
||||
|
||||
if isinstance(encrypted_treasure_map, bytes):
|
||||
encrypted_treasure_map = EncryptedTreasureMap.from_bytes(encrypted_treasure_map)
|
||||
|
||||
|
@ -187,7 +184,7 @@ class BobInterface(CharacterPublicInterface):
|
|||
encrypted_treasure_map = EncryptedTreasureMap.from_bytes(b64decode(tmap_bytes))
|
||||
|
||||
plaintexts = self.implementer.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=policy_encrypting_key,
|
||||
alice_verifying_key=alice_verifying_key,
|
||||
encrypted_treasure_map=encrypted_treasure_map)
|
||||
|
||||
|
|
|
@ -29,22 +29,22 @@ class Retrieve(BaseSchema):
|
|||
policy_encrypting_key = character_fields.Key(
|
||||
required=True,
|
||||
load_only=True,
|
||||
click=options.option_policy_encrypting_key(required=False)
|
||||
click=options.option_policy_encrypting_key(required=True)
|
||||
)
|
||||
alice_verifying_key = character_fields.Key(
|
||||
required=False,
|
||||
required=True,
|
||||
load_only=True,
|
||||
click=click.option(
|
||||
'--alice-verifying-key',
|
||||
'-avk',
|
||||
help="Alice's verifying key as a hexadecimal string",
|
||||
type=click.STRING,
|
||||
required=False)
|
||||
required=True)
|
||||
)
|
||||
message_kit = character_fields.MessageKit(
|
||||
required=True,
|
||||
load_only=True,
|
||||
click=options.option_message_kit(required=False)
|
||||
click=options.option_message_kit(required=True)
|
||||
)
|
||||
|
||||
encrypted_treasure_map = EncryptedTreasureMap(required=True,
|
||||
|
|
|
@ -634,12 +634,7 @@ class Bob(Character):
|
|||
message_kits: Sequence[Union[MessageKit, PolicyMessageKit]],
|
||||
alice_verifying_key: PublicKey, # KeyFrag signer's key
|
||||
encrypted_treasure_map: EncryptedTreasureMap,
|
||||
|
||||
# Optional policy-related args
|
||||
policy_encrypting_key: Optional[PublicKey] = None,
|
||||
enrico: Optional["Enrico"] = None,
|
||||
|
||||
# Retrieval Behaviour
|
||||
policy_encrypting_key: PublicKey, # TODO: #2792
|
||||
cache_cfrags: bool = False,
|
||||
use_cached_cfrags: bool = False,
|
||||
) -> List[PolicyMessageKit]:
|
||||
|
@ -671,18 +666,6 @@ class Bob(Character):
|
|||
# Otherwise we could check the message kits for completeness right away.
|
||||
treasure_map = self._decrypt_treasure_map(encrypted_treasure_map)
|
||||
|
||||
# Check that the sender is set correctly. See #2743
|
||||
if enrico:
|
||||
if policy_encrypting_key is None:
|
||||
policy_encrypting_key = enrico.policy_pubkey
|
||||
else:
|
||||
assert enrico.policy_encrypting_key == policy_encrypting_key
|
||||
for message_kit in message_kits:
|
||||
assert message_kit.sender_verifying_key == enrico.stamp.as_umbral_pubkey()
|
||||
else:
|
||||
if policy_encrypting_key is None:
|
||||
raise ValueError("Either `enrico` or `policy_encrypting_key` must be specified")
|
||||
|
||||
# Normalize input
|
||||
message_kits: List[PolicyMessageKit] = [
|
||||
message_kit.as_policy_kit(policy_encrypting_key, treasure_map.threshold)
|
||||
|
|
|
@ -55,7 +55,7 @@ def test_policy_simple_sinpa(blockchain_ursulas,
|
|||
|
||||
with pytest.raises(Ursula.NotEnoughUrsulas): # Return a more descriptive request error?
|
||||
blockchain_bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=bupkiss_policy.public_key,
|
||||
alice_verifying_key=amonia.stamp,
|
||||
cache_cfrags=True,
|
||||
encrypted_treasure_map=bupkiss_policy.treasure_map)
|
||||
|
@ -93,7 +93,7 @@ def test_try_to_post_free_arrangement_by_hacking_enact(blockchain_ursulas,
|
|||
|
||||
with pytest.raises(Ursula.NotEnoughUrsulas): # Return a more descriptive request error?
|
||||
blockchain_bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=bupkiss_policy.public_key,
|
||||
alice_verifying_key=amonia.stamp,
|
||||
cache_cfrags=True,
|
||||
encrypted_treasure_map=bupkiss_policy.treasure_map)
|
||||
|
@ -129,7 +129,7 @@ def test_pay_a_flunky_instead_of_the_arranged_ursula(blockchain_alice,
|
|||
|
||||
with pytest.raises(Ursula.NotEnoughUrsulas):
|
||||
blockchain_bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=bupkiss_policy.public_key,
|
||||
alice_verifying_key=amonia.stamp,
|
||||
cache_cfrags=True,
|
||||
encrypted_treasure_map=bupkiss_policy.treasure_map)
|
||||
|
|
|
@ -159,7 +159,7 @@ def test_blockchain_ursulas_reencrypt(blockchain_ursulas, blockchain_alice, bloc
|
|||
plaintexts = blockchain_bob.retrieve([message_kit],
|
||||
encrypted_treasure_map=_policy.treasure_map,
|
||||
alice_verifying_key=blockchain_alice.stamp.as_umbral_pubkey(),
|
||||
enrico=enrico)
|
||||
policy_encrypting_key=_policy.public_key)
|
||||
assert plaintexts == [message]
|
||||
|
||||
# Let's consider also that a node may be down when granting
|
||||
|
|
|
@ -643,7 +643,7 @@ def test_collect_rewards_integration(click_runner,
|
|||
|
||||
# Decrypt
|
||||
cleartexts = blockchain_bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=blockchain_policy.public_key,
|
||||
alice_verifying_key=verifying_key,
|
||||
encrypted_treasure_map=blockchain_policy.treasure_map)
|
||||
assert random_data == cleartexts[0]
|
||||
|
|
|
@ -48,7 +48,7 @@ def test_federated_bob_full_retrieve_flow(federated_ursulas,
|
|||
alices_verifying_key = federated_alice.stamp.as_umbral_pubkey()
|
||||
|
||||
delivered_cleartexts = federated_bob.retrieve([the_message_kit],
|
||||
enrico=capsule_side_channel.enrico,
|
||||
policy_encrypting_key=enacted_federated_policy.public_key,
|
||||
alice_verifying_key=alices_verifying_key,
|
||||
encrypted_treasure_map=enacted_federated_policy.treasure_map)
|
||||
|
||||
|
@ -100,7 +100,7 @@ def test_bob_retrieves(federated_alice,
|
|||
|
||||
# Bob takes the message_kit and retrieves the message within
|
||||
delivered_cleartexts = bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=policy.public_key,
|
||||
alice_verifying_key=alices_verifying_key,
|
||||
cache_cfrags=True,
|
||||
encrypted_treasure_map=policy.treasure_map)
|
||||
|
@ -108,7 +108,7 @@ def test_bob_retrieves(federated_alice,
|
|||
assert plaintext == delivered_cleartexts[0]
|
||||
|
||||
cleartexts_delivered_a_second_time = bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=policy.public_key,
|
||||
alice_verifying_key=alices_verifying_key,
|
||||
use_cached_cfrags=True,
|
||||
encrypted_treasure_map=policy.treasure_map)
|
||||
|
@ -123,7 +123,7 @@ def test_bob_retrieves(federated_alice,
|
|||
# One thing to note here is that Bob *can* still retrieve with the cached CFrags,
|
||||
# even though this Policy has been revoked. #892
|
||||
_cleartexts = bob.retrieve([message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=policy.public_key,
|
||||
alice_verifying_key=alices_verifying_key,
|
||||
use_cached_cfrags=True,
|
||||
encrypted_treasure_map=policy.treasure_map)
|
||||
|
@ -147,7 +147,7 @@ def test_bob_retrieves_with_treasure_map(
|
|||
# Deserialized treasure map
|
||||
text1 = federated_bob.retrieve(
|
||||
[message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=enacted_federated_policy.public_key,
|
||||
alice_verifying_key=alice_verifying_key,
|
||||
encrypted_treasure_map=treasure_map)
|
||||
|
||||
|
@ -175,7 +175,7 @@ def test_bob_retrieves_too_late(federated_bob, federated_ursulas,
|
|||
# with pytest.raises(Ursula.NotEnoughUrsulas):
|
||||
federated_bob.retrieve(
|
||||
[message_kit],
|
||||
enrico=enrico,
|
||||
policy_encrypting_key=enacted_federated_policy.public_key,
|
||||
alice_verifying_key=alice_verifying_key,
|
||||
encrypted_treasure_map=treasure_map,
|
||||
use_cached_cfrags=False)
|
||||
|
|
Loading…
Reference in New Issue