Class: Scalar
Represents a Scalar.
Table of contents
Constructors
Methods
- add
- div
- mul
- neg
- sub
- toFields
- toJSON
- check
- fromBits
- fromFields
- fromJSON
- random
- sizeInFields
- toAuxiliary
- toFields
- toJSON
Constructors
constructor
• new Scalar()
Methods
add
▸ add(y
): Scalar
Add scalar field elements. Can only be called outside of circuit execution
Parameters
Name | Type |
---|---|
y | Scalar |
Returns
Defined in
div
▸ div(y
): Scalar
Divide scalar field elements. Can only be called outside of circuit execution
Parameters
Name | Type |
---|---|
y | Scalar |
Returns
Defined in
mul
▸ mul(y
): Scalar
Multiply scalar field elements. Can only be called outside of circuit execution
Parameters
Name | Type |
---|---|
y | Scalar |
Returns
Defined in
neg
▸ neg(): Scalar
Negate a scalar field element. Can only be called outside of circuit execution
Returns
Defined in
sub
▸ sub(y
): Scalar
Subtract scalar field elements. Can only be called outside of circuit execution
Parameters
Name | Type |
---|---|
y | Scalar |
Returns
Defined in
toFields
▸ toFields(this
): Field
[]
Parameters
Name | Type |
---|---|
this | Scalar |
Returns
Field
[]
Defined in
toJSON
▸ toJSON(): string
Returns
string
Defined in
check
▸ Static
check(x
): void
Parameters
Name | Type |
---|---|
x | Scalar |
Returns
void
Defined in
fromBits
▸ Static
fromBits(bits
): Scalar
Creates a data structure from an array of serialized Bool.
Parameters
Name | Type |
---|---|
bits | Bool [] |
Returns
Defined in
fromFields
▸ Static
fromFields(fields
): Scalar
Creates a data structure from an array of serialized Field elements.
Parameters
Name | Type |
---|---|
fields | Field [] |
Returns
Defined in
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
Name | Type |
---|---|
x | string | number | boolean |
Returns
Defined in
random
▸ Static
random(): Scalar
Returns a random Scalar. Randomness can not be proven inside a circuit!
Returns
Defined in
sizeInFields
▸ Static
sizeInFields(): number
Returns the size of this type.
Returns
number
Defined in
toAuxiliary
▸ Static
toAuxiliary(x?
): []
Static method to serialize a Scalar into its auxiliary data.
Parameters
Name | Type |
---|---|
x? | Scalar |
Returns
[]
Defined in
toFields
▸ Static
toFields(x
): Field
[]
Static method to serialize a Scalar into an array of Field elements.
Parameters
Name | Type |
---|---|
x | Scalar |
Returns
Field
[]
Defined in
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
Name | Type |
---|---|
x | Scalar |
Returns
string