Skip to main content

Circuit

SnarkyJS / 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:14


array

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

Type declaration

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

Deprecated

use Array

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

InferredProvable<A[]>

Defined in

lib/circuit.ts:110


asProver

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

Type declaration

▸ (f): void

Deprecated

use asProver

Parameters
NameType
f() => void
Returns

void

Defined in

lib/circuit.ts:94


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

Deprecated

use assertEqual

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

void

▸ <T>(x, y): void

Deprecated

use assertEqual

Type parameters
NameType
Textends ToFieldable
Parameters
NameType
xT
yT
Returns

void

Defined in

lib/circuit.ts:114


constraintSystem

Static constraintSystem: <T>(f: () => T) => { digest: string ; gates: Gate[] ; publicInputSize: number ; result: T ; rows: number } = Provable.constraintSystem

Type declaration

▸ <T>(f): Object

Deprecated

use constraintSystem

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

Object

NameType
digeststring
gatesGate[]
publicInputSizenumber
resultT
rowsnumber

Defined in

lib/circuit.ts:106


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

Deprecated

use equal

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

Bool

▸ <T>(x, y): Bool

Deprecated

use equal

Type parameters
NameType
Textends ToFieldable
Parameters
NameType
xT
yT
Returns

Bool

Defined in

lib/circuit.ts:118


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

Deprecated

use if

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

T

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

Deprecated

use if

Type parameters
NameType
Textends ToFieldable
Parameters
NameType
conditionBool
xT
yT
Returns

T

Defined in

lib/circuit.ts:122


inCheckedComputation

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

Type declaration

▸ (): boolean

Deprecated

use inCheckedComputation

Returns

boolean

Defined in

lib/circuit.ts:134


inProver

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

Type declaration

▸ (): boolean

Deprecated

use inProver

Returns

boolean

Defined in

lib/circuit.ts:130


log

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

Type declaration

▸ (...args): void

Deprecated

use log

Parameters
NameType
...argsany
Returns

void

Defined in

lib/circuit.ts:138


runAndCheck

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

Type declaration

▸ (f): void

Deprecated

use runAndCheck

Parameters
NameType
f() => void
Returns

void

Defined in

lib/circuit.ts:98


runUnchecked

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

Type declaration

▸ (f): void

Deprecated

use runUnchecked

Parameters
NameType
f() => void
Returns

void

Defined in

lib/circuit.ts:102


switch

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

Type declaration

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

Deprecated

use switch

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

T

Defined in

lib/circuit.ts:126


witness

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

Type declaration

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

Deprecated

use witness

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

T

Defined in

lib/circuit.ts:90

Methods

generateKeypair

Static generateKeypair(): Promise<Keypair>

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

Example

const keypair = await MyCircuit.generateKeypair();

Returns

Promise<Keypair>

Defined in

lib/circuit.ts:23


prove

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

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

Example

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

Parameters

NameType
privateInputany[]
publicInputany[]
keypairKeypair

Returns

Promise<Proof>

Defined in

lib/circuit.ts:42


verify

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

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

Example

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

Parameters

NameType
publicInputany[]
verificationKeyVerificationKey
proofProof

Returns

Promise<boolean>

Defined in

lib/circuit.ts:68