Skip to content

Reject a private-key hex string with a non-hex digit - #473

Open
SashaMIT wants to merge 1 commit into
bitpay:10.3.xfrom
SashaMIT:codered-hex-key
Open

SashaMIT wants to merge 1 commit into
bitpay:10.3.xfrom
SashaMIT:codered-hex-key

Conversation

@SashaMIT

Copy link
Copy Markdown

Summary

  • hexToBytes throws when the length is odd, and it accepts any other character.
  • hexToBytes("0G") returned. G is not a hex digit. The nibble math maps it to 16, so 0G decodes to the same byte as 10.
  • A non-hex digit now throws BitPayGenericException. 0123456789abcdef still decodes.

Test plan

  • On tip, it_should_reject_a_non_hex_key_digit expected BitPayGenericException and nothing was thrown
  • After the change, mvn -Dtest=KeyUtilsTest test is 6 tests, 0 failures

Made with Cursor

hexToBytes already rejects an odd length, but 0G still decoded to the same byte as 10.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant