sign

Signs data, so anyone with the public key can check it hasn't been changed and was signed by the owner of the pair.

Parameter

Description

data

The data to sign, in any format that can be converted to JSON.

pair

A pair object with pub and priv keys.

callback

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

Returns an object with two properties, m (the message) and s (its signature), which can be passed to verify(). Returns null if the pair is missing a key.

Examples

// With await.
const pair = await holster.SEA.pair()
const signed = await holster.SEA.sign("hello self", pair)
const verified = await holster.SEA.verify(signed, pair)
console.log(verified) // "hello self"

// With a callback.
holster.SEA.sign("hello self", pair, signed => console.log(signed.s))

The User API signs every update for you, so you only need sign() for data you send some other way, such as a request to your own server.