Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
This might be a trivial comment, but if you insist on $E\subset \mathbb{Z}$ (it might be better for $E\subset \mathbb{Z}^2$), uniqueness is out of the question: clearly $E$ contains more than one nonzero element, and then $1=x/x = y/y$ for $0\neq x,y\in E$.
It might be nice to consider a generalization of the ideal class group that measures how far a ring is from being a PID. Then you could hope this group is finite, and that the parity of its cardinality solves the problem... just a guess, though.
Yes, the little Fermat part I had figured out already; the part about $p^2$ not being a factor is beyond me, I fear. Ribenboim's book looks interesting, I'll check it out. Thanks for the tip!
I have checked a few cases, and if $m = 2^p-1$, it actually seems the case that $p$ is a factor of $n = \frac{m^2-1}{2}$ and $p^2$ isn't. This even seems to work when $m$ isn't a prime but just the $p$-th Mersenne number with $p$ prime. I can't prove it, though...