derivePath function

Keys derivePath(
  1. String path,
  2. String seed, {
  3. int offset = HARDENED_OFFSET,
})

Implementation

Keys derivePath(String path, String seed, {int offset = HARDENED_OFFSET}) {
 if (!isValidPath(path)) {
   throw ArgumentError("Invalid derivation path");
 }

 final keys = getMasterKeyFromSeed(seed);
 final segments = path
     .split("/")
     .sublist(1)
     .map(replaceDerive)
     .map((el) => int.parse(el, radix: 10));

 Keys parentKeys = keys;
 for (int i in segments) {
   parentKeys = ckdPriv(parentKeys, i + offset);
 }
 return parentKeys;
}