Intro to blockchain and zero knowledge proofs

Nicholas Singh
5 min readAug 29, 2021

Blockchain is one of those topics that seem complicated at first, but if broken down into parts, gets a little easier to understand. That’s what we’re going to do in this article.

Photo by Matthew Lancaster on Unsplash

What is a blockchain?

Think of blockchain as a decentralized way of storing data in blocks. When someone adds something to the blockchain, a new block gets added with that data. Each block contains the unique identifier (aka hash) of that block and the block preceding it, this is what connects the blockchain together like linked cubes. To be able to add to this blockchain (aka ledger) you need to update it on all the versions of the ledgers that exist. Because it is decentralized, multiple people have the blockchain, and depending on what proof system (we’ll talk more about this later) the blockchain uses, the people with copies of the ledger would need to validate that block before adding it to the ledger.

If all the ledgers validate the block then it gets added. However, if one or more of the validators deny the block because it’s invalid, the block does not get added to any of the ledgers. Unlike databases, the data on a blockchain is immutable, once it’s on there you can’t take it off or change it.

A good comparison between blockchain and a database is that you can think of a database like an excel sheet, where a blockchain is a set of linked blocks, where the blocks connect. The hash that each block contains is not just a random unique identifier, it contains all the information for that specific block.

How Hashing Works

When the data on a blockchain is stored, it gets encrypted. Hashing allows you to take input data of any length and return a fixed-length string called a hash and given the same data every time, you’ll get the same output.

However, given the output, you don’t always get the same input. A good example is to imagine you have the number 10. You need to find out what numbers multiplied together got you to the output 10, it could be 10 x 1 or 5 x 2 or 2.5 x 4… you get the point. In the same sense, this is what makes this encryption method so secure. To break it is almost impossible with the technology that exists today, because of the number of combinations to get you to that output string. An example of a hashing method commonly used today is called SHA256 that returns an output 256 characters long.

The different blockchains that exist

Bitcoin and Ethereum are both examples of blockchains. Ethereum brings something to the blockchain that makes it unique, called smart contracts. You can code a contract that could execute commands on a blockchain. For example, if you wanted to trade Ethereum with someone in exchange for something, you could write a smart contract to automate that trade for both of you. Before execution, you would both agree on the code. These contracts are written in a language called solidity, which is similar to JavaScript and java. Using this technology we can apply it so we can automate transactions between people (for example, a transaction on the Ethereum blockchain).

How proof works

As mentioned, to make sure the blockchain is secure, they have a validation system also known as proof. There are two main ways that blockchains validate their blocks:

Proof of work: This is where a group of miners competes to verify a hash. The first one to finish it gets the reward (bitcoin, for example). The problem with this attempt is that it takes a lot of computing power. The more mining someone does on a blockchain, the harder the challenges that a computer would need to solve, making this method very inefficient. One of the major flaws of the proof of work method is a 51% attack. A 51% attack is where one or a group of miners gain 51% of the power of the blockchain and have the ability to manipulate it (add invalid blocks etc..).

Proof of stake: On the other hand, proof of stake is where one person, chosen at random, gets selected to validate the hash. To do so they have to put some of their coins into the network, known as a stake. The size of the stake increases the chances that that person (validator) can mine (forge) the next block. Validators that approve invalid hashes get a portion of their stake taken from them. Now that we’ve covered some of the fundamentals of blockchain, let’s get into how zero-knowledge proofs (one of the bigger important topics of blockchain) works .

Zero knowledge proofs

Imagine having the ability to see if a user has at least a certain amount of money (say $100) in their account without knowing how much money they have in their account, or needing any personal information from that person.

Zero-knowledge proofs generally follow 3 criteria.

  • Soundness: the verifier cannot get any false information, meaning that if something is false (like they don’t have that amount in their account), they cannot convince you otherwise.
  • Completeness: the prover convinces the verifier that they know what they’re trying to prove.
  • Zero-knowledge: the prover can prove it without revealing any other data.

Here’s an example of how zero-knowledge proofs would work. Let’s say you’re trying to see whether the information on two different pieces is the same without looking at them.

  1. First, you ask the person that wrote on those papers if they’re the same, they say yes but you can’t be sure.
  2. Then, you put the papers behind your back where they can’t see them and you switch hands that are holding the paper.
  3. You ask the person if they changed hands and they say no. This means that the information on the paper must be the same so you try again and get the same response.
  4. Doing this more and more reduces the chances that the other person (the prover) is telling the truth to you (the verifier).

Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (Z-SNARK) is the zero-knowledge proof idea but applied to the cryptography (in encryption) world. Z-SNARKS are used to provide information in a transaction without revealing that exact information between the two parties making that transaction.

Now that you understand the basics of blockchain and zero-knowledge proofs, how do you think this will impact the world in the next five years? How do you think it is going to impact our lives?

--

--