mnemonic2Seed method
Convert a mnemonic to a seed. Does not check for validity of the mnemonic - for that, you should manually run check() first.
Implementation
Bip39 mnemonic2Seed([String? passphrase]) {
passphrase = passphrase ?? '';
var mnemonic = this.mnemonic!;
if (!this.check()) {
throw ('Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?');
}
// if (typeof passphrase != 'string') {
// throw ('passphrase must be a string or undefined')
// }
mnemonic = unorm.nfkd(mnemonic);
passphrase = unorm.nfkd(passphrase);
var mbuf = Uint8List.fromList(utf8.encode(mnemonic));
var pbuf = Uint8List.fromList([
...utf8.encode('mnemonic'),
...utf8.encode(passphrase),
]);
// this.seed = pbkdf2.pbkdf2Sync(mbuf, pbuf, 2048, 64, 'sha512')
// final hmacSha512 = HMac(SHA512Digest(), 2048)..init(KeyParameter(mbuf));
// final derivator = PBKDF2KeyDerivator(hmacSha512);
final derivator = KeyDerivator('SHA-512/HMAC/PBKDF2')
..init(Pbkdf2Parameters(pbuf, 2048, 64));
// KeyDerivator('SHA-512/HMAC/PBKDF2')
// ..init(Pbkdf2Parameters(mbuf, 2048, 64))
// ..process(pbuf);
// this.seed = derivator.process(pbuf);
this.seed = derivator.process(mbuf);
return this;
}