0

I have a mnemonic phrase generated by the bip39 tool.

(The prior use case was that program uses the public keys in an array and people send to the one they randomly get. Occassionally when an address gets funds an admin goes and retrieves the private key to move the funds)

In any case, one of the addresses in the high hundreds does not import. Its private key gets an error that it is malformed.

Expected private key to be an Uint8Array with length 32

What can I do about that? This is the first time I've encountered that and the other private keys from this mnemonic phrase and derivation path work.

It seems like I could simply import the mnemonic phrase itself and add that many accounts, but this will be very time consuming. So, it also seems like a glitch, so reporting it here.

edit: I imported the mnemonic phrase into metamask, and recorded a screen macro of importing accounts, which I let run for several hundred times until the address I wanted was added. There is no batch feature in metamask as metamask's features are based on what most people do. Metamask was able to resolve that address and sign and broadcast transactions, which you would think must use the same private key. I guess there is no actual error with the private key, only library validation of it, which should be further investigated.

6
  • What library are you using to derive the key from the seed? It appears to be a bug in the implementation. I'd try another library or other programming language.
    – Ismael
    Oct 28, 2021 at 20:05
  • You should post what you have done. Deriving an address from the node with ethers is like 5 lines of codes. Oct 29, 2021 at 4:04
  • @MadeInDreams I used Ian Coleman's Bip39 tool which allows me to view an infinite number of addresses, public keys, and private key, for any particular seed phrase and derivation path. I tried to manually import a private key by copy and pasting it from the list into Metamask's import, and Metamask gave the import error. Seeding Metamask with the mnemonic phrase and simply adding the addresses until I reached that index did allow it to work properly. Seems more like a Metamask (or whatever validation library it is using) glitch but likely a common glitch that has just gone unnotticed
    – CQM
    Oct 29, 2021 at 14:28
  • But from the seed you create a node from which you derive the addresses right? Oct 29, 2021 at 20:01
  • @MadeInDreams what do you mean by node? its a mnemonic phrase + a derivation path that generates all the addresses.
    – CQM
    Oct 29, 2021 at 22:33

1 Answer 1

0
+100

Try to generate the addresses this way. Pass your Bip39 seed to it. Generate as much addresses. let me know if the issue persist

import ethers from 'ethers'
    const ethHDW = async (seed) =>{
        return new Promise(resolve => {
    
            const ethNode = ethers.utils.HDNode.fromSeed(seed)
            const derived =  ethNode.derivePath("m/44'/60'/0'/0/0")
    
            resolve(derived)
        })
    }

For each address you increase the last 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.