From ddfacf81e8f8950751a4bc5c68791822bd51f3a3 Mon Sep 17 00:00:00 2001 From: Belma Gutlic Date: Tue, 7 Jan 2020 16:59:41 +0100 Subject: [PATCH 1/4] use libp2p keys from PeerId argument --- src/handshake.ts | 34 +++++----------------------------- src/noise.ts | 25 ++++++++++++++----------- src/utils.ts | 28 ++++++++++++++++++++++------ test/handshake.test.ts | 26 +++++++++++++------------- test/index.test.ts | 2 +- test/noise.test.ts | 24 ++++++++++-------------- 6 files changed, 65 insertions(+), 74 deletions(-) diff --git a/src/handshake.ts b/src/handshake.ts index b2d96dc..7052c7e 100644 --- a/src/handshake.ts +++ b/src/handshake.ts @@ -5,10 +5,6 @@ import { KeyPair, PeerId } from "./@types/libp2p"; import { bytes, bytes32 } from "./@types/basic"; import { NoiseSession } from "./@types/handshake"; import { - createHandshakePayload, - getHandshakePayload, - signEarlyDataPayload, - signPayload, verifySignedPayload, } from "./utils"; import { logger } from "./logger"; @@ -19,8 +15,7 @@ export class Handshake { public isInitiator: boolean; public session: NoiseSession; - private libp2pPrivateKey: bytes; - private libp2pPublicKey: bytes; + private payload: bytes; private prologue: bytes32; private staticKeys: KeyPair; private connection: WrappedConnection; @@ -29,8 +24,7 @@ export class Handshake { constructor( isInitiator: boolean, - libp2pPrivateKey: bytes, - libp2pPublicKey: bytes, + payload: bytes, prologue: bytes32, staticKeys: KeyPair, connection: WrappedConnection, @@ -38,8 +32,7 @@ export class Handshake { handshake?: XXHandshake, ) { this.isInitiator = isInitiator; - this.libp2pPrivateKey = libp2pPrivateKey; - this.libp2pPublicKey = libp2pPublicKey; + this.payload = payload; this.prologue = prologue; this.staticKeys = staticKeys; this.connection = connection; @@ -81,16 +74,7 @@ export class Handshake { logger("All good with the signature!"); } else { logger('Stage 1 - Responder sending out first message with signed payload and static key.'); - const signedPayload = signPayload(this.libp2pPrivateKey, getHandshakePayload(this.staticKeys.publicKey)); - const signedEarlyDataPayload = signEarlyDataPayload(this.libp2pPrivateKey, Buffer.alloc(0)); - const handshakePayload = await createHandshakePayload( - this.libp2pPublicKey, - this.libp2pPrivateKey, - signedPayload, - signedEarlyDataPayload, - ); - - const messageBuffer = this.xx.sendMessage(this.session, handshakePayload); + const messageBuffer = this.xx.sendMessage(this.session, this.payload); this.connection.writeLP(encodeMessageBuffer(messageBuffer)); logger('Stage 1 - Responder sent the second handshake message with signed payload.') } @@ -100,15 +84,7 @@ export class Handshake { async finish(earlyData?: bytes): Promise { if (this.isInitiator) { logger('Stage 2 - Initiator sending third handshake message.'); - const signedPayload = signPayload(this.libp2pPrivateKey, getHandshakePayload(this.staticKeys.publicKey)); - const signedEarlyDataPayload = signEarlyDataPayload(this.libp2pPrivateKey, earlyData || Buffer.alloc(0)); - const handshakePayload = await createHandshakePayload( - this.libp2pPublicKey, - this.libp2pPrivateKey, - signedPayload, - signedEarlyDataPayload - ); - const messageBuffer = this.xx.sendMessage(this.session, handshakePayload); + const messageBuffer = this.xx.sendMessage(this.session, this.payload); this.connection.writeLP(encodeMessageBuffer(messageBuffer)); logger('Stage 2 - Initiator sent message with signed payload.'); } else { diff --git a/src/noise.ts b/src/noise.ts index 068ade3..1b06e7f 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -7,7 +7,14 @@ import pipe from 'it-pipe'; import lp from 'it-length-prefixed'; import { Handshake } from "./handshake"; -import { generateKeypair } from "./utils"; +import { + createHandshakePayload, + generateKeypair, + getHandshakePayload, + getPayload, + signEarlyDataPayload, + signPayload +} from "./utils"; import { uint16BEDecode, uint16BEEncode } from "./encoder"; import { decryptStream, encryptStream } from "./crypto"; import { bytes } from "./@types/basic"; @@ -19,12 +26,10 @@ export type WrappedConnection = ReturnType; export class Noise implements NoiseConnection { public protocol = "/noise"; - private readonly privateKey: bytes; private readonly staticKeys: KeyPair; private readonly earlyData?: bytes; - constructor(privateKey: bytes, staticNoiseKey?: bytes, earlyData?: bytes) { - this.privateKey = privateKey; + constructor(staticNoiseKey?: bytes, earlyData?: bytes) { this.earlyData = earlyData || Buffer.alloc(0); if (staticNoiseKey) { @@ -47,8 +52,7 @@ export class Noise implements NoiseConnection { */ public async secureOutbound(localPeer: PeerId, connection: any, remotePeer: PeerId): Promise { const wrappedConnection = Wrap(connection); - const libp2pPublicKey = localPeer.marshalPubKey(); - const handshake = await this.performHandshake(wrappedConnection, true, libp2pPublicKey, remotePeer); + const handshake = await this.performHandshake(wrappedConnection, true, localPeer, remotePeer); const conn = await this.createSecureConnection(wrappedConnection, handshake); return { @@ -66,8 +70,7 @@ export class Noise implements NoiseConnection { */ public async secureInbound(localPeer: PeerId, connection: any, remotePeer: PeerId): Promise { const wrappedConnection = Wrap(connection); - const libp2pPublicKey = localPeer.marshalPubKey(); - const handshake = await this.performHandshake(wrappedConnection, false, libp2pPublicKey, remotePeer); + const handshake = await this.performHandshake(wrappedConnection, false, localPeer, remotePeer); const conn = await this.createSecureConnection(wrappedConnection, handshake); return { @@ -79,11 +82,12 @@ export class Noise implements NoiseConnection { private async performHandshake( connection: WrappedConnection, isInitiator: boolean, - libp2pPublicKey: bytes, + localPeer: PeerId, remotePeer: PeerId, ): Promise { const prologue = Buffer.from(this.protocol); - const handshake = new Handshake(isInitiator, this.privateKey, libp2pPublicKey, prologue, this.staticKeys, connection, remotePeer); + const payload = await getPayload(localPeer, this.staticKeys.publicKey); + const handshake = new Handshake(isInitiator, payload, prologue, this.staticKeys, connection, remotePeer); try { await handshake.propose(); @@ -119,5 +123,4 @@ export class Noise implements NoiseConnection { return user; } - } diff --git a/src/utils.ts b/src/utils.ts index 005f826..63cd295 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -23,6 +23,22 @@ export function generateKeypair(): KeyPair { } } +export async function getPayload( + localPeer: PeerId, + staticPublicKey: bytes, + earlyData?: bytes, +): Promise { + const signedPayload = await signPayload(localPeer, getHandshakePayload(staticPublicKey)); + const signedEarlyDataPayload = await signEarlyDataPayload(localPeer, earlyData || Buffer.alloc(0)); + + return await createHandshakePayload( + localPeer.marshalPubKey(), + localPeer.marshalPrivKey(), + signedPayload, + signedEarlyDataPayload + ); +} + export async function createHandshakePayload( libp2pPublicKey: bytes, libp2pPrivateKey: bytes, @@ -46,8 +62,8 @@ export async function createHandshakePayload( } -export function signPayload(libp2pPrivateKey: bytes, payload: bytes) { - return ed25519.sign(payload, libp2pPrivateKey); +export async function signPayload(peerId: PeerId, payload: bytes): Promise { + return peerId.privKey.sign(payload); } type EarlyDataPayload = { @@ -55,9 +71,9 @@ type EarlyDataPayload = { libp2pDataSignature: bytes; } -export function signEarlyDataPayload(libp2pPrivateKey: bytes, earlyData: bytes): EarlyDataPayload { +export async function signEarlyDataPayload(peerId: PeerId, earlyData: bytes): Promise { const payload = getEarlyDataPayload(earlyData); - const signedPayload = signPayload(libp2pPrivateKey, payload); + const signedPayload = await signPayload(peerId, payload); return { libp2pData: payload, @@ -84,8 +100,8 @@ export async function verifySignedPayload(noiseStaticKey: bytes, plaintext: byte const generatedPayload = getHandshakePayload(noiseStaticKey); // Unmarshaling from PublicKey protobuf and taking key buffer only. - const publicKey = crypto.keys.unmarshalPublicKey(receivedPayload.libp2pKey).marshal(); - if (!ed25519.verify(generatedPayload, receivedPayload.noiseStaticKeySignature, publicKey)) { + const publicKey = crypto.keys.unmarshalPublicKey(receivedPayload.libp2pKey); + if (!publicKey.verify(generatedPayload, receivedPayload.noiseStaticKeySignature)) { throw new Error("Static key doesn't match to peer that signed payload!"); } } diff --git a/test/handshake.test.ts b/test/handshake.test.ts index 6019711..1c93e84 100644 --- a/test/handshake.test.ts +++ b/test/handshake.test.ts @@ -4,7 +4,7 @@ import {Buffer} from "buffer"; import Wrap from "it-pb-rpc"; import {Handshake} from "../src/handshake"; -import {generateKeypair} from "../src/utils"; +import {generateKeypair, getPayload} from "../src/utils"; import {createPeerIdsFromFixtures} from "./fixtures/peer"; import {getKeyPairFromPeerId} from "./utils"; @@ -26,11 +26,11 @@ describe("Handshake", () => { const staticKeysInitiator = generateKeypair(); const staticKeysResponder = generateKeypair(); - const { privateKey: initiatorPrivKey, publicKey: initiatorPubKey } = getKeyPairFromPeerId(peerA); - const handshakeInitator = new Handshake(true, initiatorPrivKey, initiatorPubKey, prologue, staticKeysInitiator, connectionFrom, peerB); + const initPayload = await getPayload(peerA, staticKeysInitiator.publicKey); + const handshakeInitator = new Handshake(true, initPayload, prologue, staticKeysInitiator, connectionFrom, peerB); - const { privateKey: responderPrivKey, publicKey: responderPubKey } = getKeyPairFromPeerId(peerB); - const handshakeResponder = new Handshake(false, responderPrivKey, responderPubKey, prologue, staticKeysResponder, connectionTo, peerA); + const respPayload = await getPayload(peerB, staticKeysResponder.publicKey); + const handshakeResponder = new Handshake(false, respPayload, prologue, staticKeysResponder, connectionTo, peerA); await handshakeInitator.propose(); await handshakeResponder.propose(); @@ -71,11 +71,11 @@ describe("Handshake", () => { const staticKeysInitiator = generateKeypair(); const staticKeysResponder = generateKeypair(); - const { privateKey: initiatorPrivKey, publicKey: initiatorPubKey } = getKeyPairFromPeerId(peerA); - const handshakeInitator = new Handshake(true, initiatorPrivKey, initiatorPubKey, prologue, staticKeysInitiator, connectionFrom, fakePeer); + const initPayload = await getPayload(peerA, staticKeysInitiator.publicKey); + const handshakeInitator = new Handshake(true, initPayload, prologue, staticKeysInitiator, connectionFrom, fakePeer); - const { privateKey: responderPrivKey, publicKey: responderPubKey } = getKeyPairFromPeerId(peerB); - const handshakeResponder = new Handshake(false, responderPrivKey, responderPubKey, prologue, staticKeysResponder, connectionTo, peerA); + const respPayload = await getPayload(peerB, staticKeysResponder.publicKey); + const handshakeResponder = new Handshake(false, respPayload, prologue, staticKeysResponder, connectionTo, peerA); await handshakeInitator.propose(); await handshakeResponder.propose(); @@ -99,11 +99,11 @@ describe("Handshake", () => { const staticKeysInitiator = generateKeypair(); const staticKeysResponder = generateKeypair(); - const { privateKey: initiatorPrivKey, publicKey: initiatorPubKey } = getKeyPairFromPeerId(peerA); - const handshakeInitator = new Handshake(true, initiatorPrivKey, initiatorPubKey, prologue, staticKeysInitiator, connectionFrom, peerB); + const initPayload = await getPayload(peerA, staticKeysInitiator.publicKey); + const handshakeInitator = new Handshake(true, initPayload, prologue, staticKeysInitiator, connectionFrom, peerB); - const { privateKey: responderPrivKey, publicKey: responderPubKey } = getKeyPairFromPeerId(peerB); - const handshakeResponder = new Handshake(false, responderPrivKey, responderPubKey, prologue, staticKeysResponder, connectionTo, fakePeer); + const respPayload = await getPayload(peerB, staticKeysResponder.publicKey); + const handshakeResponder = new Handshake(false, respPayload, prologue, staticKeysResponder, connectionTo, fakePeer); await handshakeInitator.propose(); await handshakeResponder.propose(); diff --git a/test/index.test.ts b/test/index.test.ts index 808094f..f1287cf 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -3,7 +3,7 @@ import { Noise } from "../src"; describe("Index", () => { it("should expose class with tag and required functions", () => { - const noise = new Noise(Buffer.from("privatekey")); + const noise = new Noise(); expect(noise.protocol).to.equal('/noise'); expect(typeof(noise.secureInbound)).to.equal('function'); expect(typeof(noise.secureOutbound)).to.equal('function'); diff --git a/test/noise.test.ts b/test/noise.test.ts index 6594473..f10b0b1 100644 --- a/test/noise.test.ts +++ b/test/noise.test.ts @@ -9,7 +9,7 @@ import {Handshake} from "../src/handshake"; import { createHandshakePayload, generateKeypair, - getHandshakePayload, + getHandshakePayload, getPayload, signPayload } from "../src/utils"; import { decodeMessageBuffer, encodeMessageBuffer } from "../src/encoder"; @@ -26,10 +26,8 @@ describe("Noise", () => { it("should communicate through encrypted streams", async() => { try { - const { privateKey: libp2pInitPrivKey } = getKeyPairFromPeerId(localPeer); - const { privateKey: libp2pRespPrivKey } = getKeyPairFromPeerId(remotePeer); - const noiseInit = new Noise(libp2pInitPrivKey); - const noiseResp = new Noise(libp2pRespPrivKey); + const noiseInit = new Noise(); + const noiseResp = new Noise(); const [inboundConnection, outboundConnection] = DuplexPair(); const [outbound, inbound] = await Promise.all([ @@ -48,8 +46,7 @@ describe("Noise", () => { }); it("should test that secureOutbound is spec compliant", async() => { - const { privateKey: libp2pInitPrivKey } = getKeyPairFromPeerId(localPeer); - const noiseInit = new Noise(libp2pInitPrivKey); + const noiseInit = new Noise(); const [inboundConnection, outboundConnection] = DuplexPair(); const [outbound, { wrapped, handshake }] = await Promise.all([ @@ -59,9 +56,9 @@ describe("Noise", () => { const prologue = Buffer.from('/noise'); const staticKeys = generateKeypair(); const xx = new XXHandshake(); - const { privateKey: libp2pPrivKey, publicKey: libp2pPubKey } = getKeyPairFromPeerId(remotePeer); - const handshake = new Handshake(false, libp2pPrivKey, libp2pPubKey, prologue, staticKeys, wrapped, localPeer, xx); + const payload = await getPayload(remotePeer, staticKeys.publicKey); + const handshake = new Handshake(false, payload, prologue, staticKeys, wrapped, localPeer, xx); let receivedMessageBuffer = decodeMessageBuffer((await wrapped.readLP()).slice()); // The first handshake message contains the initiator's ephemeral public key @@ -69,7 +66,8 @@ describe("Noise", () => { xx.recvMessage(handshake.session, receivedMessageBuffer); // Stage 1 - const signedPayload = signPayload(libp2pPrivKey, getHandshakePayload(staticKeys.publicKey)); + const { privateKey: libp2pPrivKey, publicKey: libp2pPubKey } = getKeyPairFromPeerId(remotePeer); + const signedPayload = await signPayload(remotePeer, getHandshakePayload(staticKeys.publicKey)); const handshakePayload = await createHandshakePayload(libp2pPubKey, libp2pPrivKey, signedPayload); const messageBuffer = xx.sendMessage(handshake.session, handshakePayload); @@ -101,10 +99,8 @@ describe("Noise", () => { it("should test large payloads", async() => { try { - const { privateKey: libp2pInitPrivKey } = getKeyPairFromPeerId(localPeer); - const { privateKey: libp2pRespPrivKey } = getKeyPairFromPeerId(remotePeer); - const noiseInit = new Noise(libp2pInitPrivKey); - const noiseResp = new Noise(libp2pRespPrivKey); + const noiseInit = new Noise(); + const noiseResp = new Noise(); const [inboundConnection, outboundConnection] = DuplexPair(); const [outbound, inbound] = await Promise.all([ From 5be8f6159919ada59babc37f16395e07c4d40cd0 Mon Sep 17 00:00:00 2001 From: Belma Gutlic Date: Tue, 7 Jan 2020 17:01:52 +0100 Subject: [PATCH 2/4] Remove unused --- src/handshake.ts | 2 +- src/handshakes/xx.ts | 2 +- src/noise.ts | 8 ++------ src/utils.ts | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/handshake.ts b/src/handshake.ts index 7052c7e..646b07c 100644 --- a/src/handshake.ts +++ b/src/handshake.ts @@ -81,7 +81,7 @@ export class Handshake { } // stage 2 - async finish(earlyData?: bytes): Promise { + async finish(): Promise { if (this.isInitiator) { logger('Stage 2 - Initiator sending third handshake message.'); const messageBuffer = this.xx.sendMessage(this.session, this.payload); diff --git a/src/handshakes/xx.ts b/src/handshakes/xx.ts index 3b8b0a9..694d8b8 100644 --- a/src/handshakes/xx.ts +++ b/src/handshakes/xx.ts @@ -3,7 +3,7 @@ import { BN } from 'bn.js'; import { bytes32, bytes } from '../@types/basic' import { KeyPair } from '../@types/libp2p' -import {generateKeypair, getHkdf, isValidPublicKey} from '../utils'; +import {generateKeypair, isValidPublicKey} from '../utils'; import { HandshakeState, MessageBuffer, NoiseSession } from "../@types/handshake"; import {AbstractHandshake} from "./abstract-handshake"; diff --git a/src/noise.ts b/src/noise.ts index 1b06e7f..79dc158 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -8,12 +8,8 @@ import lp from 'it-length-prefixed'; import { Handshake } from "./handshake"; import { - createHandshakePayload, generateKeypair, - getHandshakePayload, getPayload, - signEarlyDataPayload, - signPayload } from "./utils"; import { uint16BEDecode, uint16BEEncode } from "./encoder"; import { decryptStream, encryptStream } from "./crypto"; @@ -86,13 +82,13 @@ export class Noise implements NoiseConnection { remotePeer: PeerId, ): Promise { const prologue = Buffer.from(this.protocol); - const payload = await getPayload(localPeer, this.staticKeys.publicKey); + const payload = await getPayload(localPeer, this.staticKeys.publicKey, this.earlyData); const handshake = new Handshake(isInitiator, payload, prologue, this.staticKeys, connection, remotePeer); try { await handshake.propose(); await handshake.exchange(); - await handshake.finish(this.earlyData); + await handshake.finish(); } catch (e) { throw new Error(`Error occurred during handshake: ${e.message}`); } diff --git a/src/utils.ts b/src/utils.ts index 63cd295..4a3b267 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { x25519, ed25519, HKDF, SHA256 } from 'bcrypto'; +import { x25519, HKDF, SHA256 } from 'bcrypto'; import protobuf from "protobufjs"; import { Buffer } from "buffer"; import PeerId from "peer-id"; From d3a652aecb3b269c6e8d0e247224f84dd8025b6a Mon Sep 17 00:00:00 2001 From: Belma Gutlic Date: Tue, 7 Jan 2020 17:08:08 +0100 Subject: [PATCH 3/4] Remove comment --- src/utils.ts | 3 ++- test/utils.ts | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 4a3b267..08b8cea 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -99,7 +99,8 @@ export async function verifySignedPayload(noiseStaticKey: bytes, plaintext: byte } const generatedPayload = getHandshakePayload(noiseStaticKey); - // Unmarshaling from PublicKey protobuf and taking key buffer only. + + // Unmarshaling from PublicKey protobuf const publicKey = crypto.keys.unmarshalPublicKey(receivedPayload.libp2pKey); if (!publicKey.verify(generatedPayload, receivedPayload.noiseStaticKeySignature)) { throw new Error("Static key doesn't match to peer that signed payload!"); diff --git a/test/utils.ts b/test/utils.ts index 5e8b430..2ac5b7b 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,6 +1,5 @@ import * as crypto from 'libp2p-crypto'; import {KeyPair, PeerId} from "../src/@types/libp2p"; -import {bytes} from "../src/@types/basic"; export async function generateEd25519Keys() { return await crypto.keys.generateKeyPair('ed25519'); From e2b7eef295ce5266ab9a97b61af90f74f1d9d1fe Mon Sep 17 00:00:00 2001 From: Belma Gutlic Date: Fri, 10 Jan 2020 11:10:48 +0100 Subject: [PATCH 4/4] Address PR comment --- src/utils.ts | 2 -- test/handshakes/ik.test.ts | 4 ++-- test/handshakes/xx.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 08b8cea..003159c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -33,7 +33,6 @@ export async function getPayload( return await createHandshakePayload( localPeer.marshalPubKey(), - localPeer.marshalPrivKey(), signedPayload, signedEarlyDataPayload ); @@ -41,7 +40,6 @@ export async function getPayload( export async function createHandshakePayload( libp2pPublicKey: bytes, - libp2pPrivateKey: bytes, signedPayload: bytes, signedEarlyData?: EarlyDataPayload, ): Promise { diff --git a/test/handshakes/ik.test.ts b/test/handshakes/ik.test.ts index 6a4bf8e..69a674f 100644 --- a/test/handshakes/ik.test.ts +++ b/test/handshakes/ik.test.ts @@ -31,7 +31,7 @@ describe("Index", () => { const initSignedPayload = await libp2pInitKeys.sign(getHandshakePayload(kpInitiator.publicKey)); const libp2pInitPrivKey = libp2pInitKeys.marshal().slice(0, 32); const libp2pInitPubKey = libp2pInitKeys.marshal().slice(32, 64); - const payloadInitEnc = await createHandshakePayload(libp2pInitPubKey, libp2pInitPrivKey, initSignedPayload); + const payloadInitEnc = await createHandshakePayload(libp2pInitPubKey, initSignedPayload); // initiator sends message const message = Buffer.concat([Buffer.alloc(0), payloadInitEnc]); @@ -48,7 +48,7 @@ describe("Index", () => { const libp2pRespPrivKey = libp2pRespKeys.marshal().slice(0, 32); const libp2pRespPubKey = libp2pRespKeys.marshal().slice(32, 64); const respSignedPayload = await libp2pRespKeys.sign(getHandshakePayload(kpResponder.publicKey)); - const payloadRespEnc = await createHandshakePayload(libp2pRespPubKey, libp2pRespPrivKey, respSignedPayload); + const payloadRespEnc = await createHandshakePayload(libp2pRespPubKey, respSignedPayload); const message1 = Buffer.concat([message, payloadRespEnc]); const messageBuffer2 = ikR.sendMessage(responderSession, message1); diff --git a/test/handshakes/xx.test.ts b/test/handshakes/xx.test.ts index b6d93f4..ddd9137 100644 --- a/test/handshakes/xx.test.ts +++ b/test/handshakes/xx.test.ts @@ -58,7 +58,7 @@ describe("Index", () => { const libp2pInitPrivKey = libp2pInitKeys.marshal().slice(0, 32); const libp2pInitPubKey = libp2pInitKeys.marshal().slice(32, 64); - const payloadInitEnc = await createHandshakePayload(libp2pInitPubKey, libp2pInitPrivKey, initSignedPayload); + const payloadInitEnc = await createHandshakePayload(libp2pInitPubKey, initSignedPayload); // initiator sends message const message = Buffer.concat([Buffer.alloc(0), payloadInitEnc]); @@ -75,7 +75,7 @@ describe("Index", () => { // responder creates payload const libp2pRespPrivKey = libp2pRespKeys.marshal().slice(0, 32); const libp2pRespPubKey = libp2pRespKeys.marshal().slice(32, 64); - const payloadRespEnc = await createHandshakePayload(libp2pRespPubKey, libp2pRespPrivKey, respSignedPayload); + const payloadRespEnc = await createHandshakePayload(libp2pRespPubKey, respSignedPayload); const message1 = Buffer.concat([message, payloadRespEnc]); const messageBuffer2 = xx.sendMessage(nsResp, message1);