HDPrivateKey.fromSeed constructor

HDPrivateKey.fromSeed(
  1. Uint8List seed, {
  2. String key = "Bitcoin seed",
})

Generates a master key from a 16-64 byte seed. The default BIP32 HMAC key can also be changed.

Implementation

factory HDPrivateKey.fromSeed(Uint8List seed, { String key = "Bitcoin seed" }) {

  if (seed.length < 16 || seed.length > 64) {
    throw ArgumentError("Seed should be between 16 and 64 bytes", "seed");
  }

  final hash = hmacSha512(utf8.encode("Bitcoin seed"), seed);
  return HDPrivateKey(
    privateKey: ECPrivateKey(hash.sublist(0, 32)),
    chaincode: hash.sublist(32),
    depth: 0, index: 0, parentFingerprint: 0,
  );

}