mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 14:12:30 +00:00
Fix errors
This commit is contained in:
parent
26b112f712
commit
4d09d63a4a
@ -1,5 +1,6 @@
|
||||
import {bytes, bytes32} from "./types/basic";
|
||||
import {KeyPair, NoiseSession, XXHandshake} from "./xx";
|
||||
import { bytes, bytes32 } from "./types/basic";
|
||||
import { NoiseSession, XXHandshake } from "./xx";
|
||||
import { KeyPair } from "./types/libp2p";
|
||||
|
||||
export class Handshake {
|
||||
static async runXX(
|
||||
|
10
src/noise.ts
10
src/noise.ts
@ -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,
|
||||
|
@ -57,5 +57,4 @@ export interface SecureConnection {
|
||||
xxComplete: boolean,
|
||||
|
||||
noiseKeypair: KeyPair,
|
||||
msgBuffer: bytes,
|
||||
}
|
||||
|
@ -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> {
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { expect } from "chai";
|
||||
import DuplexPair from 'it-pair/duplex';
|
||||
|
||||
import { Noise } from "../src";
|
||||
import {generateEd25519Keys} from "./utils";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user