@airgap/coinlib-core
Version:
The @airgap/coinlib-core is a protocol agnostic library to prepare, sign and broadcast cryptocurrency transactions.
77 lines (76 loc) • 2.14 kB
TypeScript
/**
* Package blake2b implements BLAKE2b cryptographic hash function.
*/
import { SerializableHash } from "../../../../@stablelib/hash-1.0.1/packages/hash/hash";
export declare const BLOCK_SIZE = 128;
export declare const DIGEST_LENGTH = 64;
export declare const KEY_LENGTH = 64;
export declare const PERSONALIZATION_LENGTH = 16;
export declare const SALT_LENGTH = 16;
export declare const MAX_LEAF_SIZE: number;
export declare const MAX_FANOUT = 255;
export declare const MAX_MAX_DEPTH = 255;
/**
* Configuration for hash function.
*/
export declare type Config = {
key?: Uint8Array;
salt?: Uint8Array;
personalization?: Uint8Array;
tree?: Tree;
};
/**
* Tree hashing parameters.
*/
export declare type Tree = {
fanout: number;
maxDepth: number;
leafSize: number;
nodeOffsetHighBits: number;
nodeOffsetLowBits: number;
nodeDepth: number;
innerDigestLength: number;
lastNode: boolean;
};
/**
* BLAKE2b hash function.
*/
export declare class BLAKE2b implements SerializableHash {
digestLength: number;
readonly blockSize = 128;
private _state;
private _buffer;
private _bufferLength;
private _ctr;
private _flag;
private _lastNode;
private _finished;
private _vtmp;
private _mtmp;
private _paddedKey;
private _initialState;
constructor(digestLength?: number, config?: Config);
reset(): this;
validateConfig(config: Config): void;
update(data: Uint8Array, dataLength?: number): this;
finish(out: Uint8Array): this;
digest(): Uint8Array;
clean(): void;
saveState(): SavedState;
restoreState(savedState: SavedState): this;
cleanSavedState(savedState: SavedState): void;
private _G;
private _incrementCounter;
private _processBlock;
}
export declare type SavedState = {
state: Uint32Array;
buffer: Uint8Array;
bufferLength: number;
ctr: Uint32Array;
flag: Uint32Array;
lastNode: boolean;
paddedKey: Uint8Array | undefined;
initialState: Uint32Array;
};
export declare function hash(data: Uint8Array, digestLength?: number, config?: Config): Uint8Array;