bech32 decoder looks for the first '1' as the HRP separator, not the last '1' as specified
daira opened this issue · 2 comments
daira commented
Lines 95 to 99 in 60848c2
https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32 says that the last '1' in the string is the HRP separator. The reference code is inconsistent with that and with Bitcoin Core.
sipa commented
I don't think so; (*data_len)
increments, but is used as a negative in the index to input
: input[(input_len - 1) - *data_len]
, so it counts backwards.
There is also a unit test for an HRP that includes a "1", which both the C and C++ code pass.
daira commented
You're right, sorry for the invalid report.