Class CryptoUtils

Provide utilities to due with cryptography

Hierarchy

  • CryptoUtils

Constructors

Methods

  • It hashes the input using the blake2b algorithm.

    Parameters

    • x: Uint8Array

      The input to the hash function.

    • Optional length: number = 32

      The length of the output hash in bytes.

    Returns Uint8Array

    The hash of the input.

  • It uses the HMAC function to generate a key and chain code.

    Parameters

    • data: Hex

      The data to be hashed.

    • key: Hex

      The private key.

    Returns {
        chainCode: Uint8Array;
        key: Uint8Array;
    }

    an object with two properties: key and chainCode.

    • chainCode: Uint8Array
    • key: Uint8Array
  • Given a byte array, return the hash160 of the sha256 of the byte array

    Parameters

    • data: Hex

      The data to be hashed.

    Returns Uint8Array

    The hash160 of the input data.

  • It hashes the data using the SHA-256 algorithm.

    Parameters

    • data: Hex

      The data to be hashed.

    Returns Uint8Array

    The hash256 function returns a hash256 value.

  • It hashes the password using the PBKDF2 algorithm.

    Parameters

    • password: Uint8Array

      The password to use for the key derivation.

    • salt: Uint8Array

      A salt to use for the key derivation function (salt's length must be from 16).

    • iterations: number

      The number of iterations to perform (must be from 120k).

    • keySize: number

      The size of the derived key in bytes (must be from 16).

    Returns Uint8Array

    The PBKDF2 function returns a Uint8Array.

  • Generate a random array of bytes of the given length

    Parameters

    • len: number

      the length of the random bytes to generate.

    Returns Uint8Array

    A random Uint8Array of length len.

  • Create a strong private key from any input, where the key is longer and more secure.

    Parameters

    • input: string
    • salt: Uint8Array

    Returns Uint8Array

Generated using TypeDoc