Stably Blog

Understanding Hash Functions

Hash functions are one of the most important pieces in creating a blockchain. These functions give blockchain its immutability and provide a way to verify data.

A hash function takes input data and returns a “hash” of the data. This hash is known as a digital fingerprint of the input data. There are many hash functions, Bitcoin uses SHA-256.

Hash functions are also one-way functions. Given input x, the hash function will return output y. However, given the output y, it is nearly impossible to know what the input, x, was. If x stays the same, the hash function will always return y. If anything about x changes, y will also change. This will become clearer in the example below.

Using Hash Functions

This site will generate a SHA-256 hash with whatever input the user gives.


Input: The month is October

Output (hash): A3272CB34F4A4721BA14AF6F3FFA1A27E093401C0F459067FAFF7F093CEE9A4C

That output is a unique representation of the input “The Month is October”. Now the input is going to slightly change with an exclamation point added at the end. The corresponding output will change as well.

Input: The month is October!

Output (hash):

BE1130EBC9EC0C07C8F78152AFD4AA590EF9728BFFA62181A6FD319529972A2C

Just the addition of an exclamation point completely changed the output. If two output hashes are different, that means the two inputs are not the same. This feature of hash functions is incredibly valuable and important for blockchain.

How does this relate to blockchain?

As mentioned above, the hash is a digital fingerprint of some data, just like a real fingerprint, the hash is unique to that set of data. The word data here could be anything, some text, a picture, or in the case of blockchain and cryptocurrency, transactions.

Since public blockchains are distributed, such as Bitcoin or Ethereum, there needs to be a way to verify that someone’s copy of the blockchain is correct and has not been tampered with.

As seen above, any change to the input data will result in a change to the output hash. Distributed blockchains need consensus, nodes (more specifically miners or validators) need to agree on the current state of the blockchain. Hash functions provide a way to verify data on the blockchain.


----

Sign up for our newsletter to receive recent news & updates, and follow us on social media:

Website | Twitter | Linkedin | Facebook | Telegram

Contact:

Legal: legal@stably.io

Press: marketing@stably.io

Exchanges or Market Makers: exchanges@stably.io

Partnerships: info@stably.io

Investors: Kory Hoang, CEO — kory@stably.io

Subscribe to the Staby Newsletter for all the latest updates!

Bottom.png

Copyright © 2019-2020 Stably Corporation. All Rights Reserved 

Social Icon-04-stably.png
Social Icon-03-stably.png
Social Icon-02-stably.png
Social Icon-01-stably.png
Social Icon-05-stably.png
Social Icon-06-stably.png

Like being first? Subscribe to the Stably Newsletter!

Company

About

Partners


Careers

Blog

Contact

All asset custody, funds processing, convertible virtual currency administration, trustee and fiduciary services are provided by Prime Trust, a Nevada chartered financial institution and licensed trust company. Digital assets are held in secure cold storage and USD funds are held in FDIC-insured bank accounts by Prime Trust. Stably is not a licensed financial institution and Stably does not manage nor take custody of client funds. Prime Trust neither endorses nor guarantees any of the information, recommendations, optional programs, products, or services advertised, offered by, or made available through the external website ("Products and Services") and disclaims any liability for any failure of the Products and Services.