paulmillr / scure-base

Secure, audited & 0-deps implementation of bech32, base64, base32, base16 & base58
https://paulmillr.com/noble/#scure
MIT License
106 stars 13 forks source link

fix: bech32 prefix length #28

Closed mahnunchik closed 8 months ago

mahnunchik commented 8 months ago

https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32

The human-readable part, which is intended to convey the type of data, or anything else that is relevant to the reader. This part MUST contain 1 to 83 US-ASCII characters

Current implementation allows to do:

console.log(bech32.encode('', []))
// 10a06t8

But decode fails with error:

console.log(bech32.decode('10a06t8'))