Bip32.fromSeed constructor

Bip32.fromSeed(
  1. Uint8List seed
)

Implementation

factory Bip32.fromSeed(Uint8List seed) {
  if (seed.length < 16) {
    throw ArgumentError('Seed should be at least 128 bits');
  }

  if (seed.length > 64) {
    throw ArgumentError('Seed should be at most 512 bits');
  }

  final bitcointSeedKey = Uint8List.fromList('Bitcoin seed'.codeUnits);
  final hmac = HMac(SHA512Digest(), 128)..init(KeyParameter(bitcointSeedKey));

  final i = hmac.process(seed);
  final iL = i.sublist(0, 32);
  final iR = i.sublist(32);

  return Bip32.fromPrivateKey(privateKey: iL, chainCode: iR);
}