我正在尝试在 P192r1 的素数字段上实现标量乘法。通过使用从java Scalar Multiplication借来的代码,点加法工作得很好
但是关于我从那个链接再次使用代码的点加倍,它没有得到正确的结果。我试图找出错误,但我找不到。有没有人已经解决了这个错误。
`public static ECPoint doublePoint(ECPoint r) {
// TODO Auto-generated method stub
BigInteger ONE = new BigInteger("1");;
BigInteger TWO = new BigInteger("2");
BigInteger p = new BigInteger("6277101735386680763835789423207666416083908700390324961279");
BigInteger slope = (r.getAffineX().pow(2)).multiply(new BigInteger("3"));
slope = slope.add(new BigInteger("3"));
slope = slope.multiply((r.getAffineY().multiply(TWO)).modInverse(p));
BigInteger Xout = slope.pow(2).subtract(r.getAffineX().multiply(new BigInteger("2"))).mod(p);
BigInteger Yout = (r.getAffineY().negate()).add(slope.multiply(r.getAffineX().subtract(Xout))).mod(p);
ECPoint out = new ECPoint(Xout, Yout);
return out;
}`