Circuit
Class: Circuit
Table of contents
Constructors
Properties
- _main
- array
- asProver
- assertEqual
- constraintSystem
- equal
- if
- inCheckedComputation
- inProver
- log
- runAndCheck
- runUnchecked
- switch
- witness
Methods
Constructors
constructor
• new Circuit()
Properties
_main
▪ Static _main: CircuitData\<any, any>
Defined in
array
▪ Static array: \<A>(elementType: A, length: number) => InferredProvable\<A[]> = Provable.Array
Type declaration
▸ \<A>(elementType, length): InferredProvable\<A[]>
Type parameters
| Name | Type | 
|---|---|
| A | extends FlexibleProvable\<any> | 
Parameters
| Name | Type | 
|---|---|
| elementType | A | 
| length | number | 
Returns
InferredProvable\<A[]>
Deprecated
use Array
Defined in
asProver
▪ Static asProver: (f: () => void) => void = Provable.asProver
Type declaration
▸ (f): void
Parameters
| Name | Type | 
|---|---|
| f | () => void | 
Returns
void
Deprecated
use asProver
Defined in
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
| Name | Type | 
|---|---|
| type | FlexibleProvable\<T> | 
| x | T | 
| y | T | 
Returns
void
Deprecated
use assertEqual
▸ \<T>(x, y): void
Type parameters
| Name | Type | 
|---|---|
| T | extends ToFieldable | 
Parameters
| Name | Type | 
|---|---|
| x | T | 
| y | T | 
Returns
void
Deprecated
use assertEqual
Defined in
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
| Name | Type | 
|---|---|
| f | () => T | 
Returns
Object
| Name | Type | 
|---|---|
| digest | string | 
| gates | Gate[] | 
| publicInputSize | number | 
| result | T | 
| rows | number | 
| print | () => void | 
| summary | () => Partial\<Record\<GateType|"Total rows",number>> | 
Deprecated
use constraintSystem
Defined in
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
| Name | Type | 
|---|---|
| type | FlexibleProvable\<T> | 
| x | T | 
| y | T | 
Returns
Deprecated
use equal
▸ \<T>(x, y): Bool
Type parameters
| Name | Type | 
|---|---|
| T | extends ToFieldable | 
Parameters
| Name | Type | 
|---|---|
| x | T | 
| y | T | 
Returns
Deprecated
use equal
Defined in
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
| Name | Type | 
|---|---|
| condition | Bool | 
| type | FlexibleProvable\<T> | 
| x | T | 
| y | T | 
Returns
T
Deprecated
use if
▸ \<T>(condition, x, y): T
Type parameters
| Name | Type | 
|---|---|
| T | extends ToFieldable | 
Parameters
| Name | Type | 
|---|---|
| condition | Bool | 
| x | T | 
| y | T | 
Returns
T
Deprecated
use if
Defined in
inCheckedComputation
▪ Static inCheckedComputation: () => boolean = Provable.inCheckedComputation
Type declaration
▸ (): boolean
Returns
boolean
Deprecated
Defined in
inProver
▪ Static inProver: () => boolean = Provable.inProver
Type declaration
▸ (): boolean
Returns
boolean
Deprecated
use inProver
Defined in
log
▪ Static log: (...args: any) => void = Provable.log
Type declaration
▸ (...args): void
Parameters
| Name | Type | 
|---|---|
| ...args | any | 
Returns
void
Deprecated
use log
Defined in
runAndCheck
▪ Static runAndCheck: (f: () => void) => void = Provable.runAndCheck
Type declaration
▸ (f): void
Parameters
| Name | Type | 
|---|---|
| f | () => void | 
Returns
void
Deprecated
use runAndCheck
Defined in
runUnchecked
▪ Static runUnchecked: (f: () => void) => void = Provable.runUnchecked
Type declaration
▸ (f): void
Parameters
| Name | Type | 
|---|---|
| f | () => void | 
Returns
void
Deprecated
use runUnchecked
Defined in
switch
▪ Static switch: \<T, A>(mask: Bool[], type: A, values: T[]) => T = Provable.switch
Type declaration
▸ \<T, A>(mask, type, values): T
Type parameters
| Name | Type | 
|---|---|
| T | T | 
| A | extends FlexibleProvable\<T> | 
Parameters
| Name | Type | 
|---|---|
| mask | Bool[] | 
| type | A | 
| values | T[] | 
Returns
T
Deprecated
use switch
Defined in
witness
▪ Static witness: \<T, S>(type: S, compute: () => T) => T = Provable.witness
Type declaration
▸ \<T, S>(type, compute): T
Type parameters
| Name | Type | 
|---|---|
| T | T | 
| S | extends FlexibleProvable\<T> =FlexibleProvable\<T> | 
Parameters
| Name | Type | 
|---|---|
| type | S | 
| compute | () => T | 
Returns
T
Deprecated
use witness
Defined in
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
prove
▸ Static prove(privateInput, publicInput, keypair): Promise\<Proof>
Proves a statement using the private input, public input, and the Keypair of the circuit.
Parameters
| Name | Type | 
|---|---|
| privateInput | any[] | 
| publicInput | any[] | 
| keypair | Keypair | 
Returns
Promise\<Proof>
Example
const keypair = await MyCircuit.generateKeypair();
const proof = await MyCircuit.prove(privateInput, publicInput, keypair);
Defined in
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
| Name | Type | 
|---|---|
| publicInput | any[] | 
| verificationKey | VerificationKey | 
| proof | Proof | 
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);