UInt32
A 32 bit unsigned integer with values ranging from 0 to 4,294,967,295.
Extends
CircuitValue
Constructors
new UInt32()
new UInt32(x:
| string
| number
| bigint
| FieldVar
| UInt32): UInt32
Create a UInt32.
The max value of a UInt32 is 2^32 - 1 = UInt32.MAXINT().
Warning: Cannot overflow, an error is thrown if the result is greater than UInt32.MAXINT()
Parameters
• x:
| string
| number
| bigint
| FieldVar
| UInt32
Returns
Overrides
CircuitValue.constructor
Source
Properties
value
value: Field;
Source
NUM_BITS
static NUM_BITS: number = 32;
Source
Unsafe
static Unsafe: {
"fromField": UInt32;
};
fromField()
Create a UInt32 from a Field without constraining its range.
Warning: This is unsafe, because it does not prove that the input Field actually fits in 32 bits.
Only use this if you know what you are doing, otherwise use the safe UInt32.from.
Parameters
• x: Field
Returns
Source
Accessors
one
get static one(): UInt32
Static method to create a UInt32 with value 0.
Returns
Source
zero
get static zero(): UInt32
Static method to create a UInt32 with value 0.
Returns
Source
Methods
add()
add(y: number | UInt32): UInt32
Addition with overflow checking.
Parameters
• y: number | UInt32
Returns
Source
addMod32()
addMod32(y: UInt32): UInt32
Addition modulo 2^32. Check Gadgets.addMod32 for a detailed description.
Parameters
• y: UInt32