Fix errors

This commit is contained in:
morrigan 2019-11-12 14:07:25 +01:00
parent 26b112f712
commit 4d09d63a4a
5 changed files with 9 additions and 11 deletions

View File

@ -1,5 +1,6 @@
import { bytes, bytes32 } from "./types/basic";
import {KeyPair, NoiseSession, XXHandshake} from "./xx";
import { NoiseSession, XXHandshake } from "./xx";
import { KeyPair } from "./types/libp2p";
export class Handshake {
static async runXX(

View File

@ -6,7 +6,7 @@ import { InsecureConnection, NoiseConnection, PeerId, SecureConnection, KeyPair
import { Handshake } from "./handshake";
import { generateKeypair, signPayload } from "./utils";
import {encryptStream} from "./crypto";
import { encryptStreams } from "./crypto";
export class Noise implements NoiseConnection {
private readonly privateKey: bytes;
@ -64,17 +64,13 @@ export class Noise implements NoiseConnection {
const prologue = Buffer.from(this.protocol());
const session = await Handshake.runXX(isInitiator, remotePublicKey, prologue, signedPayload, this.staticKeys);
await encryptStream(connection.streams, session);
await encryptStreams(connection.streams(), session);
return {
...connection,
initiator: isInitiator,
prologue,
// localKey: get public key,
local: {
noiseKey: this.staticKeys.publicKey,
// libp2pKey:
},
localKey: Buffer.alloc(0), // get libp2p public key,
xxNoiseSession: session,
xxComplete: true,
noiseKeypair: this.staticKeys,

View File

@ -57,5 +57,4 @@ export interface SecureConnection {
xxComplete: boolean,
noiseKeypair: KeyPair,
msgBuffer: bytes,
}

View File

@ -1,7 +1,7 @@
import { x25519 } from 'bcrypto';
import * as crypto from 'libp2p-crypto';
import { KeyPair } from "./xx";
import { KeyPair } from "./types/libp2p";
import { bytes } from "./types/basic";
export async function generateKeypair() : Promise<KeyPair> {

View File

@ -1,4 +1,6 @@
import { expect } from "chai";
import DuplexPair from 'it-pair/duplex';
import { Noise } from "../src";
import {generateEd25519Keys} from "./utils";