Closed jaekwon closed 2 years ago
Here is the problem.
1) gno's amino marshaled pubkey byte length is 58 2) converted base256 pubkey byte length is 93 3) encoded bech32 pubkey byte length is 104
however, the github.com/btcsuite/btcutil v1.0.2 require the bech32 max length to be 90
When we add gno pubkey back to the local keybase, btcutil.bech32 tried to decode it and threw an error. "invalid bech32 string length 104"
Solution:
1) install the latest version of btcutil github.com/btcsuite/btcd/btcutil v1.1.1
2) call a new method bech32.DecodeNoLimit(bech), which does not limit the pubkey bech32 length to 90.
I will make a pull request, if this solution is accepted.
Trade-Off:
Since Bech32 is designed for max length 90 bytes/character with 6 checksum characters to detect and correct 4 errors with 0 faults. When we extend the length to 104, it will slightly decrease the success rate of error detection.
However, the chances of failure could be tiny. According to the BIP173 the current code selection performs well up to 1023 characters.
that sounds great, yes please.
Fixed by #264
i think it might be failing due to a bech32 decoding error. it could be that the prefix is set to "g" and length assumed to be shorter than a "gpub" prefixed bech32 pubkey. i suppose we should check the prefix and then check the length accordingly, in some places.