Class Field

Hierarchy

  • Field

Constructors

  • Coerces anything field-like to a Field.

    Parameters

    • x: string | number | bigint | boolean | Field

    Returns Field

Properties

ORDER: bigint

The field order as a bigint.

minusOne: Field

Deprecated

Static constant values on Field are deprecated in favor of using the constructor Field(-1).

The number -1 as a [[Field]].

one: Field

Deprecated

Static constant values on Field are deprecated in favor of using the constructor Field(1).

The number 1 as a [[Field]].

zero: Field

Deprecated

Static constant values on Field are deprecated in favor of using the constructor Field(0).

The number 0 as a [[Field]].

Methods

  • Adds this Field element to another to a Field element.

    let a = Field(3);
    let sum = a.add(5)

    Parameters

    • y: string | number | boolean | Field

    Returns Field

  • Assert that this Field is either 0 or 1.

    Field(0).assertBool();
    

    Parameters

    • Optional message: string

    Returns void

  • Deprecated

    Deprecated - use assertBool instead

    Assert that this Field is either 0 or 1.

    Field(0).assertBoolean();
    

    Parameters

    • Optional message: string

    Returns void

  • Assert that this Field equals another Field-like value. Throws an error if the assertion fails.

    Field(1).assertEquals(1);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Assert that this Field is greater than another Field-like value.

    Field(1).assertGt(0);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Assert that this Field is greater than or equal to another Field-like value.

    Field(1).assertGte(0);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Deprecated

    Deprecated - use assertGreaterThan instead

    Assert that this Field is greater than another Field-like value.

    Field(1).assertGt(0);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Deprecated

    Deprecated - use assertGreaterThanOrEqual instead

    Assert that this Field is greater than or equal to another Field-like value.

    Field(1).assertGte(0);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Assert that this Field is lower than another Field-like value.

    Field(1).assertLessThan(2);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Assert that this Field is lower than or equal to another Field-like value.

    Field(1).assertLessThanOrEqual(2);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Deprecated

    Deprecated - use assertLessThan instead

    Assert that this Field is lower than another Field-like value.

    Field(1).assertLessThan(2);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Deprecated

    Deprecated - use assertLessThanOrEqualinstead

    Assert that this Field is lower than or equal to another Field-like value.

    Field(1).assertLte(2);
    

    Parameters

    • y: string | number | boolean | Field
    • Optional message: string

    Returns void

  • Divides this Field element through another coercible to a field.

    Parameters

    • y: string | number | boolean | Field

    Returns Field

  • Check if this Field equals another Field-like value. Returns a Bool.

    Field(2).equals(2); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Check if this Field is greater than another Field-like value. Returns a Bool.

    Field(2).greaterThan(1); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Check if this Field is greater than or equal to another Field-like value. Returns a Bool.

    Field(2).greaterThanOrEqual(1); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Deprecated

    Deprecated - use {@link greaterThan} instead

    Check if this Field is greater than another Field-like value. Returns a Bool.

    Field(2).gt(1); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Deprecated

    Deprecated - use greaterThanOrEqual instead

    Check if this Field is greater than or equal to another Field-like value. Returns a Bool.

    Field(2).gte(1); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Inverts this Field element.

    const invX = x.inv();
    invX.assertEquals(Field(1).div(x));

    Returns

    A Field element that is equivalent to one divided by this element.

    Returns Field

  • Checks whether this is a hard-coded constant in the Circuit.

    Returns boolean

  • Check if this Field is lower than another Field-like value. Returns a Bool.

    Field(2).lessThan(3); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Check if this Field is lower than or equal to another Field-like value. Returns a Bool.

    Field(2).lessThanOrEqual(3); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Deprecated

    Deprecated - use lessThan instead

    Check if this Field is lower than another Field-like value. Returns a Bool.

    Field(2).lt(3); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Deprecated

    Deprecated - use lessThanOrEqual instead

    Check if this Field is lower than or equal to another Field-like value. Returns a Bool.

    Field(2).lte(3); // Bool(true)
    

    Parameters

    • y: string | number | boolean | Field

    Returns Bool

  • Multiplies this Field element with another coercible to a field.

    Parameters

    • y: string | number | boolean | Field

    Returns Field

  • Negates this Field. This is equivalent to multiplying the Field by -1.

    const negOne = Field(1).neg();
    negOne.assertEquals(-1);

    Returns Field

  • Returns the size of this type.

    Returns number

  • Serialize this instance of a Field to a bigint. This operation does NOT affect the circuit and can't be used to prove anything about the bigint representation of the Field.

    Returns bigint

  • Little endian binary representation of the field element.

    Returns Bool[]

  • Little endian binary representation of the field element. Fails if the field element cannot fit in length bits.

    Parameters

    • length: number

    Returns Bool[]

  • Serialize this instance of a Field to a JSON string. This operation does NOT affect the circuit and can't be used to prove anything about the string representation of the Field.

    Returns string

  • Serialize the Field to a string, e.g. for printing. This operation does NOT affect the circuit and can't be used to prove anything about the string representation of the Field.

    Returns string

  • Converts a bit array into a field element (little endian) Fails if the field element cannot fit given too many bits.

    Parameters

    • x: (boolean | Bool)[]

    Returns Field

  • Deserialize a JSON structure into a Field. This operation does NOT affect the circuit and can't be used to prove anything about the string representation of the Field.

    Parameters

    • x: string

    Returns Field

  • Parameters

    • bytes: number[]
    • offset: number

    Returns [value: Field, offset: number]

  • Returns the size of this type.

    Returns number

  • Static method to serialize a Field into its auxiliary data.

    Parameters

    Returns []

  • Serialize a Field to a JSON string. This operation does NOT affect the circuit and can't be used to prove anything about the string representation of the Field.

    Parameters

    Returns string

Generated using TypeDoc