fromSeedWithSlip0010 function

Future<Ed25519KeyIdentity> fromSeedWithSlip0010(
  1. Uint8List masterSeed,
  2. List<int>? derivationPath, {
  3. int offset = hardened,
})

Create an Ed25519 according to SLIP 0010: https://github.com/satoshilabs/slips/blob/master/slip-0010.md

The derivation path is an array that always interpreted as a hardened path. e.g. to generate m/44'/223’/0’/0’/0' the derivation path should be 44, 223, 0, 0, 0.

Implementation

Future<Ed25519KeyIdentity> fromSeedWithSlip0010(
  Uint8List masterSeed,
  List<int>? derivationPath, {
  int offset = hardened,
}) {
  final chainSet = generateMasterKey(masterSeed);
  Uint8List slipSeed = chainSet.first;
  Uint8List chainCode = chainSet.last;
  derivationPath ??= [];
  for (int i = 0; i < derivationPath.length; i++) {
    final newSet = derive(slipSeed, chainCode, derivationPath[i] | offset);
    slipSeed = newSet.first;
    chainCode = newSet.last;
  }
  return Ed25519KeyIdentity.generate(slipSeed);
}