fromSeed function

ECKeys fromSeed(
  1. Uint8List seed, {
  2. int index = 0,
})

Implementation

ECKeys fromSeed(Uint8List seed, {int index = 0}) {
  final node = bip32.BIP32.fromSeed(seed);

  var masterPrv = node.derivePath("$ICP_PATH/0/$index");
  var masterPrvRaw = node.derivePath(ICP_PATH);
  final xpub = masterPrvRaw.toBase58();

  final prv = masterPrv.privateKey;

  final pub = prv != null ? getPublicFromPrivateKey(prv, false) : null;
  final pubCompressed = prv != null ? getPublicFromPrivateKey(prv, true) : null;

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