Hashing and Digital Signatures

Eugene Cofie
FAB CHAIN
Published in
5 min readAug 22, 2018

A little cryptography 101.

A big reason why many people have become interested in cryptocurrencies is the ability to prove ownership without a third party. Banks and other third parties dealing with value serve two major purposes in the area of ownership:

  1. the bank verifies who is sending funds and gives you access to money sent to you
  2. the bank verifies how much money is actually in your account at any given time

With cryptocurrency, these two functions can be done using cryptography instead of a third party. Digital signatures are used to verify a message is sent from the right person and gives access to who it is meant for, while hashing is used to verify the state of each account across a crypto network.

Let’s take a look at how these two cryptographic concepts work.

Hashing

Hashing is when you take an amount input data, apply an algorithm to it, and generate a fixed size of output data.

The input data is represented in “bits”, short for “binary digit”. The bits of information could be a spreadsheet, a ledger, an audio file or the entire internet- it can be any size.

The algorithm takes any number of bits and transforms it into a set standard amount of bits, creating a hash.

Hashes are generally used to give a unique identity to a file. This is called a “check-sum”. Check-sums are derived from a block of digital data for the purpose of checking it’s authenticity to see if it has been altered at any time.

The hash is used to verify that a file has not been changed or tampered with by anyone besides the author of that file.

Example

A government whistleblower could publish files publicly and publish hashes of those files as well and the hashing algorithm used. Anyone who downloads the files can verify they are from the whistleblower by calculating the hash from the file using the hashing algorithm.

If there is a discrepancy, then you know it is not the exact file that the whistleblower released.

Hashes in the Blockchain

Hashes are used in blockchain to represent the current state of the network. The input is all the transactions that have happened on the blockchain while the output hash is the current state of the blockchain.

The hash is used to agree between all peers that the blockchain state is the same (consensus).

The current state of the blockchain is decided by a 264 bit hash. The blockchain is made up of blocks of data (transactions) that are chained together through their hashes.

The first hash is calculated for the first block of data, the Genesis block, using the set of transactions on the block. The initial transactions generate a block hash for the Genesis.

For each subsequent block generated, the previous blocks hash as well as it’s own transactions are used as inputs to generate the new block hash.

The blockchain is formed by each new block identifying the previous block before it. This system means if a previous transaction is changed, so does the hash of the block to which it belongs as well as following blocks. You can see tampering on any blocks by comparing the hashes of previous blocks.

Because this system makes the blockchain ledge tamper-proof, nodes on the network know the official account status for any account by looking at the hashes.

Digital Signatures

Digital Signatures are ways to prove that a message or agreement came from a specific party, not a hacker. They confirm that the contents of a message or delivery have not been changed in transit.

They are like real signatures except more secure; they use cryptography instead of personalized writing.

We can see digital signatures already on many digital systems such as websites with “https” which confirm authenticity.

Within the blockchain, asymmetric encryption systems are used for digital signatures.

Asymmetric Encryption Systems

Asymmetric Encryption Systems have users create a Public Key and Private Key using an algorithm.

The public and private keys are related to each other through a mathematical relationship.

The public key is distributed publicly as an address to receive messages or transactions. The private key is used to digitally sign messages sent or received. The private key is meant to be kept secret. It ensures that money sent of an account can only be done by whoever knows the private key.

The key is sent with messages so that both parties know only the opposite party could have sent the message.

Private and public keys allow us to use the Blockchain without registering an account.

Example

John can send an email to Robert. When John sends the email, the computer creates a hash value from the message to send to Robert. John can sign the message with a digital signature from the email application which encrypts the message.

Robert receives the message along with the digital signature. Robert’s email application notes the digital signature and his computer decrypts the digital signature using John’s public key.
From there, the computer will calculate the hash of the original message and compare the hash it has computed from the received message with the decrypted hash received with the message.

--

--

Eugene Cofie
FAB CHAIN

Product Manager, Tech and Blockchain Enthusiast, Avid Reader, Sports Fanatic. @eugcofie.