Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GroupContext

A GroupContext wraps up a lot of state for managing elements of the cryptographic groups that we use in ElectionGuard. It also allows us to manage and differentiate between incompatible groups (e.g., 3072-bits versus 4096-bits).

While the GroupContext defines a bunch of methods for things like adding and multiplying members of a group, external code shouldn't use those methods. Instead, use the top-level functions defined by group-common.ts at the bottom of the file. Every Element knows its internal context, so for the most part, you can just call functions like addQ() and all the compatibility checks and context management will be handled inside.

You will need the GroupContext for the various "create" methods that allow you to go from external strings or numbers into Elements. You'll also see that the GroupContext is necessary in a few other places, like the property-based testing value generators.

Hierarchy

  • GroupContext

Index

Properties

G: bigint
G_INVERSE_MOD_P: ElementModP
G_MOD_P: ElementModP
G_SQUARED_MOD_P: ElementModP
ONE_MOD_P: ElementModP
ONE_MOD_Q: ElementModQ
P: bigint
Q: bigint
TWO_MOD_P: ElementModP
TWO_MOD_Q: ElementModQ
ZERO_MOD_P: ElementModP
ZERO_MOD_Q: ElementModQ
electionConstants: ElectionConstants
name: string

Textual description of the group (e.g., "BigInt-4096 GroupContext", or "HACL-WASM-3072 GroupContext").

Methods

  • createElementModP(value: string | number | bigint): undefined | ElementModP
  • Creates a new ElementModP from a bigint, a string (base 10), or a number. Returns undefined if the input is not well-formed or is out of the desired range of [0, P).

    Parameters

    • value: string | number | bigint

    Returns undefined | ElementModP

  • createElementModPFromHex(value: string): undefined | ElementModP
  • createElementModPSafe(value: string | number | bigint): ElementModP
  • Creates a new ElementModP from a bigint, a string (base 10 or prefixed with "0x" for base16), or a number. If the number is out of range, it will be wrapped (in an undefined manner) to [0, P).

    Parameters

    • value: string | number | bigint

    Returns ElementModP

  • createElementModQ(value: string | number | bigint): undefined | ElementModQ
  • Creates a new ElementModQ from a bigint, a string (base 10, or a number. Returns undefined if the input is not well-formed or is out of the desired range of [0, Q).

    Parameters

    • value: string | number | bigint

    Returns undefined | ElementModQ

  • createElementModQFromHex(value: string): undefined | ElementModQ
  • createElementModQSafe(value: string | number | bigint, minimum?: number): ElementModQ
  • Creates a new ElementModQ from a bigint, a string (base 10), or a number. If the number is out of range, it will be wrapped to [minimum, Q). If the input isn't a well-defined number, the result will be zero.

    Parameters

    • value: string | number | bigint
    • Optional minimum: number

    Returns ElementModQ

  • Computes the discrete log, in the base of the generator. If it cannot find a solution, it returns undefined.

    Parameters

    Returns undefined | number

Generated using TypeDoc