OthentKMS signMessage() function

The signMessage() function creates a cryptographic signature for any data using the connected user’s details.

Example Usage

To use the signMessage() function, import it from the @othent/kms package and call it within an asynchronous function as follows:

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

const handleSignMessage = async () => {
  const data = new TextEncoder().encode(
    "The hash of this msg will be signed.",
  );
  const res = await signMessage(data);
  console.log("Sign Message,\\n", res);
};

The signMessage() function requires a data argument.

<aside> ⚠️ Note: A user must be logged in to an application to successfully encrypt data.

</aside>

Result

On successful execution, the function returns the signature of the data as an Array:

(512) [143, 0, 192, 253, 25, 34, 147, 199, 62, 234, 64, 19, 53, 197, 125, 0, 193, 102, 52, 247, 75, 98, 255, 71, 172, 97, 149, 52, 232, 92, 36, 182, 112, 30, 112, 74, 157, 173, 31, 108, 52, 138, 41, 214, 75, 189, 207, 180, 45, 121, 198, 139, 179, 113, 138, 8, 59, 138, 111, 180, 111, 219, 162, 241, 94, 173, 67, 93, 225, 195, 94, 203, 76, 126, 164, 3, 253, 61, 197, 28, 192, 243, 39, 26, 105, 175, 117, 253, 183, 65, 217, 54, 198, 69, 37, 83, 150, 220, 77, 164, …]

This signature can then be validated using the verifyMessage() function.