Bls.verify
Verifies a payload was signed by the provided public key(s).
Imports
Named
import { Bls } from 'ox'
Examples
import { Bls, Hex } from 'ox'
const payload = Hex.random(32)
const privateKey = Bls.randomPrivateKey()
const publicKey = Bls.getPublicKey({ privateKey })
const signature = Bls.sign({ payload, privateKey })
const verified = Bls.verify({
payload,
publicKey,
signature,
})
Verify Aggregated Signatures
We can also pass a public key and signature that was aggregated with Bls.aggregate
to Bls.verify
.
import { Bls, Hex } from 'ox'
const payload = Hex.random(32)
const privateKeys = Array.from({ length: 100 }, () => Bls.randomPrivateKey())
const publicKeys = privateKeys.map((privateKey) =>
Bls.getPublicKey({ privateKey }),
)
const signatures = privateKeys.map((privateKey) =>
Bls.sign({ payload, privateKey }),
)
const publicKey = Bls.aggregate(publicKeys)
const signature = Bls.aggregate(signatures)
const valid = Bls.verify({ payload, publicKey, signature })
Definition
function verify(
options: verify.Options,
): boolean
Source: src/core/Bls.ts
Parameters
options
- Type:
verify.Options
Verification options.
options.payload
- Type:
0x${string} | Uint8Array
Payload that was signed.
options.publicKey
- Type:
{ x: { c0: bigint; c1: bigint; }; y: { c0: bigint; c1: bigint; }; z: { c0: bigint; c1: bigint; }; }
options.signature
- Type:
{ x: bigint; y: bigint; z: bigint; }
options.suite
- Type:
string
- Optional
Ciphersuite to use for verification. Defaults to "Basic".
Return Type
Whether the payload was signed by the provided public key.
boolean