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.
This function assumes (and requires) a user is authenticated. See requireAuth().
API
verifyMessage(
data: string | BinaryDataType,
signature: string | BinaryDataType,
publicKey?: B64UrlString,
options: SignMessageOptions,
): Promise<boolean>;data: string | BinaryDataType
data: string | BinaryDataTypeThe data to verify the signature for.
signature: string | BinaryDataType
signature: string | BinaryDataTypeThe signature to validate.
publicKey?: B64UrlString
publicKey?: B64UrlStringThe 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
options: SignMessageOptionsThe options argument is optional. If it is not provided, the extension will use the SHA-256 hash algorithm.
return Promise<boolean>
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.
The wallet's public key.
Below is the JavaScript (TypeScript) example implementation with the Web Crypto API, using SHA-256 hashing:
Last updated