Repository navigation
fix(crypto): reject infinity in point address derivation - #66
Open
Federico2014 wants to merge 3 commits into
Open
Federico2014 wants to merge 3 commits into
Federico2014 wants to merge 3 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crypto/src/main/java/org/tron/common/crypto/Hash.java">
<violation number="1" location="crypto/src/main/java/org/tron/common/crypto/Hash.java:194">
P2: This Javadoc incorrectly presents the byte-array overload as accepting only 65-byte uncompressed keys, while legacy signature-recovery paths still intentionally pass encodings such as `{0x00}`. Document the unchanged no-validation behavior and the legacy compatibility requirement so callers do not reject valid consensus inputs or add incompatible validation later.</violation>
</file>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Reject the point at infinity in
Hash.computeAddress(ECPoint)withIllegalArgumentException. Document the uncompressed public-key input format of thebyte[]overload.Why are these changes required?
The infinity encoding is
{0x00}. Previously, removing its first byte caused address derivation to hash empty input and return a well-formed address for an invalid public key.This PR has been tested by:
HashTest,ECKeyTest, andBouncyCastleTest, including 3 new regression tests for infinity rejection, known public-key addresses, and legacy byte-array behavior.:framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain,check_math_usage.sh, andgit diff --check.Follow up
None.
Extra details
Transaction/block signature verification and TVM address recovery use the unchanged
byte[]overload. ExistingECKeyconstruction already rejects infinity, so normalgetAddress()behavior is preserved. Direct callers passing infinity to theECPointoverload now receive an exception; null-input behavior is unchanged.Summary by cubic
Rejects the point at infinity in
Hash.computeAddress(ECPoint)so invalid public keys no longer produce a well-formed address, and documents the input contract of thebyte[]overload.{0x00}previously lost its first byte and hashed empty input, returning a valid-looking address for an invalid public key.ECPointoverload now throwsIllegalArgumentExceptionfor infinity; thebyte[]overload keeps its legacy behavior, which consensus paths such as signature recovery rely on.Written for commit 8e726af. Summary will update on new commits.