Rename to remoteEarlyData

This commit is contained in:
Matija Petrunic 2020-04-17 11:04:50 +02:00
parent 9b650d5b5f
commit 7625aa8e46
6 changed files with 9 additions and 9 deletions

View File

@ -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};
}

View File

@ -14,7 +14,7 @@ export interface INoiseConnection {
export type SecureOutbound = {
conn: any;
earlyData: Buffer;
remoteEarlyData: Buffer;
remotePeer: PeerId;
}

View File

@ -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<void> {

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -116,7 +116,7 @@ export class Noise implements INoiseConnection {
return {
conn,
earlyData: handshake.earlyData,
remoteEarlyData: handshake.remoteEarlyData,
remotePeer: handshake.remotePeer
};
}