How Bitcoin’s hash functions work
Hash functions are a crucial part in a cryptocurrency protocol and in security in general.
A hash function is a mathematical process that intakes data of any size, process the data and returns an output of a fixed size. The input data can be virtually anything – a single letter, a word or the entire collection of the British Library. After being processed, that data, no matter its size, will produce a same length of letters and numbers, an alphanumeric string, that is unique for that input. The alphanumeric string is called a digest.
To give you an idea on how hashing works, we ran a few phrases through the SHA256 function (the same one the Bitcoin network uses)
As you can see, all we did was capitalize a single letter in our input and got radically different results.
Here is the hash digest for this entire article and how it compares to the single letter I.
Hash(“ ”)
Hash(“I”) – a83dd0ccbffe39d071cc317ddf6e97f5c6b1c87af91919271f9fa140b0508c6c
Of course, as mentioned before, the digest has the exact same lenght, even though the lenght of the input is very different.
Hash functions are used to store passwords. When you create a password, the server never stores the actual password on their servers. How then can they tell if the password you introduced is the correct one, without comparing the two? The server will store the hash digest. When you login, your password goes through a hashing process, generates an output, and that output is compared to the hash digest stored on the server. If they match, you are granted access to your account.
This ensures that if a hacker manages to access the database that contains all the hashes from the users of a service, he will only get the digests, not the actual passwords. Therefore, he will not be able to compromise the account of the users, because there is no easy way to find the password that produces a certain hash.
Bitcoin’s hash functions
Hashing algorithms are part of the bitcoin protocol. They are used to write new transactions in the blockchain.
The input for Bitcoin’s hash function is represented by all the recent transactions that have not yet been confirmed, along with an extra input tied to a time stamp and to the reference to a previous block. As you can see, the results of a hash changes with the slightest change to the input.
In order to be granted a block reward, miners have to run these inputs with their own, different input, in such a way that the resulting hash contains a certain numbers of zeros. It is a repetitive task made automatically by miners. Once they find that input, they practically mined a block. This takes processing power from the part of the miners and an expenditure of electricity.
To give you an idea of how mining works, we will try to hash a mockup of a transaction (the phrase ICONetworkTransactions123), along with today’s date (26th of April 2017), and a mockup reference to a previous block (xyz). To this, we will add a random extra letter, until we obtain an even number at the beginning of the hash function.
hash(“ICONetworkTransactions123 26th of April 2017 xyzA”)
hash(“ICONetworkTransactions123 26th of April 2017 xyzB”)
hash(“ICONetworkTransactions123 26th of April 2017 xyzF”)
With a small challenge of obtaining an even number at the beginning of the digest, it still took us six guesses.
Of course, solving the hash for a bitcoin block requires great processing power. The combined power of all the devices connected to the network takes aproximately 10 minutes to solve a block. This ensures that newly generated bitcoins are minted over a longer period of time, instead of all at once.
The numbers of zeros required at the beginning of the hash digest depends on the mining difficulty. The more processing power the network has, the more the difficulty raises. This is a clever mechanism that ensures that, the more miners join, the harder it becomes for any one miner to find the block. This aspect contributes to the deflationary value of bitcoin. At the moment of writing this article, the hash digest is required to have 19 zeros at the beginning.
After a miner finds the hash of a block, it simply adds it to a permanent register, listing all of the hash digests of blocks mined previously. This way, the blockchain is extended. In return, according to the protocol, the miner is granted a bitcoin reward (after the 2016 halving, the reward for every solved block is 12 Bitcoins). New Bitcoins enter the market through this mining process.

9 thoughts on “How Bitcoin’s hash functions work

  • May 7, 2017 at 2:24 pm

    Hurrah! Finally I got a web site from where I be capable of actually take valuable data concerning my study and knowledge.

  • May 7, 2017 at 2:29 pm

    It’s amazing designed for me to have a web site, which is useful designed for my know-how. thanks admin

  • May 7, 2017 at 8:12 pm

    With havin so much written content do you ever run into any issues of plagorism or copyright violation? My website has a lot of completely unique content I’ve either created myself or outsourced but it appears a lot of it is popping it up all over the web without my permission. Do you know any solutions to help reduce content from being ripped off? I’d genuinely appreciate it.

  • May 7, 2017 at 9:59 pm

    I am extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it’s rare to see a great blog like this one nowadays.

  • May 10, 2017 at 12:09 am

    This is a very good tip particularly to those fresh to the blogosphere. Brief but very precise info… Thank you for sharing this one. A must read post!

  • May 11, 2017 at 2:20 am

    If you desire to increase your experience simply keep visiting this web page and be updated with the most recent news posted here.

  • May 18, 2017 at 2:30 am

    Wow, marvelous weblog structure! How long have you been running a blog for? you make blogging look easy. The total glance of your site is magnificent, as well as the content!

  • May 20, 2017 at 7:37 pm

    I’m not sure where you’re getting your information, but great topic. I needs to spend some time learning more or understanding more. Thanks for magnificent information I was looking for this info for my mission.


Leave a Reply

Your email address will not be published. Required fields are marked *