如何使用matlab在有限域上绘制椭圆曲线

Mat*_*son 5 matlab cryptography matlab-figure

我需要在有限域F17上画一条椭圆曲线(换句话说,我想在曲线上绘制一些特定的点),但不知怎的,我不能正确.

曲线由以下等式定义:

y^2 = x^3 +x + 1 (mod 17)
Run Code Online (Sandbox Code Playgroud)

我尝试了下面的方法,但它无法正常工作.

对于x = 0:16,绘图(x,mod(sqrt(x ^ 3 + x + 1),16),'r')',结束

有人可以帮忙吗?

[更新]

根据内森和比尔的建议,这是一个略有修改的版本.

 x = 0:18
 plot(mod(x,16), mod(sqrt(x.^3+x+1), 16),'ro')
Run Code Online (Sandbox Code Playgroud)

但是,我觉得这个数字是错误的,例如,当x = 4时,y不是整数.

在此输入图像描述

Luc*_*cas 3

您必须测试满足方程的所有点y^2 = x^3 +x + 1 (mod 17)。由于它是一个有限域,因此不能简单地求右侧的平方根。

这就是我的做法:

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;
Run Code Online (Sandbox Code Playgroud)

椭圆曲线