mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 15:12:32 +00:00
Move handshake types to separate file
This commit is contained in:
parent
e66ee7d677
commit
dbbf579288
39
src/@types/handshake.ts
Normal file
39
src/@types/handshake.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import {bytes, bytes32, uint32, uint64} from "./basic";
|
||||
import {KeyPair} from "./libp2p";
|
||||
|
||||
export type Hkdf = [bytes, bytes, bytes];
|
||||
|
||||
export interface MessageBuffer {
|
||||
ne: bytes32;
|
||||
ns: bytes;
|
||||
ciphertext: bytes;
|
||||
}
|
||||
|
||||
export type CipherState = {
|
||||
k: bytes32;
|
||||
n: uint32;
|
||||
}
|
||||
|
||||
export type SymmetricState = {
|
||||
cs: CipherState;
|
||||
ck: bytes32; // chaining key
|
||||
h: bytes32; // handshake hash
|
||||
}
|
||||
|
||||
export type HandshakeState = {
|
||||
ss: SymmetricState;
|
||||
s: KeyPair;
|
||||
e?: KeyPair;
|
||||
rs: bytes32;
|
||||
re: bytes32;
|
||||
psk: bytes32;
|
||||
}
|
||||
|
||||
export type NoiseSession = {
|
||||
hs: HandshakeState;
|
||||
h?: bytes32;
|
||||
cs1?: CipherState;
|
||||
cs2?: CipherState;
|
||||
mc: uint64;
|
||||
i: boolean;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import {Buffer} from "buffer";
|
||||
import {bytes} from "./@types/basic";
|
||||
import {MessageBuffer} from "./handshakes/xx";
|
||||
import {MessageBuffer} from "./@types/handshake";
|
||||
|
||||
export const int16BEEncode = (value, target, offset) => {
|
||||
target = target || Buffer.allocUnsafe(2);
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Buffer } from "buffer";
|
||||
|
||||
import { bytes, bytes32 } from "./@types/basic";
|
||||
import { NoiseSession, XXHandshake } from "./handshakes/xx";
|
||||
import { XXHandshake } from "./handshakes/xx";
|
||||
import { KeyPair, PeerId } from "./@types/libp2p";
|
||||
import { bytes, bytes32 } from "./@types/basic";
|
||||
import { NoiseSession } from "./@types/handshake";
|
||||
import {
|
||||
createHandshakePayload,
|
||||
getHandshakePayload,
|
||||
|
@ -5,42 +5,8 @@ import { BN } from 'bn.js';
|
||||
import { bytes32, uint32, uint64, bytes } from '../@types/basic'
|
||||
import { KeyPair } from '../@types/libp2p'
|
||||
import { generateKeypair } from '../utils';
|
||||
import { CipherState, HandshakeState, Hkdf, MessageBuffer, NoiseSession, SymmetricState } from "../@types/handshake";
|
||||
|
||||
export interface MessageBuffer {
|
||||
ne: bytes32;
|
||||
ns: bytes;
|
||||
ciphertext: bytes;
|
||||
}
|
||||
|
||||
type CipherState = {
|
||||
k: bytes32;
|
||||
n: uint32;
|
||||
}
|
||||
|
||||
type SymmetricState = {
|
||||
cs: CipherState;
|
||||
ck: bytes32; // chaining key
|
||||
h: bytes32; // handshake hash
|
||||
}
|
||||
|
||||
type HandshakeState = {
|
||||
ss: SymmetricState;
|
||||
s: KeyPair;
|
||||
e?: KeyPair;
|
||||
rs: bytes32;
|
||||
re: bytes32;
|
||||
psk: bytes32;
|
||||
}
|
||||
|
||||
export type NoiseSession = {
|
||||
hs: HandshakeState;
|
||||
h?: bytes32;
|
||||
cs1?: CipherState;
|
||||
cs2?: CipherState;
|
||||
mc: uint64;
|
||||
i: boolean;
|
||||
}
|
||||
export type Hkdf = [bytes, bytes, bytes];
|
||||
|
||||
const minNonce = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user