Skip to main content

Circuit

o1js / Modules / Circuit

Class: Circuit

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Circuit()

Properties

_main

Static _main: CircuitData\<any, any>

Defined in

lib/circuit.ts:15


array

Static array: \<A>(elementType: A, length: number) => InferredProvable\<A[]> = Provable.Array

Type declaration

▸ \<A>(elementType, length): InferredProvable\<A[]>

Type parameters
NameType
Aextends FlexibleProvable\<any>
Parameters
NameType
elementTypeA
lengthnumber
Returns

InferredProvable\<A[]>

Deprecated

use Array

Defined in

lib/circuit.ts:111


asProver

Static asProver: (f: () => void) => void = Provable.asProver

Type declaration

▸ (f): void

Parameters
NameType
f() => void
Returns

void

Deprecated

use asProver

Defined in

lib/circuit.ts:95


assertEqual

Static assertEqual: \<T>(type: FlexibleProvable\<T>, x: T, y: T) => void\<T>(x: T, y: T) => void = Provable.assertEqual

Type declaration

▸ \<T>(type, x, y): void

Type parameters
Name
T
Parameters
NameType
typeFlexibleProvable\<T>
xT
yT
Returns

void

Deprecated

use assertEqual

▸ \<T>(x, y): void

Type parameters
NameType
Textends ToFieldable
Parameters
NameType
xT
yT
Returns

void

Deprecated

use assertEqual

Defined in

lib/circuit.ts:115


constraintSystem

Static constraintSystem: \<T>(f: () => T) => { digest: string ; gates: Gate[] ; publicInputSize: number ; result: T ; rows: number ; print: () => void ; summary: () => Partial\<Record\<GateType | "Total rows", number>> } = Provable.constraintSystem

Type declaration

▸ \<T>(f): Object

Type parameters
Name
T
Parameters
NameType
f() => T
Returns

Object

NameType
digeststring
gatesGate[]
publicInputSizenumber
resultT
rowsnumber
print() => void
summary() => Partial\<Record\<GateType | "Total rows", number>>

Deprecated

use constraintSystem

Defined in

lib/circuit.ts:107


equal

Static equal: \<T>(type: FlexibleProvable\<T>, x: T, y: T) => Bool\<T>(x: T, y: T) => Bool = Provable.equal

Type declaration

▸ \<T>(type, x, y): Bool

Type parameters
Name
T
Parameters
NameType
typeFlexibleProvable\<T>
xT
yT
Returns

Bool

Deprecated

use equal

▸ \<T>(x, y): Bool

Type parameters
NameType
Textends ToFieldable
Parameters
NameType
xT
yT
Returns

Bool

Deprecated

use equal

Defined in

lib/circuit.ts:119


if

Static if: \<T>(condition: Bool, type: FlexibleProvable\<T>, x: T, y: T) => T\<T>(condition: Bool, x: T, y: T) => T = Provable.if

Type declaration

▸ \<T>(condition, type, x, y): T

Type parameters
Name
T
Parameters
NameType
conditionBool
typeFlexibleProvable\<T>
xT
yT
Returns

T

Deprecated

use if

▸ \<T>(condition, x, y): T

Type parameters
NameType
Textends ToFieldable
Parameters
NameType
conditionBool
xT
yT
Returns

T

Deprecated

use if

Defined in

lib/circuit.ts:123


inCheckedComputation

Static inCheckedComputation: () => boolean = Provable.inCheckedComputation

Type declaration

▸ (): boolean

Returns

boolean

Deprecated

use inCheckedComputation

Defined in

lib/circuit.ts:135


inProver

Static inProver: () => boolean = Provable.inProver

Type declaration

▸ (): boolean

Returns

boolean

Deprecated

use inProver

Defined in

lib/circuit.ts:131


log

Static log: (...args: any) => void = Provable.log

Type declaration

▸ (...args): void

Parameters
NameType
...argsany
Returns

void

Deprecated

use log

Defined in

lib/circuit.ts:139


runAndCheck

Static runAndCheck: (f: () => void) => void = Provable.runAndCheck

Type declaration

▸ (f): void

Parameters
NameType
f() => void
Returns

void

Deprecated

use runAndCheck

Defined in

lib/circuit.ts:99


runUnchecked

Static runUnchecked: (f: () => void) => void = Provable.runUnchecked

Type declaration

▸ (f): void

Parameters
NameType
f() => void
Returns

void

Deprecated

use runUnchecked

Defined in

lib/circuit.ts:103


switch

Static switch: \<T, A>(mask: Bool[], type: A, values: T[]) => T = Provable.switch

Type declaration

▸ \<T, A>(mask, type, values): T

Type parameters
NameType
TT
Aextends FlexibleProvable\<T>
Parameters
NameType
maskBool[]
typeA
valuesT[]
Returns

T

Deprecated

use switch

Defined in

lib/circuit.ts:127


witness

Static witness: \<T, S>(type: S, compute: () => T) => T = Provable.witness

Type declaration

▸ \<T, S>(type, compute): T

Type parameters
NameType
TT
Sextends FlexibleProvable\<T> = FlexibleProvable\<T>
Parameters
NameType
typeS
compute() => T
Returns

T

Deprecated

use witness

Defined in

lib/circuit.ts:91

Methods

generateKeypair

Static generateKeypair(): Promise\<Keypair>

Generates a proving key and a verification key for this circuit.

Returns

Promise\<Keypair>

Example

const keypair = await MyCircuit.generateKeypair();

Defined in

lib/circuit.ts:24


prove

Static prove(privateInput, publicInput, keypair): Promise\<Proof>

Proves a statement using the private input, public input, and the Keypair of the circuit.

Parameters

NameType
privateInputany[]
publicInputany[]
keypairKeypair

Returns

Promise\<Proof>

Example

const keypair = await MyCircuit.generateKeypair();
const proof = await MyCircuit.prove(privateInput, publicInput, keypair);

Defined in

lib/circuit.ts:43


verify

Static verify(publicInput, verificationKey, proof): Promise\<boolean>

Verifies a proof using the public input, the proof, and the initial Keypair of the circuit.

Parameters

NameType
publicInputany[]
verificationKeyVerificationKey
proofProof

Returns

Promise\<boolean>

Example

const keypair = await MyCircuit.generateKeypair();
const proof = await MyCircuit.prove(privateInput, publicInput, keypair);
const isValid = await MyCircuit.verify(publicInput, keypair.vk, proof);

Defined in

lib/circuit.ts:69