# polysum Checksum a set of elements that are randomly distributed in a field. Choose a random element in the field $R$. Call the elements to be checksummed $V = [v_0, v_1, ... v_n]$ The polysum function can be defined as $H = \sum_{i=0}^nv_i*R^i$ In unirep we typically start the polysum at $R^1$ instead of $R^0$ ~~to avoid a zero hash if the first element is 0~~. So for $V = [v_0, v_1, v_2]$ we have $H = v_0*R + v_1*R^2 + v_2*R^3$ ## Safety Inputs to a polysum must _not_ be chosen by a user. A collision can trivially be calculated. In unirep we use hash outputs as inputs to a polysum. In all ZK proofs we calculate the poseidon hash _in the proof_ before using an element in a polysum. Given that $V$ is random over $\mathbb{F}_p$ the collision odds should be $1/p$ based on [Schwartz-Zippel](https://brilliant.org/wiki/schwartz-zippel-lemma/). Note that the degree of $v_0*R + v_1*R^2 + v_2*R^3$ should be $1$ because this is a multivariate linear polynomial.