Verify the authenticity of signed messages and typed data to ensure they originated from the expected address.

Prerequisites

You need Web3 libraries configured with Para authentication.

Setup Web3 Libraries

Verify Personal Signatures

import { ethers } from "ethers";

async function verifyPersonalSignature(
  message: string,
  signature: string,
  signerAddress: string
) {
  const recoveredAddress = ethers.verifyMessage(message, signature);
  const isValid = recoveredAddress.toLowerCase() === signerAddress.toLowerCase();
  console.log("Signature valid:", isValid);
  return isValid;
}

Verify Typed Data Signatures (EIP-712)

import { ethers } from "ethers";

async function verifyTypedDataSignature(
  domain: any,
  types: any,
  value: any,
  signature: string,
  signerAddress: string
) {
  const recoveredAddress = ethers.verifyTypedData(domain, types, value, signature);
  const isValid = recoveredAddress.toLowerCase() === signerAddress.toLowerCase();
  console.log("Signature valid:", isValid);
  return isValid;
}

Next Steps