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

标签 matlab cryptography matlab-figure

我需要在有限域 F17 上绘制一条椭圆曲线(换句话说,我想在曲线上绘制一些特定的点),但不知何故我没有做对。

曲线由等式定义:

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

我试过下面的方法,还是不行。

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

有人可以帮忙吗?

[更新]

根据 Nathan 和 Bill 的建议,这里有一个稍微修改的版本。

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

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

enter image description here

最佳答案

您必须测试满足方程 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;

elliptic curve

关于matlab - 你如何使用matlab在有限域上绘制椭圆曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9156782/

相关文章:

matlab - 如果 y 方向设置为 'reverse',如何修复 Matlab 中矢量注释头的错误对齐

c - MATLAB Coder 动态调整大小的结构数组

matlab - 如何在mac终端运行matlab脚本

matlab - 生成1到10之间的随机数,matlab中的单个数字除外

ruby - 使用 Golang 和 Ruby 加密和解密 AES

c++ - 如何使用 cryptoAPI 进行 AES CBC 加密

java - Bouncy CaSTLe ECC Key Pair Generation为EC公钥点坐标生成不同大小

algorithm - 在 Matlab 中绘制轮廓图需要帮助

matlab - 在消息框中显示变量的值

matlab - 从 Octave 保存 .fig 文件