//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
//! SPDX-License-Identifier: GPL-3.0-or-later AND ISC
-import { UnknownNumber, UnknownUint8Array } from "#types"
-
/**
* Implementation derived from blake2b@2.1.4. Copyright 2017 Emil Bay
* <github@tixz.dk> (https://github.com/emilbayes/blake2b). See LICENSES/ISC.txt
* @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) {
+ constructor (length: number, key?: Uint8Array<ArrayBuffer>, salt?: Uint8Array<ArrayBuffer>, personal?: Uint8Array<ArrayBuffer>)
+ constructor (length: unknown, key?: unknown, salt?: unknown, personal?: unknown) {
if (length == null) {
throw new TypeError(`length is required`)
}
*/
export declare class Bip39Mnemonic {
#private
- get phrase (): string
- private constructor ()
+ /**
+ * Derives a mnemonic phrase from source of entropy or seed.
+ *
+ * The entropy must be between 16-32 bytes (32-64 characters) to stay within
+ * the limit of 128-256 bits defined in BIP-39. Typically, wallets use the
+ * maximum entropy allowed.
+ *
+ * @param {(string|ArrayBuffer|Uint8Array<ArrayBuffer>)} entropy - Cryptographically secure random value
+ * @returns {string} Mnemonic phrase created using the BIP-39 wordlist
+ */
+ static fromEntropy (entropy: string | ArrayBuffer | Uint8Array<ArrayBuffer>): Promise<Bip39Mnemonic>
/**
* Imports and validates an existing mnemonic phrase.
*
- * The phrase must be valid according to the BIP-39 specification. Typically
+ * The phrase must be valid according to the BIP-39 specification. Typically,
* wallets use the maximum of 24 words.
*
* @param {string} phrase - String of 12, 15, 18, 21, or 24 words
*/
static fromPhrase (phrase: string): Promise<Bip39Mnemonic>
/**
- * Derives a mnemonic phrase from source of entropy or seed.
+ * Validates a mnemonic phrase meets the BIP-39 specification.
*
- * The entropy must be between 32-64 characters to stay within the defined
- * limit of 128-256 bits. Typically wallets use the maximum entropy allowed.
- *
- * @param {string} entropy - Hexadecimal string
- * @returns {string} Mnemonic phrase created using the BIP-39 wordlist
+ * @param {string} mnemonic - Mnemonic phrase to validate
+ * @returns {boolean} True if the mnemonic phrase is valid
*/
- static fromEntropy (entropy: string): Promise<Bip39Mnemonic>
- /**
- * SHA-256 hash of entropy that is appended to the entropy and subsequently
- * used to generate the mnemonic phrase.
- *
- * @param {Entropy} entropy - Cryptographically strong pseudorandom data of length N bits
- * @returns {Promise<string>} First N/32 bits of the hash as a hexadecimal string
- */
- static checksum (entropy: Entropy): Promise<string>
+ static validate (mnemonic: string): Promise<boolean>
+ get phrase (): string | undefined
+ private constructor ()
/**
- * Erases seed bytes and releases variable references to allow garbage
- * collection.
+ * Erases seed bytes and releases variable references.
*/
destroy (): void
/**
- * Validates a mnemonic phrase.
+ * Converts the mnemonic phrase to a BIP-39 seed.
*
- * @param {string} mnemonic - Mnemonic phrase to validate
- * @returns {boolean} True if the mnemonic phrase is valid
+ * A passphrase string can be specified. If the passphrase is undefined, null,
+ * or not a string, the empty string ("") is used instead.
+ *
+ * @param {string} [passphrase=''] - Used as the PBKDF2 salt. Default: ""
+ * @returns {Promise<Uint8Array<ArrayBuffer>>} Promise for seed as bytes
*/
- static validate (mnemonic: string): Promise<boolean>
toBip39Seed (passphrase: string): Promise<Uint8Array<ArrayBuffer>>
/**
* Converts the mnemonic phrase to a BIP-39 seed.
* or not a string, the empty string ("") is used instead.
*
* @param {string} [passphrase=''] - Used as the PBKDF2 salt. Default: ""
- * @returns {string} Hexadecimal seed
+ * @returns {Promise<string>} Promise for seed as hexadecimal string
*/
toBip39Seed (passphrase: string, format: 'hex'): Promise<string>
+ /**
+ * Converts the mnemonic phrase to a BLAKE2b seed.
+ *
+ * @returns {Promise<Uint8Array<ArrayBuffer>>} Promise for seed as bytes
+ */
toBlake2bSeed (): Promise<Uint8Array<ArrayBuffer>>
/**
* Converts the mnemonic phrase to a BLAKE2b seed.
*
- * @returns {string} Hexadecimal seed
+ * @param {string} format
+ * @returns {Promise<string>} Promise for seed as hexadecimal string
*/
toBlake2bSeed (format: 'hex'): Promise<string>
}
* @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)
+ constructor (length: number, key?: Uint8Array<ArrayBuffer>, salt?: Uint8Array<ArrayBuffer>, personal?: Uint8Array<ArrayBuffer>)
update (input: Uint8Array): Blake2b
digest (): Uint8Array<ArrayBuffer>
digest (out: 'hex'): string
}
export declare const PasskeyWorker: WorkerQueue
-
-export type UnknownNumber = number | unknown
-
-export type UnknownUint8Array = Uint8Array | unknown