refactor(crypto): remove unused SM2 and SM3 support - #54
Conversation
📝 WalkthroughWalkthroughThe PR removes SM2/SM3 support and the ChangesCryptography cleanup
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
All reported issues were addressed across 95 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
d1d1111 to
6540280
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
What does this PR do?
This PR removes the unused SM2 signing and SM3 hashing implementations, eliminates the runtime crypto engine switch, and simplifies the signing and hashing APIs to use ECKey and SHA-256 directly.
It updates the dependent actuator, chainbase, common, consensus, framework, crypto, and plugin call sites. It also removes the
crypto.engineconfiguration and Toolkit--sm2option, updates documentation, and adjusts the related tests.Why are these changes required?
SM2 and SM3 are not used by the supported default node configuration. Maintaining the alternate crypto path adds duplicated logic, configuration ambiguity, and unnecessary maintenance overhead.
The cross-module changes are required because the removed algorithm-selection parameters were propagated through hashing, signing, transaction, block, consensus, Keystore, and Toolkit APIs.
This PR has been tested by:
Follow up
None.
Extra details
The supported ECKey and SHA-256 consensus behavior remains unchanged. This PR does not change database formats, does not require a hard fork, and preserves compatibility with standard ECKey Keystore files.
The removed
crypto.engineconfiguration, SM2/SM3 APIs, SM2 Keystore handling, and Toolkit--sm2option are no longer supported.This implementation follows the direction of tronprotocol#6627 and closes #51.
Summary by cubic
Removes SM2/SM3 and the runtime crypto engine, standardizing all signing to ECKey and hashing to SHA-256. Simplifies APIs, deletes unused code, and updates call sites, tests, configs, and Toolkit.
Refactors
SM2,SM2Signer, related tests/utilities).SignUtilsnow always uses ECKey; removed engine flags.Sha256Hashnow always does SHA-256; removed SM3 and boolean overloads (of/hash/create).CommonParameter.cryptoEngine,MiscConfig.cryptoEngine, andConstant.ECKey_ENGINE.crypto.enginefromreference.confandconfig.conf.--sm2option; CLI rejects it.CryptoUitlsand SM3 test helperSha256Sm3Hash.Migration
crypto.engineand--sm2; ECKey + SHA-256 is the only path.SignUtils.fromPrivate(byte[]),SignUtils.getGeneratedRandomSign(SecureRandom),Wallet.decrypt(String, WalletFile),WalletUtils.loadCredentials(String, File), andSha256Hash.of/hash/create(...)without engine params.Written for commit 6540280. Summary will update on new commits.
Summary by CodeRabbit
Breaking Changes
crypto.engineconfiguration and--sm2keystore option.Improvements
Bug Fixes