The idea is brilliant and the math behind supports the argument that for integer inputs it is IMPOSSIBLE to construct a diamond with an inner angle 60 degrees.

The code itself it robust.

I just wrote a stupid one but it is easy to understand.

public class Solution {
public boolean validSquare(int[] p1, int[] p2, int[] p3, int[] p4) {
HashMap<Integer, Integer> map = new HashMap<>();
int a12 = getDistanceSquare(p1, p2);
int a13 = getDistanceSquare(p1, p3);
int a14 = getDistanceSquare(p1, p4);
int a23 = getDistanceSquare(p2, p3);
int a24 = getDistanceSquare(p2, p4);
int a34 = getDistanceSquare(p3, p4);
if (a12 == 0 || a13 == 0 || a14 == 0 || a23 == 0 || a24 == 0 || a34 == 0) return false;
map.put(a12, map.getOrDefault(a12, 0) + 1);
map.put(a13, map.getOrDefault(a13, 0) + 1);
map.put(a14, map.getOrDefault(a14, 0) + 1);
map.put(a23, map.getOrDefault(a23, 0) + 1);
map.put(a24, map.getOrDefault(a24, 0) + 1);
map.put(a34, map.getOrDefault(a34, 0) + 1);
return map.size() == 2 && (map.get(a12) == 2 || map.get(a12) == 4);
}
private int getDistanceSquare(int[] a, int[] b) {
return (a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]);
}
}