Skip to main content

Class: Scalar

Represents a Scalar.

Table of contents

Constructors

Methods

Constructors

constructor

new Scalar()

Methods

add

add(y): Scalar

Add scalar field elements. Can only be called outside of circuit execution

Parameters

NameType
yScalar

Returns

Scalar

Defined in

snarky.d.ts:774


div

div(y): Scalar

Divide scalar field elements. Can only be called outside of circuit execution

Parameters

NameType
yScalar

Returns

Scalar

Defined in

snarky.d.ts:792


mul

mul(y): Scalar

Multiply scalar field elements. Can only be called outside of circuit execution

Parameters

NameType
yScalar

Returns

Scalar

Defined in

snarky.d.ts:786


neg

neg(): Scalar

Negate a scalar field element. Can only be called outside of circuit execution

Returns

Scalar

Defined in

snarky.d.ts:768


sub

sub(y): Scalar

Subtract scalar field elements. Can only be called outside of circuit execution

Parameters

NameType
yScalar

Returns

Scalar

Defined in

snarky.d.ts:780


toFields

toFields(this): Field[]

Parameters

NameType
thisScalar

Returns

Field[]

Defined in

snarky.d.ts:762


toJSON

toJSON(): string

Returns

string

Defined in

snarky.d.ts:794


check

Static check(x): void

Parameters

NameType
xScalar

Returns

void

Defined in

snarky.d.ts:831


fromBits

Static fromBits(bits): Scalar

Creates a data structure from an array of serialized Bool.

Parameters

NameType
bitsBool[]

Returns

Scalar

Defined in

snarky.d.ts:815


fromFields

Static fromFields(fields): Scalar

Creates a data structure from an array of serialized Field elements.

Parameters

NameType
fieldsField[]

Returns

Scalar

Defined in

snarky.d.ts:807


fromJSON

Static fromJSON(x): Scalar

Deserialize a JSON structure into a Scalar. This operation does NOT affect the circuit and can't be used to prove anything about the string representation of the Field.

Parameters

NameType
xstring | number | boolean

Returns

Scalar

Defined in

snarky.d.ts:830


random

Static random(): Scalar

Returns a random Scalar. Randomness can not be proven inside a circuit!

Returns

Scalar

Defined in

snarky.d.ts:820


sizeInFields

Static sizeInFields(): number

Returns the size of this type.

Returns

number

Defined in

snarky.d.ts:811


toAuxiliary

Static toAuxiliary(x?): []

Static method to serialize a Scalar into its auxiliary data.

Parameters

NameType
x?Scalar

Returns

[]

Defined in

snarky.d.ts:803


toFields

Static toFields(x): Field[]

Static method to serialize a Scalar into an array of Field elements.

Parameters

NameType
xScalar

Returns

Field[]

Defined in

snarky.d.ts:799


toJSON

Static toJSON(x): string

Serialize a Scalar to a JSON string. This operation does NOT affect the circuit and can't be used to prove anything about the string representation of the Field.

Parameters

NameType
xScalar

Returns

string

Defined in

snarky.d.ts:825