CanonicalForeignField
Extends
ForeignFieldWithMul
Constructors
new CanonicalForeignField()
new CanonicalForeignField(x:
| string
| number
| bigint
| Field3
| CanonicalForeignField): CanonicalForeignField
Parameters
• x:
| string
| number
| bigint
| Field3
| CanonicalForeignField
Returns
Overrides
ForeignFieldWithMul.constructor
Source
lib/provable/foreign-field.ts:529
Properties
type
type: "FullyReduced";
Source
lib/provable/foreign-field.ts:527
value
value: Field3;
The internal representation of a foreign field element, as a tuple of 3 limbs.
Inherited from
ForeignFieldWithMul.value
Source
lib/provable/foreign-field.ts:49
_Bigint
static _Bigint: undefined | {} = undefined;
Inherited from
ForeignFieldWithMul._Bigint
Source
lib/provable/foreign-field.ts:27
_modulus
static _modulus: undefined | bigint = undefined;
Inherited from
ForeignFieldWithMul._modulus
Source
lib/provable/foreign-field.ts:28
_provable
static _provable: undefined | ProvablePureExtended<CanonicalForeignField, bigint, string> = undefined;
Overrides
ForeignFieldWithMul._provable
Source
lib/provable/foreign-field.ts:533
_variants
static _variants: undefined | {
"almostReduced": typeof AlmostForeignField;
"canonical": typeof CanonicalForeignField;
"unreduced": typeof UnreducedForeignField;
} = undefined;
Sibling classes that represent different ranges of field elements.
Inherited from
ForeignFieldWithMul._variants
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
Returns
bigint
Source
lib/provable/foreign-field.ts:35
provable
get static provable(): ProvablePureExtended<CanonicalForeignField, bigint, string>
Returns
ProvablePureExtended<CanonicalForeignField, bigint, string>
Source
lib/provable/foreign-field.ts:536
sizeInBits
get static sizeInBits(): number
Returns
number
Source
lib/provable/foreign-field.ts:42
Methods
add()
add(y: number | bigint | ForeignField): UnreducedForeignField
Finite field addition
Parameters
• y: number | bigint | ForeignField
Returns
UnreducedForeignField
Inherited from
ForeignFieldWithMul.add
Example
x.add(2); // x + 2 mod p
Source
lib/provable/foreign-field.ts:218
assertAlmostReduced()
assertAlmostReduced(): AlmostForeignField
Assert that this field element lies in the range [0, 2^k), where k = ceil(log2(p)) and p is the foreign field modulus.
Returns the field element as a AlmostForeignField.
For a more efficient version of this for multiple field elements, see assertAlmostReduced.
Note: this does not ensure that the field elements is in the canonical range [0, p). To assert that stronger property, there is assertCanonical. You should typically use assertAlmostReduced though, because it is cheaper to prove and sufficient for ensuring validity of all our non-native field arithmetic methods.
Returns
Inherited from
ForeignFieldWithMul.assertAlmostReduced
Source
lib/provable/foreign-field.ts:173
assertCanonical()
assertCanonical(): CanonicalForeignField
Assert that this field element is fully reduced, i.e. lies in the range [0, p), where p is the foreign field modulus.
Returns the field element as a CanonicalForeignField.
Returns
Inherited from
ForeignFieldWithMul.assertCanonical
Source
lib/provable/foreign-field.ts:204
assertEquals()
assertEquals(y, message)
assertEquals(y: number | bigint | CanonicalForeignField, message?: string): CanonicalForeignField
Assert equality with a ForeignField-like value
Parameters
• y: number | bigint | CanonicalForeignField
• message?: string
Returns
Inherited from
ForeignFieldWithMul.assertEquals
Example
x.assertEquals(0, "x is zero");
Since asserting equality can also serve as a range check,
this method returns x with the appropriate type:
Example
let xChecked = x.assertEquals(1, "x is 1");
xChecked satisfies CanonicalForeignField;
Source
lib/provable/foreign-field.ts:296
assertEquals(y, message)
assertEquals(y: AlmostForeignField, message?: string): AlmostForeignField
Parameters
• y: AlmostForeignField
• message?: string
Returns
Inherited from
ForeignFieldWithMul.assertEquals