]> git.codecow.com Git - libnemo.git/commitdiff
Start taking only string passwords.
authorChris Duncan <chris@zoso.dev>
Sun, 27 Jul 2025 08:28:34 +0000 (01:28 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 27 Jul 2025 08:28:34 +0000 (01:28 -0700)
src/lib/wallets/bip44-wallet.ts
src/lib/wallets/blake2b-wallet.ts

index 8490ca7923ee44a5fe57c8415606ec3da75f4e38..87ad89432777b4236299b4b6e4242d03fa20c48c 100644 (file)
@@ -78,19 +78,7 @@ export class Bip44Wallet extends Wallet {
        * @param {string} [salt=''] - Used when generating the final seed\r
        * @returns {Bip44Wallet} A newly instantiated Bip44Wallet\r
        */\r
-       static async fromEntropy (password: string, entropy: string, salt?: string): Promise<Bip44Wallet>\r
-       /**\r
-       * Creates a new HD wallet by using a pregenerated entropy value. The user\r
-       * must ensure that it is cryptographically strongly random.\r
-       *\r
-       * @param {Uint8Array} key - Used to lock and unlock the wallet\r
-       * @param {string} entropy - Used when generating the initial mnemonic phrase\r
-       * @param {string} [salt=''] - Used when generating the final seed\r
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet\r
-       */\r
-       static async fromEntropy (key: Uint8Array<ArrayBuffer>, entropy: string, salt?: string): Promise<Bip44Wallet>\r
-       static async fromEntropy (passkey: Key, entropy: string, salt: string = ''): Promise<Bip44Wallet> {\r
-               if (typeof passkey === 'string') passkey = utf8.toBytes(passkey)\r
+       static async fromEntropy (password: string, entropy: string, salt: string = ''): Promise<Bip44Wallet> {\r
                let wallet: Bip44Wallet\r
                try {\r
                        const id = await Entropy.create()\r
@@ -103,7 +91,7 @@ export class Bip44Wallet extends Wallet {
                        throw new Error('Error importing Bip44Wallet from entropy', { cause: err })\r
                }\r
                try {\r
-                       await wallet.lock(passkey)\r
+                       await wallet.lock(password)\r
                } catch (err) {\r
                        await wallet.destroy()\r
                        throw new Error('Error locking Bip44Wallet while importing from entropy', { cause: err })\r
@@ -119,18 +107,7 @@ export class Bip44Wallet extends Wallet {
        * @param {string} [salt=''] - Used when generating the final seed\r
        * @returns {Bip44Wallet} A newly instantiated Bip44Wallet\r
        */\r
-       static async fromMnemonic (password: string, mnemonic: string, salt?: string): Promise<Bip44Wallet>\r
-       /**\r
-       * Creates a new HD wallet by using a pregenerated mnemonic phrase.\r
-       *\r
-       * @param {Uint8Array} key - Used to lock and unlock the wallet\r
-       * @param {string} mnemonic - Used when generating the final seed\r
-       * @param {string} [salt=''] - Used when generating the final seed\r
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet\r
-       */\r
-       static async fromMnemonic (key: Uint8Array<ArrayBuffer>, mnemonic: string, salt?: string): Promise<Bip44Wallet>\r
-       static async fromMnemonic (passkey: Key, mnemonic: string, salt: string = ''): Promise<Bip44Wallet> {\r
-               if (typeof passkey === 'string') passkey = utf8.toBytes(passkey)\r
+       static async fromMnemonic (password: string, mnemonic: string, salt: string = ''): Promise<Bip44Wallet> {\r
                let wallet: Bip44Wallet\r
                try {\r
                        const id = await Entropy.create()\r
@@ -142,7 +119,7 @@ export class Bip44Wallet extends Wallet {
                        throw new Error('Error importing Bip44Wallet from mnemonic', { cause: err })\r
                }\r
                try {\r
-                       await wallet.lock(passkey)\r
+                       await wallet.lock(password)\r
                } catch (err) {\r
                        await wallet.destroy()\r
                        throw new Error('Error locking Bip44Wallet while importing from mnemonic', { cause: err })\r
@@ -159,19 +136,7 @@ export class Bip44Wallet extends Wallet {
        * @param {string} seed - Hexadecimal 128-character string used to derive private-public key pairs\r
        * @returns {Bip44Wallet} A newly instantiated Bip44Wallet\r
        */\r
-       static async fromSeed (password: string, seed: string): Promise<Bip44Wallet>\r
-       /**\r
-       * Creates a new HD wallet by using a pregenerated seed value. This seed cannot\r
-       * be used to regenerate any higher level randomness which includes entropy,\r
-       * mnemonic phrase, and salt.\r
-       *\r
-       * @param {Uint8Array} key - Used to lock and unlock the wallet\r
-       * @param {string} seed - Hexadecimal 128-character string used to derive private-public key pairs\r
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet\r
-       */\r
-       static async fromSeed (key: Uint8Array<ArrayBuffer>, seed: string): Promise<Bip44Wallet>\r
-       static async fromSeed (passkey: Key, seed: string): Promise<Bip44Wallet> {\r
-               if (typeof passkey === 'string') passkey = utf8.toBytes(passkey)\r
+       static async fromSeed (password: string, seed: string): Promise<Bip44Wallet> {\r
                if (seed.length !== SEED_LENGTH_BIP44) {\r
                        throw new Error(`Expected a ${SEED_LENGTH_BIP44}-character seed, but received ${seed.length}-character string.`)\r
                }\r
@@ -182,7 +147,7 @@ export class Bip44Wallet extends Wallet {
                Bip44Wallet.#isInternal = true\r
                const wallet = new this(id, hex.toBytes(seed))\r
                try {\r
-                       await wallet.lock(passkey)\r
+                       await wallet.lock(password)\r
                } catch (err) {\r
                        await wallet.destroy()\r
                        throw new Error('Error locking Bip44Wallet while importing from seed', { cause: err })\r
index 3b465fba4fc9e988a89ba02681fa649e66a7df59..87b906c6d74f48824767ecb032a826ec30cad008 100644 (file)
@@ -69,18 +69,7 @@ export class Blake2bWallet extends Wallet {
        * @param {string} seed - Hexadecimal 64-character string used to derive private-public key pairs\r
        * @returns {Blake2bWallet} A newly instantiated Blake2bWallet\r
        */\r
-       static async fromSeed (password: string, seed: string): Promise<Blake2bWallet>\r
-       /**\r
-       * Creates a new BLAKE2b wallet by using a pregenerated seed. The user must\r
-       * ensure that it is cryptographically strongly random.\r
-       *\r
-       * @param {Uint8Array} key - Used to lock and unlock the wallet\r
-       * @param {string} seed - Hexadecimal 64-character string used to derive private-public key pairs\r
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet\r
-       */\r
-       static async fromSeed (key: Uint8Array<ArrayBuffer>, seed: string): Promise<Blake2bWallet>\r
-       static async fromSeed (passkey: Key, seed: string): Promise<Blake2bWallet> {\r
-               if (typeof passkey === 'string') passkey = utf8.toBytes(passkey)\r
+       static async fromSeed (password: string, seed: string): Promise<Blake2bWallet> {\r
                if (seed.length !== SEED_LENGTH_BLAKE2B) {\r
                        throw new Error(`Expected a ${SEED_LENGTH_BLAKE2B}-character seed, but received ${seed.length}-character string.`)\r
                }\r
@@ -94,7 +83,7 @@ export class Blake2bWallet extends Wallet {
                Blake2bWallet.#isInternal = true\r
                const wallet = new this(id, s, m)\r
                try {\r
-                       await wallet.lock(passkey)\r
+                       await wallet.lock(password)\r
                } catch (err) {\r
                        await wallet.destroy()\r
                        throw new Error('Error locking Blake2bWallet while importing from seed', { cause: err })\r
@@ -109,17 +98,7 @@ export class Blake2bWallet extends Wallet {
        * @param {string} mnemonic - Used when generating the final seed\r
        * @returns {Blake2bWallet} A newly instantiated Blake2bWallet\r
        */\r
-       static async fromMnemonic (password: string, mnemonic: string): Promise<Blake2bWallet>\r
-       /**\r
-       * Creates a new BLAKE2b wallet by using a pregenerated mnemonic phrase.\r
-       *\r
-       * @param {Uint8Array} key - Used to lock and unlock the wallet\r
-       * @param {string} mnemonic - Used when generating the final seed\r
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet\r
-       */\r
-       static async fromMnemonic (key: Uint8Array<ArrayBuffer>, mnemonic: string): Promise<Blake2bWallet>\r
-       static async fromMnemonic (passkey: Key, mnemonic: string): Promise<Blake2bWallet> {\r
-               if (typeof passkey === 'string') passkey = utf8.toBytes(passkey)\r
+       static async fromMnemonic (password: string, mnemonic: string): Promise<Blake2bWallet> {\r
                let wallet: Blake2bWallet\r
                try {\r
                        const id = await Entropy.create()\r
@@ -131,7 +110,7 @@ export class Blake2bWallet extends Wallet {
                        throw new Error('Error importing Blake2bWallet from mnemonic', { cause: err })\r
                }\r
                try {\r
-                       await wallet.lock(passkey)\r
+                       await wallet.lock(password)\r
                } catch (err) {\r
                        await wallet.destroy()\r
                        throw new Error('Error locking Blake2bWallet while importing from mnemonic', { cause: err })\r