Class: Circuit
Table of contents
Constructors
Methods
- addConstraint
- array
- asProver
- assertEqual
- constraintSystem
- equal
- generateKeypair
- if
- inCheckedComputation
- inProver
- newVariable
- prove
- runAndCheck
- switch
- toFields
- verify
- witness
Constructors
constructor
• new Circuit()
Methods
addConstraint
▸ Static
addConstraint(this
, kind
, x
, y
, z
): void
Parameters
Name | Type |
---|---|
this | Circuit |
kind | "multiply" |
x | Field |
y | Field |
z | Field |
Returns
void
Defined in
▸ Static
addConstraint(this
, kind
, x
, y
, z
): void
Parameters
Name | Type |
---|---|
this | Circuit |
kind | "add" |
x | Field |
y | Field |
z | Field |
Returns
void
Defined in
▸ Static
addConstraint(this
, kind
, x
, y
, z
): void
Parameters
Name | Type |
---|---|
this | Circuit |
kind | "equal" |
x | Field |
y | Field |
z | Field |
Returns
void
Defined in
▸ Static
addConstraint(this
, kind
, x
, y
, z
): void
Parameters
Name | Type |
---|---|
this | Circuit |
kind | "boolean" |
x | Field |
y | Field |
z | Field |
Returns
void
Defined in
array
▸ Static
array<T
>(elementType
, length
): AsFieldElements
<T
[]>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
elementType | AsFieldElements <T > |
length | number |
Returns
AsFieldElements
<T
[]>
Defined in
asProver
▸ Static
asProver(f
): void
Parameters
Name | Type |
---|---|
f | () => void |
Returns
void
Defined in
assertEqual
▸ Static
assertEqual<T
>(ctor
, x
, y
): void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
ctor | Object |
ctor.toFields | (x : T ) => Field [] |
x | T |
y | T |
Returns
void
Defined in
▸ Static
assertEqual<T
>(x
, y
): void
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
x | T |
y | T |
Returns
void
Defined in
constraintSystem
▸ Static
constraintSystem<T
>(f
): Object
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
f | () => T |
Returns
Object
Name | Type |
---|---|
digest | string |
result | T |
rows | number |
Defined in
equal
▸ Static
equal<T
>(ctor
, x
, y
): Bool
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
ctor | Object |
ctor.toFields | (x : T ) => Field [] |
x | T |
y | T |
Returns
Defined in
▸ Static
equal<T
>(x
, y
): Bool
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
x | T |
y | T |
Returns
Defined in
generateKeypair
▸ Static
generateKeypair(): Keypair
Returns
Defined in
if
▸ Static
if<T
>(b
, ctor
, x
, y
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
b | boolean | Bool |
ctor | AsFieldElements <T > |
x | T |
y | T |
Returns
T
Defined in
▸ Static
if<T
>(b
, x
, y
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
b | boolean | Bool |
x | T |
y | T |
Returns
T
Defined in
inCheckedComputation
▸ Static
inCheckedComputation(): boolean
Returns
boolean
Defined in
inProver
▸ Static
inProver(): boolean
Returns
boolean
Defined in
newVariable
▸ Static
newVariable(f
): Field
Parameters
Name | Type |
---|---|
f | () => string | number | boolean | Field |
Returns
Defined in
prove
▸ Static
prove(privateInput
, publicInput
, kp
): Proof
Parameters
Name | Type |
---|---|
privateInput | any [] |
publicInput | any [] |
kp | Keypair |
Returns
Proof
Defined in
runAndCheck
▸ Static
runAndCheck<T
>(f
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
f | () => T |
Returns
T
Defined in
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 Bool
s 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
Name | Type |
---|---|
T | T |
A | extends AsFieldElements <T , A > |
Parameters
Name | Type |
---|---|
mask | Bool [] |
type | A |
values | T [] |
Returns
T
Defined in
toFields
▸ Static
toFields<A
>(a
): Field
[]
Type parameters
Name |
---|
A |
Parameters
Name | Type |
---|---|
a | A |
Returns
Field
[]
Defined in
verify
▸ Static
verify(publicInput
, vk
, pi
): boolean
Parameters
Name | Type |
---|---|
publicInput | any [] |
vk | VerificationKey |
pi | Proof |
Returns
boolean
Defined in
witness
▸ Static
witness<T
, S
>(ctor
, f
): T
Type parameters
Name | Type |
---|---|
T | T |
S | extends AsFieldElements <T , S > = AsFieldElements <T > |
Parameters
Name | Type |
---|---|
ctor | S |
f | () => T |
Returns
T