mymonero / mymonero-core-js

The JS library containing the Monero crypto plus lightwallet functions behind the official MyMonero apps
BSD 3-Clause "New" or "Revised" License
101 stars 103 forks source link

Japanese mnemonic seed problems ( Encoding? ) #43

Closed Oyshoboy closed 6 years ago

Oyshoboy commented 6 years ago

Hey guys! Using mymonero-core-js to generate wallets. Everything is fine, exept japanese mnemonic seed. Don't know why, but it's giving wrong seeds. By the way other languages are working great!

Here is what I'm having when using "NewlyCreatedWallet()" function:

{"seed":"71734790b2b7bef02130bb8a1e67651a033f783c699c65da662560ecc056b30d","mnemonicString":"のんき しちょう いだく ちきん こもん げんき おどろかす しゅみ いねむり こぼれる ねまき あつめる はんぺん たんじょうび はいけん きれつ おうよう あずかる たいざい そうり ずいぶん さくし こえる さいしょ ずいぶん","keys":{"spend":{"sec":"71734790b2b7bef02130bb8a1e67651a033f783c699c65da662560ecc056b30d","pub":"6bbba9158e9c05c0716c6c0da1f57ef7f69a3f7b901d9ae19b82f63f5aa1099d"},"view":{"sec":"c05cb78f0f85771bb1e424bb2a0b15976dc008ea9f2e0ca09bf96efc16ce930e","pub":"7037e24d5c3675d98310869ba4a5ce02e20732a6f68fc72a5a1f3d4f05386a35"},"public_addr":"45hu7izYuF2ZBwSxpG3K1PiUZATXSfZNRejg9q1Ynf4CTLMFqGh3mcgdP93CV9UUzZ1Uy9DCjM3Dg85sLPW93g5P6zfucDn"}}

Maybe something with encoding?

paulshapiro commented 6 years ago

Hi, I'm going to check into this very shortly. I'm working on replacing all the code associated with this, so want to see what's wrong after that. How did you detect that the seed is wrong?

Oyshoboy commented 6 years ago

@paulshapiro I just generated it using this code : const wallet = walletUtils.NewlyCreatedWallet(lang, 0);

This code I using as well for generating other languages wallets, and all languages are working fine except Japanese.

paulshapiro commented 6 years ago

But how can you tell it's wrong? Those words look fine to me at first glance.

paulshapiro commented 6 years ago

Hi @Oyshoboy,

I've submitted my PR for a fully rebuilt mnemonics system. It has support for all languages supported by Monero src now. Could you go to the branch cpp and try generating a Japanese mnemonic? You can send the locale language code of "ja" to monero_utils.newly_created_wallet(…).

Thanks Paul

Oyshoboy commented 6 years ago

@paulshapiro okay, will check this out, thanks so much!

Also I regognized that it's wrong, when was trying to import this wallet on mymonero.com. Only Japanese occurres an error

Oyshoboy commented 6 years ago

Now i Getting an error: modules.js?hash=03022e3b4ede27b1b81acf4327504a544c539362:142216 Uncaught Not expecting this module to be included in this environment: non-node or web

I'm executing this code on client-side ( previous version works perfect except Japanese ). Here is the code:

const walletUtils = require('mymonero-core-js/monero_utils/_monero_utils_i_nonthrowing');
const wallet = walletUtils.newly_created_wallet('ja')
console.log('## Wallet address:', wallet)
paulshapiro commented 6 years ago

You would never want to access _monero_utils_i_nonthrowing directly. It's specifically used under electron builds. Just include monero_utils as before – it gives you a singleton instance of cryptonote_utils, just as before.

paulshapiro commented 6 years ago

Looks fixed now, in any case…

Feel free to comment and reopen

newly_created_wallet { mnemonic_string: 'そつぎょう てまえ いたずら にんそう にんよう そうび はけん うける くどく ぎゅうにく いっぽう たろっと ねんかん うつる そろう さとし はんぱ あさい たくさん いりょう ひいき そまる しっかり じどう たろっと',
  mnemonic_language: '日本語',
  sec_seed_string: '9ed75e4218dfcbb9a432a8341a96dba3ab862f88664720058367fae833e63c01',
  address_string: '48SmJdBWnqMhjH6MCgA7pS8CaT64pWfaSf8R2N2fBZaCQVujT8A1e1597JCRvHVwvEFb5YJx8QdTThjwEsStsjkyMpyJSPv',
  pub_viewKey_string: '7ceac9791c16a8307a58a29feeafa757369aedf98e7936f391f29bc5057f7eb8',
  sec_viewKey_string: '9d4765c0349bb47b2542ddd4944d0d17782000d421c2c4e9242dbd7202728504',
  pub_spendKey_string: 'b403218dc0d130f3809788a0ead5cf2b0b289227774383e3f38f745986eb558c',
  sec_spendKey_string: '9ed75e4218dfcbb9a432a8341a96dba3ab862f88664720058367fae833e63c01' }
seed_and_keys_from_mnemonic { mnemonic_string: 'そつぎょう てまえ いたずら にんそう にんよう そうび はけん うける くどく ぎゅうにく いっぽう たろっと ねんかん うつる そろう さとし はんぱ あさい たくさん いりょう ひいき そまる しっかり じどう たろっと',
  mnemonic_language: '日本語',
  sec_seed_string: '9ed75e4218dfcbb9a432a8341a96dba3ab862f88664720058367fae833e63c01',
  address_string: '48SmJdBWnqMhjH6MCgA7pS8CaT64pWfaSf8R2N2fBZaCQVujT8A1e1597JCRvHVwvEFb5YJx8QdTThjwEsStsjkyMpyJSPv',
  pub_viewKey_string: '7ceac9791c16a8307a58a29feeafa757369aedf98e7936f391f29bc5057f7eb8',
  sec_viewKey_string: '9d4765c0349bb47b2542ddd4944d0d17782000d421c2c4e9242dbd7202728504',
  pub_spendKey_string: 'b403218dc0d130f3809788a0ead5cf2b0b289227774383e3f38f745986eb558c',
  sec_spendKey_string: '9ed75e4218dfcbb9a432a8341a96dba3ab862f88664720058367fae833e63c01' }