Skip to content

P256.verify

Verifies a payload was signed by the provided public key.

Imports

Named
import { P256 } from 'ox'

Examples

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

Definition

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

Source: src/core/P256.ts

Parameters

options

  • Type: verify.Options

The verification options.

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; } | { r: bigint; s: bigint; yParity?: number; }

Signature of the payload.

Return Type

Whether the payload was signed by the provided public key.

boolean