UNPKG

node-noise

Version:
45 lines (44 loc) 1.46 kB
import { AbstractHandshake } from './abstract-handshake'; import { NoiseSession } from '../@types/handshake'; import { KeyPair } from '../@types/keypair'; import { bytes, bytes32 } from '../@types/basic'; import { ICryptoInterface } from '../crypto'; import { Uint8ArrayList } from '../uint8arraylist'; export declare enum PatternToken { S = 1, E = 2, EE = 3, ES = 4, SE = 5, SS = 6, F = 7, FF = 8, FLIP_DIR = 255 } export declare enum PatternFlag { FLAG_LOCAL_STATIC = 1, FLAG_LOCAL_EPHEMERAL = 2, FLAG_LOCAL_REQUIRED = 4, FLAG_LOCAL_EPHEM_REQ = 8, FLAG_LOCAL_HYBRID = 16, FLAG_LOCAL_HYBRID_REQ = 32, FLAG_REMOTE_STATIC = 256, FLAG_REMOTE_EPHEMERAL = 512, FLAG_REMOTE_REQUIRED = 1024, FLAG_REMOTE_EPHEM_REQ = 2048, FLAG_REMOTE_HYBRID = 4096, FLAG_REMOTE_HYBRID_REQ = 8192 } export interface Pattern { flags: PatternFlag; steps: PatternToken[]; } export declare const PATTERNS: Readonly<Record<string, Pattern>>; export declare class PatternHandshake extends AbstractHandshake { readonly name: string; readonly pattern: Pattern; constructor(crypto: ICryptoInterface, name: string, pattern: Pattern); initSession(initiator: boolean, prologue: bytes32, s: KeyPair, remotePublicKey: bytes | null): NoiseSession; writeMessage(session: NoiseSession, message: bytes): Uint8ArrayList; readMessage(session: NoiseSession, message: Uint8Array): bytes; }