Browse Source

Amended elliptic curve code

crypto
Thomas Johnson 3 years ago
parent
commit
36c4ba5d80
  1. 7
      crypto/WeierstrassCurve.java
  2. 16
      crypto/WeierstrassPoint.java

7
crypto/WeierstrassCurve.java

@ -7,4 +7,11 @@ public class WeierstrassCurve
public BigInteger a;
public BigInteger b;
public BigInteger mod;
public WeierstrassCurve(BigInteger a, BigInteger b, BigInteger mod)
{
this.a = a;
this.b = b;
this.mod = mod;
}
}

16
crypto/WeierstrassPoint.java

@ -52,4 +52,20 @@ public class WeierstrassPoint {
y = x.add(this.x.negate()).multiply(m).add(this.y);
return new WeierstrassPoint(this.curve, x, y);
}
public WeierstrassPoint mult(BigInteger n)
{
if (n.compareTo(BigInteger.ZERO) == 0)
{
return new WeierstrassPoint(this.curve);
}
WeierstrassPoint half = this.mult(n.shiftRight(1));
if (n.getLowestSetBit() == 0)
{
return this.add(half).add(half);
} else
{
return half.add(half);
}
}
}
Loading…
Cancel
Save