nucypher.policy.conditions

Submodules

class ReencryptionCondition

Bases: nucypher.policy.conditions.base._Serializable, abc.ABC

class Schema(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = , many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = , dump_only: types.StrSequenceOrSet = , partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)

Bases: marshmallow.schema.Schema

name = NotImplemented
opts = <marshmallow.schema.SchemaOpts object>
abstract verify(*args, **kwargs) → Tuple[bool, Any]

Returns the boolean result of the evaluation and the returned value in a two-tuple.

class UserAddress(**kwargs)

Bases: eip712_structs.struct.EIP712Struct

address = <eip712_structs.types.String object>
blockNumber = <eip712_structs.types.Uint object>
blockHash = <eip712_structs.types.Bytes object>
signatureText = <eip712_structs.types.String object>
type_name = 'UserAddress'
is_context_variable(variable)bool
get_context_value(context_variable: str, **context) → Any
class RPCCondition(chain: int, method: str, return_value_test: nucypher.policy.conditions.lingo.ReturnValueTest, parameters: Optional[List[Any]] = None)

Bases: nucypher.policy.conditions.base.ReencryptionCondition

ALLOWED_METHODS = ('balanceOf', 'eth_getBalance')
class Schema(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = , many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = , dump_only: types.StrSequenceOrSet = , partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)

Bases: nucypher.policy.conditions._utils.CamelCaseSchema

make(data, **kwargs)
opts = <marshmallow.schema.SchemaOpts object>
validate_method(method)
verify(providers: Dict[int, web3.providers.base.BaseProvider], **context) → Tuple[bool, Any]

Verifies the onchain condition is met by performing a read operation and evaluating the return value test.

class ContractCondition(contract_address: NewType.<locals>.new_type, standard_contract_type: Optional[str] = None, function_abi: Optional[web3.types.ABIFunction] = None, *args, **kwargs)

Bases: nucypher.policy.conditions.evm.RPCCondition

class Schema(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = , many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = , dump_only: types.StrSequenceOrSet = , partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)

Bases: nucypher.policy.conditions.evm.RPCCondition.Schema

SKIP_VALUES = (None,)
make(data, **kwargs)
opts = <marshmallow.schema.SchemaOpts object>
validate_method(method)
exception NoConnectionToChain(chain: int)

Bases: RuntimeError

Raised when a node does not have an associated provider for a chain.

exception ReturnValueEvaluationError

Bases: Exception

Issue with Return Value and Key

exception RequiredContextVariable

Bases: Exception

No value provided for context variable

exception InvalidContextVariableData

Bases: Exception

Context variable could not be processed

exception ContextVariableVerificationFailed

Bases: Exception

Issue with using the provided context variable.

exception InvalidCondition

Bases: ValueError

Invalid value for condition.

exception ConditionEvaluationFailed

Bases: Exception

Could not evaluate condition.

exception RPCExecutionFailed

Bases: nucypher.policy.conditions.exceptions.ConditionEvaluationFailed

Raised when an exception is raised from an RPC call.

class Operator(_operator: str)

Bases: object

OPERATORS = ('and', 'or')
to_dict() → Dict[str, str]
classmethod from_dict(data: Dict[str, str])nucypher.policy.conditions.lingo.Operator
classmethod from_json(data)nucypher.policy.conditions.lingo.Operator
to_json()str
class ReturnValueTest(comparator: str, value: Any, key: Union[int, str, None] = None)

Bases: object

exception InvalidExpression

Bases: ValueError

COMPARATORS = ('==', '!=', '>', '<', '<=', '>=')
class ReturnValueTestSchema(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = , many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = , dump_only: types.StrSequenceOrSet = , partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)

Bases: nucypher.policy.conditions._utils.CamelCaseSchema

SKIP_VALUES = (None,)
make(data, **kwargs)
opts = <marshmallow.schema.SchemaOpts object>
eval(data)bool
class ConditionLingo(conditions: List[Union[nucypher.policy.conditions.base.ReencryptionCondition, nucypher.policy.conditions.lingo.Operator, Any]])

Bases: object

A Collection of re-encryption conditions evaluated as a compound boolean expression.

This is an alternate implementation of the condition expression format used in the Lit Protocol (https://github.com/LIT-Protocol); credit to the authors for inspiring this work.

classmethod from_list(payload: List[Dict[str, str]])nucypher.policy.conditions.lingo.ConditionLingo
to_list()
to_json()str
classmethod from_json(data: str)nucypher.policy.conditions.lingo.ConditionLingo
to_base64()bytes
classmethod from_base64(data: bytes)nucypher.policy.conditions.lingo.ConditionLingo
eval(*args, **kwargs)bool
class TimeCondition(return_value_test: nucypher.policy.conditions.lingo.ReturnValueTest, method: str = 'timelock')

Bases: nucypher.policy.conditions.base.ReencryptionCondition

METHOD = 'timelock'
class Schema(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = , many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = , dump_only: types.StrSequenceOrSet = , partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)

Bases: nucypher.policy.conditions._utils.CamelCaseSchema

make(data, **kwargs)
opts = <marshmallow.schema.SchemaOpts object>
property method
property timestamp
verify(*args, **kwargs) → Tuple[bool, float]

Returns the boolean result of the evaluation and the returned value in a two-tuple.