I am running your bech32 library through a list of test vectors that I have lifted from Bitcoin BIP 173.
It passes most tests, but fails on a number of edge cases (such as weird version numbers).
I had previously been using another bech32 implementation written by Pieter Wuille. That implementation passes the test vectors and had been previously working okay, but it is not designed to handle longer bech32 strings.
The bech32 format is a mess, and I'm not sure if these failing test vectors are that important, but I'd like to hear your feedback.
P.S I converted the test vectors to JSON for easier use.
[
["an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx", "overall max length exceeded"],
["pzry9x0s0muk", "No separator character"],
["1pzry9x0s0muk", "Empty HRP"],
["x1b4n0q5v", "Invalid data character"],
["li1dgmt3", "Too short checksum"],
["A1G7SGD8", "checksum calculated with uppercase form of HRP"],
["10a06t8", "empty HRP"],
["1qzzfhee", "empty HRP"],
["bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", "Invalid checksum"],
["BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", "Invalid witness version"],
["bc1rw5uspcuh", "Invalid program length"],
["bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", "Invalid program length"],
["bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", "zero padding of more than 4 bits"],
["tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv", "Non-zero padding in 8-to-5 conversion"],
["bc1gmk9yu", "Empty data section"]
]
Hello Paul, I hope all is well with you!
I am running your bech32 library through a list of test vectors that I have lifted from Bitcoin BIP 173.
It passes most tests, but fails on a number of edge cases (such as weird version numbers).
I had previously been using another bech32 implementation written by Pieter Wuille. That implementation passes the test vectors and had been previously working okay, but it is not designed to handle longer bech32 strings.
The bech32 format is a mess, and I'm not sure if these failing test vectors are that important, but I'd like to hear your feedback.
P.S I converted the test vectors to JSON for easier use.
Pass vectors:
Fail vectors: