ecKeysfromSeed function

ECKeys ecKeysfromSeed(
  1. Uint8List seed, {
  2. int index = 0,
  3. int coinType = CoinType.icp,
})

Implementation

ECKeys ecKeysfromSeed(
  Uint8List seed, {
  int index = 0,
  int coinType = CoinType.icp,
}) {
  final basePath = getPathWithCoinType(coinType: coinType);
  final node = bip32.BIP32.fromSeed(seed);

  final masterPrv = node.derivePath('$basePath/0/$index');
  final masterPrvRaw = node.derivePath(basePath);
  final xpub = masterPrvRaw.toBase58();

  final prv = masterPrv.privateKey;
  final pub = prv != null ? getPublicFromPrivateKey(prv) : null;
  final pubCompressed = prv != null ? getPublicFromPrivateKey(prv, true) : null;

  return ECKeys(
    ecPrivateKey: prv,
    ecPublicKey: pub,
    ecCompressedPublicKey: pubCompressed,
    extendedECPublicKey: xpub,
  );
}