Int64
A 64 bit signed integer with values ranging from -18,446,744,073,709,551,615 to 18,446,744,073,709,551,615.
Extends
CircuitValue
Implements
BalanceChange
Constructors
new Int64()
new Int64(magnitude: UInt64, sgn: Sign): Int64
Parameters
• magnitude: UInt64
• sgn: Sign
= Sign.one
Returns
Overrides
CircuitValue.constructor
Source
Properties
magnitude
magnitude: UInt64;
Implementation of
BalanceChange.magnitude
Source
sgn
sgn: Sign;
Implementation of
BalanceChange.sgn
Source
Accessors
minusOne
get static minusOne(): Int64
Static method to create a Int64 with value -1
.
Returns
Source
one
get static one(): Int64
Static method to create a Int64 with value 1
.
Returns
Source
zero
get static zero(): Int64
Static method to create a Int64 with value 0
.
Returns
Source
Methods
add()
add(y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64
Addition with overflow checking.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
Source
assertEquals()
assertEquals(y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64, message?: string): void
Asserts that two values are equal.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
• message?: string
Returns
void
Overrides
CircuitValue.assertEquals
Source
div()
div(y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64
Integer division.
x.div(y)
returns the floor of x / y
, that is, the greatest
z
such that z * y <= x
.
On negative numbers, this rounds towards zero.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
Source
equals()
equals(y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Bool
Checks if two values are equal.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
Overrides
CircuitValue.equals
Source
isConstant()
isConstant(): boolean
Returns
boolean
Overrides
CircuitValue.isConstant
Source
isPositive()
isPositive(): Bool
Returns
Deprecated
Use isPositiveV2 instead. The current implementation actually tests for non-negativity, but is wrong for the negative representation of 0.
Source
isPositiveV2()
isPositiveV2(): Bool
Checks if the value is positive (x > 0).
Returns
Source
mod()
mod(y:
| string
| number
| bigint
| UInt64
| UInt32): Int64
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
Returns
Deprecated
Use () instead.
This implementation is vulnerable whenever this
is zero.
It allows the prover to return y
instead of 0 as the result.
Source
modV2()
modV2(y:
| string
| number
| bigint
| UInt64
| UInt32): Int64
Integer remainder.
x.mod(y)
returns the value z
such that 0 <= z < y
and
x - z
is divisible by y
.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
Returns
Source
mul()
mul(y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64
Multiplication with overflow checking.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
Source
neg()
neg(): Int64
Returns
Deprecated
Use () instead. The current implementation will not be backwards-compatible with v2.
Source
negV2()
negV2(): Int64
Negates the value.
Int64.from(5).neg()
will turn into Int64.from(-5)
Returns
Source
sub()
sub(y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64
Subtraction with underflow checking.
Parameters
• y:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
Source
toConstant()
toConstant(): this
Returns
this
Inherited from
CircuitValue.toConstant
Source
lib/provable/types/circuit-value.ts:122
toField()
toField(): Field
Returns the Field value.
Returns
Source
toFields()
toFields(): Field[]
Returns
Field
[]
Inherited from
CircuitValue.toFields
Source
lib/provable/types/circuit-value.ts:85
toJSON()
toJSON(): any
Returns
any
Inherited from
CircuitValue.toJSON
Source
lib/provable/types/circuit-value.ts:118
toString()
toString(): string
Turns the Int64 into a string.
Returns
string
Source
check()
static check<T>(this: T, v: InstanceType<T>): void
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
void
Inherited from
CircuitValue.check
Source
lib/provable/types/circuit-value.ts:163
checkV2()
static checkV2(__namedParameters: {
"magnitude": UInt64;
"sgn": Sign;
}): void
Checks if the value is negative (x < 0).
Parameters
• __namedParameters
• __namedParameters.magnitude: UInt64
• __namedParameters.sgn: Sign
Returns
void
Source
empty()
static empty<T>(): InstanceType<T>
Type parameters
• T extends AnyConstructor
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.empty
Source
lib/provable/types/circuit-value.ts:218
from()
static from(x:
| string
| number
| bigint
| Field
| UInt64
| UInt32
| Int64): Int64
Creates a new Int64.
Check the range if the argument is a constant.
Parameters
• x:
| string
| number
| bigint
| Field
| UInt64
| UInt32
| Int64
Returns
Source
fromField()
static fromField(x: Field): Int64
Static method to create a Int64 from a Field.
Parameters
• x: Field
Returns
Source
fromFields()
static fromFields<T>(this: T, xs: Field[]): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• xs: Field
[]
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromFields
Source
lib/provable/types/circuit-value.ts:138
fromJSON()
static fromJSON<T>(this: T, value: any): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• value: any
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromJSON
Source
lib/provable/types/circuit-value.ts:196
fromObject()
static fromObject<T>(this: T, value: NonMethods<InstanceType<T>>): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• value: NonMethods
\<InstanceType
\<T
>>
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromObject
Source
lib/provable/types/circuit-value.ts:30
fromUnsigned()
static fromUnsigned(x: UInt64 | UInt32): Int64
Creates a new Int64 from a Field.
Does not check if the Field is within range.
Parameters
Returns
Source
fromValue()
static fromValue<T>(this: T, value: any): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• value: any
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromValue
Source
lib/provable/types/circuit-value.ts:98
sizeInFields()
static sizeInFields(): number
Returns
number
Inherited from
CircuitValue.sizeInFields
Source
lib/provable/types/circuit-value.ts:37
toAuxiliary()
static toAuxiliary(): []
Returns
[]
Inherited from
CircuitValue.toAuxiliary
Source
lib/provable/types/circuit-value.ts:59
toConstant()
static toConstant<T>(this: T, t: InstanceType<T>): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• t: InstanceType
\<T
>
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.toConstant
Source
lib/provable/types/circuit-value.ts:177
toFields()
static toFields<T>(this: T, v: InstanceType<T>): Field[]
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
Field
[]
Inherited from
CircuitValue.toFields
Source
lib/provable/types/circuit-value.ts:42
toInput()
static toInput<T>(this: T, v: InstanceType<T>): HashInput
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
HashInput
Inherited from
CircuitValue.toInput
Source
lib/provable/types/circuit-value.ts:63
toJSON()
static toJSON<T>(this: T, v: InstanceType<T>): any
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
any
Inherited from
CircuitValue.toJSON
Source
lib/provable/types/circuit-value.ts:185
toValue()
static toValue<T>(this: T, v: InstanceType<T>): any
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
any
Inherited from
CircuitValue.toValue