How do you build elliptical curves over a finite field using matlab

I need to draw an elliptic curve over the final field F17 (in other words, I want to draw some specific points on the curve), but for some reason I do not understand.

The curve is determined by the equation:

y^2 = x^3 +x + 1 (mod 17) 

I tried the path below, but it cannot work.

for x = 0:16, graph (x, mod (sqrt (x ^ 3 + x + 1), 16), 'r') ', end

Can anyone help?

[Update]

As suggested by Nathan and Bill, here is a slightly modified version.

  x = 0:18 plot(mod(x,16), mod(sqrt(x.^3+x+1), 16),'ro') 

However, I believe that the digit WRONG , for example, y is not an integer when x = 4.

enter image description here

+4
source share
3 answers

You must check all points that satisfy the equation y^2 = x^3 +x + 1 (mod 17) . Since this is a finite field, you cannot just take the square root on the right side.

Here's how I do it:

 a=0:16 %all points of your finite field left_side = mod(a.^2,17) %left side of the equation right_side = mod(a.^3+a+1,17) %right side of the equation points = []; %testing if left and right side are the same %(you could probably do something nicer here) 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 plot(points(:,1),points(:,2),'ro') set(gca,'XTick',0:1:16) set(gca,'YTick',0:1:16) grid on; 

elliptic curve

+2
source

Matlab works with vectors natively.

your syntax was close, but should be vectorized:

 x = 0:16 plot(x, mod(sqrt(x.^3+x+1), 16),'r') 

Pay attention to . in x.^3 . This tells Matlab to cube each element x individually, as opposed to raising the vector x to a third power, which means nothing.

0
source

You can use this code if you want to put on real numbers:

 syms xy; v=y^2-x^3-x-1; ezplot(v, [-1,3,-5,5]); 

But, for a plot modulo, first you can write the code below;

 X=[]; for x=[0:16], z=[x; mod(x^3+x+1,17)]; X=[X, z]; end, X, 

Then you can build X with the coordinate matrix.

0
source

Source: https://habr.com/ru/post/1394966/


All Articles