serialize method

  1. @override
String serialize(
  1. int type,
  2. Uint8List sealed,
  3. Uint8List iv, {
  4. Uint8List? senderPublicKey,
})
override

Implementation

@override
String serialize(
  int type,
  Uint8List sealed,
  Uint8List iv, {
  Uint8List? senderPublicKey,
}) {
  List<int> l = [type];

  if (type == EncodeOptions.TYPE_2) {
    l.addAll(sealed);
    return base64Url.encode(l);
  }

  if (type == EncodeOptions.TYPE_1) {
    if (senderPublicKey == null) {
      throw const ReownCoreError(
        code: -1,
        message: 'Missing sender public key for type 1 envelope',
      );
    }

    l.addAll(senderPublicKey);
  }

  // l.addAll(iv);
  l.addAll(sealed);

  return base64Encode(l);
}