Bitcoin Core 0.21 supports Tor v3 - NADO 13
Ep. 13

Bitcoin Core 0.21 supports Tor v3 - NADO 13

•

Episode description

Bitcoin Core 0.21 will support Tor v3 addresses. Aaron and Sjors explain what this means and why it matters, and also discuss how new Bitcoin nodes find existing Bitcoin nodes when they bootstrap to the network.

Helpful Links:

* Tor V3 (onion) address support in Bitcoin Core: https://github.com/bitcoin/bitcoin/pull/19954

* the ADDRv2 message added in BIP155 that allows nodes to gossip those new Tor addresses: https://github.com/bitcoin/bips/blob/master/bip-0155.mediawiki#Specification

* DNS seeds and the bootstrap problem: https://stackoverflow.com/questions/41673073/how-does-the-bitcoin-client-determine-the-first-ip-address-to-connect

Timestamps:

00:00 - 00:34 - intro 

1:02 - 2:10: how Tor Works

2:25 - 3:03: benefits of running a bitcoin node behind tor. 

7:12 - 8:19 Discussing how Bitcoin node gossip addresses. 

8:56 - 10:40 Explaining how DNS works 

12:30 - 13:30: DNS is storing list of bitcoin nodes. 

Support the Show!

Follow Bitcoin Magazine on Twitter @BitcoinMagazine

Follow Aaron van Wirdum @AaronvanW

Follow Sjors Provoost @provoost

Follow Ruben Somsen @SomsenRuben

Music:

Song Title: Segwit Sounds

By: The NakamoTones

Album: Citadel Music

Produced by: Bitcoin Audio

Transcript

Download transcript (.vtt)
0:07

Aaron van Wirdum Live from Utrecht, this is the van Wirdum Sjorsnado.

0:10

Sjors Provoost Hello.

0:11

Aaron van Wirdum Sjors, you pointed out to me that Bitcoin Core has an amazing new feature merged into its repository.

0:19

Sjors Provoost Absolutely. We have bigger onions now.

0:22

Aaron van Wirdum Bigger onions.

0:23

Sjors Provoost Bigger onions.

0:23

Aaron van Wirdum Right. So I had basically no idea what it meant. You figured it out.

0:28

Sjors Provoost I did.

0:29

Aaron van Wirdum You know everything about this.

0:30

Sjors Provoost Well, I wouldn't say that. But I know a thing or two. So basically...

0:34

Aaron van Wirdum Yeah, so let's start at the beginning. It's about Tor.

0:37

Sjors Provoost Well, it's also about Tor.

0:39

Aaron van Wirdum Okay.

0:39

Sjors Provoost But Tor was kind of the big, I guess, the big motivator to get everything in there. So if you're familiar with... Have you ever used Tor? Or do you know what Tor is? I shouldn't ask those kind of questions.

0:50

Aaron van Wirdum I have a basic understanding of what Tor is, yes.

0:53

Sjors Provoost Exactly. And when you see a Tor address, it's this weird little... It looks quite weird. Right. That's a nice way to say it. And so the idea is that it's actually a public key, essentially, a Tor address.

1:07

Aaron van Wirdum Mm-hmm.

1:08

Sjors Provoost And that refers to a hidden service somewhere on the internet.

1:14

Aaron van Wirdum Right.

1:14

Sjors Provoost And the way you communicate to that hidden service is not directly, because you don't know its IP address, but indirectly through the Tor network. And you use Onion packages for that.

1:24

Aaron van Wirdum Yeah.

1:25

Sjors Provoost So the idea is that you start from the inside, like the last hop before the hidden service, and you give that hop instructions how to reach the hidden service, and then you... write instructions for the second last hop, and you give it instructions how to reach the first hop.

1:42

Aaron van Wirdum Sure, everyone is still using IP addresses, it's just you don't know the IP address of the Tor node you're communicating with. Instead, you're communicating with other Tor nodes, and every Tor node communicates with a direct peer, so everyone only knows the IP address of their direct peer, but they don't know where the message... originated or where it ends up, plus they can't read the message because it's encrypted.

2:10

Sjors Provoost That's right.

2:10

Aaron van Wirdum And in order to support this, all of these Tor nodes have their own sort of IP address, which is their Onion address, and that's what they use to, that's what you're communicating with directly, so to say.

2:23

Sjors Provoost Yeah, and Bitcoin Core nodes can run behind such a hidden service. So everybody can have their Bitcoin node run at a secret location, so your IP address remains secret.

2:35

Aaron van Wirdum Right. What's the practical benefit of that?

2:37

Sjors Provoost Well, your IP address remains secret. So if you don't want the rest of the world to know that your IP address is running a Bitcoin node, maybe that's useful.

2:48

Aaron van Wirdum Yeah. And I think it's also because if you're sending transactions... from an IP address, then network analysis can reveal where transactions originated. Although I guess that's also being solved, right? There's other solutions for that as well.

3:03

Sjors Provoost Well, that's defense in depth, right? So ideally your node behaves in a way that it looks indistinguishable from all other nodes. So your node downloads all the blocks and it downloads all the mempool transactions and you can't tell which wallet is running inside which node, but there's all these sneaky companies that try anyway. And then they might know that you sent a specific transaction. Well, then they might know which Bitcoins belong to you. And since your IP address is, you know, quite easy to figure out who you are, it could be nice to have Tor.

3:35

Aaron van Wirdum Right.

3:36

Sjors Provoost In theory. But regardless, I mean, that's just how it works.

3:40

Aaron van Wirdum Okay, so you can use Bitcoin from behind Tor. And I think the thing was that there's a new type of onion addresses. There was an updating in the Tor protocol.

3:52

Sjors Provoost That's right.

3:52

Aaron van Wirdum And that uses new addresses.

3:55

Sjors Provoost Yes. So the Tor addresses are now longer, essentially, which just makes them more secure. And I guess we don't need to go into why that is because I don't know why that is. All we know is that Onion addresses now, version 3, are a bit longer. That means that if you want to keep running a Bitcoin node on Tor, you'll have to use those longer addresses. Because Tor is centralized, and they have decided to eventually get rid of the version 2 addresses.

4:23

Aaron van Wirdum Okay, but they didn't yet. So right now, version 2 addresses are still usable?

4:27

Sjors Provoost Yes, I think they've been officially deprecated now. And I think in about a year or so, they won't work anymore.

4:33

Aaron van Wirdum I see. So anyone who wants to continue using Tor needs to upgrade before... Next year, so to say.

4:42

Sjors Provoost Something like that. Roughly.

4:43

Aaron van Wirdum So that's why Bitcoin would need to be upgraded in order to support this new address.

4:47

Sjors Provoost Yes. So then we get to the question of why would this make a difference? What's wrong with a longer address? And that has to do with how Bitcoin nodes spread the word about who they are. Because how do you know... which node to connect to. And the idea there is that nodes can communicate with each other. They send each other lists of known nodes. So they ask each other, hey, which Bitcoin nodes do you know? And then they get a list of IP addresses. And generally those are either IPv4 addresses or IPv6 addresses. IPv6 is the new kid in town since, I don't know, 1998 or something.

5:26

Aaron van Wirdum Right. These are the regular IP addresses.

5:29

Sjors Provoost Correct.

5:30

Aaron van Wirdum Yeah, and the IP 6 ones are longer as well, and that's because IP 4 was running out, right?

5:36

Sjors Provoost Right, there's only, I think, 4 billion potential IPv4 addresses, whereas there's just enough for every molecule in the universe of IPv6 addresses.

5:46

Aaron van Wirdum Right, so there's a list, or Bitcoin nodes keep lists of other Bitcoin nodes and their IP addresses.

5:54

Sjors Provoost Yes, and the way you would communicate a Tor address that way is you would kind of piggyback on IPv6. Because there is a convention, I think it's used outside of Bitcoin too, where if the IPv6 address starts with a certain prefix, certain numbers, then everything that follows is the Tor address. Because the Tor version 2 address, let me see if I got it right, an IPv6 address is 16 bytes and a Tor address is only 10 bytes. So you can hide inside of it.

6:26

Aaron van Wirdum So Bitcoin nodes keep... The IP addresses of other Bitcoin nodes they know, and these are these IPv4 and IP6, and some of the IPv6 are also the Tor addresses.

6:38

Sjors Provoost Exactly.

6:38

Aaron van Wirdum And this is what, when nodes connect with each other, they share their lists, so everyone has an even more complete list of all of the Bitcoin nodes. Is this correct?

6:48

Sjors Provoost That's right, yes. The problem with Tor version 3 addresses is that they are 32 bytes, which is twice as long as an IPv6 address.

6:56

Aaron van Wirdum Right, so now you can't hide it inside an IPv6 address.

6:59

Sjors Provoost No, so just nodes have no way to communicate those addresses at the moment.

7:04

Aaron van Wirdum Right. So that has been upgraded.

7:08

Sjors Provoost Exactly. So this is not rocket science to solve, but somebody actually needs to do it. And somebody, Wladimir van der Laan, wrote a standard a while ago, I think in 2019, that has a new way of communicating, of gossiping addresses. And the major change is that you can, each message says, okay, this is the type of address I'm going to communicate. And there can be various types, including the new Tor one, but also future ones. and then it can have different lengths.

7:39

Aaron van Wirdum Right.

7:40

Sjors Provoost So in the future, if a new address format comes along that's too long, that's not going to be a problem.

7:44

Aaron van Wirdum Right. So that sounds like a pretty straightforward upgrade from my layman's perspective as a non-programmer.

7:52

Sjors Provoost It is.

7:53

Aaron van Wirdum But a very important one because we do want to keep using Tor potentially.

7:58

Sjors Provoost Yeah, and the nice thing is it's a completely new peer-to-peer message. So I guess old nodes just... ignore that message or if you know it's an old node that you're talking to you don't use that message so newer nodes will will know this new message and can communicate all these new address types and older nodes just carry on like nothing happened.

8:18

Aaron van Wirdum Right. Okay, I have one one follow-up question about this sharing of lists and sharing of IP addresses which is not Tor specific I guess, but what, how does it actually, how do you actually connect to the first node? How do you bootstrap to the network? if you have no idea, if you have no list yet of other nodes, then how do you find the first node? How does this actually work in Bitcoin?

8:44

Sjors Provoost Yeah, so the bootstrap problem, basically, you've just downloaded Bitcoin Core or some other client and you start it up, and now what? Is it just going to guess random IP addresses? No, right? So it needs to know another node to connect to, at least one, preferably a couple. The way it tries to do that is using something called DNS seeds. The internet DNS system is used for websites when you type an address, www.google.com. What your browser does is it asks a DNS server what IP addresses are from that Google domain.

9:18

Aaron van Wirdum Do you know how many DNS servers there are?

9:21

Sjors Provoost Lots of them because... Basically, if you run a website, your hosting provider will have a DNS server that points to your website, but then your country will have a DNS server that will point to your hosting provider, and your internet provider has a DNS server that points to all these different countries, et cetera, et cetera. So it's very redundant, basically.

9:44

Aaron van Wirdum We're going very off the trail here, but I do find it interesting. How are these DNS servers, how do they remain in sync?

9:52

Sjors Provoost So basically, when you have a DNS record, so if you are maintaining a website, you usually have to go into some control panel and type in the IP address of your server and then your domain name, and that's stored on the DNS server. One of the fields you have to fill out is the timeout. So what you're saying is after 24 hours, for example, or after one hour, you should ask me again. So when you're... when you're visiting a website, you're going to ask maybe your ISP, hey, do you know the IP address for this website? And if it doesn't, it's going to ask the next DNS server up the street, basically. Say, do you know it? And then as soon as it finds a record, it's going to say, okay, is this record still valid or is this expired? And if it's still valid, it'll use it. And if it's expired, it'll go up closer and closer to the actual hosting provider. So it's basically cached. Does that make sense? So the easiest would be if you go to a domain, like, say, google.com. Okay, how do you find the IP address? Well, you ask Google what the IP address is. But how do you know what the IP address is for google.com? You don't know that because that's what you were trying to find out. So you have to ask somebody else. And so you ask your internet provider, do you know the way to google.com? Well, your internet provider might not know that, but it says, well, I know the way to .com. basically, and .com will know the way to .google.com. So that's kind of how it works. .nl, same, you go to, you ask .nl, you know, where is Google.nl?

11:27

Aaron van Wirdum Okay, yeah, that makes total sense.

11:29

Sjors Provoost Yeah, and ideally, they already have this cached because so many people go to Google.com that if you ask your ISP, where's Google.com, they'll know because somebody else asked. But if they don't know, they'll send you to .com.

11:40

Aaron van Wirdum Right, okay, well, so this is where I'm really getting at. The DNS system is ultimately centralized, right?

11:47

Sjors Provoost Yes.

11:48

Aaron van Wirdum There's a centralization risk there.

11:50

Sjors Provoost Absolutely.

11:51

Aaron van Wirdum Where you're trusting the DNS server.

11:53

Sjors Provoost And for Bitcoin, we're kind of abusing it.

11:55

Aaron van Wirdum Right.

11:56

Sjors Provoost Because Bitcoin nodes are not websites. But the idea is that there are a couple of core developers who run DNS seeds, which are essentially DNS servers. And we're just pretending that, for example, seed.bitcoin.sprovoost .nl, which is what I'm running, is a website, quote unquote. And when you ask that website, quote unquote, what its IP address is, you get a whole list of IP addresses. But those IP addresses are Bitcoin nodes. And every time you ask it, it's going to give you different IP addresses.

12:28

Aaron van Wirdum Right. So what if someone corrupts you?

12:31

Sjors Provoost Well, one step back. So this means that the standard infrastructure of the internet, all the internet service providers in the world and all these others are caching exactly where all the Bitcoin nodes are because they think it's just a website. So it's kind of nice that you keep all these lists of nodes redundantly stored on the internet. And there's quite a few protections on the internet against censorship of DNS. So you're leveraging all that. But at the same time, of course, if I and the other people were to lie and run a fake server, we could send you to any node we want. But that would be very visible.

13:05

Aaron van Wirdum All right. And the reason it's visible is because anyone can request these IP addresses from you and then check if they're actually Bitcoin nodes or not, or if you're trying to cheat there. That's the reason they're visible. Yeah, exactly. It would be hard to cheat.

13:20

Sjors Provoost If you were to cheat like that, like very non-randomly, like to add to the whole world, it'd be very obvious.

13:26

Aaron van Wirdum Right. So, but what if it happens? Like, is there another way to connect to the Bitcoin network at that point?

13:31

Sjors Provoost Well, if they're lying, it's tricky. But if they're just offline... So if all the Bitcoin DNS seeds are not reachable, then inside the Bitcoin core source code and also in the thing you download is a list of IP addresses and as well as a few hidden services.

13:47

Aaron van Wirdum Right. So that's also Bitcoin nodes. They're embedded into the source code.

13:52

Sjors Provoost Yeah. So every year or so.

13:53

Aaron van Wirdum Which nodes are these or why are these embedded in the source code?

13:57

Sjors Provoost Okay. So it happens every six months or so, is we ask all the DNS seed maintainers to provide a list of the most reliable nodes. Just all the nodes sorted by how frequently they're online. Because your DNS seed tends to track, I've polled this node once and it was online. So basically what a DNS seed does on its side is it is just a crawler. So the DNS seed goes to a couple of Bitcoin nodes, asks it for all the nodes it knows, keeps a list and just goes to the list, pings them all. And then once it's done pinging them all, it's just going to ping them all again. And it keeps track of how often they're online. And so you make a list of that sorted by reliability. You take that from all the contributors and that goes into the source code. So that's the fallback.

14:48

Aaron van Wirdum Interesting.

14:49

Sjors Provoost But it's only the first time you start your node, at least in theory. So only the very first time you start your node, you need this. After that, you keep track of the nodes you know about. You store all these gossip nodes in a file and you start opening the file and you just try the nodes you know about. And only if you run out, if it doesn't work, you ask the seed again.

15:10

Aaron van Wirdum Yep. And then you keep syncing your list of IP addresses with the new nodes.

15:16

Sjors Provoost Yeah, exactly. I think whenever a node connects to you for the first time, that's one of the first things they ask. Who else do you know? I think you can even send them unsolicited.

15:26

Aaron van Wirdum Okay.

15:26

Sjors Provoost Which is why, you know, if you start a new node, you get inbound connections pretty quickly because you've announced your IP address to other people and they're gossiping it around and these other nodes then start connecting.

15:38

Aaron van Wirdum Interesting. Okay, so that makes it pretty clear to me. You bootstrap to the Bitcoin network by first querying DNS records to find other Bitcoin nodes. You get a list of IP addresses. You use these to connect to the actual Bitcoin nodes, which could also be Tor nodes at that point, right? These you can also query from the DNS records. At that point, you ask... about all of the nodes they know and you update your list and from that point on you're also sharing the IP addresses you have with other nodes. So far these were IPv4 and IPv6 and IPv6 had a subset of onion nodes and with this upgrade we'll be ready for a newer version of onion nodes. That's the story.

16:28

Sjors Provoost That's about right.

16:29

Aaron van Wirdum That's our podcast.

16:29

Sjors Provoost Great. And one tiny little thing that was recently added is that the Bitcoin node actually can spin up the version three onion node, but that is actually like a five-line change. So that's quite nice. That'll just work, TM, when you start a, I don't know, I think it's version 0.21. If you start it up, if you were running a version two node before, it's going to run a version three Tor node after. If you weren't, then you need to read the documentation how to set it up if you want to use it.

16:57

Aaron van Wirdum Good.

16:59

Sjors Provoost So, yeah. That's all.

17:01

Aaron van Wirdum I guess that's it. All right. Guys, I forgot to mention something.

17:04

Sjors Provoost Oh, my God.

17:05

Aaron van Wirdum I have amazing news.

17:07

Sjors Provoost Tell me.

17:08

Aaron van Wirdum Actually, Sjors, you already know the news.

17:09

Ruben Somsen I know.

17:10

Aaron van Wirdum Ruben.

17:10

Ruben Somsen What's the news?

17:11

Aaron van Wirdum The van Wirdum Sjorsnado has its own feed now.

17:15

Ruben Somsen Wow.

17:15

Aaron van Wirdum Its own RSS feed, and it showed up in my podcast app.

17:19

Sjors Provoost Excellent.

17:20

Aaron van Wirdum So, I'm now subscribed to the van Wirdum Sjorsnado. If you're listening and if you want to hear it for all our episodes, then you can subscribe to the van Wirdum Sjorsnado.

17:29

Ruben Somsen I'll be subscribing for sure. It's actually exactly what I was asking you guys for, like what I was missing. I just wanted to be able to subscribe to your podcast specifically, so great.

17:37

Aaron van Wirdum That's two subscribers already, Sjors, me and Ruben. That's excellent. We're on a roll.

17:42

Sjors Provoost I was already subscribed.

17:44

Aaron van Wirdum It's free.

17:45

Sjors Provoost Another related news is that we have had our first swap cast.

17:49

Ruben Somsen Oh yeah, that's true.

17:50

Sjors Provoost Because we actually featured on the Unhashed podcast.

17:54

Ruben Somsen That's right. Yeah. So sometimes we're getting technical issues or whatever and unable to record. And then what we do is we look at other... podcast or something where maybe I appear or one of the other guys and we broadcast that so in this case I came onto your show so I asked you guys maybe we can put that on the Unhashed podcast so our Unhashed podcast listeners were also able to listen to the last episode and probably you know if I don't know a couple weeks from now we run into issues again maybe I'll be asking you to air this episode so, maybe it'll be number two.

18:25

Sjors Provoost Yeah, and if you need an extra motivation to check that out, we actually re-edited the audio, so it's going to be a little bit better than the original.

18:32

Ruben Somsen Yeah, that's correct.

18:32

Sjors Provoost Check it out.

18:33

Aaron van Wirdum All right, I wanted to mention that.

18:34

Sjors Provoost Thank you for listening to the Van Wirdum Sjorsnado.

18:37

Aaron van Wirdum There you go.