Skip to Content
Foundations of Blockchain
book

Foundations of Blockchain

by Koshik Raj
January 2019
Beginner to intermediate
372 pages
11h 17m
English
Packt Publishing
Content preview from Foundations of Blockchain

An example implementation of Proof of Work

In the previous section, we covered how Proof of Work used a hashing algorithm. We also looked at computing a target hash to solve the hashing puzzle. We're now going to implement a Proof of Work algorithm using the SHA-256 algorithm in order to analyze how hashing and probability contribute to this consensus algorithm.

Since the main intention of the Proof of Work algorithm is to find a nonce that, when attached to the blockchain header, results in the required target hash value, the task here is to randomly guess a nonce value and establish the digest value of the block. Thanks to the properties of hash functions, which make guessing the nonce really hard and non-deterministic, the only way to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain Basics

Blockchain Basics

Daniel Drescher
What Is Blockchain?

What Is Blockchain?

Sir John Hargrave, Evan Karnoupakis
Mastering Blockchain

Mastering Blockchain

Lorne Lantz, Daniel Cawrey

Publisher Resources

ISBN: 9781789139396Supplemental Content