]> git.codecow.com Git - libnemo.git/commitdiff
Add blake type definition.
authorChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 19:55:24 +0000 (12:55 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 19:55:24 +0000 (12:55 -0700)
src/types.d.ts

index 64d87dd2f702fdd6eac16364ecaefd9042d1e65c..5d945fd1a46fc4e098bff998b83ba8b98767cd38 100644 (file)
@@ -216,6 +216,40 @@ export declare class Bip39Mnemonic {
        toBlake2bSeed (format: 'hex'): Promise<string>
 }
 
+/**
+* Implementation derived from blake2b@2.1.4. Copyright 2017 Emil Bay
+* <github@tixz.dk> (https://github.com/emilbayes/blake2b). See LICENSES/ISC.txt
+*
+* Modified to use BigUint64 values, eliminate dependencies, port to TypeScript,
+* and embed in web workers.
+*
+* Original source commit: https://github.com/emilbayes/blake2b/blob/1f63e02e3f226642959506cdaa67c8819ff145cd/index.js
+*/
+export declare class Blake2b {
+       #private
+       static get OUTBYTES_MIN (): 1
+       static get OUTBYTES_MAX (): 64
+       static get KEYBYTES_MIN (): 1
+       static get KEYBYTES_MAX (): 64
+       static get SALTBYTES (): 16
+       static get PERSONALBYTES (): 16
+       static get IV (): bigint[]
+       static get SIGMA (): number[][]
+       /**
+       * Creates a BLAKE2b hashing context.
+       *
+       * @param {number} length - Output length between 1-64 bytes
+       * @param {Uint8Array} [key] - (_optional_) Used for keyed hashing (MAC and PRF)
+       * @param {Uint8Array} [salt] - (_optional_) Used to simplify randomized hashing for digital signatures
+       * @param {Uint8Array} [personal] - (_optional_) Arbitrary user-specified value
+       */
+       constructor (length: UnknownNumber, key?: UnknownUint8Array, salt?: UnknownUint8Array, personal?: UnknownUint8Array)
+       update (input: Uint8Array): Blake2b
+       digest (): Uint8Array<ArrayBuffer>
+       digest (out: 'hex'): string
+       digest (out: 'binary' | Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>
+}
+
 /**
 * Represents a block as defined by the Nano cryptocurrency protocol. The Block
 * class is abstract and cannot be directly instantiated. Every block must be one