Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "constant-time/constant-time"

NOTE! Due to the inability to guarantee real constant time evaluation of anything in JavaScript VM, this is module is the best effort.

Index

Functions

compare

  • compare(a: Uint8Array, b: Uint8Array): number
  • Returns 1 if a and b are of equal length and their contents are equal, or 0 otherwise.

    Note that unlike in equal(), zero-length inputs are considered the same, so this function will return 1.

    Parameters

    • a: Uint8Array
    • b: Uint8Array

    Returns number

equal

  • equal(a: Uint8Array, b: Uint8Array): boolean
  • Returns true if a and b are of equal non-zero length, and their contents are equal, or false otherwise.

    Note that unlike in compare() zero-length inputs are considered not equal, so this function will return false.

    Parameters

    • a: Uint8Array
    • b: Uint8Array

    Returns boolean

lessOrEqual

  • lessOrEqual(a: number, b: number): number
  • Returns 1 if a <= b, or 0 if not. Arguments must be positive 32-bit integers less than or equal to 2^31 - 1.

    Parameters

    • a: number
    • b: number

    Returns number

select

  • select(subject: number, resultIfOne: number, resultIfZero: number): number
  • Returns resultIfOne if subject is 1, or resultIfZero if subject is 0.

    Supports only 32-bit integers, so resultIfOne or resultIfZero are not integers, they'll be converted to them with bitwise operations.

    Parameters

    • subject: number
    • resultIfOne: number
    • resultIfZero: number

    Returns number

Generated using TypeDoc