Address PR comments

This commit is contained in:
morrigan
2019-11-20 13:23:36 +01:00
parent 4d09d63a4a
commit ca4e2777ff
12 changed files with 104 additions and 110 deletions

View File

@ -1,19 +1,43 @@
import { bytes, bytes32 } from "./types/basic";
import { bytes, bytes32 } from "./@types/basic";
import { NoiseSession, XXHandshake } from "./xx";
import { KeyPair } from "./types/libp2p";
import { KeyPair, PeerId } from "./@types/libp2p";
type handshakeType = "XX";
export class Handshake {
static async runXX(
isInitiator: boolean,
private type: handshakeType;
private remotePublicKey: bytes;
private signedPayload: bytes;
private prologue: bytes32;
private staticKeys: KeyPair;
constructor(
type: handshakeType,
remotePublicKey: bytes,
prologue: bytes32,
signedPayload: bytes,
staticKeys: KeyPair,
) : Promise<NoiseSession> {
) {
this.type = type;
this.remotePublicKey = remotePublicKey;
this.signedPayload = signedPayload;
this.prologue = prologue;
this.staticKeys = staticKeys;
}
async propose(isInitiator: boolean) : Promise<NoiseSession> {
const xx = new XXHandshake();
const nsInit = await xx.initSession(isInitiator, prologue, staticKeys, remotePublicKey);
const nsInit = await xx.initSession(isInitiator, this.prologue, this.staticKeys, this.remotePublicKey);
// TODO: exchange handshake messages and confirm handshake
return nsInit;
}
async exchange() : Promise<NoiseSession> {
}
async finish() : Promise<NoiseSession> {
}
}