Skip to content

Commit

Permalink
feat(precompiles): check negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
AllFi committed Dec 20, 2023
1 parent 410cce4 commit 04a00c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crypto/src/main/java/org/tron/common/crypto/zksnark/Fp.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public class Fp implements Field<Fp> {
static Fp create(byte[] v) {
BigInteger value = new BigInteger(1, v);
if (value.compareTo(P) >= 0) {
// Only the values less than P are valid
// Only the positive values less than P are valid
return null;
}
return new Fp(toMontgomery(value));
}

static Fp create(BigInteger v) {
if (v.compareTo(P) >= 0) {
// Only the values less than P are valid
if (v.compareTo(P) >= 0 || v.signum() == -1) {
// Only the positive values less than P are valid
return null;
}
return new Fp(toMontgomery(v));
Expand Down

0 comments on commit 04a00c2

Please sign in to comment.