ProvablePure
Interface: ProvablePure\<T>
ProvablePure<T> is a special kind of Provable interface, where the "auxiliary" (non-provable) data is empty. This means the type consists only of field elements, in that sense it is "pure".
Any element on the interface ProvablePure<T> is also an element of the interface Provable<T> where the "auxiliary" data is empty.
Examples where ProvablePure<T> is required are types of on-chain state, events and actions.
It includes the same properties and methods as the Provable interface.
Type parameters
| Name |
|---|
T |
Hierarchy
Provable\<T>↳
ProvablePure
Table of contents
Properties
Methods
Properties
check
• check: (value: T) => void
Type declaration
▸ (value): void
Add assertions to the proof to check if value is a valid member of type T.
This function does not return anything, rather creates any number of assertions on the proof to prove value is a valid member of the type T.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Parameters
| Name | Type | Description |
|---|---|---|
value | T | the element of type T to put assertions on. |
Returns
void
Overrides
Defined in
fromFields
• fromFields: (fields: Field[]) => T
Type declaration
▸ (fields): T
A function that returns an element of type T from the given provable data.
Important: For any element of type T, this function is the reverse operation of calling toFields method on an element of type T.
Parameters
| Name | Type | Description |
|---|---|---|
fields | Field[] | an array of Field elements describing the provable data of the new T element. |
Returns
T
An element of type T generated from the given provable data.
Overrides
Defined in
toAuxiliary
• toAuxiliary: (value?: T) => any[]
Type declaration
▸ (value?): any[]
A function that takes value (optional), an element of type T, as argument and returns an array of any type that make up the "auxiliary" (non-provable) data of value.
As any element of the interface ProvablePure<T> includes no "auxiliary" data by definition, this function always returns a default value.
Parameters
| Name | Type | Description |
|---|---|---|
value? | T | the element of type T to generate the auxiliary data array from, optional. If not provided, a default value for auxiliary data is returned. |
Returns
any[]
An empty array, as any element of the interface ProvablePure<T> includes no "auxiliary" data by definition.
Overrides
Defined in
toFields
• toFields: (value: T) => Field[]
Type declaration
▸ (value): Field[]
A function that takes value, an element of type T, as argument and returns an array of Field elements that make up the provable data of value.
Parameters
| Name | Type | Description |
|---|---|---|
value | T | the element of type T to generate the Field array from. |
Returns
Field[]
A Field array describing how this T element is made up of Field elements.
Overrides
Defined in
Methods
sizeInFields
▸ sizeInFields(): number
Return the size of the T type in terms of Field type, as Field is the primitive type.
Warning: This function returns a number, so you cannot use it to prove something on chain. You can use it during debugging or to understand the memory complexity of some type.
Returns
number
A number representing the size of the T type in terms of Field type.