|
|
|
@ -660,9 +660,9 @@ this case to vary the output of the SHA256 commitment to the phrase.
|
|
|
|
|
|
|
|
|
|
To make a challenge out of this algorithm, let's set a target: find a
|
|
|
|
|
phrase that produces a hexadecimal hash that starts with a zero.
|
|
|
|
|
Fortunately, this isn't difficult, as shown in <<sha256_example_generator_output>>:
|
|
|
|
|
Fortunately, this isn't difficult, as shown in <<sha256_example_generator_output2>>:
|
|
|
|
|
|
|
|
|
|
[[sha256_example_generator_output]]
|
|
|
|
|
[[sha256_example_generator_output2]]
|
|
|
|
|
.Simple proof-of-work implementation
|
|
|
|
|
----
|
|
|
|
|
$ for nonce in $( seq 100 ) ; do echo "Hello, world! $nonce" | sha256sum ; done
|
|
|
|
@ -713,7 +713,7 @@ any possible outcome can be calculated in advance. Therefore, an outcome
|
|
|
|
|
of specified difficulty constitutes proof of a specific amount of work.
|
|
|
|
|
====
|
|
|
|
|
|
|
|
|
|
In <<sha256_example_generator_output>>, the winning "nonce" is 32 and
|
|
|
|
|
In <<sha256_example_generator_output2>>, the winning "nonce" is 32 and
|
|
|
|
|
this result can be confirmed by anyone independently. Anyone can add the
|
|
|
|
|
number 32 as a suffix to the phrase "Hello, world!" and compute
|
|
|
|
|
the hash, verifying that it is less than the target:
|
|
|
|
@ -740,7 +740,7 @@ below the target. The target and difficulty are inversely related.
|
|
|
|
|
====
|
|
|
|
|
|
|
|
|
|
Bitcoin's Proof-of-Work is very similar to the challenge
|
|
|
|
|
shown in <<sha256_example_generator_output>>. The miner constructs a
|
|
|
|
|
shown in <<sha256_example_generator_output2>>. The miner constructs a
|
|
|
|
|
candidate block filled with transactions. Next, the miner calculates the
|
|
|
|
|
hash of this block's header and sees if it is smaller than the current
|
|
|
|
|
_target_. If the hash is not less than the target, the miner will modify
|
|
|
|
|