feat(crypto): validate BTC/ETH address checksums - #11
Draft
ClaudiuCeia with Copilot wants to merge 3 commits into
Draft
feat(crypto): validate BTC/ETH address checksums#11ClaudiuCeia with Copilot wants to merge 3 commits into
ClaudiuCeia with Copilot wants to merge 3 commits into
Conversation
- Add @std/crypto dependency for SHA-256 (Base58Check) and Keccak-256 (EIP-55) - Replace length-only BTC Base58Check guard with full decode + double-SHA-256 checksum verification (version bytes 0x00/0x05) - Replace length-only Bech32 guard with full polymod (Bech32 const=1, Bech32m const=0x2bc830a3), witness program length/padding checks - Accept uppercase Bech32/Bech32m addresses (BC1Q.../BC1P...); reject mixed-case - Add EIP-55 Keccak-256 checksum validation for mixed-case ETH addresses; accept all-lower/all-upper freely - Use BIP-0173/BIP-0350/EIP-55 spec test vectors in tests - Add one-char mutation rejection tests for P2PKH, P2SH, Bech32, Bech32m - Add uppercase Bech32 acceptance test - Add EIP-55 acceptance (spec addresses) and rejection (case-bit flip) tests
- Use regex + optional chaining for declarative leading-zeros count - Build base58 byte array with push+reverse instead of repeated unshift - Add comment explaining Bech32 padding constraint (BIP-0173/0350) - Extract byteIndex variable to avoid duplicate Math.floor(i/2) in EIP-55 loop
Copilot
AI
changed the title
[WIP] Validate BTC and ETH address checksums
feat(crypto): validate BTC/ETH address checksums
Jul 25, 2026
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.
Crypto addresses were accepted on shape alone — a single-character mutation of a valid address still matched. This adds full cryptographic checksum validation as a post-shape guard, keeping regexes as cheap prefilters.
BTC P2PKH / P2SH (Base58Check)
0x00/0x05) → double-SHA-256 checksum verification via@std/cryptodigestSyncBTC Bech32 / Bech32m
1, Bech32m constant0x2bc830a3)BC1Q…/BC1P…in addition to their lowercase formsETH (EIP-55)
Dependency
@std/crypto@1for synchronousdigestSync(SHA-256 and KECCAK-256)Tests
BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4) → accept