-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Background
The java-tron codebase contains a complete SM2 implementation in the crypto module. The SignUtils.java provides a configuration flag isECKeyCryptoEngine to switch between ECKey (SECP256K1) and SM2. Additionally, SM3 hash implementation exists alongside SM2.
The crypto.engine configuration option allows switching between cryptographic engines, but in practice only ECKey is ever used in production.
Problem Statement
-
SM2/SM3 is never used in production: All production deployments use
ECKey (SECP256K1). TheisECKeyCryptoEngineflag is alwaystrue. -
Dead code maintenance burden: Maintaining ~1,100+ lines of unused cryptographic code (SM2 + SM3) increases complexity, testing surface, and audit scope.
-
Incompatible with TRON network: TRON uses
SECP256K1for all transactions. SM2 would not work with existing accounts. -
Bug Bounty false positives: The unused SM2 code frequently triggers false positive reports in bug bounty programs. Security researchers often flag SM2-related code as potential vulnerabilities, requiring time-consuming investigation and response.
-
Unnecessary configuration complexity: The
crypto.engineconfig andisECKeyCryptoEnginechecks exist throughout the codebase but only serve unused code paths.
Rationale
Why should this feature exist?
Removing unused code improves code quality and reduces maintenance overhead. Eliminating the crypto.engine configuration simplifies the codebase by removing conditional logic that never changes in production.
What are the use cases?
- Developers will have cleaner codebase to work with
- Security audits will focus on actually-used cryptography
- Fewer false positive reports in bug bounty programs
- Simplified code with no unnecessary conditional branches
Scope of Impact
- Core protocol
- API/RPC
- Database
- Network layer
- Smart contracts
- Documentation
- Other: crypto module, keystore, config
Breaking Changes:
Yes - but only for non-production code paths:
crypto.engineconfiguration option will be ignoredisECKeyCryptoEnginemethod calls must be updated- SM2-related test files will be removed
Backward Compatibility:
Fully backward compatible for production:
- Default ECKey behavior remains unchanged
- No production config uses SM2
- Config
crypto.enginecan remain in old configs (will be ignored with warning)
Implementation
Are you willing to implement this feature?
- Yes, I can implement this feature