mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-06-21 03:21:42 +00:00
Address PR comments
This commit is contained in:
@ -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> {
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user