marshal method

  1. @override
Uint8List marshal()
override

Returns the protobuf bytes of the key

Implementation

@override
Uint8List marshal() {
  final publicKeyBytes = publicKey.raw;

  // Create a dummy private key (32 zeros) followed by the real public key
  final combined = Uint8List(32 + publicKeyBytes.length);
  // Leave the first 32 bytes as zeros (dummy private key)
  combined.setRange(32, combined.length, publicKeyBytes);

  final pbKey = pb.PrivateKey(
    type: type,
    data: combined,
  );

  return pbKey.writeToBuffer();
}