Resource Logic¶
A resource logic is a computable predicate associated with a resource that constrains the creation and consumption of a resource. Each time an action consumes or creates a particular resource, the corresponding resource logic proof is required in order for the action (and thus the transaction) to be valid.
Every proof has three types of inputs and constraints:
- Architecture-level inputs and constraints. This type of inputs and constraints allow to enforce certain resource machine properties and have to be present in each resource logic, no matter in the context of which instantiation and application the resource logic was produced. These contraints ensure basic resource machine properties.
- Instantiation-level inputs and constraints. These inputs and constraints must be present in every resource logic compatible with a concrete resource machine instantiation but might not be required by other instantiations. These constraints ensure additional resource machine properties desired by the instantiation.
- Application-level (custom) inputs and constraints that are present in every resource logic specified by a concrete application. These constraints define how the application works.
This specification explicitly defines only the architecture-level inputs and constraints. Only application-level constraints are referred to as custom.
Proving¶
When proving, resource logics take as input resources created and consumed in the action:
Instance¶
tag
— identifies the current resource being checkedaction.consumed
(possibly excluding the tagged resource, if it is consumed)action.created
(possibly excluding the tagged resource, if it is created)action.applicationData
Witness¶
- for consumed resources:
1. resource object
2.
nullifierKey
- for created resources: 1. resource object
- Application inputs
Note
The instance and witness values are expected to correspond to each other: the first tag in the instance corresponds to the first resource object in the witness (and corresponds to the resource being checked), and so on. Note that the tag has to be recomputed from the object to verify that it indeed corresponds to the tag (this condition is included in the constraints)
Constraints¶
- Created commitment integrity:
r.commitment() = cm
- Consumed nullifier integrity:
r.nullifier(nullifierKey) = nf
- Application constraints