I think when the spec says "canonical" it means that this is the official
way of encoding proto messages in JSON, but it doesn't necessarily mean
that the JSON serialization of a particular message will always be exactly
equal in a byte-for-byte comparison. Protobuf doesn't support any canonical
serialization for things like creating a unique hash key.

But actually, if you are just using this for signing then do you really
need the serialization to be unique for a given message? Given the same
message, serializing it twice might result in different output (because for
example, map fields are serialized in an arbitrary order). But that should
be OK just for signing a message. You would only run into trouble if you
need to hash the output and use it as a key into a table or something along
those lines.

On Thu, Feb 14, 2019 at 9:10 AM Zohar Etzioni <[email protected]>
wrote:

> Hello,
>
> I'm looking for a canonical representation for a proto3 message for
> signing. I was hoping I could use the json representation as the proto3
> spec claims it is canonical. Is the proto3 spec for canonical json safe for
> this purpose? if so, is there a recommended method for encoding in json (in
> scala/java)?, if not, is there some other standard canonical format that is
> recommended for using?
>
> Thanks,
> Z
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to