In this episode of The Van Wirdum Sjorsnado, hosts Aaron van Wirdum and Sjors Provoost discuss Bitcoin addresses. Every Bitcoin user has probably at one point used Bitcoin addresses, but what are they, exactly? Aaron and Sjors explain that Bitcoin addresses are not part of the Bitcoin protocol. Instead, they are conventions used by Bitcoin (wallet) software to communicate where coins must be spent to: either a public key (P2PK), a public key hash (P2PKH), a script hash (P2SH), a witness public key hash (P2WPKH), or a witness script hash (P2WSH). Addresses also include some meta data about the address type itself. Bitcoin addresses communicate these payment options using their own “numeric systems”, Aaron and Sjors explain. The first version of this was base58, which uses 58 different symbols to represent numbers. Newer address types, bech32 addresses, instead use base32 which uses 32 different symbols to represent numbers. Aaron and Sjors discuss some of the benefits of using Bitcoin addresses in general. and bech32 addresses in specific. In addition, Sjors explains that the first version of bech32 addresses included a (relatively harmless) bug, and how a newer standard for bech32 addresses has fixed this bug. Chapters 00:00:00 Bitcoin addresses, IP payments and public keys 00:04:49 Paying to a public-key hash 00:06:33 Base58 and numeral systems 00:11:58 Address conventions and version prefixes 00:14:01 Pay-to-script-hash addresses 00:16:14 Bech32 and native SegWit addresses 00:18:56 Decoding the parts of a Bech32 address 00:21:38 Checksums and locating typing errors 00:24:49 The Bech32 insertion bug and Bech32m 00:28:16 Future formats and Lightning invoices
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Aaron van WirdumBefore the show, a quick word from our sponsor. Live from Utrecht, this is the Van Wirdum Sjorsnado.
Sjors ProvoostHello.
Aaron van WirdumHey, Sjors.
Sjors ProvoostWhat's up?
Aaron van WirdumThe other day I wanted to send Bitcoin to someone, but I didn't.
Sjors ProvoostShouldn't you hodl?
Aaron van WirdumI hodl all I can, but sometimes I need to eat, or I need to pay my rent, or I need to buy a new plant for my living room.
Sjors ProvoostYeah, that's true.
Aaron van WirdumSo the problem was the person I wanted to send Bitcoin to, I didn't have their IP address.
Sjors ProvoostYou did not have their IP address.
Aaron van WirdumI did not have their IP address.
Sjors ProvoostOkay.
Aaron van WirdumLuckily, it turns out there's this trick in Bitcoin called Bitcoin addresses.
Sjors ProvoostThat's right.
Aaron van WirdumHave you heard of this?
Sjors ProvoostYes.
Aaron van WirdumMaybe our reader, cut that please. Maybe our listener hasn't yet, Sjors. So let's explain what Bitcoin addresses are.
Sjors ProvoostOkay. What are Bitcoin addresses?
Aaron van WirdumFirst of all, so I made a stupid joke about IP addresses, but this was actually an option, wasn't it?
Sjors ProvoostYeah, so in the initial version of Bitcoin, Satoshi announced it on the mailing list and said, well, if you want to send somebody some coins, you just enter their IP address and then it'll exchange, I guess, an address to send it to.
Aaron van WirdumYeah so it was actually possible to send bitcoins to people's IP addresses. I don't think that's possible anymore. That's not in any of the code.
Sjors ProvoostI don't think so either. I haven't seen it. Yeah because the other way is that you just get an address to send to and then it goes to the blockchain and because the other side is checking the blockchain also it'll show up yeah.
Aaron van WirdumWell, that's actually not how it works at all. But we're going to explain it now, I think.
Sjors ProvoostYep.
Aaron van WirdumLet's go. Okay, first of all, Sjors, when you send Bitcoin to someone, what do you actually do? What happens?
Sjors ProvoostWell, you're creating a transaction that has a bunch of inputs and it has an output. And that output describes who can spend it.
Aaron van WirdumYeah.
Sjors ProvoostSo you could say anybody can spend this. That's not a good idea. We talked about that in an earlier episode. So what you do is you put a constraint on it. And the very first version of that constraint was he or she who has this public key can spend the coins. So that's called pay to public key.
Aaron van WirdumYes, exactly. And then we just mentioned this IP example. So what actually happened was you would connect to someone's IP. I don't know the nitty gritty details, but in general, you would connect to someone's IP and you'd ask for a public key and that person would give you the public key. And I think that's what you send the bitcoins to.
Sjors ProvoostYeah, I believe so too, but I haven't seen that code in action, so we could be slightly wrong there. Somebody should dig it up. I'd love to see screenshots of what that used to look like.
Aaron van WirdumYeah, is there anyone who's ever used this way of paying someone pay to IP address?
Sjors ProvoostYeah, we'd love to know.
Aaron van WirdumIt was technically possible. If anyone listening... Has anyone ever actually used this? We'd be curious to hear that.
Sjors ProvoostI mean, it makes sense to think that way in the first version of Bitcoin, right? Because before that, you had all these peer-to-peer applications and they were generally very direct. So with Napster and all these things, or Kazaa, I don't know which one, you would connect to other people and you would download things from them. And with Bitcoin, you connect to other peers, but nowadays you just connect to random peers. But perhaps in the beginning, the idea might have been, okay, you connect to peers you know, and so then you might as well, you know, do transactions with them. But right now you don't really do transactions with the
Sjors Provoostpeers you're directly connected to, at least not in Bitcoin on chain.
Aaron van WirdumYeah. Well, anyway, so that's one way of paying someone to a public key is you'd connect to their IP address and you'd get their public key. The other way is if you mine Bitcoins. So if you're a miner, then you're actually sending the block rewards to your public key. Is that still the case? It used to be the case in the beginning, at least.
Sjors ProvoostWell, in the beginning, Bitcoin had a piece of mining software built into software, right? So if you if you downloaded the Bitcoin software, it would just start mining. And so it would use that mechanism.
Aaron van WirdumWell, you just have to press a button, but yeah.
Sjors ProvoostYeah, I guess. And then later on, you know, you had mining pools and it all became more professional. So the way they would pay out might be very different. Probably, you know, might go to a multi-sig address from which it's paid back to the individual pool participants. Or it could be paid directly to the pool participants, although that's a bit inefficient because you need a long list of addresses in the coinbase. But I've seen huge coinbase transactions, so probably people were doing that.
Aaron van WirdumRight. Well, anyway, so the point I was making was this pay to public key way of paying someone. I learned this while doing a little bit of research for the show. That was only ever really used for pay to IP address and for the miner, the block reward.
Sjors ProvoostOkay.
Aaron van WirdumIt wasn't actually used for anything other than that. What was used? Other than that was pay to public key hash, right? So you're not sending money to a public key, but you're sending money to the hash of that public key.
Sjors ProvoostYeah.
Aaron van WirdumAnd this is where addresses come in.
Sjors ProvoostYeah.
Aaron van WirdumAnd this type of payment actually used addresses for the first time. Not for the first time. This was always there. Also something I learned while doing a little bit of research. This was there since day one. There were Bitcoin addresses since day one, but they were only there for pay to public key hash.
Sjors ProvoostRight, so basically so the script on the Bitcoin blockchain would in that case say okay the person who can spend this must have the public key belonging to this hash so you know the nice thing about that is that you're not saying which public key you have or at least at the time it was thought that maybe that was safer against quantum attacks but the other benefit is that it's a little bit shorter so it saves a bit on block space although of course that wasn't an issue back then. So yeah, you pay to the public key hash.
Aaron van WirdumYeah, I guess in a way it's slightly more private as well, right? Because you're only revealing your public key when you're paying. No, that doesn't make sense.
Sjors ProvoostNo, I think that exactly doesn't matter.
Aaron van WirdumNo. Okay, so that's paying to public key hash. And like you said, what you see on the blockchain itself, what's recorded on the blockchain, is the actual hash of a public key. However, when you're getting paid on a public... pay to pub key hash, what you're sharing with someone is not this hash; it's actually an address.
Sjors ProvoostYes, well you are sharing the hash but you do that using an address.
Aaron van WirdumExactly, so what is an address?
Sjors ProvoostSo an address essentially is at least this type of address is the number one followed by the hash of the public key but it is encoded using something called base 58.
Aaron van WirdumWhat's base 58?
Sjors ProvoostOkay, so let's go back to base 64. I don't know if you've ever seen an email source code, like an attachment, all these weird characters in there. That's base 64. And base 58 is based on that. But maybe to say what it is, it is all the lowercase letters, all the uppercase letters, and all the numbers, and without any of the signs, and with some ambiguous things removed. So you do not have the small O, the big O, and the zero.
Aaron van WirdumShould we start with base 10?
Sjors ProvoostYeah. So, I mean, there's two things.
Aaron van WirdumI want people to understand what base means.
Sjors ProvoostYeah, exactly. So this is what's in base 58, but then the question is, what is base?
Aaron van WirdumYes.
Sjors ProvoostAnd so base 10 is you have 10 fingers. And so if you want to express, say, the number 115, you can make three gestures, right? You show a 1 and a 1 and a 5. And that is base 10 because you're using your 10 fingers three times. And that's also how you write down numbers. But there have been different bases. I think the Babylonians were very much into base 360. That's why we have…
Aaron van WirdumHang on, hang on. Because we're not actually using fingers most of the time. So I want to make this clear that it just means we have a decimal system. So that means we have 10 different symbols that represent the number.
Sjors ProvoostThat's right.
Aaron van WirdumThe symbol zero, which is a round thing, and then we have the one.
Sjors ProvoostBut it's probably not a coincidence that that happens to [unclear]…
Aaron van WirdumI totally agree. I just want to make it clear that we're not actually using fingers most of the time.
Sjors ProvoostNo, and so the…
Aaron van WirdumOkay, so we have 10 symbols, so that means that once you get by the 11th number, at that point, you're going to have to reuse symbols you've already used, or you're now going to use combinations. So in our case, that would be... Well, it's going to get confusing because the first number is a zero. So then the 11th number is the 1 and the 0.
Sjors ProvoostYeah, exactly. And there have been different bases in use, right? So base 360, I believe, was used by Babylonians, or maybe base 60. And then for computers, we tend to use base 2 internally, because chips are either on or off. So it's a 0 or a 1, so a long series of 0s and 1s. And you can express any number of that. Now, in order to read machine code, typically you would use hexadecimal, which is base 16. So that is 0 to 9 and then A to F.
Aaron van WirdumYeah.
Sjors ProvoostRight, and so base 58 is basically this 58 possible characters to express something with.
Aaron van WirdumYeah, it's it's all it's all numbers and there's different ways of expressing a number based on your base. Yeah, and that determines how many symbols you're using.
Sjors ProvoostThe trade-off here is readability, really, because you could represent machine code as normal characters. So the ASCII alphabet or the ASCII character set is 256 different characters. So that's base 256. But if you've ever done something like print and then the name of a file, your computer will show complete gibberish on the screen and it will start beeping. And the reason it starts beeping is because one of these... codes somewhere in the base 256 is a beep which actually makes your terminal beep so it is completely
Sjors Provoostimpractical to view a file using base 256 even though there is a character for every of the 256 things there so that's why you tend to do that in base 16 hexadecimal is relatively easy to read but then it's quite long if you take a public key and you write it as hexadecimal it's it's a rather long thing to write down but and base 58 is a little bit shorter so maybe you know it's easier to copy paste perhaps or it's not even easy to read on the phone. Base 58 is pretty terrible because it's uppercase, lowercase, uppercase, lowercase.
Aaron van WirdumYeah. Okay. Just to restate that briefly. So base two is just, you're just using two symbols, which is one and zero. And base 10 is what we use most of the time. It's zero, one, two, three, four, up until nine. Then you have hexadecimal, which uses zero through nine plus A, B, C, D, E, F. And then what we're talking about here is base 58, which uses 58 different symbols, which are zero through nine.
Aaron van WirdumMost of the alphabet in both capital letters and undercase, right?
Sjors ProvoostYeah, I think it's lowercase and uppercase and then most of the numbers, but there are some letters and numbers that are skipped that are ambiguous. So the number zero, the letter O, both lowercase and uppercase, or at least uppercase is not in there.
Aaron van WirdumYeah, I think, for example, the capital I and the lowercase L are both not in there because they look too similar.
Sjors ProvoostRight, and that's why you get a little bit less than, you know, if you just add 26 letters plus 26 uppercase plus 10 numbers, right?
Aaron van WirdumOkay, I think we finally explained what base 58 means.
Sjors ProvoostYeah, and just as a sidestep, I talked about email earlier, that's base 64. That is the same, but it also has some characters like underscore and plus and equals. And that was mostly used for email attachments. And I guess they didn't want to use all 256 characters either because they didn't want the email to start beeping, but they did want to squeeze a lot of information into the attachment.
Aaron van WirdumOkay, that's base 58. Now, why are we talking about this? What is an address?
Sjors ProvoostYeah, so the address again is actually the value 0, I believe, but that's expressed as a 1, because that's the first digit in this character set.
Aaron van WirdumBase 58 system, yeah.
Sjors ProvoostYeah, so it starts with a 1, and then it's followed by the public key hash, which is just expressed in base 58.
Aaron van WirdumRight, is that all it is?
Sjors ProvoostYes. And keep in mind, so that is the information you send to somebody else when you want them to send you Bitcoin. You could also just send them 00 and then the public key. And maybe they would be able to interpret that. Probably not. You could send them the actual script that's used on the blockchain. Because on the blockchain, there is no base 58 or base 64 or anything like that. The blockchain is just binary information. So the blockchain has this script that says if the person has the right public key hash, has the public key belonging to this public
Sjors Provoostkey hash, then you can spend it. And we talked about in an earlier episode how Bitcoin scripts work. So you could send somebody the Bitcoin script in hexadecimal, anything you want. But the convention is you use this address format. And that's why all traditional Bitcoin addresses start with a one. And they're all the same, roughly the same length.
Aaron van WirdumOkay, so a Bitcoin address is basically just a base 58 representation of a version number plus a public key hash. Sjors, is base 58 used for anything else in Bitcoin?
Sjors ProvoostYeah, you can also use it to communicate a private key. And in that case, your version number is, well, it's written as 5. But it actually represents, I think, 128.
Aaron van WirdumRight.
Sjors ProvoostAnd then followed by the private key.
Aaron van WirdumSo that's why all private keys start with a 5. Or at least used to start with a 5.
Sjors ProvoostYeah, so in the old days you had paper wallets that you could print. And if you generate them actually securely without a backdoor, then on one side of the piece of paper you would have something starting with a 5. And on the other side of the paper you would have something starting with a 1. And then it would say, like, show this to other people and don't show this to other people.
Aaron van WirdumRight. Now, I happen to know, Sjors, that there are also addresses that start with a three.
Sjors ProvoostThat's right.
Aaron van WirdumWhat's up with that?
Sjors ProvoostWell, usually those are multi-signature addresses, but they don't have to be. They could be single-signature addresses. What they are are...
Aaron van WirdumThey could also be types of SegWit addresses or... They could be many things, right?
Sjors ProvoostYes.
Aaron van WirdumThey could also be... Single sig, but you already mentioned that. So let's go on. Okay, three. What does it mean?
Sjors ProvoostSo it basically says pay to public key hash. So it is that number followed by…
Aaron van WirdumPay to public script hash.
Sjors ProvoostSorry, public script hash. Well, not even public, just pay to script hash.
Aaron van WirdumWe're getting there eventually. Pay to script hash.
Sjors ProvoostYes, and it says basically anybody who has the script belonging to this hash. And who can satisfy the script. So just knowing the script is not enough you actually have to do whatever the script says you should do.
Aaron van WirdumYeah so the first version we just described was pay to public key hash which required people to offer a valid signature corresponding to the public key and now we're talking about pay to script hash which means someone needs to present the script and be able to solve the script. So why do these start with a three?
Sjors ProvoostThis is a convention, so as we said, there is a... Basically, a version number that everything that you communicate through Base58 starts with a version number. And if it starts with a 1, then you know it's paid public key hash. If it starts with a 3, you know it's paid script hash. If it starts with a 5, you know it's a private key. So it's just a convention, and it has no meaning on the blockchain itself.
Aaron van WirdumOnce again, all this is is a version number plus this hash represented in Base58. Is that all it is?
Sjors ProvoostYeah.
Aaron van WirdumThis is all. So much simpler than I once thought Sjors.
Sjors ProvoostNo, it's really simple. And the only mystery that has been solved today, I guess, is, well, what if you only use the public key, but that wasn't done using this system. So there is no initial letter that would represent trying to do that.
Aaron van WirdumYeah that was never represented.
Sjors ProvoostOtherwise… otherwise probably that would have been version zero, and then all normal addresses might have started with the two. Who knows?
Aaron van WirdumOkay I think for anyone who already knew this which is probably a good chunk of people this is a very boring episode so far but I think it's gonna get better because oh my god because Sjors, we now have a new type of address since I don't know a year or two which starts with bc1
Sjors ProvoostBC1Q even, usually.
Aaron van WirdumYeah, usually, but not always. And we're getting into that, I think.
Sjors ProvoostYep.
Aaron van WirdumSo what is this all about?
Sjors ProvoostWell, that is Bech32 or Bech32 or however you want to pronounce it. And it's been used since SegWit, basically. And again, it is something that doesn't exist on the blockchain. So it's just a convention that wallets can use. This is a, as the name suggests, a Base32 system, which means you have almost all the letters and almost all the numbers minus some ambiguous characters that you don't want to have because they look too much like numbers or letters.
Aaron van WirdumYeah, and I think one of the big differences compared to base 58 is that this time there are no longer... uppercase and lowercase letters there's just any… every letter is only in there once.
Sjors ProvoostExactly. The other difference is that it has a benefit…
Aaron van WirdumI'll mention one benefit of that which is that if you want to read an address out loud it's going to be a little bit easier now that there's no difference between uppercase and lowercase.
Sjors ProvoostYeah and the other difference is, I didn't check with base 58 but basically it doesn't start with zero or anything like that it's it looks pretty arbitrary so The value 0 is written as a Q. The value 1 is written as a P. The value 2 is written as a Z, etc.
Aaron van WirdumWhy is the value 1 just written as a 1?
Sjors ProvoostWell, it's completely arbitrary, first of all, right? You can connect any value to any symbol you want.
Aaron van WirdumSure.
Sjors ProvoostIf there is a human interpretation that depends on it, then you don't want to do anything confusing. But if your only goal is to make it easy to copy-paste things, and if your other goal is for every address to start with bc1q, because bc1 sounds cool, then maybe there's a reason why you want to do them out of order. I haven't read what the rationale is in the order.
Aaron van WirdumOkay, now Bech32.
Sjors ProvoostYeah, so there's a set of 32 characters, and… that means you're… but it's doing the same thing, right? It's again saying, okay, here's a pay to public key. Yeah, a pay to public key address. In this case, a pay to witness public key because it's using SegWit, but it's the same idea, public key hash. So it says, hello, and then followed by the hash of the public key.
Aaron van WirdumOkay, so Bech32 addresses, what are we looking at exactly? Because what we're seeing for each address, it starts with B, C, 1, and then usually a Q, and then a whole bunch of other symbols. So what does this all mean?
Sjors ProvoostThat's right. So there is something called the human readable part. And that doesn't really have any meaning other than that humans can recognize, okay, if the address starts with BC, then it refers to Bitcoin. And the software, of course, can see this too, but both humans and software can understand this.
Aaron van WirdumYeah, so if Litecoin would want to use these kinds of addresses, maybe they do actually, I don't know.
Sjors ProvoostProbably, then they might start with LT.
Aaron van WirdumExactly. So these first two letters just refer to which currency is this about? What blockchain is this for?
Sjors ProvoostYeah, and it can be, I think, a fairly arbitrary number of letters. The idea is that it's separated by a one.
Aaron van WirdumOh, it could be more than two letters as well?
Sjors ProvoostYeah, I think initially Bitcoin Cash was using a much longer introduction.
Aaron van WirdumI see, okay.
Sjors ProvoostSo that's pretty arbitrary. Obviously, you want to conserve space. So BC is nice and short. And a one, that's a separator, has no value. So if you look at what do all the 32 numbers mean, then one is not in it.
Aaron van WirdumOne just means…
Sjors ProvoostSkip this.
Aaron van WirdumThe human readable part is over. Now the fun stuff starts.
Sjors ProvoostNow the meat and potatoes.
Aaron van WirdumRight.
Sjors ProvoostAnd the fun stuff, it's a little bit easier, actually, than with Base58, because there's a convention that says if it's... Well, the convention is it starts with the SegWit version. So the first version of SegWit is 0, which in Bech32 is written as Q. And then it's either followed by 20 bytes or 32 bytes. And that is… then it means either it's the public key hash, or it is the script hash. And they're different lengths now because SegWit uses the SHA-256 hash of
Sjors Provoostthe script rather than the RIPEMD 160 hash of the script. So in Base58, the script hash is the same length as the public key hash, but in SegWit, they're not the same length. So simply by looking at how long the address is, you know whether you're paying to a script or you're paying to a public key hash, so we don't have to say it.
Aaron van WirdumRight, so to reiterate the first two letters, PC, that just means this is about Bitcoin. Then the one says, okay, that was the… part telling you which currency this is, now pay attention to what you're actually going to pay money to. Then the Q means which version is going to follow, which version of address.
Sjors ProvoostYep.
Aaron van WirdumAnd then what comes after that?
Sjors ProvoostWhich version of SegWit.
Aaron van WirdumYeah, what comes after it is actually the Bech32 representation of this hash. Which is either pay to public key hash or pay to script hash.
Sjors ProvoostYeah, exactly. Or pay to witness public key hash or pay to witness script hash.
Aaron van WirdumSjors, is there anything else cool about Bech32?
Sjors ProvoostYeah, there is. And it's about error correction. So in base 58, there is a checksum. So a checksum basically means you add something to the address at the end. And that way, if you make a typo... then that checksum at the end of the address is not going to work.
Aaron van Wirdum[unclear] going to compute with the rest of the address.
Sjors ProvoostSo it'll tell you, okay, this address is wrong.
Aaron van WirdumRight.
Sjors ProvoostNow there is a certain chance…
Aaron van WirdumIt doesn't tell you what the correct version would be. It just tells you this is wrong.
Sjors ProvoostExactly. Now there is, you know, there's a chance that you make a typo that happens to have a correct checksum. I don't know what the odds are with base [unclear]. They're pretty low.
Aaron van WirdumYou'd probably have to make several typos.
Sjors ProvoostWell, yeah, you'd have to have the unlucky typo. I don't know if the odds are 1 in 10,000 or 100,000 or something.
Aaron van WirdumRight.
Sjors ProvoostBut, you know, there's a lot of Bitcoin users. But in Bech32, it's actually better because it will not just tell you that there's a typo. It'll tell you where the typo is. And that's done differently. So where we talked about in the Base 58 system, there is a checksum, which just... takes all the bytes, basically takes all the bytes from the address and then hashes it. Here there is very sophisticated mathematical magic. I don't think it's super sophisticated, but I can't explain what the actual magic is. But the magic makes
Sjors Provoostit so that you can actually make a typo and it'll actually tell you where the typo is. And you can make about four typos and it'll still know where the typo is and what the real value is. If you do more than that, it won't. And the analogy I like to make with that... as someone once told me is it's like if you have a wall and you draw a bunch of circles on it and each circle represents a correct value and you're throwing a dart at it and you know you might hit the bullseye then you have the right value or you might just slightly miss the bullseye but you're
Sjors Provooststill within that big circle then you know you know you know exactly where it should have been.
Aaron van WirdumAre you talking about interlocking circles?
Sjors ProvoostNo, they're not overlapping.
Aaron van WirdumOkay.
Sjors ProvoostSo the idea there is you want the circles to be as big as possible, obviously, but you don't want to waste any space. So that's an optimization problem in general. And of course, in the example of a two-dimensional wall with two-dimensional circles, it's pretty simple to visualize, right? You throw the dart and you see, okay, it's still within the big circle, so it should belong to this dot. So that is like saying, okay, here's your typo and this is how you fix it.
Aaron van WirdumRight.
Sjors ProvoostBut, and in the case of Bech32, the way I think you should imagine it is that instead of a two-dimensional wall, you have a 32-dimensional wall, and the circles are also probably 32-dimensional hyperspheres.
Aaron van WirdumI find that a little bit hard to imagine, Sjors, but I'm not a wizard like you.
Sjors ProvoostWell, if you've studied something like physics or math, you know that anything you can do in two dimensions, you know, you can see it in three dimensions, and you can do it in n dimensions, you can abstract all these things out too… to as many dimensions as you need. But the general intuition is the same. So now you're hitting your keyboard, and somewhere in that 32-dimensional space, you're slightly off, but you're still inside this sphere, whatever that might look like. And so it knows where the mistake is. But there's a problem.
Aaron van WirdumOh.
Sjors ProvoostYes.
Aaron van WirdumOh, no.
Sjors ProvoostAll this amazing wizardry missed something. And it basically…
Aaron van WirdumIt lost me a long time ago, but go on.
Sjors ProvoostWell, basically, it turns out that if your Bech32 address ends with a P, then you can add an arbitrary number of Qs to it, and it still will match the checksum.
Aaron van WirdumOh, yeah, this is the bug. There was a bug in Bech32.
Sjors ProvoostYeah, so I guess the analogy would be that the circles are not entirely separate in some weird way, and that's not good, but that's actually not a problem originally.
Aaron van WirdumSo any address that ended with a P… could have any arbitrary numbers of Q following it, and then you wouldn't be told that there's a typo. Your software would think it's right, and then you're sending money to the wrong address.
Sjors ProvoostYeah, which means it's unspendable.
Aaron van WirdumRight, yeah, yeah, exactly.
Sjors ProvoostBut the good news is that there's another constraint for the original version of SegWit, SegWit version 0, which is that an address is either, well, 20 bytes or 32 bytes.
Aaron van WirdumRight.
Sjors ProvoostAnd that means that it's constrained, right? Because if you add another Q to it, then it's too long. So you still know it's wrong.
Aaron van WirdumYeah, if you have a 20 byte address and you add one Q, then it's 21, which is still invalid. So you'd have to accidentally add 15 Qs or how many were?
Sjors Provoost12.
Aaron van Wirdum12 Qs.
Sjors ProvoostYeah, or something like that. I don't know.
Aaron van WirdumThat's pretty unlikely to happen.
Sjors ProvoostYeah, because I might be confusing bytes and characters, but exactly. That's very unlikely to happen for SegWit version 0. But now we would say, okay, we're going to have a new, you know, we're going to have future versions of SegWit, such as Taproot.
Aaron van WirdumRight.
Sjors ProvoostYou know, it would be bc1p, because p is version one. And I believe for Taproot, there's also a constraint in how long these addresses are supposed to be. So it's still not an acute problem. But in the future, maybe we want to have addresses that are somewhat more arbitrary in length, because maybe you want to add some weird conditions to it. Or you want to communicate other information, not just the address. Maybe you want to put the amount inside the address.
Aaron van WirdumRight.
Sjors ProvoostSo this is why there's a new standard proposed BIP 350, which is called Bech32m. And it's actually... a very simple change. I think it adds to the all the math. It adds one extra number to that math and then it fixes that particular bug and everybody's happy.
Aaron van WirdumSo it fixes the bug that the Qs don't matter anymore?
Sjors ProvoostYeah, you can't just add stuff to it without running into problems.
Aaron van WirdumBut I guess this does mean that wallets that have by now upgraded to support these special SegWit addresses, Bech32 addresses, they now have to upgrade again.
Sjors ProvoostThat's right. So that's annoying because it does mean that if your wallet wants to support sending to a Taproot address, then it has to make a small change to the Bech32 implementation. And there's some example code on the BIP. It's not a big change because it just adds one number. And if you look at the Bitcoin Core implementation, it's a fairly simple change. That does it. But it does mean that moving forward, when you see a Bech32 address, you have to parse it, then see if it's the version 0 or the version 1, and then do things slightly differently. But
Sjors Provoosteven that is just a very small change.
Aaron van WirdumRight.
Sjors ProvoostBut it is annoying. Yeah, it does mean that especially hardware wallets with firmware updates could take a while.
Aaron van WirdumRight. So we started out with base 58 addresses. Now we're all starting to use Bech32 addresses. Is this final? Are we going to keep using Bech32 or are you anticipating some other address format somewhere in the future?
Sjors ProvoostNo, I think this will do for a long time. Bech32 is a way to write addresses. Now, what is actually inside an address, there could be more information in it, right? And the most interesting example of that is Lightning Invoices. Lightning Invoices uses Bech32, but they're much longer because they contain a lot more information. They contain the public key. They contain the amount. They contain the deadline. They contain a bunch of secrets. They contain all sorts of stuff, all sorts of routing hints even. It's like a whole book you're sending over. So
Sjors ProvoostBech32 is just an alphabet, essentially. You can make it as long as you want with this little caveat in mind that we talked about. But you're probably not going to manually type Lightning invoices anyway because they're too long. So you tend to copy-paste them.
Aaron van WirdumYeah, and generally you copy-paste any address. I don't retype addresses, do you, Sjors?
Sjors ProvoostWell, you might, I don't know, you might have some like nuclear cold storage and the addresses for that nuclear cold storage might be written down on a piece of paper because you don't want them ever to touch anything that's on the internet. But, you know, generally people copy paste, but there was some discussion early on with Bech32, I think, that was explicitly talking about, can this be communicated over the phone?
Aaron van WirdumYeah, true. That's why there's this…
Sjors ProvoostEven in your nuclear bunker situation, maybe you need to communicate something to somebody else in another nuclear bunker through smoke signals. And then, you know, you could use Bech32 for smoke signals, although maybe a Base2 system is easier. I don't know. I've never done smoke signaling.
Aaron van WirdumNo, I usually copy-paste.
Sjors ProvoostOkay, that's cool. It's also like a smoke signal, just a bit more complicated. All right.
Aaron van WirdumWas that everything there is to know about addresses, Sjors?
Sjors ProvoostI'm sure there's more, but I think this is a nice primer.
Aaron van WirdumYou're going to call it a day?
Sjors ProvoostWe are. So thank you for listening to the Van Wirdum Sjorsnado.
Aaron and Sjors discuss Bitcoin Core 32.1 and its updated security disclosure policy in this live conference recording, followed by audience questions. Links Bitcoin Core 32.1 release announcement and release notes...
Aaron and Sjors discuss the COLDCARD hack: the bug itself, how it could have happened, and some reflections on having had Coinkite as a sponsor. Note: If you’re using a COLDCARD and still haven’t moved your funds to a...
The COLDCARD hardware wallet has a critical vulnerability. If you are using the COLDCARD to store bitcoin, move them to a secure location as soon as you can. More information:...
Aaron and Sjors discuss what’s new in Bitcoin Core 31. Chapters 00:00:00 Episode 100 and Core 31 00:02:41 Cluster Mempool 00:10:45 Package Relay and Fee Selection 00:18:59 Private Broadcast over Tor 00:24:03 ASMAP and...