繁体   English   中英

椭圆曲线上的零点

[英]Point zero on an elliptic curve

我正在使用允许使用椭圆曲线的库。 它仍然处于萌芽状态,到目前为止,它仅由EllipticCurvePoint两类组成。

现在,我正在实现存在,所有,求和,反射等基本操作。

不幸的是,我现在不得不实施零概念,即椭圆曲线E的点穿过P和-P的直线,其中P =(x,y)和-P =(x, -y)。 因此,我的问题可以改写为“如何实现无穷远点?”

到目前为止,这是Point类的一部分:

public class Point implements Comparable<Point> {
    private static final BigDecimal MINUSONE = new BigDecimal(-1);

    private BigDecimal x;
    private BigDecimal y;
    private EllipticCurve e;

    public Point(BigDecimal x, BigDecimal y, EllipticCurve e) {
        if(x != null && y != null && e != null) {
            if(liesOn(x,y,e)) {
                this.x = x;
                this.y = y;
                this.e = e;
            }
        }
    }

    public Point reflect() {
        return new Point(x,y.multiply(MINUSONE),e);
    }

    public Point add(Point o) {
        if(this.e == o.getE()) {
            if(this == o) {
                return this.multiply(2);
            }
            if(o == this.reflect()) {
                return /*THE INFAMOUS ZERO POINT*/;
            }

            BigDecimal a;
            BigDecimal b;

            /*
             * computation I still haven't implemented
             */

            return new Point(a,b,e);
        }
    }
    /*
     * other methods
     */
}

PS:我知道java.security.spec.EllipticCurve的存在,但是由于我主要是出于数学目的使用此类,所以我觉得有必要从头创建我的个人库。

使用BigDecimal本身无法表示无穷大。 我知道的Java唯一方法是:

Double.POSITIVE_INFINITY;

IntegerFloat等。您也不能从上面获取valueOf ,因为它将抛出NumberFormatException

您可以使用一种解决方法,即您知道一个非常大的值将始终大于其他任何值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM