Never Hash With Polynomials

You hash rooted trees to test isomorphism by combining child hashes. What do you combine with?

A

The maximum of the child hashes, taken over the multiset, with a random constant mixed in before and after. Order independence is exactly what a multiset needs, and the merge is O(1)O(1) per node.

B

A shift-xor function applied to each child hash, summed or XORed over the multiset, with a random constant mixed in before and after. A fixed polynomial is guessable, and a setter can build two non-isomorphic trees that collide.

C

A polynomial in a fixed base applied to each child hash, summed over the multiset, with the base chosen once at compile time. Addition is commutative, so the combination is already multiset-safe and therefore already collision-resistant.

D

The plain sum of the child hashes, taken over the multiset, with no constant mixed in before or after. Addition is commutative, which is exactly what a multiset needs, and no setter can predict the child hashes anyway.