seedFromEntropy static method

Future<List<int>> seedFromEntropy(
  1. List<int> entropy, {
  2. String? password,
})

Similar to miniSecretFromEntropy, except that it provides the 64-byte seed directly.

Implementation

static Future<List<int>> seedFromEntropy(List<int> entropy,
    {String? password}) async {
  if (entropy.length < 16 || entropy.length > 32 || entropy.length % 4 != 0) {
    throw SubstrateBip39Exception.invalidEntropy(
        'InvalidEntropy: byte length must be between 16 and 32 and multiple of 4');
  }

  final salt = 'mnemonic${password ?? ''}';
  final pbkdf2 =
      Pbkdf2(macAlgorithm: Hmac.sha512(), iterations: 2048, bits: 512);

  final secret = await pbkdf2.deriveKey(
    secretKey: SecretKey(entropy),
    nonce: utf8.encode(salt),
  );

  return secret.extractBytes();
}