Handshake payload refactor

This commit is contained in:
morrigan
2019-11-20 21:38:14 +01:00
parent 3519df482d
commit af95dc2fcd
6 changed files with 64 additions and 42 deletions

View File

@ -1,6 +1,7 @@
import { bytes, bytes32 } from "./@types/basic";
import { NoiseSession, XXHandshake } from "./xx";
import { KeyPair, PeerId } from "./@types/libp2p";
import {Buffer} from "buffer";
type handshakeType = "XX";
@ -29,7 +30,10 @@ export class Handshake {
const xx = new XXHandshake();
const nsInit = await xx.initSession(isInitiator, this.prologue, this.staticKeys, this.remotePublicKey);
// TODO: exchange handshake messages and confirm handshake
if (isInitiator) {
const message = Buffer.concat([Buffer.alloc(0), this.signedPayload]);
const messageBuffer = await xx.sendMessage(nsInit, message);
}
return nsInit;
}