Skip to content

Commit 5ef7de6

Browse files
authored
feat(crypto): shielded transaction API security enhancement (#6694)
1 parent 9362961 commit 5ef7de6

18 files changed

Lines changed: 610 additions & 229 deletions

File tree

common/src/main/java/org/tron/common/parameter/CommonParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public class CommonParameter {
338338

339339
@Getter
340340
@Setter
341-
public boolean allowShieldedTransactionApi; // clearParam: true
341+
public boolean allowShieldedTransactionApi; // clearParam: false
342342
@Getter
343343
@Setter
344344
public long blockNumForEnergyLimit;

common/src/main/java/org/tron/core/config/args/NodeConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class NodeConfig {
8686
private boolean unsolidifiedBlockCheck = false;
8787
private int maxUnsolidifiedBlocks = 54;
8888
private String zenTokenId = "000000";
89-
private boolean allowShieldedTransactionApi = true;
89+
private boolean allowShieldedTransactionApi = false;
9090
private double activeConnectFactor = 0.1;
9191
private double connectFactor = 0.6;
9292
// Legacy alias `maxActiveNodesWithSameIp` has no bean field: we only peek at it via

common/src/main/java/org/tron/core/exception/ZksnarkException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ public ZksnarkException() {
99
public ZksnarkException(String message) {
1010
super(message);
1111
}
12+
13+
public ZksnarkException(String message, Throwable cause) {
14+
super(message, cause);
15+
}
1216
}

common/src/main/resources/reference.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ node {
215215
minParticipationRate = 0
216216

217217
# Whether to enable shielded transaction API
218-
allowShieldedTransactionApi = true
218+
allowShieldedTransactionApi = false
219219

220220
# Whether to print config log at startup
221221
openPrintLog = true

common/src/test/java/org/tron/core/config/args/NodeConfigTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,26 +284,26 @@ public void testLegacyAliasTakesPriorityOverModernKey() {
284284
}
285285

286286
@Test
287-
public void testShieldedApiDefaultsToTrueWhenNeitherKeySet() {
287+
public void testShieldedApiDefaultsToFalseWhenNeitherKeySet() {
288288
NodeConfig nc = NodeConfig.fromConfig(withRef());
289-
assertTrue(nc.isAllowShieldedTransactionApi());
289+
assertFalse(nc.isAllowShieldedTransactionApi());
290290
}
291291

292292
@Test
293293
public void testShieldedApiModernKeyRespected() {
294294
NodeConfig nc = NodeConfig.fromConfig(
295-
withRef("node.allowShieldedTransactionApi = false"));
296-
assertFalse(nc.isAllowShieldedTransactionApi());
295+
withRef("node.allowShieldedTransactionApi = true"));
296+
assertTrue(nc.isAllowShieldedTransactionApi());
297297
}
298298

299299
@Test
300300
public void testShieldedApiLegacyKeyRespected() {
301-
// Regression guard: reference.conf ships `allowShieldedTransactionApi = true`, which
301+
// Regression guard: reference.conf ships `allowShieldedTransactionApi = false`, which
302302
// used to make the legacy-key fallback dead code. A user who only set the legacy key
303303
// must still have their value honored.
304304
NodeConfig nc = NodeConfig.fromConfig(
305-
withRef("node.fullNodeAllowShieldedTransaction = false"));
306-
assertFalse(nc.isAllowShieldedTransactionApi());
305+
withRef("node.fullNodeAllowShieldedTransaction = true"));
306+
assertTrue(nc.isAllowShieldedTransactionApi());
307307
}
308308

309309
@Test
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.tron.core.exception;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class ZksnarkExceptionTest {
7+
8+
@Test
9+
public void testNoArgConstructor() {
10+
ZksnarkException e = new ZksnarkException();
11+
Assert.assertNull(e.getMessage());
12+
Assert.assertNull(e.getCause());
13+
}
14+
15+
@Test
16+
public void testMessageConstructor() {
17+
ZksnarkException e = new ZksnarkException("boom");
18+
Assert.assertEquals("boom", e.getMessage());
19+
Assert.assertNull(e.getCause());
20+
}
21+
22+
@Test
23+
public void testMessageAndCauseConstructor() {
24+
Throwable cause = new ArithmeticException("overflow");
25+
ZksnarkException e = new ZksnarkException("wrapped", cause);
26+
Assert.assertEquals("wrapped", e.getMessage());
27+
Assert.assertSame(cause, e.getCause());
28+
}
29+
}

0 commit comments

Comments
 (0)