derive function

Set<Uint8List> derive(
  1. Uint8List parentKey,
  2. Uint8List parentChaincode,
  3. int i
)

Implementation

Set<Uint8List> derive(Uint8List parentKey, Uint8List parentChaincode, int i) {
  // From the spec: Data = 0x00 || ser256(kpar) || ser32(i)
  final data = Uint8List.fromList([0, ...parentKey, ...toBigEndianArray(i)]);
  final hmacSha512 = Hmac(sha512, parentChaincode);
  final h = hmacSha512.convert(data);
  final slipSeed = Uint8List.fromList(h.bytes.sublist(0, 32));
  final chainCode = Uint8List.fromList(h.bytes.sublist(32));
  return {slipSeed, chainCode};
}