Policy

class nucypher.policy.policies.Arrangement(alice: nucypher.characters.lawful.Alice, expiration: maya.core.MayaDT, ursula: nucypher.characters.lawful.Ursula = None, arrangement_id: bytes = None, kfrag: umbral.kfrags.KFrag = UNKNOWN_KFRAG)[source]

A Policy must be implemented by arrangements with n Ursulas. This class tracks the status of that implementation.

alice = None

These will normally not be set if Alice is drawing up this arrangement - she hasn’t assigned a kfrag yet (because she doesn’t know if this Arrangement will be accepted). She doesn’t have an Ursula, for the same reason.

encrypt_payload_for_ursula()[source]

Craft an offer to send to Ursula.

abstract revoke()[source]

Revoke arrangement.

class nucypher.policy.policies.BlockchainArrangement(alice: nucypher.characters.lawful.Alice, ursula: nucypher.characters.lawful.Ursula, rate: int, expiration: maya.core.MayaDT, duration_periods: int, *args, **kwargs)[source]

A relationship between Alice and a single Ursula as part of Blockchain Policy

exception InvalidArrangement[source]
revoke() → str[source]

Revoke this arrangement and return the transaction hash as hex.

class nucypher.policy.policies.BlockchainPolicy(alice: nucypher.characters.lawful.Alice, value: int, rate: int, duration_periods: int, expiration: maya.core.MayaDT, first_period_reward: int, *args, **kwargs)[source]

A collection of n BlockchainArrangements representing a single Policy

exception InvalidPolicy[source]
exception InvalidPolicyValue[source]
exception NoSuchPolicy[source]
exception NotEnoughBlockchainUrsulas[source]
publish(**kwargs) → dict[source]

Spread word of this Policy far and wide.

Base publication method for spreading news of the policy. If this is a blockchain policy, this includes writing to PolicyManager contract storage.

class nucypher.policy.policies.FederatedPolicy(alice, label, expiration: maya.core.MayaDT, bob=None, kfrags=(UNKNOWN_KFRAG, ), public_key=None, m: int = None, alice_signature=NOT_SIGNED)[source]
class nucypher.policy.policies.Policy(alice, label, expiration: maya.core.MayaDT, bob=None, kfrags=(UNKNOWN_KFRAG, ), public_key=None, m: int = None, alice_signature=NOT_SIGNED)[source]

An edict by Alice, arranged with n Ursulas, to perform re-encryption for a specific Bob for a specific path.

Once Alice is ready to enact a Policy, she generates KFrags, which become part of the Policy.

Each Ursula is offered a Arrangement (see above) for a given Policy by Alice.

Once Alice has secured agreement with n Ursulas to enact a Policy, she sends each a KFrag, and generates a TreasureMap for the Policy, recording which Ursulas got a KFrag.

exception MoreKFragsThanArrangements[source]

Raised when a Policy has been used to generate Arrangements with Ursulas insufficient number such that we don’t have enough KFrags to give to each Ursula.

exception Rejected[source]

Too many Ursulas rejected

enact(network_middleware, publish=True) → dict[source]

Assign kfrags to ursulas_on_network, and distribute them via REST, populating enacted_arrangements

hrac() → bytes[source]

# TODO: #180 - This function is hanging on for dear life. After 180 is closed, it can be completely deprecated.

The “hashed resource authentication code”.

A hash of: * Alice’s public key * Bob’s public key * the label

Alice and Bob have all the information they need to construct this. Ursula does not, so we share it with her.

publish(network_middleware: nucypher.network.middleware.RestMiddleware) → dict[source]

Spread word of this Policy far and wide.

Base publication method for spreading news of the policy. If this is a blockchain policy, this includes writing to PolicyManager contract storage.