"use strict";

var _ = require(".");

// Copyright 2017-2020 @polkadot/util-crypto authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
describe('naclSeal', () => {
  it('seals a message', () => {
    const message = new Uint8Array([1, 2, 3, 4, 5, 4, 3, 2, 1]);
    const sender = (0, _.naclKeypairFromString)('sender');
    const receiver = (0, _.naclKeypairFromString)('receiver');
    const senderBox = (0, _.naclBoxKeypairFromSecret)(sender.secretKey);
    const receiverBox = (0, _.naclBoxKeypairFromSecret)(receiver.secretKey);
    const senderBoxSecret = senderBox.secretKey;
    const receiverBoxPublic = receiverBox.publicKey;
    expect((0, _.naclSeal)(message, senderBoxSecret, receiverBoxPublic, new Uint8Array(24))).toEqual({
      sealed: new Uint8Array([137, 195, 104, 255, 67, 199, 40, 235, 148, 177, 180, 73, 239, 131, 215, 80, 61, 191, 167, 213, 152, 138, 5, 47, 135]),
      nonce: new Uint8Array(24)
    });
  });
});