Is the serialization output of the buffering protocol fully deterministic?

Given the protocol buffer scheme and some data, is protocol buffer serialization deterministic across libraries and languages?

Basically, I'm sure the same data will serialize sequentially the same way (down to the byte) regardless of the library used?

+4


source to share


1 answer


In general, the same data will be serialized in exactly the same way.

However, this is not guaranteed by the protobuf specifications. For example, the following encoding differences are valid and must decode to the same result in all relevant libraries:



  • Encoding fields in a different order than the order of tag numbers.
  • Encoding packed fields as unpacked.
  • Encoding integers as longer sequences of varint sequences than necessary.
  • Encoding the same (non-repeating) field multiple times.
  • Perhaps others.
+2


source







All Articles