# Alice can get the public key even before creating the policy. # From this moment on, any Data Source that knows the public key # can encrypt data originally intended for Alice, but that can be shared with # any Bob that Alice grants access. policy_pubkey = ALICE.get_policy_encrypting_key_from_label(label) BOB = Bob(known_nodes=[ursula], domains={TEMPORARY_DOMAIN}, network_middleware=RestMiddleware(), federated_only=True, start_learning_now=True, learn_on_same_thread=True) ALICE.start_learning_loop(now=True) ALICE.block_until_number_of_known_nodes_is( 8, timeout=30, learn_on_this_thread=True ) # In case the fleet isn't fully spun up yet, as sometimes happens on CI. policy = ALICE.grant(BOB, label, m=m, n=n, expiration=policy_end_datetime) assert policy.public_key == policy_pubkey policy.publishing_mutex.block_until_complete() # Alice puts her public key somewhere for Bob to find later... alices_pubkey_bytes_saved_for_posterity = bytes(ALICE.stamp) # ...and then disappears from the internet. ALICE.disenchant() del ALICE #####################
verifying_key = bob.public_keys(SigningPower) encrypting_key = bob.public_keys(DecryptingPower) ###################################### # Alice, the Authority of the Policy # ###################################### alice = Alice(federated_only=True, domain=TEMPORARY_DOMAIN, known_nodes=[ursula]) # Start node discovery and wait until 8 nodes are known in case # the fleet isn't fully spun up yet, as sometimes happens on CI. alice.start_learning_loop(now=True) alice.block_until_number_of_known_nodes_is(8, timeout=30, learn_on_this_thread=True) # Alice can get the public key even before creating the policy. # From this moment on, any Data Source that knows the public key # can encrypt data originally intended for Alice, but that can be shared with # any Bob that Alice grants access. policy_public_key = alice.get_policy_encrypting_key_from_label(label) # Alice grant access to Bob. She already knows Bob's public keys from a side-channel. remote_bob = Bob.from_public_keys(encrypting_key=encrypting_key, verifying_key=verifying_key) policy = alice.grant(remote_bob, label, threshold=threshold, shares=shares,