Skip to content

Secp256k1.verify

Verifies a payload was signed by the provided address.

Imports

Named
import { Secp256k1 } from 'ox'

Examples

Verify with Ethereum Address

import { Secp256k1 } from 'ox'
 
const signature = Secp256k1.sign({ payload: '0xdeadbeef', privateKey: '0x...' })
 
const verified = Secp256k1.verify({ 
  address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  payload: '0xdeadbeef', 
  signature, 
})

Verify with Public Key

import { Secp256k1 } from 'ox'
 
const privateKey = '0x...'
const publicKey = Secp256k1.getPublicKey({ privateKey })
const signature = Secp256k1.sign({ payload: '0xdeadbeef', privateKey })
 
const verified = Secp256k1.verify({ 
  publicKey, 
  payload: '0xdeadbeef', 
  signature, 
})

Definition

function verify(
  options: verify.Options,
): boolean

Source: src/core/Secp256k1.ts

Parameters

options

  • Type: verify.Options

The verification options.

options.address

  • Type: abitype_Address

Address that signed the payload.

options.hash

  • Type: boolean
  • Optional

If set to true, the payload will be hashed (sha256) before being verified.

options.payload

  • Type: 0x${string} | Uint8Array

Payload that was signed.

options.publicKey

  • Type: { prefix: number; x: bigint; y: bigint; } | { prefix: number; x: bigint; y?: undefined; }

Public key that signed the payload.

options.signature

  • Type: { r: bigint; s: bigint; yParity?: number; }

Signature of the payload.

Return Type

Whether the payload was signed by the provided address.

boolean