Function verifySignature

    • Verifies a signature asynchronously using Ed25519 cryptography.

      Parameters

      • message: Uint8Array

        The original message that was signed

      • signature: Uint8Array

        The 64-byte signature to verify

      • publicKey: Uint8Array

        The 32-byte public key used for verification

      Returns Promise<boolean>

      A promise that resolves to true if the signature is valid, false otherwise

      This function verifies that a signature was created by the holder of the private key corresponding to the given public key. It ensures message authenticity and integrity.

      Returns true if the signature is valid, false otherwise. This function never throws on invalid signatures - it returns false instead, making it safe to use in validation logic.

      const message = new TextEncoder().encode('Hello, Klever!')
      const signatureBytes = new Uint8Array(64) // Signature from signMessage
      const publicKeyBytes = new Uint8Array(32) // Public key

      const isValid = await verifySignature(message, signatureBytes, publicKeyBytes)

      if (isValid) {
      console.log('Signature is valid!')
      } else {
      console.log('Invalid signature')
      }