Skip to main content

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

Int64

Overrides

CircuitValue.constructor

Source

lib/provable/int.ts:1051

Properties

magnitude

magnitude: UInt64;

Implementation of

BalanceChange.magnitude

Source

lib/provable/int.ts:1028


sgn

sgn: Sign;

Implementation of

BalanceChange.sgn

Source

lib/provable/int.ts:1029

Accessors

minusOne

get static minusOne(): Int64

Static method to create a Int64 with value -1.

Returns

Int64

Source

lib/provable/int.ts:1126


one

get static one(): Int64

Static method to create a Int64 with value 1.

Returns

Int64

Source

lib/provable/int.ts:1120


zero

get static zero(): Int64

Static method to create a Int64 with value 0.

Returns

Int64

Source

lib/provable/int.ts:1114

Methods

add()

add(y: 
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64

Addition with overflow checking.

Parameters

y: | string | number | bigint | UInt64 | UInt32 | Int64

Returns

Int64

Source

lib/provable/int.ts:1173


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

lib/provable/int.ts:1243


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

Int64

Source

lib/provable/int.ts:1198


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

Bool

Overrides

CircuitValue.equals

Source

lib/provable/int.ts:1236


isConstant()

isConstant(): boolean

Returns

boolean

Overrides

CircuitValue.isConstant

Source

lib/provable/int.ts:1103


isPositive()

isPositive(): Bool

Returns

Bool

Deprecated

Use isPositiveV2 instead. The current implementation actually tests for non-negativity, but is wrong for the negative representation of 0.

Source

lib/provable/int.ts:1254


isPositiveV2()

isPositiveV2(): Bool

Checks if the value is positive (x > 0).

Returns

Bool

Source

lib/provable/int.ts:1261


mod()

mod(y: 
| string
| number
| bigint
| UInt64
| UInt32): Int64

Parameters

y: | string | number | bigint | UInt64 | UInt32

Returns

Int64

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

lib/provable/int.ts:1210


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

Int64

Source

lib/provable/int.ts:1223


mul()

mul(y: 
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64

Multiplication with overflow checking.

Parameters

y: | string | number | bigint | UInt64 | UInt32 | Int64

Returns

Int64

Source

lib/provable/int.ts:1187


neg()

neg(): Int64

Returns

Int64

Deprecated

Use () instead. The current implementation will not be backwards-compatible with v2.

Source

lib/provable/int.ts:1152


negV2()

negV2(): Int64

Negates the value.

Int64.from(5).neg() will turn into Int64.from(-5)

Returns

Int64

Source

lib/provable/int.ts:1162


sub()

sub(y: 
| string
| number
| bigint
| UInt64
| UInt32
| Int64): Int64

Subtraction with underflow checking.

Parameters

y: | string | number | bigint | UInt64 | UInt32 | Int64

Returns

Int64

Source

lib/provable/int.ts:1180


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

Field

Source

lib/provable/int.ts:1133


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

lib/provable/int.ts:1098


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

lib/provable/int.ts:1284


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

Int64

Source

lib/provable/int.ts:1088


fromField()

static fromField(x: Field): Int64

Static method to create a Int64 from a Field.

Parameters

x: Field

Returns

Int64

Source

lib/provable/int.ts:1139


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

x: UInt64 | UInt32

Returns

Int64

Source

lib/provable/int.ts:1078


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

Source

lib/provable/types/circuit-value.ts:89