Kit
Functions

verifySignature

verifySignature(key, signature, data): Promise<boolean>

Given a public CryptoKey, some SignatureBytes, and a Uint8Array of data, this method will return true if the signature was produced by signing the data using the private key associated with the public key, and false otherwise.

Parameters

ParameterType
keyCryptoKey
signatureSignatureBytes
dataReadonlyUint8Array

Returns

Promise<boolean>

Example

import { verifySignature } from '@solana/keys';
 
const data = new Uint8Array([1, 2, 3]);
if (!(await verifySignature(publicKey, signature, data))) {
    throw new Error('The data were *not* signed by the private key associated with `publicKey`');
}

On this page