signMessage()

Othent JS SDK signMessage() function

The signMessage() function creates a cryptographic signature of any data (after hashing it) for later validation, using the active (authenticated) user's private key.

Tip: This function's implementation is compatible with ArConnect's signMessage() and verifyMessage()'s.

Tip: The function first hashes the input data for security reasons. We recommend using the built in verifyMessage() function to validate the signature, or hashing the data the same way, before validation (example).

API

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

data: string | BinaryDataType

The data to generate the signature for.

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 an Uint8Array with the signed hash of the data, which can be verified with Othent.verifyMessage.

Example usage

Last updated