privateHash()

Othent JS SDK privateHash() function

The privateHash() function allows you to create deterministic secrets (hashes) from some data.

This function assumes (and requires) a user is authenticated. See requireAuth().

API

privateHash(
  data: string | BinaryDataType,
  options?: SignMessageOptions,
): Promise<Uint8Array>;

data: string | BinaryDataType

The data to hash.

options?: SignMessageOptions

The options argument is optional. If it is not provided, the extension will use the SHA-256 hash algorithm.

interface SignMessageOptions {
  hashAlgorithm?: "SHA-256" | "SHA-384" | "SHA-512";
}

return Promise<Uint8Array>

A Promise containing a Uint8Array with the hashed data.

Example usage

import { Othent } from "@othent/kms";

const othent = new Othent({ appInfo, throwErrors: false, ... });

// Make sure the user is authenticated, or prompt them to authenticate:
await othent.requireAuth();

// Data to be hashed:
const data = "The hash of this msg will be signed.";

// create the hash using the active wallet
const hash = await othent.privateHash(
    data,
    { hashAlgorithm: "SHA-256" }
);


console.log(`The hash is "${ hash }".`);

Last updated