question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

encrypt wallet with Mnemonic Spanish language

See original GitHub issue

Hi, I’m trying to encrypt a wallet created with Mnemonic in Spanish and I get some errors. The strange thing is that if I do it in English works perfect. First I have tried the following code:

import { ethers } from 'ethers';
import { es } from 'ethers/wordlists';

private async all(){
    const randomBytes = ethers.utils.randomBytes(24);
    const mnemonic =  ethers.utils.HDNode.entropyToMnemonic(randomBytes, es);
    const wallet = ethers.Wallet.fromMnemonic(mnemonic, null, es);
    const json = await wallet.encrypt("123");
    return json;
  }

And I get the following error:

ERROR Error: Uncaught (in promise): Error: entropy and mnemonic mismatch
Error: entropy and mnemonic mismatch
    at Object.r.encrypt (ethers.min.js:1)
    at _.encrypt (ethers.min.js:1)
    at WalletService.<anonymous> (wallet.service.ts:81)
    at Generator.next (<anonymous>)
    at tslib.es6.js:73
    at new ZoneAwarePromise (zone-evergreen.js:876)
    at Module.__awaiter (tslib.es6.js:69)
    at WalletService.all (wallet.service.ts:76)
    at WalletService.<anonymous> (wallet.service.ts:46)
    at Generator.next (<anonymous>)
    at resolvePromise (zone-evergreen.js:797)
    at zone-evergreen.js:707
    at rejected (tslib.es6.js:71)
    at ZoneDelegate.invoke (zone-evergreen.js:359)
    at Object.onInvoke (core.js:39699)
    at ZoneDelegate.invoke (zone-evergreen.js:358)
    at Zone.run (zone-evergreen.js:124)
    at zone-evergreen.js:855
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39680)

The second code I have tried is:

 private async all(){
    const randomBytes = ethers.utils.randomBytes(24);
    const mnemonic =  ethers.utils.HDNode.entropyToMnemonic(randomBytes, es);
    const entropy = ethers.utils.HDNode.mnemonicToEntropy(mnemonic, es);
    const wallet = ethers.Wallet.fromMnemonic(mnemonic, null, es);
    const json = await wallet.encrypt("123", {entropy: entropy}); 
    return json;
  }

and I get the following error:

ERROR Error: Uncaught (in promise): Error: entropy and mnemonic mismatch
Error: entropy and mnemonic mismatch
    at Object.r.encrypt (ethers.min.js:1)
    at _.encrypt (ethers.min.js:1)
    at WalletService.<anonymous> (wallet.service.ts:81)
    at Generator.next (<anonymous>)
    at tslib.es6.js:73
    at new ZoneAwarePromise (zone-evergreen.js:876)
    at Module.__awaiter (tslib.es6.js:69)
    at WalletService.all (wallet.service.ts:76)
    at WalletService.<anonymous> (wallet.service.ts:46)
    at Generator.next (<anonymous>)
    at resolvePromise (zone-evergreen.js:797)
    at zone-evergreen.js:707
    at rejected (tslib.es6.js:71)
    at ZoneDelegate.invoke (zone-evergreen.js:359)
    at Object.onInvoke (core.js:39699)
    at ZoneDelegate.invoke (zone-evergreen.js:358)
    at Zone.run (zone-evergreen.js:124)
    at zone-evergreen.js:855
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39680)

What I’m doing wrong??? Thanks in advance 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Dec 15, 2019

I’ve confirmed this is an issue in v4 and v5. I am trying to figure out a backwards-compatible fix that is safe.

Since v5 is not officially released yet, backwards compatibility isn’t as important, so I may fix it there first to try out a few ideas.

I’ll keep this ticket updated and sorry for the inconvenience.

0reactions
ricmoocommented, Jun 4, 2020

I have no idea what that error means. Maybe there is more info in the react documentation?

Also, where are you getting the es from? If you are using the dist files, make sure you are using the -all variant which includes all languages. The normal dist file only includes English. Similar things may happen if you use the browser mainField in rollup. Do a console.log on the 'es` object to make sure it is a Wordlist object…

Let me know. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to store private keys and mnemonic seed - Atomic Wallet
Do you know how to protect you private keys? Check this article and learn how to safely store the seed phrase and private...
Read more >
The Journey from Secret Recovery Phrase (Mnemonic Phrase ...
Secret recovery phrases (or mnemonic phrases) may seem very simple at ... wordlists in different languages (e.g. English, Chinese, Spanish).
Read more >
How the Pitfalls of Mnemonic Phrases Are Solved ... - LinkedIn
The advice here is to really avoid wallets with low quality key generation processes. The ECB encryption mode is used for the key...
Read more >
BIP39 - Mnemonic Code - iancoleman.io
More info · BIP39 Mnemonic code for generating deterministic keys · BIP32 Hierarchical Deterministic Wallets · BIP44 Multi-Account Hierarchy for Deterministic ...
Read more >
Can't import seed: seed phrase in Spanish (12 Spanish words)
Today, I cannot import that seed into the wallet, same app: it returns error "invalid mnemonic". I have tried: Importing in Electron Cash: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found