Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/starkbank/ellipticcurve/Curve.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public boolean contains(Point p) {
return false;
}
// y^2 - (x^3 + A*x + B) mod P == 0
BigInteger lhs = p.y.modPow(BigInteger.TWO, this.P);
BigInteger lhs = p.y.modPow(BigInteger.valueOf(2), this.P);
BigInteger rhs = p.x.modPow(BigInteger.valueOf(3), this.P)
.add(this.A.multiply(p.x))
.add(this.B)
Expand Down Expand Up @@ -148,7 +148,7 @@ public BigInteger y(BigInteger x, boolean isEven) {
.add(this.B)
.mod(this.P);
BigInteger y = Math.modularSquareRoot(ySquared, this.P);
if (isEven != y.mod(BigInteger.TWO).equals(BigInteger.ZERO)) {
if (isEven != y.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) {
y = this.P.subtract(y);
}
return y;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/starkbank/ellipticcurve/PublicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public String toString(boolean encoded) {
*/
public String toCompressed() {
int baseLength = 2 * curve.length();
String parityTag = point.y.mod(BigInteger.TWO).equals(BigInteger.ZERO) ? EVEN_TAG : ODD_TAG;
String parityTag = point.y.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO) ? EVEN_TAG : ODD_TAG;
String xHex = leftPad(point.x.toString(16), baseLength);
return parityTag + xHex;
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/starkbank/ellipticcurve/SecurityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public void testPrimeCongruent1Mod4() {
BigInteger P = BigInteger.valueOf(17);
for (int value = 1; value < 17; value++) {
BigInteger val = BigInteger.valueOf(value);
BigInteger halfP = P.subtract(BigInteger.ONE).divide(BigInteger.TWO);
BigInteger halfP = P.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
if (val.modPow(halfP, P).equals(BigInteger.ONE)) {
BigInteger root = Math.modularSquareRoot(val, P);
assertEquals(val, root.multiply(root).mod(P));
Expand All @@ -436,7 +436,7 @@ public void testPrimeCongruent5Mod8() {
BigInteger P = BigInteger.valueOf(13);
for (int value = 1; value < 13; value++) {
BigInteger val = BigInteger.valueOf(value);
BigInteger halfP = P.subtract(BigInteger.ONE).divide(BigInteger.TWO);
BigInteger halfP = P.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
if (val.modPow(halfP, P).equals(BigInteger.ONE)) {
BigInteger root = Math.modularSquareRoot(val, P);
assertEquals(val, root.multiply(root).mod(P));
Expand All @@ -450,7 +450,7 @@ public void testPrimeCongruent3Mod4() {
BigInteger P = BigInteger.valueOf(7);
for (int value = 1; value < 7; value++) {
BigInteger val = BigInteger.valueOf(value);
BigInteger halfP = P.subtract(BigInteger.ONE).divide(BigInteger.TWO);
BigInteger halfP = P.subtract(BigInteger.ONE).divide(BigInteger.valueOf(2));
if (val.modPow(halfP, P).equals(BigInteger.ONE)) {
BigInteger root = Math.modularSquareRoot(val, P);
assertEquals(val, root.multiply(root).mod(P));
Expand Down