Files
common/packages/util-crypto/docs/nacl.md
T
2018-05-08 10:49:11 +00:00

1.9 KiB

nacl

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

  • naclDecrypt Decrypts a message using the supplied secretKey and nonce
  • naclEncrypt Encrypts a message using the supplied secretKey and nonce
  • naclSign Signs a message using the supplied secretKey
  • naclSign Verifies the signature on the supplied message.

naclDecrypt

Decrypts a message using the supplied secretKey and nonce

naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array

Returns an decrypted message, using the secret and nonce.

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

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

naclEncrypt

Encrypts a message using the supplied secretKey and nonce

naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array }

Returns an encrypted message, using the secretKey and nonce. If the nonce was not supplied, a random value is generated.

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

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

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