UNPKG

646 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import nacl from 'tweetnacl';
4/**
5 * @name naclOpen
6 * @summary Opens a message using the receiver's secretKey and nonce
7 * @description
8 * Returns a message sealed by the sender, using the receiver's `secret` and `nonce`.
9 * @example
10 * <BR>
11 *
12 * ```javascript
13 * import { naclOpen } from '@polkadot/util-crypto';
14 *
15 * naclOpen([...], [...], [...]); // => [...]
16 * ```
17 */
18
19export function naclOpen(sealed, nonce, senderBoxPublic, receiverBoxSecret) {
20 return nacl.box.open(sealed, nonce, senderBoxPublic, receiverBoxSecret) || null;
21}
\No newline at end of file