BCH (Bose-Chaudhuri-Hocquenghem) Error Correction Code class.

Constructors

  • Initializes the ECC state with given parameters.

    Parameters

    • t: number

      Number of error correctable bits, max number of bit flips we can account for, increasing this increase the ecc length

    • poly: number

      The polynomial used for ECC.

    Returns BCH

Properties

ECCstate: any

Methods

  • Builds a cyclic table for error correction.

    Parameters

    • g: bigint[]

      The generator polynomial.

    Returns void

  • Computes the ceiling of the division of two integers.

    Parameters

    • a: number

      The dividend.

    • b: number

      The divisor.

    Returns number

    The ceiling of the division of a by b.

  • Processes an array of bits in chunks, converting each chunk into a BigInt.

    Parameters

    • bitArray: number[]

      The array of bits to process.

    • chunkSize: number

      The size of each chunk of bits to process.

    Returns bigint[]

    • An array of BigInt values representing chunks of the original bit array.
  • Converts an array of bits into a single BigInt value.

    Parameters

    • bitArray: number[]

      The array of bits to convert.

    • bitLimit: number

      The maximum number of bits to process.

    Returns bigint

    • The combined value of all bits in the array.
  • Converts an array of up to 4 bytes into a single BigInt value.

    Parameters

    • byteArray: bigint[]

      The array of bytes to convert.

    Returns bigint

    • The combined value of the bytes as a BigInt.
  • Decodes the data and corrects errors using ECC.

    Parameters

    • data: number[]

      The input data array.

    • recvecc: number[]

      The received ECC data.

    Returns any

    • The corrected data and status.
  • Computes the degree of a polynomial represented as an integer.

    Parameters

    • x: number

      The polynomial represented as an integer.

    Returns number

    The degree of the polynomial.

  • Computes the degree of a polynomial represented as a BigInt.

    Parameters

    • x: bigint

      The polynomial represented as a BigInt.

    Returns number

    The degree of the polynomial.

  • Encodes the data and generates ECC bytes.

    Parameters

    • data: number[]

      The input data array.

    Returns Uint8Array

    • The generated ECC bytes.
  • Divides two values in a Galois field.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • a: number

      The dividend.

    • b: number

      The divisor.

    Returns number

    The quotient of the division in the Galois field.

  • Computes the logarithm of a value in a Galois field.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • x: number

      The value whose logarithm is to be computed.

    Returns number

    The logarithm of the value in the Galois field.

  • Multiplies two values in a Galois field.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • a: number

      The first value to be multiplied.

    • b: number

      The second value to be multiplied.

    Returns number

    The product of the two values in the Galois field.

  • Computes the power of a value in a Galois field.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • i: number

      The exponent value.

    Returns number

    The result of raising a value to the power i in the Galois field.

  • Computes the square root of a value in a Galois field.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • a: number

      The value whose square root is to be computed.

    Returns number

    The square root of the value in the Galois field.

  • Gets the number of ECC bits.

    Returns number

    • The number of ECC bits.
  • Gets the number of ECC bytes.

    Returns number

    • The number of ECC bytes.
  • Finds the roots of a polynomial.

    Parameters

    • instance: any

      The instance of the ECC state.

    • k: number

      The degree of the polynomial.

    • poly: any

      The polynomial.

    Returns number

    • The number of roots found.
  • Reduces a value modulo the Galois field size.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • v: number

      The value to be reduced.

    Returns number

    The value reduced modulo the Galois field size.

  • Reduces a value modulo the Galois field size.

    Parameters

    • instance: any

      The current context containing Galois field parameters.

    • v: number

      The value to be reduced.

    Returns number

    The value reduced modulo the Galois field size.

  • Converts a number to a binary string of a given length.

    Parameters

    • num: number

      The number to convert.

    • length: number

      The desired length of the binary string.

    Returns string

    • The binary string representation of the number.
  • Decodes a Uint8Array to a string using 7-bit ASCII encoding.

    Parameters

    • data: any[]

      The input byte array.

    Returns string

    • The decoded string.
  • Generates a binary string from data.

    Parameters

    • dataout: any[]

      The data output array.

    • datalen: number

      The desired length of the binary string.

    Returns string

    • The binary string representation of the data.
  • Converts an array of numbers to a hexadecimal string.

    Parameters

    • data: any[]

      The array of numbers to convert.

    • datalen: number

    Returns string

    • The hexadecimal string representation of the numbers.