Small style changes

This commit is contained in:
Joel Torstensson
2018-05-14 15:12:43 +02:00
parent 0436c73b5d
commit 6816088212

View File

@@ -5,7 +5,8 @@ const SECRET_LENGTH = 64
const lengthToPrefix = { 64: '', 56: 'd', 48: 'c', 40: 'b', 32: 'a' }
const prefixToLength = { '': 64, 'd': 56, 'c': 48, 'b': 40, 'a': 32 }
const getExtraEntopy = length => bip39.mnemonicToEntropy(bip39.generateMnemonic(128)).substring(0, SECRET_LENGTH - length)
const getExtraEntopy = length => bip39.mnemonicToEntropy(
bip39.generateMnemonic(SECRET_LENGTH * 2)).substring(0, SECRET_LENGTH - length)
async function split(seed, numShards, threshold) {
@@ -30,7 +31,7 @@ async function combine(shardMnemonics) {
let prefix = ""
let shards = shardMnemonics.map(sm => {
if (!bip39.validateMnemonic(sm.split(' ').slice(1).join(' '))) {
throw new Error('Invalid mnemonic')
throw new Error('Invalid mnemonic ' + sm.split(' ')[0])
}
let buf = new Buffer.from('00' + bip39.mnemonicToEntropy(sm.split(' ').slice(1).join(' ')), 'hex')