fix(crypto): reject infinity in point address derivation
What does this PR do?
Reject the point at infinity in Hash.computeAddress(ECPoint) with IllegalArgumentException. Document the uncompressed public-key input format of the byte[] 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:
- 39 tests passed across
HashTest,ECKeyTest, andBouncyCastleTest, including 3 new regression tests for infinity rejection, known public-key addresses, and legacy byte-array behavior. - Passed
:framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain,check_math_usage.sh, andgit diff --check. - Full test suite and manual node testing were not run.
Follow up
None.
Extra details
Transaction/block signature verification and TVM address recovery use the unchanged byte[] overload. Existing ECKey construction already rejects infinity, so normal getAddress() behavior is preserved. Direct callers passing infinity to the ECPoint overload 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 the byte[] overload.
- The infinity encoding
{0x00}previously lost its first byte and hashed empty input, returning a valid-looking address for an invalid public key. - The
ECPointoverload now throwsIllegalArgumentExceptionfor infinity; thebyte[]overload keeps its legacy behavior, which consensus paths such as signature recovery rely on. - Adds regression tests covering infinity rejection, known public-key addresses, and legacy byte-array behavior.