mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 18:32:22 +00:00
fix lint
This commit is contained in:
parent
94a990a479
commit
6d7be49f55
48
src/xx.ts
48
src/xx.ts
@ -4,43 +4,43 @@ import { AEAD, x25519, HKDF, SHA256 } from 'bcrypto';
|
|||||||
import { BN } from 'bn.js';
|
import { BN } from 'bn.js';
|
||||||
|
|
||||||
export interface KeyPair {
|
export interface KeyPair {
|
||||||
publicKey: bytes32,
|
publicKey: bytes32;
|
||||||
privateKey: bytes32,
|
privateKey: bytes32;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MessageBuffer {
|
interface MessageBuffer {
|
||||||
ne: bytes32,
|
ne: bytes32;
|
||||||
ns: bytes,
|
ns: bytes;
|
||||||
ciphertext: bytes
|
ciphertext: bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
type CipherState = {
|
type CipherState = {
|
||||||
k: bytes32,
|
k: bytes32;
|
||||||
n: uint32,
|
n: uint32;
|
||||||
}
|
}
|
||||||
|
|
||||||
type SymmetricState = {
|
type SymmetricState = {
|
||||||
cs: CipherState,
|
cs: CipherState;
|
||||||
ck: bytes32, // chaining key
|
ck: bytes32; // chaining key
|
||||||
h: bytes32, // handshake hash
|
h: bytes32; // handshake hash
|
||||||
}
|
}
|
||||||
|
|
||||||
type HandshakeState = {
|
type HandshakeState = {
|
||||||
ss: SymmetricState,
|
ss: SymmetricState;
|
||||||
s: KeyPair,
|
s: KeyPair;
|
||||||
e?: KeyPair,
|
e?: KeyPair;
|
||||||
rs: bytes32,
|
rs: bytes32;
|
||||||
re: bytes32,
|
re: bytes32;
|
||||||
psk: bytes32,
|
psk: bytes32;
|
||||||
}
|
}
|
||||||
|
|
||||||
type NoiseSession = {
|
type NoiseSession = {
|
||||||
hs: HandshakeState,
|
hs: HandshakeState;
|
||||||
h?: bytes32,
|
h?: bytes32;
|
||||||
cs1?: CipherState,
|
cs1?: CipherState;
|
||||||
cs2?: CipherState,
|
cs2?: CipherState;
|
||||||
mc: uint64,
|
mc: uint64;
|
||||||
i: boolean,
|
i: boolean;
|
||||||
}
|
}
|
||||||
export type Hkdf = [bytes, bytes, bytes];
|
export type Hkdf = [bytes, bytes, bytes];
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ export class XXHandshake {
|
|||||||
|
|
||||||
private async hashProtocolName(protocolName: bytes): Promise<bytes32> {
|
private async hashProtocolName(protocolName: bytes): Promise<bytes32> {
|
||||||
if (protocolName.length <= 32) {
|
if (protocolName.length <= 32) {
|
||||||
let h = Buffer.alloc(32);
|
const h = Buffer.alloc(32);
|
||||||
protocolName.copy(h);
|
protocolName.copy(h);
|
||||||
return h;
|
return h;
|
||||||
} else {
|
} else {
|
||||||
@ -226,7 +226,7 @@ export class XXHandshake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async writeMessageA(hs: HandshakeState, payload: bytes): Promise<MessageBuffer> {
|
private async writeMessageA(hs: HandshakeState, payload: bytes): Promise<MessageBuffer> {
|
||||||
let ns = Buffer.alloc(0);
|
const ns = Buffer.alloc(0);
|
||||||
hs.e = await this.generateKeypair();
|
hs.e = await this.generateKeypair();
|
||||||
const ne = hs.e.publicKey;
|
const ne = hs.e.publicKey;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user