decodeFromBytes static method

EciesData decodeFromBytes(
  1. Uint8List bytes
)

Implementation

static EciesData decodeFromBytes(Uint8List bytes) {
  int offset = 0;
  int publicKeyLength =
      Int8.decodeFromBytes(bytes.sublist(offset, offset + 1));
  offset++;
  int macLength = Int8.decodeFromBytes(bytes.sublist(offset, offset + 1));
  offset++;
  int originalDataLength =
      Int16.decodeFromBytes(bytes.sublist(offset, offset + 2));
  offset += 2;
  int originaDataLengthIncPadding =
      Int16.decodeFromBytes(bytes.sublist(offset, offset + 2));
  offset += 2;
  Uint8List pubKey = bytes.sublist(offset, offset + publicKeyLength);
  offset += publicKeyLength;
  Uint8List mac = bytes.sublist(offset, offset + macLength);
  offset += macLength;
  Uint8List encryptedData = bytes.sublist(offset);

  return EciesData(
      publicKey: pubKey,
      mac: mac,
      encryptedData: encryptedData,
      originalDataLength: originalDataLength,
      originalDataLengthIncPadding: originaDataLengthIncPadding);
}