Merkle hash implementation. Needs testing.