@proto-kit/library • Docs
Documentation / @proto-kit/library / UInt224
Class: UInt224
UInt is a base class for all soft-failing UInt* implementations. It has to be overridden for every bitlength that should be available.
For this, the developer has to create a subclass of UInt implementing the static methods from interface UIntConstructor
Extends
UInt<224>
Constructors
new UInt224()
new UInt224(
value):UInt224
Parameters
• value
• value.value: Field
Returns
Inherited from
Defined in
packages/library/src/math/UInt.ts:72
Properties
value
value:
Field=Field
Inherited from
Defined in
packages/library/src/math/UInt.ts:45
_isStruct
static_isStruct:true
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/struct.d.ts:104
assertionFunction()
readonlystaticassertionFunction: (bool,msg?) =>void
Parameters
• bool: Bool
• msg?: string
Returns
void
Inherited from
Defined in
packages/library/src/math/UInt.ts:47
empty()
staticempty: () =>object
Returns
object
value
value:
Field=Field
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/struct.d.ts:113
fromFields()
staticfromFields: (fields) =>object
Parameters
• fields: Field[]
Returns
object
value
value:
Field=Field
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:95
fromJSON()
staticfromJSON: (x) =>object
Parameters
• x
• x.value: string = Field
Returns
object
value
value:
Field=Field
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/struct.d.ts:112
fromValue
staticfromValue: (x) =>object& (value) =>object
Convert provable type from a normal JS type.
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:68
Safe
staticSafe:object
fromField()
Parameters
• value: Field
Returns
Defined in
packages/library/src/math/UInt224.ts:12
toAuxiliary()
statictoAuxiliary: (value?) =>any[]
A function that takes value (optional), an element of type T, as argument and
returns an array of any type that make up the “auxiliary” (non-provable) data of value.
Parameters
• value?
the element of type T to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
• value.value?: Field = Field
Returns
any[]
An array of any type describing how this T element is made up of “auxiliary” (non-provable) data.
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:34
toCanonical()?
staticoptionaltoCanonical: (x) =>object
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical() converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical() is not present on a type.
Parameters
• x
• x.value: Field = Field
Returns
object
value
value:
Field=Field
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:85
toFields()
statictoFields: (value) =>Field[]
A function that takes value, an element of type T, as argument and returns
an array of Field elements that make up the provable data of value.
Parameters
• value
the element of type T to generate the Field array from.
• value.value: Field = Field
Returns
Field[]
A Field array describing how this T element is made up of Field elements.
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:24
toInput()
statictoInput: (x) =>object
Parameters
• x
• x.value: Field = Field
Returns
object
fields?
optionalfields:Field[]
packed?
optionalpacked: [Field,number][]
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/struct.d.ts:107
toJSON()
statictoJSON: (x) =>object
Parameters
• x
• x.value: Field = Field
Returns
object
value
value:
string=Field
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/struct.d.ts:111
toValue()
statictoValue: (x) =>object
Convert provable type to a normal JS type.
Parameters
• x
• x.value: Field = Field
Returns
object
value
value:
bigint=Field
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:64
Unsafe
staticUnsafe:object
fromField()
Parameters
• value: Field
Returns
Defined in
packages/library/src/math/UInt224.ts:6
Accessors
max
Get Signature
get
staticmax():UInt224
Returns
Defined in
packages/library/src/math/UInt224.ts:35
zero
Get Signature
get
staticzero():UInt224
Returns
Defined in
packages/library/src/math/UInt224.ts:31
Methods
add()
add(
y):UInt<224>
Addition with overflow checking.
Parameters
• y: number | bigint | UInt<224>
Returns
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:299
assertEquals()
assertEquals(
y,message?):void
Asserts that a UInt is equal to another one.
Parameters
• y: number | bigint | UInt<224>
• message?: string
Returns
void
Inherited from
Defined in
packages/library/src/math/UInt.ts:411
assertGreaterThan()
assertGreaterThan(
y,message?):void
Asserts that a UInt is greater than another one.
Parameters
• y: UInt<224>
• message?: string
Returns
void
Inherited from
Defined in
packages/library/src/math/UInt.ts:383
assertGreaterThanOrEqual()
assertGreaterThanOrEqual(
y,message?):void
Asserts that a UInt is greater than or equal to another one.
Parameters
• y: UInt<224>
• message?: string
Returns
void
Inherited from
Defined in
packages/library/src/math/UInt.ts:397
assertLessThan()
assertLessThan(
y,message?):void
Asserts that a UInt is less than another one.
Parameters
• y: UInt<224>
• message?: string
Returns
void
Inherited from
Defined in
packages/library/src/math/UInt.ts:369
assertLessThanOrEqual()
assertLessThanOrEqual(
y,message?):void
Asserts that a UInt is less than or equal to another one.
Parameters
• y: UInt<224>
• message?: string
Returns
void
Inherited from
Defined in
packages/library/src/math/UInt.ts:339
constructorReference()
constructorReference():
UIntConstructor<224>
Returns
UIntConstructor<224>
Overrides
Defined in
packages/library/src/math/UInt224.ts:39
div()
div(
y):UInt<224>
Integer division.
x.div(y) returns the floor of x / y, that is, the greatest
z such that z * y <= x.
Parameters
• y: number | bigint | UInt<224>
Returns
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:181
divMod()
divMod(
divisor):object
Integer division with remainder.
x.divMod(y) returns the quotient and the remainder.
Parameters
• divisor: string | number | bigint | UInt<224>
Returns
object
quotient
quotient:
UInt<224>
rest
rest:
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:120
equals()
equals(
y):Bool
Checks if a UInt is equal to another one.
Parameters
• y: number | bigint | UInt<224>
Returns
Bool
Inherited from
Defined in
packages/library/src/math/UInt.ts:404
greaterThan()
greaterThan(
y):Bool
Checks if a UInt is greater than another one.
Parameters
• y: UInt<224>
Returns
Bool
Inherited from
Defined in
packages/library/src/math/UInt.ts:376
greaterThanOrEqual()
greaterThanOrEqual(
y):Bool
Checks if a UInt is greater than or equal to another one.
Parameters
• y: UInt<224>
Returns
Bool
Inherited from
Defined in
packages/library/src/math/UInt.ts:390
lessThan()
lessThan(
y):Bool
Checks if a UInt is less than another one.
Parameters
• y: UInt<224>
Returns
Bool
Inherited from
Defined in
packages/library/src/math/UInt.ts:362
lessThanOrEqual()
lessThanOrEqual(
y):Bool
Checks if a UInt is less than or equal to another one.
Parameters
• y: UInt<224>
Returns
Bool
Inherited from
Defined in
packages/library/src/math/UInt.ts:323
mod()
mod(
y):UInt<224>
Integer remainder.
x.mod(y) returns the value z such that 0 <= z < y and
x - z is divisble by y.
Parameters
• y: number | bigint | UInt<224>
Returns
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:273
mul()
mul(
y):UInt<224>
Multiplication with overflow checking.
Parameters
• y: number | bigint | UInt<224>
Returns
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:280
numBits()
numBits():
224
Returns
224
Overrides
Defined in
packages/library/src/math/UInt224.ts:43
sqrtFloor()
sqrtFloor():
UInt<224>
Wraps sqrtMod() by only returning the sqrt and omitting the rest field.
Returns
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:263
sqrtMod()
sqrtMod():
object
Implements a non-overflowing square-root with rest. Normal Field.sqrt() provides the sqrt as it is defined by the finite field operations. This implementation however mimics the natural-numbers style of sqrt to be used inside applications with the tradeoff that it also returns a “rest” that indicates the amount the actual result is off (since we floor the result to stay inside the ff).
Some assertions are hard-failing, because they represent malicious witness values
Returns
object
sqrt: The non-overflowing sqrt
rest: The remainder indicating how far off the result is from the “real” sqrt
rest
rest:
UInt<224>
sqrt
sqrt:
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:200
sub()
sub(
y):UInt<224>
Subtraction with underflow checking.
Parameters
• y: number | bigint | UInt<224>
Returns
UInt<224>
Inherited from
Defined in
packages/library/src/math/UInt.ts:311
toBigInt()
toBigInt():
bigint
Turns the UInt into a BigInt.
Returns
bigint
Inherited from
Defined in
packages/library/src/math/UInt.ts:111
toO1UInt64()
toO1UInt64():
UInt64
Turns the UInt into a o1js UInt64, asserting that it fits in 32 bits.
Returns
UInt64
Inherited from
Defined in
packages/library/src/math/UInt.ts:418
toO1UInt64Clamped()
toO1UInt64Clamped():
UInt64
Turns the UInt into a o1js UInt64, clamping to the 64 bits range if it’s too large.
Returns
UInt64
Inherited from
Defined in
packages/library/src/math/UInt.ts:428
toString()
toString():
string
Turns the UInt into a string.
Returns
string
Inherited from
Defined in
packages/library/src/math/UInt.ts:103
check()
staticcheck(x):void
Add assertions to the proof to check if value is a valid member of type T.
This function does not return anything, instead it creates any number of assertions to prove that value is a valid member of the type T.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Parameters
• x
• x.value: Field
Returns
void
Overrides
UInt.check
Defined in
packages/library/src/math/UInt224.ts:20
checkConstant()
staticcheckConstant(x,numBits):Field
Parameters
• x: Field
• numBits: number
Returns
Field
Inherited from
Defined in
packages/library/src/math/UInt.ts:52
from()
staticfrom(x):UInt224
Parameters
• x: string | number | bigint | UInt<224>
Returns
Defined in
packages/library/src/math/UInt224.ts:24
maxIntField()
staticmaxIntField(numBits):Field
Creates a UInt with a value of 18,446,744,073,709,551,615.
Parameters
• numBits: number
Returns
Field
Inherited from
Defined in
packages/library/src/math/UInt.ts:68
sizeInFields()
staticsizeInFields():number
Return the size of the T type in terms of Field type, as Field is the primitive type.
Returns
number
A number representing the size of the T type in terms of Field type.
Inherited from
Defined in
node_modules/o1js/dist/node/lib/provable/types/provable-intf.d.ts:51