verifyMessage()

Othent JS SDK verifyMessage() function

The verifyMessage() function verifies a cryptographic signature created with the signMessage(), either from Othent or from any other wallet such as ArConnect.

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

API

verifyMessage(
  data: string | BinaryDataType,
  signature: string | BinaryDataType,
  publicKey?: B64UrlString,
  options: SignMessageOptions,
): Promise<boolean>;

data: string | BinaryDataType

The data to verify the signature for.

signature: string | BinaryDataType

The signature to validate.

publicKey?: B64UrlString

The publicKey argument is optional. If it is not provided, the extension will use the currently authenticated user's public key. You might only need this if the message to be verified was not made by the authenticated user. In that case, this is the Arweave wallet JWK.n field or transaction owner field.

options: SignMessageOptions

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

return Promise<boolean>

A Promise containing true if the signature was verified successfully, or false otherwise.

Example usage

Verification without Othent

You might encounter situations where you need to verify the signed message against an Othent generated signature, but the SDK is not accessible or not installed (e.g.: third-party apps, server side code, unsupported browser....).

In these cases, it is possible to validate the signature by hashing the message (with the algorithm you used when generating the signature using Othent) and verifying that against the Othent signature. This requires:

  • The message to be verified.

  • The signature.

  • The algorithm used when the message was initially signed.

Below is the JavaScript (TypeScript) example implementation with the Web Crypto API, using SHA-256 hashing:

Last updated