Files
common/packages/util-crypto/docs/nacl.md
T

2.4 KiB

nacl

Implements NaCl secret-key authenticated encryption, public-key authenticated encryption, hashing, and public-key signatures

naclKeypair

Creates a new public/secret keypair.

naclKeypair (): { secretKey: Uint8Array, publicKey: Uint8Array }

Returns a new generate object containing a publicKey & secretKey.

import { naclKeypair } from '@polkadot/util-crypto';

naclKeypair() // => { secretKey: [...], publicKey: [...] }

naclKeypairFromSecret

Creates a new public/secret keypair from a secret.

naclKeypairFromSecret (secretKey: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array }

Returns a object containing a publicKey & secretKey generated from the supplied secret.

import { naclKeypairFromSecret } from '@polkadot/util-crypto';

naclKeypairFromSecret(...) // => { secretKey: [...], publicKey: [...] }

naclKeypairFromSeed

Creates a new public/secret keypair from a seed.

naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array }

Returns a object containing a publicKey & secretKey generated from the supplied seed.

import { naclKeypairFromSeed } from '@polkadot/util-crypto';

naclKeypairFromSeed(...) // => { secretKey: [...], publicKey: [...] }

naclSign

Signs a message using the supplied secretKey

naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array

Returns message signature of message, using the secretKey.

import { naclSign } from '@polkadot/util-crypto';

naclSign([...], [...]) // => [...]

naclSign

Verifies the signature on the supplied message.

naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean

Verifies the signature on message with the supplied plublicKey. Returns true on sucess, false otherwise.

import { naclVerify } from '@polkadot/util-crypto';

naclVerify([...], [...], [...]) // => true/false