From 7625aa8e46a2cf66c19d024ecf4c02b7138617e4 Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Fri, 17 Apr 2020 11:04:50 +0200 Subject: [PATCH] Rename to remoteEarlyData --- src/@types/handshake-interface.ts | 2 +- src/@types/libp2p.ts | 2 +- src/handshake-ik.ts | 4 ++-- src/handshake-xx-fallback.ts | 2 +- src/handshake-xx.ts | 6 +++--- src/noise.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/@types/handshake-interface.ts b/src/@types/handshake-interface.ts index a2d930a..f432bda 100644 --- a/src/@types/handshake-interface.ts +++ b/src/@types/handshake-interface.ts @@ -5,7 +5,7 @@ import PeerId from "peer-id"; export interface IHandshake { session: NoiseSession; remotePeer: PeerId; - earlyData: Buffer; + remoteEarlyData: Buffer; encrypt(plaintext: bytes, session: NoiseSession): bytes; decrypt(ciphertext: bytes, session: NoiseSession): {plaintext: bytes; valid: boolean}; } diff --git a/src/@types/libp2p.ts b/src/@types/libp2p.ts index db29558..3c02747 100644 --- a/src/@types/libp2p.ts +++ b/src/@types/libp2p.ts @@ -14,7 +14,7 @@ export interface INoiseConnection { export type SecureOutbound = { conn: any; - earlyData: Buffer; + remoteEarlyData: Buffer; remotePeer: PeerId; } diff --git a/src/handshake-ik.ts b/src/handshake-ik.ts index 372319f..9d76f46 100644 --- a/src/handshake-ik.ts +++ b/src/handshake-ik.ts @@ -15,7 +15,7 @@ export class IKHandshake implements IHandshake { public isInitiator: boolean; public session: NoiseSession; public remotePeer!: PeerId; - public earlyData: Buffer; + public remoteEarlyData: Buffer; private payload: bytes; private prologue: bytes32; @@ -43,7 +43,7 @@ export class IKHandshake implements IHandshake { } this.ik = handshake || new IK(); this.session = this.ik.initSession(this.isInitiator, this.prologue, this.staticKeypair, remoteStaticKey); - this.earlyData = Buffer.alloc(0) + this.remoteEarlyData = Buffer.alloc(0) } public async stage0(): Promise { diff --git a/src/handshake-xx-fallback.ts b/src/handshake-xx-fallback.ts index 34647a3..da3f8ce 100644 --- a/src/handshake-xx-fallback.ts +++ b/src/handshake-xx-fallback.ts @@ -67,7 +67,7 @@ export class XXFallbackHandshake extends XXHandshake { this.remotePeer = this.remotePeer || await getPeerIdFromPayload(decodedPayload); await verifySignedPayload(this.session.hs.rs, decodedPayload, this.remotePeer); if(decodedPayload.data){ - this.earlyData = Buffer.from( + this.remoteEarlyData = Buffer.from( decodedPayload.data.buffer, decodedPayload.data.byteOffset, decodedPayload.data.length diff --git a/src/handshake-xx.ts b/src/handshake-xx.ts index 3f217ac..eb91f26 100644 --- a/src/handshake-xx.ts +++ b/src/handshake-xx.ts @@ -19,7 +19,7 @@ export class XXHandshake implements IHandshake { public isInitiator: boolean; public session: NoiseSession; public remotePeer!: PeerId; - public earlyData: Buffer; + public remoteEarlyData: Buffer; protected payload: bytes; protected connection: WrappedConnection; @@ -47,7 +47,7 @@ export class XXHandshake implements IHandshake { } this.xx = handshake || new XX(); this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeypair); - this.earlyData = Buffer.alloc(0) + this.remoteEarlyData = Buffer.alloc(0) } // stage 0 @@ -153,7 +153,7 @@ export class XXHandshake implements IHandshake { private setEarlyData(data: Uint8Array|null|undefined): void { if(data){ - this.earlyData = Buffer.from(data.buffer, data.byteOffset, data.length); + this.remoteEarlyData = Buffer.from(data.buffer, data.byteOffset, data.length); } } } diff --git a/src/noise.ts b/src/noise.ts index 8d93cfb..214721c 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -116,7 +116,7 @@ export class Noise implements INoiseConnection { return { conn, - earlyData: handshake.earlyData, + remoteEarlyData: handshake.remoteEarlyData, remotePeer: handshake.remotePeer }; }