ssi.nostr.generateSync()
Callback type of generate
.
Syntax
const promiseValue = await window.ssi.nostr.generateSync(
options, // object
callback, // object
)
Parameters
options
object
. Direction about generation detail.
type
NostrGenerateType
. The type that specifies the secret you want the user to generate: e.g."single"
,"mnemonic"
.
callback
object
. A reference to a function that should be called in the near future, when the result is returned. The callback function is passed two arguments — 1. Error object if failed otherwise null, 2. The resulting hex-format public key.
error
Error
.publicKey
string
.
Return value
None (undefined).
Examples
Generating a single key pair on secp256k1
const callback = (error, pubkey) => {
if (error) {
throw new Error("Failed to generate")
}
console.log(pubkey)
}
window.ssi.nostr.generateSync(
{
type: "single",
},
callback
)
console.log(pubkey)
// "5793aa60c01dba51b3e8848fa0dfd39062fa8fda77702dc142f815c39bb4c10d"
This documentation is derived from window.ssi.type.ts in gecko-dev-for-ssi.