Fork me on GitHub
#off-topic
<
2017-07-20
>
ghadi14:07:37

Do you know of any "deterministic encoding" schemes -- where the same data structure always encodes to the same byte[]? CBOR has a thing called "canonical encoding" where it sorts map keys that it serializes, but encoder support is usually broken. I'm storing payloads in a Merkle tree, and they have to always SHA to the same output, no matter who generated them

roklenarcic16:07:03

@ghadi any sort of sorted tree walk will always produce the same output

roklenarcic16:07:24

it depends on the datastructure really

roklenarcic16:07:07

naive binary tree will produce different trees for different insert orders, but the data is the same

roklenarcic17:07:42

think of it this way: how would you implement equals for your case