Skip to content

[Feature] Remove unused SM2 algorithm and related configuration #6588

@Federico2014

Description

@Federico2014

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

  1. SM2/SM3 is never used in production: All production deployments use ECKey (SECP256K1). The isECKeyCryptoEngine flag is always true.

  2. Dead code maintenance burden: Maintaining ~1,100+ lines of unused cryptographic code (SM2 + SM3) increases complexity, testing surface, and audit scope.

  3. Incompatible with TRON network: TRON uses SECP256K1 for all transactions. SM2 would not work with existing accounts.

  4. 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.

  5. Unnecessary configuration complexity: The crypto.engine config and isECKeyCryptoEngine checks 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?

  1. Developers will have cleaner codebase to work with
  2. Security audits will focus on actually-used cryptography
  3. Fewer false positive reports in bug bounty programs
  4. 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.engine configuration option will be ignored
  • isECKeyCryptoEngine method 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.engine can remain in old configs (will be ignored with warning)

Implementation

Are you willing to implement this feature?

  • Yes, I can implement this feature

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions