Textual description of the group (e.g., "BigInt-4096 GroupContext", or "HACL-WASM-3072 GroupContext").
Computes the sum, mod q, of two ElementModQ values.
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).
Creates a new ElementModP from a hexadecimal (base16) string. Assumes no leading '0x'.
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).
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).
Creates a new ElementModQ from a hexadecimal (base16) string. Assumes no leading '0x'.
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.
Computes the discrete log, in the base of the generator. If it cannot find a solution, it returns undefined.
Computes the division (really, multiplication by the modular inverse), mod p, of two ElementModP values.
Computes the division (really, multiplication by the modular inverse), mod q, of two ElementModQ values.
Computes generator^exponent mod p.
Computes the multiplicative inverse, mod p, of an ElementModP.
Computes the multiplicative inverse, mod q, of an ElementModQ.
Computes the product, mod p, of two ElementModP values.
Computes the product, mod q, of two ElementModQ values.
Computes the addtive inverse, mod q, of an ElementModQ.
Computes base^exponent mod p.
Uses a source of secure randomness to derive a fresh ElementModQ.
Computes the subtraction, mod q, of two ElementModQ values.
Generated using TypeDoc
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.