mirror of https://github.com/nucypher/nucypher.git
Finishing the layup for which @michwill set me up vis a vis TreasureMaps being passed through Bob's controller.
parent
4f8e266bf6
commit
90a3c26298
|
@ -202,10 +202,13 @@ class BobInterface(CharacterPublicInterface):
|
|||
label=label)
|
||||
|
||||
self.character.join_policy(label=label, alice_verifying_key=alice_verifying_key)
|
||||
|
||||
|
||||
plaintexts = self.character.retrieve(message_kit,
|
||||
enrico=enrico,
|
||||
alice_verifying_key=alice_verifying_key,
|
||||
label=label)
|
||||
label=label,
|
||||
treasure_map=treasure_map)
|
||||
|
||||
response_data = {'cleartexts': plaintexts}
|
||||
return response_data
|
||||
|
|
|
@ -17,7 +17,7 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
import json
|
||||
import time
|
||||
from base64 import b64encode
|
||||
from base64 import b64encode, b64decode
|
||||
from collections import OrderedDict
|
||||
from functools import partial
|
||||
from json.decoder import JSONDecodeError
|
||||
|
@ -679,13 +679,21 @@ class Bob(Character):
|
|||
|
||||
hrac, map_id = self.construct_hrac_and_map_id(alice_verifying_key, label)
|
||||
if treasure_map is not None:
|
||||
alice = Alice.from_public_keys(verifying_key=alice_verifying_key)
|
||||
compass = self.make_compass_for_alice(alice)
|
||||
|
||||
from nucypher.policy.collections import TreasureMap
|
||||
|
||||
# TODO: This LBYL is ugly and fraught with danger.
|
||||
if isinstance(treasure_map, bytes):
|
||||
treasure_map = TreasureMap.from_bytes(treasure_map)
|
||||
alice = Alice.from_public_keys(verifying_key=alice_verifying_key)
|
||||
compass = self.make_compass_for_alice(alice)
|
||||
treasure_map.orient(compass)
|
||||
|
||||
if isinstance(treasure_map, str):
|
||||
tmap_bytes = treasure_map.encode()
|
||||
b64decode(tmap_bytes)
|
||||
treasure_map = TreasureMap.from_bytes(b64decode(tmap_bytes))
|
||||
|
||||
treasure_map.orient(compass)
|
||||
_unknown_ursulas, _known_ursulas, m = self.follow_treasure_map(treasure_map=treasure_map, block=True)
|
||||
else:
|
||||
_unknown_ursulas, _known_ursulas, m = self.follow_treasure_map(map_id=map_id, block=True)
|
||||
|
|
|
@ -145,6 +145,6 @@ def test_bob_rpc_character_control_retrieve_with_tmap(
|
|||
blockchain_alice.stamp,
|
||||
b'Wrong!')
|
||||
tmap_64 = b64encode(bytes(wrong_tmap)).decode()
|
||||
params['treasure_map'] = tmap_64
|
||||
request_data['params']['treasure_map'] = tmap_64
|
||||
with pytest.raises(TreasureMap.IsDisorienting):
|
||||
bob_rpc_controller.send(request_data)
|
||||
|
|
Loading…
Reference in New Issue