Blockchain
I was just about to start writing this blog when Medium editor warned me that Blockchain is not a recognized English word. Shame on you Medium!
About 2 years ago when I was in my junior year at Computer Science in Bilkent University, my friends suggested me to take the senior design project a year early and join their group. I thought to myself that this was a great chance to gain a rare experience in college. Also, this would mean clearing my senior year from many troubles. So, I agreed.
They had already decided on the supervisor and already received a project proposal to work on. A cryptocurrency with DNA Read Mapping as proof-of-work. Written paper, or preprint whatever you call it, was slapped to my face as I was in the summer of my second year at Computer Science. What the hell is Read Mapping? What the hell is a cryptocurrency? What does proof-of-work have to do anything with these two? As you may have guessed, I was overwhelmed under pressure to the point that I thought to myself this was a huge mistake. That feeling didn’t last long because I confronted one of my group friends and he had no idea at the time either. In the end, we spent 7 months on understanding the concepts, figuring out a design and writing reports until we had 2 weeks remaining to actually implement the project.
Meeting with Blockchain
What is my purpose?
CryptoCurrency part seems easy. I can check that out.
I cannot stress this enough but you must know that I really thought the easy part was cryptocurrency. The reason is that we had false presumptions like:
- Bitcoin is already open-source. Let’s just add some fine details. Start our own currency on a new blockchain.
- There are now tons of different currencies. They must have used a core implementation.
- Even if Bitcoin code turns out to be difficult, we can still find reference implementations that cover basic structure of a blockchain.
I’m not going to delve into details on each of these items. You only need to know that they all are very stupidly wrong. After eventual realization on what is going on, I probably took the most logical action by pure chance. I decided to read Bitcoin white paper from start to the end until it makes sense. I didn’t participate in 3 days(thanks Bilkent!) spring break, play much Dota, nor I used my mind on about anything as hard as I did on Bitcoin. Now, looking back, it feels like it should not have been as difficult as I remember but back then these concepts were very new to me.
When all the pieces started to come together in my mind, I finally understood what we were trying to do and how we should do it: “This is going to suck a lot.”
What is a blockchain?
It is the technology, design, algorithm that makes Bitcoin possible. Through out 2 years, many people asked me the same question again and again and my answer kept evolving. Current draft of my answer is as follows:
- Think of a basic linked list.
- In this linked list you keep data on each node which makes it a database candidate
- Everyone has a copy of this linked list because no one trusts anyone else. Better to check to catch any suspicious activity.
- People want to store their data on this database, however there needs to be an order because everyone wants to have the same linked list. Or else, a “data sharing/accessing between multiple threads” problem might emerge.
- Mutex(mutual exclusion) among all participants is impossible. Instead, lets give everyone a really hard math problem(DOH!) and first one to solve it gets the right to add a new node on this linked list. But don’t forget to add waiting transactions(write requests of others).
- There are bad people but in general we are not total jerks. Let’s give this guy a credit and accept his new node, add it to our linked list. Also, if nothing seems suspicious and he added many write requests of others, give him a little reward for doing such a good job.
- Now, everyone has the same linked list with ordered data. So we can look at back and see whether anyone ever cheated.
Q&A:
- Q: What if two bright students solve the problem at the same time and their nodes are different?
- A: They are both right. Let’s wait for someone else to propose a new node. Whichever competing node that new node is supporting, we also support that. Rule 1 LCW: The longest chain wins.
- Q: Some bad guy wants to erase or modify something that I put in, what then?
- A: Thank god we have Public Key Cryptography. Unless s/he can prove your identity, no one can change a damn thing you own.
- Q: I made a mistake adding my data, can I reverse that?
- A: 2 options. Choose whichever you want to take: A) Go back to the node you made erroneous action, fix it, starting from there solve as many math problems as you need to win the longest chain competition. B) Make a reverse action, submit for addition to the list at the next node, quickly fixed!
- Q: That bad guy is back with more evil. Now the purpose is to change everything.
- A: Look at previous answer option A. If this evil guy is so intelligent at math that he proves he is better than other good intended people, he actually wins (51% rule). One option is to say forget this guy, we take our linked list and go somewhere else. He can bully other nerds!
I think this is my current draft on what blockchain is. Now to understand how Bitcoin uses this is very easy. We need to make some changes to the keywords we used:
- Linked List: Blockchain
- Node: Block
- Data: Transaction
I guess this mapping was obvious from the start but do not forget that I needed this to explain so many times.
After getting a grasp of blockchain and its capabilities, I focused on implementation and where to start that. My adventure in senior project and beyond will continue in a future post. Thanks for reading my first Medium post. Cheers!
