// Copyright 2017-2021 @polkadot/util-crypto authors & contributors // SPDX-License-Identifier: Apache-2.0 import nacl from 'tweetnacl'; /** * @name naclOpen * @summary Opens a message using the receiver's secretKey and nonce * @description * Returns a message sealed by the sender, using the receiver's `secret` and `nonce`. * @example *
* * ```javascript * import { naclOpen } from '@polkadot/util-crypto'; * * naclOpen([...], [...], [...]); // => [...] * ``` */ export function naclOpen (sealed: Uint8Array, nonce: Uint8Array, senderBoxPublic: Uint8Array, receiverBoxSecret: Uint8Array): Uint8Array | null { return nacl.box.open(sealed, nonce, senderBoxPublic, receiverBoxSecret) || null; }