ForeignField
Constructors
new ForeignField()
new ForeignField(x:
| string
| number
| bigint
| Field3
| ForeignField): ForeignField
Create a new ForeignField from a bigint, number, string or another ForeignField.
Parameters
• x:
| string
| number
| bigint
| Field3
| ForeignField
Returns
Example
let x = new ForeignField(5);
Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants.
- When constructing from another ForeignField instance, ensure the modulus matches. If not, check the modulus using
Gadgets.ForeignField.assertLessThan()and handle appropriately. - When constructing from a Field3 array, ensure all elements are valid Field elements and range checked.
- Ensure constants are correctly reduced to the modulus of the field.
Source
lib/provable/foreign-field.ts:101
Properties
value
value: Field3;
The internal representation of a foreign field element, as a tuple of 3 limbs.
Source
lib/provable/foreign-field.ts:49
_Bigint
static _Bigint: undefined | {} = undefined;
Source
lib/provable/foreign-field.ts:27
_modulus
static _modulus: undefined | bigint = undefined;
Source
lib/provable/foreign-field.ts:28
_provable
static _provable: any = undefined;
Source
lib/provable/foreign-field.ts:414
_variants
static _variants: undefined | {
"almostReduced": typeof AlmostForeignField;
"canonical": typeof CanonicalForeignField;
"unreduced": typeof UnreducedForeignField;
} = undefined;
Sibling classes that represent different ranges of field elements.
Source
lib/provable/foreign-field.ts:58
Accessors
Constructor
get Constructor(): typeof ForeignField
Returns
typeof ForeignField
Source
lib/provable/foreign-field.ts:51
modulus
get modulus(): bigint
Returns
bigint
Source
lib/provable/foreign-field.ts:39
AlmostReduced
get static AlmostReduced(): typeof AlmostForeignField
Constructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))).
Returns
typeof AlmostForeignField
Source
lib/provable/foreign-field.ts:76
Bigint
get static Bigint(): {}
Returns
{}
Source
lib/provable/foreign-field.ts:31
Canonical
get static Canonical(): typeof CanonicalForeignField
Constructor for field elements that are fully reduced, i.e. lie in the range [0, p).
Returns
typeof CanonicalForeignField
Source
lib/provable/foreign-field.ts:83
Unreduced
get static Unreduced(): typeof UnreducedForeignField
Constructor for unreduced field elements.
Returns
typeof UnreducedForeignField
Source
lib/provable/foreign-field.ts:69
modulus
get static modulus(): bigint