verify

Checks a signature from sign().

Parameter

Description

signed

The object returned by sign(), with m and s properties.

pair

A pair object with the signer's pub key. The other keys aren't needed.

callback

Optional function that receives the result. Leave it out to await it.

Returns the original message if the signature is valid, or null if it isn't.

Examples

// With await. Only the public key is needed to verify.
const pair = await holster.SEA.pair()
const signed = await holster.SEA.sign("hello self", pair)
const verified = await holster.SEA.verify(signed, {pub: pair.pub})
console.log(verified) // "hello self"

// With a callback.
holster.SEA.verify(signed, {pub: pair.pub}, verified => {
  if (verified === null) console.error("invalid signature")
})