Better naming

This commit is contained in:
Belma Gutlic
2020-01-05 19:09:59 +01:00
parent 4a9b814e5a
commit 096a30b289
9 changed files with 23 additions and 24 deletions

View File

@ -1,5 +1,5 @@
import {WrappedConnection} from "./noise";
import {IKHandshake} from "./handshakes/ik";
import {IK} from "./handshakes/ik";
import {NoiseSession} from "./@types/handshake";
import {bytes, bytes32} from "./@types/basic";
import {KeyPair, PeerId} from "./@types/libp2p";
@ -16,7 +16,7 @@ export class Handshake implements HandshakeInterface {
private staticKeys: KeyPair;
private connection: WrappedConnection;
private remotePeer: PeerId;
private ik: IKHandshake;
private ik: IK;
constructor(
isInitiator: boolean,
@ -26,7 +26,7 @@ export class Handshake implements HandshakeInterface {
staticKeys: KeyPair,
connection: WrappedConnection,
remotePeer: PeerId,
handshake?: IKHandshake,
handshake?: IK,
) {
this.isInitiator = isInitiator;
this.libp2pPrivateKey = libp2pPrivateKey;
@ -36,7 +36,7 @@ export class Handshake implements HandshakeInterface {
this.connection = connection;
this.remotePeer = remotePeer;
this.ik = handshake || new IKHandshake();
this.ik = handshake || new IK();
// Dummy data
// TODO: Load remote static keys if found

View File

@ -1,7 +1,7 @@
import { Buffer } from "buffer";
import { Handshake as XXHandshake } from "./handshake-xx";
import { XXHandshake as XX } from "./handshakes/xx";
import { XX } from "./handshakes/xx";
import { KeyPair, PeerId } from "./@types/libp2p";
import { bytes, bytes32 } from "./@types/basic";
import {

View File

@ -1,6 +1,6 @@
import { Buffer } from "buffer";
import { XXHandshake } from "./handshakes/xx";
import { XX } from "./handshakes/xx";
import { KeyPair, PeerId } from "./@types/libp2p";
import { bytes, bytes32 } from "./@types/basic";
import { NoiseSession } from "./@types/handshake";
@ -21,7 +21,7 @@ export class Handshake implements HandshakeInterface {
public session: NoiseSession;
protected connection: WrappedConnection;
protected xx: XXHandshake;
protected xx: XX;
protected libp2pPrivateKey: bytes;
protected libp2pPublicKey: bytes;
@ -37,7 +37,7 @@ export class Handshake implements HandshakeInterface {
staticKeys: KeyPair,
connection: WrappedConnection,
remotePeer: PeerId,
handshake?: XXHandshake,
handshake?: XX,
) {
this.isInitiator = isInitiator;
this.libp2pPrivateKey = libp2pPrivateKey;
@ -47,7 +47,7 @@ export class Handshake implements HandshakeInterface {
this.connection = connection;
this.remotePeer = remotePeer;
this.xx = handshake || new XXHandshake();
this.xx = handshake || new XX();
this.session = this.xx.initSession(this.isInitiator, this.prologue, this.staticKeys);
}

View File

@ -8,7 +8,7 @@ import {AbstractHandshake} from "./abstract-handshake";
import {KeyPair} from "../@types/libp2p";
export class IKHandshake extends AbstractHandshake {
export class IK extends AbstractHandshake {
public initSession(initiator: boolean, prologue: bytes32, s: KeyPair, rs: bytes32): NoiseSession {
const psk = this.createEmptyKey();

View File

@ -3,12 +3,12 @@ import { BN } from 'bn.js';
import { bytes32, bytes } from '../@types/basic'
import { KeyPair } from '../@types/libp2p'
import {generateKeypair, getHkdf, isValidPublicKey} from '../utils';
import {generateKeypair, isValidPublicKey} from '../utils';
import { HandshakeState, MessageBuffer, NoiseSession } from "../@types/handshake";
import {AbstractHandshake} from "./abstract-handshake";
export class XXHandshake extends AbstractHandshake {
export class XX extends AbstractHandshake {
private initializeInitiator(prologue: bytes32, s: KeyPair, rs: bytes32, psk: bytes32): HandshakeState {
const name = "Noise_XX_25519_ChaChaPoly_SHA256";
const ss = this.initializeSymmetric(name);

View File

@ -15,7 +15,6 @@ import { decryptStream, encryptStream } from "./crypto";
import { bytes } from "./@types/basic";
import { NoiseConnection, PeerId, KeyPair, SecureOutbound } from "./@types/libp2p";
import { Duplex } from "./@types/it-pair";
import {XXHandshake} from "./handshakes/xx";
import {HandshakeInterface} from "./@types/handshake-interface";
export type WrappedConnection = ReturnType<typeof Wrap>;