v12.0.0 - initial commit
This commit is contained in:
commit
e2c49ea43c
1145 changed files with 97211 additions and 0 deletions
19
packages/server/lib/mnemonic-helpers.js
Normal file
19
packages/server/lib/mnemonic-helpers.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
const bip39 = require('bip39')
|
||||
const os = require('os')
|
||||
|
||||
function fromSeed(seed) {
|
||||
const words = bip39.entropyToMnemonic(seed).split(' ')
|
||||
|
||||
let mnemonic = ''
|
||||
for (let i = 0; i < words.length; i += 6) {
|
||||
mnemonic += words.slice(i, i + 6).join(' ') + os.EOL
|
||||
}
|
||||
return mnemonic
|
||||
}
|
||||
|
||||
function toEntropyBuffer(mnemonic) {
|
||||
const hex = bip39.mnemonicToEntropy(mnemonic.split('\n').join(' ').trim())
|
||||
return Buffer.from(hex.trim(), 'hex')
|
||||
}
|
||||
|
||||
module.exports = { toEntropyBuffer, fromSeed }
|
||||
Loading…
Add table
Add a link
Reference in a new issue