MATLAB: I have some elliptic curve points as (x y) . How can i extract just y values of all the points

seperation of right hand points

e.g if i have
disp('y^2 = x^3 + 537x + 2438 mod 123457')
a=0:123456
left_side = mod(a.^2,123457);
right_side = mod(a.^3+537*a+2438,123457);
points = [];
for i = 1:length(right_side)
I = find(left_side == right_side(i));
for j=1:length(I)
points = [points;a(i),a(I(j))];
end
end
How can i extract a(I(j)) values i.e if we have… points=[(0 13456) (1 23455) (3 78965) …] i want the answer as [13456 23455 78965 …]

Best Answer

p = 123457;
a = (0:p-1);
y2 = mod(a.^2,p);
z = mod(a.^3+537*a+2438,p);
[b,i] = ismember(y2,intersect(z,y2));
y = a(i(b))
edit: fix a bug