Function createDiscriminant

  • Create a discriminant from a seed and bit length.

    The discriminant is guaranteed to be a negative prime number that fits in length bits, except with negligible probability (less than 2^-100). It is also guaranteed to equal 7 modulo 8.

    This function uses SHA-256 to expand the seed. Different seeds will result in completely different discriminants with overwhelming probability. The function is deterministic: identical seeds and lengths always produce the same discriminant.

    Parameters

    • seed: Uint8Array

      The seed bytes to generate from

    • length: number

      The bit length of the discriminant

    Returns bigint

    A negative prime discriminant