Is protobuf serialisation canonical? By that I mean, if I create two proto 
messages from the same version of the proto definition and set the fields 
to the same values, will the two protos serialise to the same sequence of 
bytes?   Regardless of programming language/proto implementation 

The reason I ask is because I'm using serialised single-field protos as 
keys in a Kafka topic and I'm questioning if that's safe.  They key must 
serialise consistently otherwise things that should share a key may end up 
having different keys once serialised.

Is it safe to use protos in this way?  Is it safe to use a subset of protos 
in this way (for example, I think map fields are not canonically 
serilalised, because ordering is not defined, but maybe other field types 
are ok)?



You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to