A little example in XOR


#1

As I tried to get more insight in the whole idea of SAFE with using XOR I made a little example. I will post it below and after that I’ll post some statements which I think apply to the system. Feel free to jump in and/or correct me if I’m wrong.

Close groups in XOR.
David wrote a very nice post about this topic on his blog. And to make things more clear I use 6 countries and apply some random numbers to them. I used this website to calculate XOR-distance.

I’ll calculate 3 XOR-groups from the perspective of 3 countries. I’ll use 2 close nodes to keep things simple. So first, let’s assign some random number between 1 and 100 to the 6 countries:

  1. Germany (77)
  2. Holland (32)
  3. China (12)
  4. United States (58)
  5. United Kingdom (47)
  6. France (99)

Now as I live in Holland I’ll start from my own perspective and see which are my closest nodes. The first one in the list is Germany so to calculate the distance to that node I’ll use the XOR-calculator and calculate the distance between 32 and 77. The answer is 109. Note that this number is higher than 100. Even if all our node numbers are between 1 and 100.

Close group for Holland
Distance to Germany = 109
Distance to China = 44
Distance to US = 26
Distance to UK = 15
Distance to France = 67

Holland’s 2 closest nodes are > UK and US.

Close group for UK
Distance to Germany = 98
Distance to Holland = 15
Distance to China = 35
Distance to US = 21
Distance to France = 76

UK’s 2 closest nodes are > Holland and US.

Close group for US
Distance to Germany = 119
Distance to Holland = 58
Distance to China = 54
Distance to UK = 21
Distance to France = 89

US closest nodes are > UK and China.

Now notice that the number of nodes in this network is extremely low. That’s why we see the same countries pop up as close nodes. In the real SAFE network we’ll probably have at least thousands of users. Notice that closeness in XOR depends on the perspective from the address even in this little example. You being close to a node doesn’t mean that node is close to you as well. So what can we conclude about close nodes in XOR?

  • In a group of nodes from your perspective, all nodes have other close nodes than you. This means your group of 32 close nodes actually has a total of 32 X 32 = 1024 nodes in it all together. It’s 32 groups in total!

  • If you target a group, you’re actually targeting 1 node. Because again, it all depends on from what perspective you look. If you were able to get closer and closer to an address (by creating new addresses to get close to someone which isn’t possible) you could become a group close to 1 node. Even if you succeeded in taking over 1 node you’re probably not close to any other node in the whole network at the same time.

  • On HOP 1 you can reach 32 nodes. On HOP 2 you can reach 1024 nodes. On HOP 3 you can reach 32.768 nodes (relay nodes are not counted as HOP’s in this example). You’ll get to a million at HOP 5.

  • If 1% of all users on the network are watching the latest episode of Game Of Thrones. You could be served Chunks out of cache from around 10 nodes at HOP 2 without your request (GET) ever reaching a Vault and without triggering a Farming Attempt somewhere.


#2

Thank You for taking time to explain XOR in examples , I found it informative and I am sure others will also gain a better understanding of XOR , the exotic creature it is to most of Us who aren’t deep enough into this , yet :ant: The Ants are coming :ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant::ant:


#3

This would fit well in the faq section of the wiki.


#4

That’s why I think the first (“lead conspirator”) node is the one you need to find if a hostile gang of nodes wants to overtake a group.
I think this approach significantly shortens the time required for a group of 32 nodes to find themselves in the same group.


#5

Very cool. I’ve linked this post in the SAFE Network School podcast on XOR). Thanks!


#6

Sounds pretty SAFE to me!