validate aead decryption

This commit is contained in:
Marin Petrunić
2020-03-01 19:05:53 +01:00
parent b93a50c8b0
commit 638b0773e5
14 changed files with 115 additions and 115 deletions

View File

@ -2,7 +2,6 @@ import {assert, expect} from "chai";
import Duplex from 'it-pair/duplex';
import {Buffer} from "buffer";
import Wrap from "it-pb-rpc";
import {XXHandshake} from "../src/handshake-xx";
import {generateKeypair, getPayload} from "../src/utils";
import {createPeerIdsFromFixtures} from "./fixtures/peer";
@ -53,8 +52,9 @@ describe("XX Handshake", () => {
// Test encryption and decryption
const encrypted = handshakeInitator.encrypt(Buffer.from("encryptthis"), handshakeInitator.session);
const decrypted = handshakeResponder.decrypt(encrypted, handshakeResponder.session);
const {plaintext: decrypted, valid} = handshakeResponder.decrypt(encrypted, handshakeResponder.session);
assert(decrypted.equals(Buffer.from("encryptthis")));
assert(valid);
} catch (e) {
assert(false, e.message);
}