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
40 changes: 20 additions & 20 deletions actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ public abstract static class VerifyProof extends PrecompiledContract {
new LibrustzcashParam.MerkleHashParams(
i, UNCOMMITTED[i], UNCOMMITTED[i], UNCOMMITTED[i + 1]));
}
} catch (Throwable any) {
logger.info("Initialize UNCOMMITTED array failed:{}", any.getMessage());
} catch (ZksnarkException e) {
throw new RuntimeException("Failed to initialize UNCOMMITTED array", e);
}
}

Expand Down Expand Up @@ -1258,7 +1258,7 @@ protected Pair<Boolean, byte[]> insertLeaves(
if (success) {
return Pair.of(true, merge(DataWord.ONE().getData(), result));
} else {
return Pair.of(true, DataWord.ZERO().getData());
return Pair.of(false, EMPTY_BYTE_ARRAY);
}
}
}
Expand All @@ -1282,6 +1282,10 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
}
boolean result;
long ctx = JLibrustzcash.librustzcashSaplingVerificationCtxInit();
if (ctx == 0) {
logger.info("VerifyMintProof: failed to init verification context");
return Pair.of(false, EMPTY_BYTE_ARRAY);
}
try {
byte[] cm = new byte[32];
byte[] cv = new byte[32];
Expand Down Expand Up @@ -1328,7 +1332,7 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
} finally {
JLibrustzcash.librustzcashSaplingVerificationCtxFree(ctx);
}
return Pair.of(true, DataWord.ZERO().getData());
return Pair.of(false, EMPTY_BYTE_ARRAY);
}
}

Expand Down Expand Up @@ -1477,6 +1481,10 @@ public Pair<Boolean, byte[]> execute(byte[] data) {

boolean withNoTimeout = countDownLatch.await(getCPUTimeLeftInNanoSecond(),
TimeUnit.NANOSECONDS);
if (!withNoTimeout) {
futures.forEach(f -> f.cancel(true));
return Pair.of(true, DataWord.ZERO().getData());
}
boolean checkResult = true;
for (Future<Boolean> future : futures) {
boolean eachTaskResult = future.get();
Expand All @@ -1497,7 +1505,7 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
}
logger.info("VerifyTransferProof exception: " + errorMsg);
}
return Pair.of(true, DataWord.ZERO().getData());
return Pair.of(false, EMPTY_BYTE_ARRAY);
}

private static class SaplingCheckSpendTask implements Callable<Boolean> {
Expand Down Expand Up @@ -1527,17 +1535,13 @@ private static class SaplingCheckSpendTask implements Callable<Boolean> {

@Override
public Boolean call() throws ZksnarkException {
boolean result;
try {
result = JLibrustzcash.librustzcashSaplingCheckSpendNew(
return JLibrustzcash.librustzcashSaplingCheckSpendNew(
new LibrustzcashParam.CheckSpendNewParams(this.cv, this.anchor, this.nullifier,
this.rk, this.zkproof, this.spendAuthSig, this.signHash));
} catch (ZksnarkException e) {
throw e;
} finally {
countDownLatch.countDown();
}
return result;
}
}

Expand All @@ -1561,17 +1565,13 @@ private static class SaplingCheckOutputTask implements Callable<Boolean> {

@Override
public Boolean call() throws ZksnarkException {
boolean result;
try {
result = JLibrustzcash.librustzcashSaplingCheckOutputNew(
return JLibrustzcash.librustzcashSaplingCheckOutputNew(
new LibrustzcashParam.CheckOutputNewParams(this.cv, this.cm,
this.ephemeralKey, this.zkproof));
} catch (ZksnarkException e) {
throw e;
} finally {
countDownLatch.countDown();
}
return result;
}
}

Expand Down Expand Up @@ -1602,18 +1602,14 @@ private static class SaplingCheckBingdingSig implements Callable<Boolean> {

@Override
public Boolean call() throws ZksnarkException {
boolean result;
try {
result = JLibrustzcash.librustzcashSaplingFinalCheckNew(
return JLibrustzcash.librustzcashSaplingFinalCheckNew(
new LibrustzcashParam.FinalCheckNewParams(this.valueBalance, this.bindingSig,
this.signHash, this.spendCvs, this.spendCvLen,
this.receiveCvs, this.receiveCvLen));
} catch (ZksnarkException e) {
throw e;
} finally {
countDownLatch.countDown();
}
return result;
}
}
}
Expand All @@ -1637,6 +1633,10 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
}
boolean result;
long ctx = JLibrustzcash.librustzcashSaplingVerificationCtxInit();
if (ctx == 0) {
logger.info("VerifyBurnProof: failed to init verification context");
return Pair.of(false, EMPTY_BYTE_ARRAY);
}
try {
byte[] nullifier = new byte[32];
byte[] anchor = new byte[32];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Slf4j
public class JLibrustzcash {

private static Librustzcash INSTANCE = LibrustzcashWrapper.getInstance();
private static final Librustzcash INSTANCE = LibrustzcashWrapper.getInstance();

public static void librustzcashZip32XskMaster(Zip32XskMasterParams params) {
INSTANCE.librustzcashZip32XskMaster(params.getData(), params.getSize(), params.getM_bytes());
Expand Down
Loading
Loading