fromSeedWithSlip0010 function

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 is 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

Ed25519KeyIdentity fromSeedWithSlip0010(
    Uint8List masterSeed, List<int>? derivationPath,
    {int offset = HARDENED}) {
  var chainSet = generateMasterKey(masterSeed);
  var slipSeed = chainSet.first;
  var chainCode = chainSet.last;

  derivationPath ??= [];

  for (var i = 0; i < derivationPath.length; i++) {
    var newSet = derive(slipSeed, chainCode, derivationPath[i] | offset);
    slipSeed = newSet.first;
    chainCode = newSet.last;
  }
  return Ed25519KeyIdentity.generate(slipSeed);
}