Options
All
  • Public
  • Public/Protected
  • All
Menu

Module crypto/utils

Index

Functions

firstError

  • firstError(list: (unknown | Error)[]): Error
  • Returns the first error of the list or an empty error, but always an error. This is useful if we have a lot of errors, to get the first of them.

    Parameters

    • list: (unknown | Error)[]

      list of errors

    Returns Error

flatten2D

  • flatten2D<T>(array: T[][]): T[]
  • Flattens a 2D array into a 1D array. We need this custom function as flatMap is not supported yet in ES027

    Type parameters

    • T

    Parameters

    • array: T[][]

    Returns T[]

isError

  • isError(obj: unknown | Error): obj is Error
  • Type predicate that returns whether the object is an error and narrows the type to either an error or the alternative type in a nested code block.

    Parameters

    • obj: unknown | Error

      obj we want to differentiate the type of

    Returns obj is Error

isNull

  • isNull(obj: unknown | null): obj is null
  • Type predicate that returns whether the object is null and narrows the type to either as null or the alternative type in a nested code block.

    Parameters

    • obj: unknown | null

      obj we want to differentiate the type of

    Returns obj is null

removeSpaces

  • removeSpaces(str: string): string
  • Returns the string without any spaces

    Parameters

    • str: string

      input string

    Returns string

strDecToByteArray

  • strDecToByteArray(decLiStr: string | number): Uint8Array
  • Receives a string of a number in decimal base and returns it as a byte array.

    Parameters

    • decLiStr: string | number

      A decimal large integer number either as a string or as a native typescript number.

    Returns Uint8Array

strDecToByteTree

  • strDecToByteTree(decLiStr: string | number): eio.ByteTree | Error
  • Converts a number as a string into a byte tree of the correct size.

    Parameters

    • decLiStr: string | number

      A decimal large integer number either as a string or as a native typescript number

    Returns eio.ByteTree | Error

strDecToHex

  • strDecToHex(decLiStr: string | number): string
  • Receives a string of a number in decimal base and returns it in hexadecimal base, also as a string.

    Parameters

    • decLiStr: string | number

      A decimal large integer number either as a string or as a native typescript number.

    Returns string

strDecToModPGroupElement

  • strDecToModPGroupElement(decLiStr: string | number, modPGroup: arithm.ModPGroup): arithm.ModPGroupElement | Error
  • Converts a number as a string into a ModPGroupElement.

    Parameters

    • decLiStr: string | number

      A decimal large integer number either as a string or as a native typescript number.

    • modPGroup: arithm.ModPGroup

      The multiplicative modular group to be used.

    Returns arithm.ModPGroupElement | Error

strDecToPRingElement

  • strDecToPRingElement(decLiStr: string | number, ring: arithm.PRing): arithm.PRingElement | Error
  • Converts a number as a string into a PRingElement.

    Parameters

    • decLiStr: string | number

      A decimal large integer number either as a string or as a native typescript number.

    • ring: arithm.PRing

      The ring to be used.

    Returns arithm.PRingElement | Error

Generated using TypeDoc