Cryptocurrency 101 (Part 4)

Photo Credit: ApolitikNow Flickr via Compfight cc

Part 1     Part 2     Part 3

Last week, I discussed 2 out of 3 key ideas of blockchain technology — how it uses cryptography to protect transaction data and how it uses distributed networks to maintain data integrity — that is, complete copies of its transaction ledgers can be freely downloaded and maintained by “miners,” thus securing the blockchain network.

The third key idea explains why anyone would bother downloading and running  “mining” software. Why would you spend resources such as computer hardware and electricity to run this piece of software? The answer is that you are rewarded for doing so. That is the third key idea — incentivized computing.

To understand this, let’s go back to the idea of a blockchain as a ledger of transactions. In a physical ledger like a notebook, transactions are recorded sequentially in different pages. You start at page 1, then 2, and so on. On the blockchain, transactions are recorded in “blocks” which are produced sequentially over time, thus they are “chained” together. The first block (usually called the genesis block, block 1, or block 0) is produced before the second block, the second before the third and so on. Each block contains a certain number of transactions.

Now, each miner in the network has the opportunity to produce a block. The miner that produces the block is rewarded by being given a certain amount of tokens or coins, as well as the fees for the transactions in that block. (As mentioned before, making transactions on a blockchain network usually involves paying some kind of fee — like the fee one pays to send money via wire transfer. So for example, to send 10 bitcoins to another account, one would pay 0.0001 bitcoin as a transfer fee.)

So how is the miner of a particular block determined?

At the beginning of every cycle, the miners are tasked to solve a mathematical problem. This problem is automatically produced by the blockchain program itself and is given to all the miners. When a miner solves the problem, it broadcasts the solution, which is verified by the other miners and once verified, that miner is then rewarded with the authority to produce the block.

I’ll try to make it clearer. Imagine that there are five accountants seated in a circle. Let’s call them A, B, C, D and E. Each accountant has a phone, pen, paper and a loose-leaf ledger (e.g. a ring binder where you manually add pages instead of a notebook that already has the pages bound together).  In the middle of the circle is a mysterious printer which produces mathematical problems for each accountant to solve.

Now, all of these accountants are ambidextrous and are capable of writing with their right and left hands at the same time. Their left hand is always working on a mathematical problem and their right hand is always ready to write transaction details. Each time someone wants to make a transaction on the network, one or more of the accountants gets a text message with the details of that transaction, which they write with their right hand.

That transaction may contain something as simple as “transfer x amount of coins from account abc to account xyz” and then contain a verification key to validate that transaction (this is handled by the private-public keypair discussed in part 3).

The accountant who receives that message then broadcasts it to the other accountants who also write the details on their own papers. So with their left hand they trying to solve a problem while with their right hand they are recording a list of transactions. Now, let’s say accountant B solves the problem. He then announces the solution to the other accountants who then check and verify that it is indeed correct. Once verified, B then gets the privilege of making a final copy of the transactions, and then add that page to his ledger. The others will then make an exact copy of that page and add it to their own ledgers. In addition, B gets bonus pay for solving the problem.

Then the mysterious printer in the middle produces another problem, and the cycle begins again.

The accountants in that example are the equivalent of the mining computers that run the blockchain. Everything that I’ve described is done automatically by the program and requires no human intervention except for initiating a transaction, of course.

I should note that I have given a simplified narrative of the mining process and did not bother going into more details such as what if one of the accountants has malicious intent (simulating a hacked miner), or is it possible for a transaction to be excluded from the final list of transactions for a block, and so on. These issues would just confuse the novice. I guess it should suffice to say that many exceptions have been considered and addressed, and the more a coin matures, the more updated and upgraded its core code becomes.

I have also only discussed one type of mining — this one is called proof-of-work. There are other types of mining — proof of stake, delegated proof of stake, etc. Again this is to avoid confusion, and you may read more about these other methods once you have gained the basic idea.

Originally published in Sunstar Davao.

Email me at andy@freethinking.me. View previous articles at www.freethinking.me.

Cryptocurrency 101 (Part 3)

Photo Credit: markethive Flickr via Compfight cc

Click here for Part 1

Click here for Part 2

What is blockchain technology and how does it work to provide decentralized transactions?

Blockchain technology is built on 3 key ideas:

  1. Private-Public Key Cryptography
  2. Distributed Networks
  3. Incentivized Computing

Cryptography is the process of writing and reading coded messages. The process of writing it is called encrypting and the process of reading it is called decrypting. In order to properly read and write a message, one needs a key which is the formula to unlock the message.

One of the simplest methods of encryption is direct substitution. An example of this is for you to take a sheet of paper and write the letters A to Z in one long column downwards. On the next column, beside the letter A, start with another letter, for example M, then continue downwards. So you would write N beside B, O beside C, and so on until you get to Z and then you start again at A.

This now is your key.

That means the when you want to write the letter A, you should instead write M. And when you want to write the letter B, you should write N, and so on.

Using this method, the word “apple” will be written as “mbbxq” and the word “balloon” will be written as “nmxxaaz” and so if we write an entire message this way, it will appear as gibberish to someone who does not have the proper key to decode it. Of course, a simple code like this can be broken very easily even by a ten-year old, which is about the age I got interested in this sort of thing.

So one can make a more complex formula, for example a=”45w”, p=”x3e”, l=”ch”, e=”6a” so now the word “apple” will read as “45wx3ex3ech6a” and this will be a more difficult code to break. Modern encryption takes advantage of the power of computers to do very complex calculations and so are many orders of magnitude harder to break than these simple encryption methods.

One of the most popular modern encryption technologies is called the private-public keypair. These keys are typically very long numbers which may look like this: “3048024100C918FACF8DEB2DEFD5FD3789B9E069EA97FC20.” Your private key is yours alone while your public key is the one you give to people you want to transact with. For someone to send you an encoded message, he only needs to know your public key. Once he encodes the message, even he will not be able to decode it, as you will need the private key to do that.

Blockchains use this method to ensure that your transaction is authentic, authorized and secure. In fact, this method is more secure than simply typing a password on a web browser.

Next, the blockchain uses the idea of a distributed network. Most of our transactions use the client-server model wherein the data resides in a central repository. For example, if we are doing online banking, all the data resides in the bank’s servers (and nowhere else). Therefore, if someone would be able to hack that server and modify certain transactions, it would be possible for that person to make a cash transfer of P1,000 to his account appear to be P1,000,000. If he were then able to withdraw that amount before the hack was discovered, then he would have gotten away with free money.

The same thing happened to a local bank several weeks ago where there was an IT glitch which caused some people to see their bank balances suddenly go to zero or negative, while others were surprised to see more money than they should have in their accounts. In fact, some were able to withdraw this excess cash before the glitch was discovered and all machines were taken offline to prevent further damage.

This happened because the transaction records were centralized and any alterations (whether authorized or malicious) to those records will immediately affect the clients accessing those records.

In contrast, cryptocurrency uses a distributed system which essentially has multiple transaction ledgers. Anyone can download and secure a copy of these ledgers. Transactions are recorded in segments called blocks, and these blocks are produced regularly and sequentially — that is why it is called a blockchain.

The software to record transactions and secure the blockchain network is called a “miner” or a “node,” and it is typically open-source and free for anyone to download and run. So anyone who does this will have a complete record of the entire blockchain since the beginning. It’s like having a complete record of all your bank’s transactions on your computer.

So now, there is no central repository of the data, and the integrity of the data can be quickly compared with all the other miners or nodes in the network. For example, if someone were able to hack my computer and change the transactions there, once the program verifies that data with the rest of the network, it will discover that my records are different from the vast majority of other miners and thus will automatically reject those hacks. For a hack to be successful, the hacker must be able to manipulate the records of 51% of all the miners in existence — a feat which is near-impossible for popular cryptocurrencies like bitcoin or ethereum which has thousands and thousands of miners all over the world.

But why would someone want to download and run a miner or node on his computer? We’ll tackle the next key idea, incentivized computing, next week.

 

Originally published in Sunstar Davao.

Email me at andy@freethinking.me. View previous articles at www.freethinking.me.

Cryptocurrency 101 (Part 2)

Photo Credit: Diari La Veu – http://diarilaveu.com Flickr via Compfight cc

Click here to read Part 1.

Last week, I said that a key concept in cryptocurrency is the idea of a trustless transaction. Let me now expand on that idea.

A lot of things we do with our money involves trusting an entity other than the one with whom we are transacting. That means if Jose wants to buy a watch from Maria, he has to trust another person or entity other than Maria, and likewise for Maria.

Let’s go with the clearest example first. Jose sees a watch on the internet and wants to buy it. He sees that the merchant is Maria and after doing some background research, he decides that Maria is trustworthy and is not a scammer. So he transacts and buys the watch using his credit card. Aside from trusting Maria, he is also TRUSTING:

  1. The owner of the website to handle his transactions securely. But this can also be checked visually by looking at the address and making sure the transaction is sent over a secure layer (https instead of http).
  2. The owner of the website not to use his credit card information maliciously. Since Jose has entered all the pertinent details of his card, the website owner can theoretically store this information and use it for ill intentions.
  3. The credit card issuer to settle the payment for him, and then bill him correctly afterwards.

These are some reasons why people are still uncomfortable with online transactions using credit cards, although that number is growing smaller.

But from Maria’s point-of-view, there is also some trust involved. She is also trusting the credit card company to pay her.

But what about if Jose uses physical cash to transact? If he goes to Maria’s store and buys the watch and hands over his money, does he still need to trust a third party? Well, yes, he is effectively trusting the Philippine government which is backing up the value of the pieces of paper he is handing over to Maria, and Maria is also trusting the government for the same thing — that the pieces of paper she is receiving has value. If Maria received that money now and 5 minutes later, she hears on the news that the government has just declared bankruptcy, that money will be worthless.

Now what if Jose simply keeps his money in the bank? There is still trust involved. Jose trusts that his money is “safe” in the bank and that when the time comes when he needs to withdraw it, the money will be readily available. But what happens when there is bank run or when the bank declares bankruptcy? Jose will be unable to recover his money beyond the maximum amount he can claim via insurance.

This issue of trust could be felt quite recently when a local bank had some problems with its systems that caused some depositors to have negative balances, double transactions, and other such errors. This caused some people to lose their trust in that bank and transfer to another bank — but what they don’t realize is that the very same thing could also happen to whatever bank they run to. Human error, carelessness and negligence is unfortunately universal.

What I hope you see here is that the power of our money system today still derives from central authorities from banks to central banks to governments. These central authorities are prone to security failures such as hacking, or even simple mistakes in programming, or manipulation by those in power within that authority.

Cryptocurrencies, by their very nature and programming, try to move away from the idea of a central authority to being truly decentralized. That does not mean that there are no rules, but that the rules, once set, will be virtually impossible to hack or to manipulate, even by the program authors themselves.

To understand that, we have to understand a key architecture of cryptocurrency called the blockchain, which I will explain next week.

Originally published in Sunstar Davao.

Email me at andy@freethinking.me. View previous articles at www.freethinking.me.

Cryptocurrency 101 (Part 1)

Photo Credit: btckeychain Flickr via Compfight cc

 

If you had 100,000 pesos in around February of 2011 and decided to buy bitcoin then (which was priced at around $1 each), and then just left it alone, you would be richer today by around 300 million pesos.

Now, before you get that urge to hit your head on the wall again and again (like me), you have to realize that you would have had to fight off the urge to cash in after its value had risen and fallen again and again. You would have had to fight off the urge to get rid of it after some major setbacks like the fall of famed bitcoin exchange Mt Gox, or China prohibiting its financial institutions from dealing in bitcoin in 2013, or the multiple times “experts” had pronounced that bitcoin was dead or dying.

Bitcoin prices have swung wildly from $1 in February, 2011 to $31 a mere 6 months later in July, and then back to $2 in December of that same year. By December 2012, it was back up to $13. By December 2013, it peaked at at $1000. In March 2014, it went down to around $600 and slowly decreased until March 2015 when it reached a low of $200. Then it began picking up again to around $500 by the end of 2015. By December of 2016, it was around $800. Since then, it has reached an all-time high of $2,800 as of this writing.

I learned about bitcoin in 2013 but didn’t really take it seriously because I couldn’t understand it and the few articles I found about it then connected it to the black market website, The Silk Road, where one could use bitcoin to buy all sorts of things including illegal items like fake driver’s licenses and illegal drugs which comprised roughly 70% of its offerings, and it could do this because bitcoin provided a certain amount of anonymity. Anyway, The Silk Road was shut down shortly after by the FBI. I decided then that I didn’t want anything to do with bitcoin because I thought it was only useful for buying illegal stuff.

It was 2 years later in 2015 when I had a chance to reconnect with the acquaintance (and now my good friend) who had introduced me to bitcoin and our conversation revolved around that and I learned more about it that shattered my previous misconceptions.

So what is bitcoin and why is it such a hot item today?

The short answer is that bitcoin is a form of digital currency (the generic term for it is cryptocurrency) that uses computer networks and high-level cryptography to secure its transactions and records. It was released as open source software in 2009. Interestingly, the inventor(s) of bitcoin remains anonymous until today as the technology was released under a pseudonym, Satoshi Nakamoto.

Over the years, despite numerous controversies surrounding it, it has slowly gained acceptance as more and more people understood what it was and what it can do. To put it simply, it allows two people to exchange value (the coin) across borders without any need to trust an intermediary or 3rd party. At first glance, this may not seem to be a big deal because some of us have gotten so used to internet transactions with credit cards and online banking.

Let me illustrate the difference. In the traditional way, in order to buy an item from another country, I have to go through a bank or use my credit card (which still boils down to a bank). In the process, I pay transaction fees for the transmission, as well as conversion fees (from PHP to USD, for example). And then, I have to implicitly trust the bank to successfully transmit my money to the seller. The seller also has to trust the bank to send my money to their account.

This need to trust a third party is removed in bitcoin as it is the protocol itself which ensures that the money is sent and received by whoever is supposed to receive it. The result is that we can transact anywhere in the world (that has internet) for a much lower transaction fee than banks or other financial institutions may charge.

So this idea of trustless transactions is a key concept in cryptocurrency, which removes the need for a central authority. Most cryptocurrency is designed around this concept and is said to be decentralized.

More on this next week.

Originally published in Sunstar Davao.

Email me at andy@freethinking.me. View previous articles at www.freethinking.me.

Holdap (Part 2)

Photo Credit: °]° Flickr via Compfight cc

Click here to read Part 1.

I had a deep, 2-inch gash on my arm and a 1-inch wound on my abdomen. The pain in my gut throbbed a little but the arm hurt like hell.

There was a commotion at the entrance of the emergency room and the nurse attending to me suddenly rushed away. They brought in a young boy who was kicking and screaming. From my angle on the bed, I couldn’t see clearly what had happened to him. I asked a passing orderly what was up and he said, “Oh, he got stabbed in the back,” and he said it in such a way that made it sound like I was just asking about the weather and him replying that it was raining outside.

It certainly put my own troubles into perspective so instead of complaining about the lack of attention, I just waited for someone to come back to me a little later.

The taxi driver then came back towing along my girlfriend and her mother (later to be known as my wife and mother-in-law) and they were understandably worried as they saw me. They arranged to have me transferred to a private hospital where I was confined for a few days because the doctors there wanted to confirm that I had not suffered any internal damage from the wound on my stomach, and it turned out that there was none. The knife happened to just nick the fat but didn’t slam into anything important.

After I was discharged, I went back to my dormitory where I was greeted by some pretty amazing stories:

“Hey, we heard you got attacked and that you were in near-death condition.” Ummm, not really.

“Hey, we heard that someone stabbed you and left you for dead and got all your belongings.” Nope, they didn’t get anything at all except that one guy who who probably got a big bump on his left temple.

“Hey, we heard you got attacked by 10 men and that you used kung-fu to defeat all of them.” This was the best one ever.

So what are a few things I learned from this encounter?

  1. Fats are useful, people. Don’t lose too much of it. They may come in handy some day.
  2. Sometimes, it’s useful to trust your gut. I still cannot explain why I felt the way I did a few minutes before the attack happened. There was just this imminent sense of danger that my body somehow knew before my brain could understand what it was.
  3. There are good people all around. That taxi driver, for instance, who broke the stereotype of Manila taxi drivers by being helpful and going beyond the call of duty. I learned that he not only called my girlfriend, but went to their house and offered to lead them to me as well.
  4. People can and will make up stories about you and there’s very little you can do about it. Live with it. Laugh at it. But you can only do that if you know who you really are inside.

Originally published in Sunstar Davao.

Email me at andy@freethinking.me. View previous articles at www.freethinking.me.