Today we are going to learn how to verify a Bech32 checksum using only pen and paper. This is useful in those cases where you need to urgently validate the checksum of a Bech32 address, but the electricity has gone out in your home or office and you have lost your smartphone.
We are going to do a worked example of verifying the checksum of BC1SW50QA3JX3S
, which is one of the test vectors from the Bech32 specification.
However, before we begin, we need to make some preparations.
We will need three tables.
a | xe86fe |
---|---|
c | wt5v4t |
d | 4vljgv |
e | ukpcrk |
f | 0reszr |
g | a7vy57 |
h | k5glc5 |
j | 7xmfyx |
k | yfatwf |
l | t2ymv2 |
m | 39zex9 |
n | vmwajm |
p | ja45ka |
q | qqqqqq |
r | lwk4nw |
s | n4cgp4 |
t | zs638s |
u | 5yjwly |
v | 832x73 |
w | 2zf8mz |
x | hu9r0u |
y | 60xz20 |
z | dnrp9n |
0 | clundl |
2 | sd093d |
3 | pgduhg |
4 | m8t7a8 |
5 | f672t6 |
6 | rchdsc |
7 | eh306h |
8 | 9pshep |
9 | gjnkuj |
acde | fghj | klmn | pqrs | tuvw | xyz0 | 2345 | 6789 | |
---|---|---|---|---|---|---|---|---|
a | q9sy | 5420 | tzxw | ua7d | kp3n | melj | hvgf | 8r6c |
c | 9q4p | 3s02 | w8rt | ecmg | ny5k | 7u6h | jfdv | zxla |
d | s4q5 | y96l | mjk7 | vdwa | x3pr | tf0z | 8uce | hn2g |
e | yp5q | s3wt | 0xz2 | ce6f | j94h | lamk | ngvd | r87u |
f | 53ys | qp7m | lkj6 | gf2e | z498 | 0dtx | rcua | nhwv |
g | 4s93 | pql6 | 7hnm | fgtc | r5yx | wv28 | zeau | jk0d |
h | 206w | 7lq9 | pgvy | kh58 | utme | 3n4c | axzr | dfsj |
j | 02lt | m69q | ydfp | nj3z | ew7u | 5ksa | cr8x | gv4h |
k | twm0 | l7py | qfd9 | hk4x | a26c | sj5e | u8rz | vg3n |
l | z8jx | khgd | fqyv | 7lu0 | 5rn3 | emas | 4w2t | 9pc6 |
m | xrkz | jnvf | dyqg | 6mct | s8h4 | ale5 | 32w0 | p9u7 |
n | wt72 | 6myp | 9vgq | jnsr | c0la | 4h3u | ezx8 | fd5k |
p | uevc | gfkn | h76j | qpz3 | 2ad0 | 89rw | ts54 | mlxy |
q | acde | fghj | klmn | pqrs | tuvw | xyz0 | 2345 | 6789 |
r | 7mw6 | 2t53 | 4ucs | zrqn | gl0d | 98pv | fjkh | eayx |
s | dgaf | ec8z | x0tr | 3snq | mvu7 | k5jl | 6p9y | 2wh4 |
t | knxj | zrue | a5sc | 2tgm | qh89 | d0fy | p67l | 34vw |
u | py39 | 45tw | 2r80 | aulv | hqsj | 6c7n | kdfg | xzme |
v | 35p4 | 9ym7 | 6nhl | dv0u | 8sqz | 2gwr | xaec | kjtf |
w | nkrh | 8xeu | c34a | 0wd7 | 9jzq | g2vp | ylm6 | 5sft |
x | m7tl | 0w35 | sea4 | 8x9k | d62g | qzyf | vhnj | ucpr |
y | eufa | dvnk | jmlh | 9y85 | 0cg2 | zqxt | w43s | 76rp |
z | l60m | t24s | 5ae3 | rzpj | f7wv | yxqd | gnhk | cu98 |
0 | jhzk | x8ca | es5u | w0vl | ynrp | ftdq | 976m | 43g2 |
2 | hj8n | rzac | u43e | t2f6 | pkxy | vwg9 | qml7 | s5d0 |
3 | vfug | cexr | 8w2z | s3jp | 6dal | h4n7 | mqy9 | t0k5 |
4 | gdcv | uaz8 | r2wx | 54k9 | 7fem | n3h6 | lyqp | 0tjs |
5 | fved | aurx | zt08 | 45hy | lgc6 | jskm | 79pq | w2n3 |
6 | 8zhr | njdg | v9pf | m6e2 | 3xk5 | u7c4 | st0w | qyal |
7 | rxn8 | hkfv | gp9d | l7aw | 4zjs | c6u3 | 50t2 | yqem |
8 | 6l27 | w0s4 | 3cu5 | x8yh | vmtf | pr9g | dkjn | aeqz |
9 | cagu | vdjh | n67k | y9x4 | weft | rp82 | 05s3 | lmzq |
bc1 | rzqrrp |
---|---|
tb1 | z5qrrp |
Print out these tables and keep them with your emergency supplies so that you can find them when you need them.
Now we can begin.
Split the message BC1SW50QA3JX3S
into its prefix, BC1
, and suffix SW50QA3JX3S
.
Take the suffix and write it vertically on a piece of paper, leaving a gap after each letter and then a line.
S ───────────── W ───────────── 5 ───────────── 0 ───────────── Q ───────────── A ───────────── 3 ───────────── J ───────────── X ───────────── 3 ───────────── S ─────────────
Find the prefix in the list of courage and write the associated word after the first letter, S, placing a diagonal line between each letter. For new prefixes, you may need to add them to the list of courage beforehand.
S\r\z\q\r\r\p ───────────── W
Take the last letter, which is p, and look it up in the table of power to find its associated word, which is ja45ka. Write this word in the gap under the Srzqrrp, extending the diagonal lines between each letter.
S\r\z\q\r\r\p \j\a\4\5\k\a\ ───────────── W
For each letter of this power word, we need to use the matrix of wisdom to add it to the letter above and to the left of it. For example, we look up row S and column j in the matrix of wisdom and we find the letter z. Write z after the W below the line, separating it with a diagonal line again.
S\r\z\q\r\r\p \j\a\4\5\k\a\ ───────────── W\z
We look up row r and column a in the matrix of wisom to find the number 7. We add 7 after the z, and keep doing this until every pair of letters is done. The matrix of wisdom is symmetric, so you do not have to worry about whether you are looking up by row/column or column/row.
S\r\z\q\r\r\p \j\a\4\5\k\a\ ───────────── W\z\7\h\5\4\7
We repeat this process with the next line. First we lookup 7 in the table of power to find eh306h and write it underneath.
W\z\7\h\5\4\7 \e\h\3\0\6\h\ ───────────── 5
Then, for each pair of letters, we add them using the matrix of wisdom.
W\z\7\h\5\4\7 \e\h\3\0\6\h\ ───────────── 5\h\4\0\c\w\z
We keep doing this until we go through all the letters of the suffix.
S\r\z\q\r\r\p \j\a\4\5\k\a\ ───────────── W\z\7\h\5\4\7 \e\h\3\0\6\h\ ───────────── 5\h\4\0\c\w\z \d\n\r\p\9\n\ ───────────── 0\e\y\k\w\a\a \x\e\8\6\f\e\ ───────────── Q\f\q\r\v\8\y \6\0\x\z\2\0\ ───────────── A\6\x\x\p\x\g \a\7\v\y\5\7\ ───────────── 3\q\y\2\z\4\c \w\t\5\v\4\t\ ───────────── J\l\t\s\x\h\7 \e\h\3\0\6\h\ ───────────── X\t\g\6\l\u\q \q\q\q\q\q\q\ ───────────── 3\x\t\g\6\l\u \5\y\j\w\l\y\ ───────────── S\9\z\e\x\9\m \3\9\z\e\x\9\ ───────────── \p\q\q\q\q\q
The final result should be pqqqqq, where q is the most powerful letter and p is the wisest letter. If you did not get this result, start over from the beginning because you probably made a mistake. Remember to mind your p's and q's.
After a couple years of practice doing this by hand, the operations become natural. For example, you learn that x and y equals z, and so forth.
Exercise for the reader: Create a variant of this procedure for computing Bech32 checksums.
P.S. This article is not meant to be taken seriously.