diff --git a/src/handshake-ik.ts b/src/handshake-ik.ts index b52de0c..ddf1de4 100644 --- a/src/handshake-ik.ts +++ b/src/handshake-ik.ts @@ -65,7 +65,7 @@ export class IKHandshake implements IHandshake { const decodedPayload = await decodePayload(plaintext); this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload); await verifySignedPayload(this.session.hs.rs, decodedPayload, this.remotePeer); - this.setEarlyData(decodedPayload.data); + this.setRemoteEarlyData(decodedPayload.data); logger("IK Stage 0 - Responder successfully verified payload!"); } catch (e) { logger("Responder breaking up with IK handshake in stage 0."); @@ -89,7 +89,7 @@ export class IKHandshake implements IHandshake { const decodedPayload = await decodePayload(plaintext); this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload); await verifySignedPayload(receivedMessageBuffer.ns.slice(0, 32), decodedPayload, this.remotePeer); - this.setEarlyData(decodedPayload.data); + this.setRemoteEarlyData(decodedPayload.data); logger("IK Stage 1 - Initiator successfully verified payload!"); } catch (e) { logger("Initiator breaking up with IK handshake in stage 1."); @@ -133,7 +133,7 @@ export class IKHandshake implements IHandshake { } } - private setEarlyData(data: Uint8Array|null|undefined): void { + private setRemoteEarlyData(data: Uint8Array|null|undefined): void { if(data){ this.remoteEarlyData = Buffer.from(data.buffer, data.byteOffset, data.length); } diff --git a/src/handshake-xx.ts b/src/handshake-xx.ts index eb91f26..bb2b849 100644 --- a/src/handshake-xx.ts +++ b/src/handshake-xx.ts @@ -84,7 +84,7 @@ export class XXHandshake implements IHandshake { const decodedPayload = await decodePayload(plaintext); this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload); this.remotePeer = await verifySignedPayload(receivedMessageBuffer.ns, decodedPayload, this.remotePeer); - this.setEarlyData(decodedPayload.data) + this.setRemoteEarlyData(decodedPayload.data) } catch (e) { throw new Error(`Error occurred while verifying signed payload: ${e.message}`); } @@ -117,7 +117,7 @@ export class XXHandshake implements IHandshake { const decodedPayload = await decodePayload(plaintext); this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload); await verifySignedPayload(this.session.hs.rs, decodedPayload, this.remotePeer); - this.setEarlyData(decodedPayload.data) + this.setRemoteEarlyData(decodedPayload.data) } catch (e) { throw new Error(`Error occurred while verifying signed payload: ${e.message}`); } @@ -151,7 +151,7 @@ export class XXHandshake implements IHandshake { } } - private setEarlyData(data: Uint8Array|null|undefined): void { + private setRemoteEarlyData(data: Uint8Array|null|undefined): void { if(data){ this.remoteEarlyData = Buffer.from(data.buffer, data.byteOffset, data.length); }