BIP173/BIP350 specify the maximum length of bech32/bech32m strings as 90 characters.
Yes, but https://en.bitcoin.it/wiki/BIP_0352 states that:
Note: BIP173 imposes a 90 character limit for Bech32 segwit addresses and limits versions to 0 through 16, whereas a silent payment address requires at least 117 characters[12] and allows versions up to 31. Additionally, since higher versions may add to the data field, it is recommended implementations use a limit of 1023 characters (see BIP173: Checksum design for more details).
Why do silent payment addresses need at least 117 characters? A silent payment address is a bech32m encoding comprised of the following parts:
HRP [2-3 characters]
separator [1 character]
version [1-2 characters]
payload, 66 bytes concatenated pubkeys [ceil(66*8/5) = 106 characters]
checksum [6 characters]
For a silent payments v0 address, this results in a 117-character address when using a 3-character HRP. Future versions of silent payment addresses may add to the payload, which is why a 1023-character limit is suggested.
enum CharLimit
only contains BECH32
for now, but we can add the 1023
limit later: https://github.com/bitcoin/bitcoin/compare/12f3f6d6d4b15276d9118f1a55f1a4f4b5d5d111..9b7023d31a3ec95f66b45f0ecb47e79762d74854
have a separate test for (much-)too-long strings
https://github.com/bitcoin/bitcoin/blob/master/src/test/bech32_tests.cpp#L131 is already testing that, so I’ll limit it to limit + 1
, thanks for the hint @sipa.
ps. is fuzzing still working on a mac?
% cmake -B build_fuzz –preset=libfuzzer
-DCMAKE_C_COMPILER="$(brew –prefix llvm)/bin/clang"
-DCMAKE_CXX_COMPILER="$(brew –prefix llvm)/bin/clang++"
-DAPPEND_LDFLAGS=-Wl,-no_warn_duplicate_libraries
…
% cmake –build build_fuzz -j10
…
ld: multiple errors: invalid r_symbolnum=1 in ‘bitcoin/build_fuzz/src/test/fuzz/CMakeFiles/fuzz.dir/addition_overflow.cpp.o’; invalid r_symbolnum=1 in ‘bitcoin/build_fuzz/src/test/fuzz/CMakeFiles/fuzz.dir/fees.cpp.o’; invalid r_symbolnum=1 in ‘bitcoin/build_fuzz/src/test/fuzz/CMakeFiles/fuzz.dir/float.cpp.o’; invalid r_symbolnum=1 in ‘bitcoin/build_fuzz/src/test/fuzz/CMakeFiles/fuzz.dir/multiplication_overflow.cpp.o’; invalid r_symbolnum=1 in ‘../../libbitcoin_cli.a2’; invalid r_symbolnum=1 in ‘../../../libcrc32c.a3’; invalid r_symbolnum=1 in ‘../../../libcrc32c.a2’; invalid r_symbolnum=1 in ‘../../../libcrc32c_arm64.a2’; invalid r_symbolnum=5 in ‘../../util/libbitcoin_util.a29’; invalid r_symbolnum=18 in ‘../../crypto/libbitcoin_crypto_arm_shani.a2’; invalid r_symbolnum=1 in ‘../../crypto/libbitcoin_crypto.a15’; invalid r_symbolnum=1 in ‘../../crypto/libbitcoin_crypto.a10’; invalid r_symbolnum=1 in ‘../../crypto/libbitcoin_crypto.a5’; invalid r_symbolnum=1 in ‘../util/libtest_util.a12’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a27’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a24’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a16’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a15’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a14’; invalid r_symbolnum=1 in ‘../util/libtest_util.a4’; invalid r_symbolnum=1 in ‘../util/libtest_util.a3’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a9’; invalid r_symbolnum=1 in ‘../../util/libbitcoin_util.a6’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a84’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a79’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a68’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a63’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a55’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a54’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a51’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a50’; invalid r_symbolnum=1 in ‘../../libbitcoin_consensus.a11’; invalid r_symbolnum=1 in ‘../../libbitcoin_consensus.a5’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a43’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a41’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a40’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a39’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a36’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a47’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a34’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a31’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a42’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a41’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a28’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a23’; invalid r_symbolnum=1 in ‘../../libbitcoin_node.a22’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a30’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a29’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a24’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a21’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a20’; invalid r_symbolnum=1 in ‘../../libbitcoin_common.a16’; invalid r_symbolnum=1 in ‘../../../libleveldb.a37’; invalid r_symbolnum=1 in ‘../../../libleveldb.a35’; invalid r_symbolnum=1 in ‘../../../libleveldb.a31’; invalid r_symbolnum=1 in ‘../../../libleveldb.a27’; invalid r_symbolnum=1 in ‘../../../libleveldb.a8’; invalid r_symbolnum=1 in ‘../../../libleveldb.a2’
c