Skip to content

Commit

Permalink
fix/MINT-930 Mnemonic to PK (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlenko authored and dkchv committed Dec 29, 2017
1 parent daa348c commit 6d2e3d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/login/network/NemWallet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import bip39 from 'bip39'
import xor from 'buffer-xor'
import { KeyPair, Address } from './nem/index'

export default class NemWallet {
Expand All @@ -16,6 +17,10 @@ export default class NemWallet {
}

static fromMnemonic (mnemonic, network) {
return new NemWallet(KeyPair.create(bip39.mnemonicToSeed(mnemonic).toString('hex')), network)
const original = bip39.mnemonicToSeedHex(mnemonic)
const part1 = Buffer.from(original.substr(0, 64), 'hex')
const part2 = Buffer.from(original.substr(64, 64), 'hex')
const hex = xor(part1, part2).toString('hex')
return new NemWallet(KeyPair.create(hex), network)
}
}

0 comments on commit 6d2e3d4

Please sign in to comment.