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 { bytes, bytes32 } from "./types/basic";
|
||||||
import {KeyPair, NoiseSession, XXHandshake} from "./xx";
|
import { NoiseSession, XXHandshake } from "./xx";
|
||||||
|
import { KeyPair } from "./types/libp2p";
|
||||||
|
|
||||||
export class Handshake {
|
export class Handshake {
|
||||||
static async runXX(
|
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 { Handshake } from "./handshake";
|
||||||
import { generateKeypair, signPayload } from "./utils";
|
import { generateKeypair, signPayload } from "./utils";
|
||||||
import {encryptStream} from "./crypto";
|
import { encryptStreams } from "./crypto";
|
||||||
|
|
||||||
export class Noise implements NoiseConnection {
|
export class Noise implements NoiseConnection {
|
||||||
private readonly privateKey: bytes;
|
private readonly privateKey: bytes;
|
||||||
@ -64,17 +64,13 @@ export class Noise implements NoiseConnection {
|
|||||||
const prologue = Buffer.from(this.protocol());
|
const prologue = Buffer.from(this.protocol());
|
||||||
const session = await Handshake.runXX(isInitiator, remotePublicKey, prologue, signedPayload, this.staticKeys);
|
const session = await Handshake.runXX(isInitiator, remotePublicKey, prologue, signedPayload, this.staticKeys);
|
||||||
|
|
||||||
await encryptStream(connection.streams, session);
|
await encryptStreams(connection.streams(), session);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...connection,
|
...connection,
|
||||||
initiator: isInitiator,
|
initiator: isInitiator,
|
||||||
prologue,
|
prologue,
|
||||||
// localKey: get public key,
|
localKey: Buffer.alloc(0), // get libp2p public key,
|
||||||
local: {
|
|
||||||
noiseKey: this.staticKeys.publicKey,
|
|
||||||
// libp2pKey:
|
|
||||||
},
|
|
||||||
xxNoiseSession: session,
|
xxNoiseSession: session,
|
||||||
xxComplete: true,
|
xxComplete: true,
|
||||||
noiseKeypair: this.staticKeys,
|
noiseKeypair: this.staticKeys,
|
||||||
|
@ -57,5 +57,4 @@ export interface SecureConnection {
|
|||||||
xxComplete: boolean,
|
xxComplete: boolean,
|
||||||
|
|
||||||
noiseKeypair: KeyPair,
|
noiseKeypair: KeyPair,
|
||||||
msgBuffer: bytes,
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { x25519 } from 'bcrypto';
|
import { x25519 } from 'bcrypto';
|
||||||
import * as crypto from 'libp2p-crypto';
|
import * as crypto from 'libp2p-crypto';
|
||||||
|
|
||||||
import { KeyPair } from "./xx";
|
import { KeyPair } from "./types/libp2p";
|
||||||
import { bytes } from "./types/basic";
|
import { bytes } from "./types/basic";
|
||||||
|
|
||||||
export async function generateKeypair() : Promise<KeyPair> {
|
export async function generateKeypair() : Promise<KeyPair> {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
import DuplexPair from 'it-pair/duplex';
|
||||||
|
|
||||||
import { Noise } from "../src";
|
import { Noise } from "../src";
|
||||||
import {generateEd25519Keys} from "./utils";
|
import {generateEd25519Keys} from "./utils";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user