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";