On Tue, Feb 21, 2017 at 02:00:23PM -0800, Bram Cohen via bitcoin-dev wrote: > When one side of a node is empty and the other contains exactly two things > the secure hash of the child is adopted verbatim rather than rehashing it. > This roughly halves the amount of hashing done, and makes it more resistant > to malicious data, and cleans up some implementation details, at the cost > of some extra complexity. Note that this is a use-case specific concept of an idea I'm calling a "generalized commitment" A commitment scheme needs only have the property that it's not feasible to find two messages m1 and m2 that map to the same commitment; it is *not* required that it be difficult to find m given the commitment. Equally, it's not required that commitments always be the same size. So a perfectly reasonable thing to do is design your scheme such that the commitment to short messages is the message itself! This adds just a single bit of data to the minimum serialized size(1) of the commitment, and in situations where sub-digest-sized messages are common, may overall be a savings. Another advantage is that the scheme becomes more user-friendly: you *want* programmers to notice when a commitment is not effectively hiding the message! If you need message privacy, you should implement an explicit nonce, rather than relying on the data to not be brute-forcable. 1) The more I look at these systems, the more I'm inclined to consider bit-granularity serialization schemes... Heck, sub-bit granularity has advantages too in some cases, e.g. by making all possible inputs to the deserializer be valid. -- https://petertodd.org 'peter'[:-1]@petertodd.org