Skip to main content

ProvablePure

o1js / Modules / 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

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
NameTypeDescription
valueTthe element of type T to put assertions on.
Returns

void

Overrides

Provable.check

Defined in

snarky.d.ts:157


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
NameTypeDescription
fieldsField[]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

Provable.fromFields

Defined in

snarky.d.ts:138


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
NameTypeDescription
value?Tthe 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

Provable.toAuxiliary

Defined in

snarky.d.ts:127


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
NameTypeDescription
valueTthe 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

Provable.toFields

Defined in

snarky.d.ts:117

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.

Overrides

Provable.sizeInFields

Defined in

snarky.d.ts:147