I have released an initial version of the
bech32(1) utility for encoding and decoding of
BIP 173 Bech32 strings and Bitcoin
Bravo Charlie Addresses (bc1). As any worthwhile software, it comes replete with a
manpage (
text),
q.v.As part of its initial feature set,
bech32(1) has special handling for
RFC 7686 .onion special-use domain names; it detects such a name, and transcodes the
RFC 4648 Base32 to and from Bech32 with an HRP of onion. For Bitcoin Bravo Charlie addresses,
bech32(1) takes and gives the witness version and the hexadecimal-coded octets of the witness program. Otherwise, for the most part, it encodes and decodes hexadecimal data with user-provided HRPs. I intend to add special interpretation of pgp1 with a concept I call PGP Descriptors; but I need to spec that out first.
Some usage examples from the manpage:
Extract the witness version and Hash160 from the bech32 utility author's
Bech32 tip address:
bech32 -S bc1qcash96s5jqppzsp8hy8swkggf7f6agex98an7h
0:0xc76172ea149002114027b90f0759084f93aea326
Get a hello, world introduction to Bech32:
bech32 -e -h hello_world 48656c6c6f2c20776f726c6421
hello_world1fpjkcmr09ss8wmmjd3jzzwhs4ff
Generate a burn address with a Hash160 of all zeroes, which would be
spendable by the same unknown private keys as the infamous
1111111111111111111114oLvT2. Warning: Do NOT send coins here:
bech32 -s 0 0x0000000000000000000000000000000000000000
bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq9e75rs
Bech32-encode the address for Wikileaks, to add error-correcting codes:
bech32 -e wlupld3ptjvsgwqw.onion
onion1kt50trm0nf4jxkskpcjy74
Now, decode the address someone gave you:
bech32 -d onion1kt50trm0nf4jxkskpcjy74
wlupld3ptjvsgwqw.onion
Licensing includes a
Bitcoin Consensus Clause, to prevent use by scamcoin pretenders.
This is an alpha-quality initial release. The code is still a bit messy; it needs test vectors, which seem insufficiently specified; features and the finer details of behaviour may be a bit in flux. However, the basic user interface should be considered stable. I am here opening a Bitcoin Forum thread for discussion of this utility; over time, I will edit and update this post as appropriate.
btw I notice that others well-known web sites (such as uj3wazyk5u4hnvtk.onion ) already get updated