Skip to main content

Class: Circuit

Table of contents

Constructors

Methods

Constructors

constructor

new Circuit()

Methods

addConstraint

Static addConstraint(this, kind, x, y, z): void

Parameters

NameType
thisCircuit
kind"multiply"
xField
yField
zField

Returns

void

Defined in

snarky.d.ts:492

Static addConstraint(this, kind, x, y, z): void

Parameters

NameType
thisCircuit
kind"add"
xField
yField
zField

Returns

void

Defined in

snarky.d.ts:499

Static addConstraint(this, kind, x, y, z): void

Parameters

NameType
thisCircuit
kind"equal"
xField
yField
zField

Returns

void

Defined in

snarky.d.ts:506

Static addConstraint(this, kind, x, y, z): void

Parameters

NameType
thisCircuit
kind"boolean"
xField
yField
zField

Returns

void

Defined in

snarky.d.ts:513


array

Static array<T>(elementType, length): AsFieldElements<T[]>

Type parameters

Name
T

Parameters

NameType
elementTypeAsFieldElements<T>
lengthnumber

Returns

AsFieldElements<T[]>

Defined in

snarky.d.ts:539


asProver

Static asProver(f): void

Parameters

NameType
f() => void

Returns

void

Defined in

snarky.d.ts:529


assertEqual

Static assertEqual<T>(ctor, x, y): void

Type parameters

Name
T

Parameters

NameType
ctorObject
ctor.toFields(x: T) => Field[]
xT
yT

Returns

void

Defined in

snarky.d.ts:544

Static assertEqual<T>(x, y): void

Type parameters

Name
T

Parameters

NameType
xT
yT

Returns

void

Defined in

snarky.d.ts:546


constraintSystem

Static constraintSystem<T>(f): Object

Type parameters

Name
T

Parameters

NameType
f() => T

Returns

Object

NameType
digeststring
resultT
rowsnumber

Defined in

snarky.d.ts:533


equal

Static equal<T>(ctor, x, y): Bool

Type parameters

Name
T

Parameters

NameType
ctorObject
ctor.toFields(x: T) => Field[]
xT
yT

Returns

Bool

Defined in

snarky.d.ts:548

Static equal<T>(x, y): Bool

Type parameters

Name
T

Parameters

NameType
xT
yT

Returns

Bool

Defined in

snarky.d.ts:550


generateKeypair

Static generateKeypair(): Keypair

Returns

Keypair

Defined in

snarky.d.ts:572


if

Static if<T>(b, ctor, x, y): T

Type parameters

Name
T

Parameters

NameType
bboolean | Bool
ctorAsFieldElements<T>
xT
yT

Returns

T

Defined in

snarky.d.ts:552

Static if<T>(b, x, y): T

Type parameters

Name
T

Parameters

NameType
bboolean | Bool
xT
yT

Returns

T

Defined in

snarky.d.ts:554


inCheckedComputation

Static inCheckedComputation(): boolean

Returns

boolean

Defined in

snarky.d.ts:582


inProver

Static inProver(): boolean

Returns

boolean

Defined in

snarky.d.ts:580


newVariable

Static newVariable(f): Field

Parameters

NameType
f() => string | number | boolean | Field

Returns

Field

Defined in

snarky.d.ts:521


prove

Static prove(privateInput, publicInput, kp): Proof

Parameters

NameType
privateInputany[]
publicInputany[]
kpKeypair

Returns

Proof

Defined in

snarky.d.ts:574


runAndCheck

Static runAndCheck<T>(f): T

Type parameters

Name
T

Parameters

NameType
f() => T

Returns

T

Defined in

snarky.d.ts:531


switch

Static switch<T, A>(mask, type, values): T

Generalization of Circuit.if for choosing between more than two different cases. It takes a "mask", which is an array of Bools that contains only one true element, as well as a type/constructor and an array of values of that type. The result is that value which corresponds to the true element of the mask. Example:

let x = Circuit.switch([Bool(false), Bool(true)], Field, [Field(1), Field(2)]);
x.assertEquals(2);

Type parameters

NameType
TT
Aextends AsFieldElements<T, A>

Parameters

NameType
maskBool[]
typeA
valuesT[]

Returns

T

Defined in

snarky.d.ts:566


toFields

Static toFields<A>(a): Field[]

Type parameters

Name
A

Parameters

NameType
aA

Returns

Field[]

Defined in

snarky.d.ts:578


verify

Static verify(publicInput, vk, pi): boolean

Parameters

NameType
publicInputany[]
vkVerificationKey
piProof

Returns

boolean

Defined in

snarky.d.ts:576


witness

Static witness<T, S>(ctor, f): T

Type parameters

NameType
TT
Sextends AsFieldElements<T, S> = AsFieldElements<T>

Parameters

NameType
ctorS
f() => T

Returns

T

Defined in

snarky.d.ts:524