encode method

Uint8List encode()

Implementation

Uint8List encode() {
  var servicesBuffer = Uint8List(0);
  services.forEach((String serviceName, Service service) {
    servicesBuffer = concatUint8List(<Uint8List>[
      servicesBuffer,
      Uint8List.fromList(<int>[serviceName.length]),
      Uint8List.fromList(serviceName.codeUnits),
      Uint8List.fromList(<int>[service.derivationPath.length]),
      Uint8List.fromList(service.derivationPath.codeUnits),
      Uint8List.fromList(<int>[crypto.curveToID(service.curve)]),
      Uint8List.fromList(<int>[crypto.hashAlgoToID(service.hashAlgo)]),
    ]);
  });

  return concatUint8List(<Uint8List>[
    toByteArray(version, length: 4),
    Uint8List.fromList(<int>[seed!.length]),
    seed!,
    Uint8List.fromList(<int>[services.length]),
    Uint8List.fromList(servicesBuffer),
  ]);
}