Skip to content

Instantly share code, notes, and snippets.

@webmaster128
Created August 4, 2019 16:16
Show Gist options
  • Save webmaster128/063aa1b2f32ff07545fcf26b9a893982 to your computer and use it in GitHub Desktop.
Save webmaster128/063aa1b2f32ff07545fcf26b9a893982 to your computer and use it in GitHub Desktop.
Split mnemonic in two parts using @iov/crypto
const original = 'dial ring shiver firm connect nominee stairs army large rubber deal crater'
const entropy = Bip39.decode(new EnglishMnemonic(original))
const part1Entropy = await Random.getBytes(entropy.length /* 16 bytes */)
const part2Entropy = entropy.map((byte, index) => byte ^ part1Entropy[index])
const part1 = Bip39.encode(part1Entropy).toString()
// 'pencil accuse tennis element peanut tent venue message process stove glory gym'
const part2 = Bip39.encode(part2Entropy).toString()
// 'panic roof boil axis mom enjoy change margin stove heavy forum food'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment