mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 12:52:15 +00:00
Remove unused
This commit is contained in:
parent
ddfacf81e8
commit
5be8f61599
@ -81,7 +81,7 @@ export class Handshake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stage 2
|
// stage 2
|
||||||
async finish(earlyData?: bytes): Promise<void> {
|
async finish(): Promise<void> {
|
||||||
if (this.isInitiator) {
|
if (this.isInitiator) {
|
||||||
logger('Stage 2 - Initiator sending third handshake message.');
|
logger('Stage 2 - Initiator sending third handshake message.');
|
||||||
const messageBuffer = this.xx.sendMessage(this.session, this.payload);
|
const messageBuffer = this.xx.sendMessage(this.session, this.payload);
|
||||||
|
@ -3,7 +3,7 @@ import { BN } from 'bn.js';
|
|||||||
|
|
||||||
import { bytes32, bytes } from '../@types/basic'
|
import { bytes32, bytes } from '../@types/basic'
|
||||||
import { KeyPair } from '../@types/libp2p'
|
import { KeyPair } from '../@types/libp2p'
|
||||||
import {generateKeypair, getHkdf, isValidPublicKey} from '../utils';
|
import {generateKeypair, isValidPublicKey} from '../utils';
|
||||||
import { HandshakeState, MessageBuffer, NoiseSession } from "../@types/handshake";
|
import { HandshakeState, MessageBuffer, NoiseSession } from "../@types/handshake";
|
||||||
import {AbstractHandshake} from "./abstract-handshake";
|
import {AbstractHandshake} from "./abstract-handshake";
|
||||||
|
|
||||||
|
@ -8,12 +8,8 @@ import lp from 'it-length-prefixed';
|
|||||||
|
|
||||||
import { Handshake } from "./handshake";
|
import { Handshake } from "./handshake";
|
||||||
import {
|
import {
|
||||||
createHandshakePayload,
|
|
||||||
generateKeypair,
|
generateKeypair,
|
||||||
getHandshakePayload,
|
|
||||||
getPayload,
|
getPayload,
|
||||||
signEarlyDataPayload,
|
|
||||||
signPayload
|
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
import { uint16BEDecode, uint16BEEncode } from "./encoder";
|
import { uint16BEDecode, uint16BEEncode } from "./encoder";
|
||||||
import { decryptStream, encryptStream } from "./crypto";
|
import { decryptStream, encryptStream } from "./crypto";
|
||||||
@ -86,13 +82,13 @@ export class Noise implements NoiseConnection {
|
|||||||
remotePeer: PeerId,
|
remotePeer: PeerId,
|
||||||
): Promise<Handshake> {
|
): Promise<Handshake> {
|
||||||
const prologue = Buffer.from(this.protocol);
|
const prologue = Buffer.from(this.protocol);
|
||||||
const payload = await getPayload(localPeer, this.staticKeys.publicKey);
|
const payload = await getPayload(localPeer, this.staticKeys.publicKey, this.earlyData);
|
||||||
const handshake = new Handshake(isInitiator, payload, prologue, this.staticKeys, connection, remotePeer);
|
const handshake = new Handshake(isInitiator, payload, prologue, this.staticKeys, connection, remotePeer);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await handshake.propose();
|
await handshake.propose();
|
||||||
await handshake.exchange();
|
await handshake.exchange();
|
||||||
await handshake.finish(this.earlyData);
|
await handshake.finish();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`Error occurred during handshake: ${e.message}`);
|
throw new Error(`Error occurred during handshake: ${e.message}`);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { x25519, ed25519, HKDF, SHA256 } from 'bcrypto';
|
import { x25519, HKDF, SHA256 } from 'bcrypto';
|
||||||
import protobuf from "protobufjs";
|
import protobuf from "protobufjs";
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
import PeerId from "peer-id";
|
import PeerId from "peer-id";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user