derivePath method

  1. @override
Zip32Sapling derivePath(
  1. String path,
  2. ZCryptoContext context
)
override

Derives a key along a BIP32 path (e.g., "m/32'/0'/0'").

Implementation

@override
Zip32Sapling derivePath(String path, ZCryptoContext context) {
  final pathInstance = Bip32PathParser.parse(path);

  if (depth.depth > 0 && pathInstance.isAbsolute) {
    throw ArgumentException.invalidOperationArguments(
      "derivePath",
      name: "path",
      reason:
          'Absolute paths can only be derived from a master key, not child ones',
    );
  }
  Zip32Sapling derivedObject = this;

  for (final pathElement in pathInstance.elems) {
    derivedObject = derivedObject.childKey(pathElement, context);
  }
  return derivedObject;
}