FROST Ed448 TypeScript Library - v0.2.2-alpha.3
    Preparing search index...

    Interface Field<S, Ser>

    A prime order finite field GF(q) over which all scalar values for our prime order group can be multiplied are defined.

    interface Field<S = unknown, Ser extends Uint8Array = Uint8Array> {
        zero(): S;
        one(): S;
        invert(scalar: S): S;
        random(rng: CryptoRng): S;
        serialize(scalar: S): Ser;
        littleEndianSerialize(scalar: S): Ser;
        deserialize(buf: Ser | Uint8Array<ArrayBufferLike>): S;
        add(a: S, b: S): S;
        sub(a: S, b: S): S;
        mul(a: S, b: S): S;
        negate(scalar: S): S;
        eq(a: S, b: S): boolean;
        isZero(scalar: S): boolean;
    }

    Type Parameters

    • S = unknown

      The scalar type for this field

    • Ser extends Uint8Array = Uint8Array

      The serialization type (fixed-length byte array)

    Index

    Methods

    • Returns the zero element of the field, the additive identity.

      Returns S

    • Returns the one element of the field, the multiplicative identity.

      Returns S

    • Computes the multiplicative inverse of an element of the scalar field, failing if the element is zero.

      Parameters

      • scalar: S

      Returns S

    • Generate a random scalar from the entire space [0, l-1]

      Parameters

      • rng: CryptoRng

      Returns S

    • Serialize a scalar to bytes.

      Parameters

      • scalar: S

      Returns Ser

    • Serialize a scalar to bytes in little-endian order.

      Parameters

      • scalar: S

      Returns Ser

    • Deserialize a scalar from bytes.

      Parameters

      • buf: Ser | Uint8Array<ArrayBufferLike>

      Returns S

    • Add two scalars.

      Parameters

      Returns S

    • Subtract two scalars.

      Parameters

      Returns S

    • Multiply two scalars.

      Parameters

      Returns S

    • Negate a scalar.

      Parameters

      • scalar: S

      Returns S

    • Check if two scalars are equal (constant-time).

      Parameters

      Returns boolean

    • Check if a scalar is zero.

      Parameters

      • scalar: S

      Returns boolean