1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-12-23 15:18:11 +00:00

fixed widthsections

This commit is contained in:
Andreas M. Antonopoulos 2013-08-26 13:03:49 -07:00
parent 19da3b7fc8
commit 8cf1217843

View File

@ -91,7 +91,8 @@ Running this will produce the hashes of several phrases, made different by addin
[[sha256_example_generator_output]]
.SHA256 Output of a script for generating many hashes by iterating on a nonce
====
++++
----
$ python hash_example.py
I am Satoshi Nakamoto0 => a80a81401765c8eddee25df36728d732acb6d135bcdee6c2f87a3784279cfaed
I am Satoshi Nakamoto1 => f7bc9a6304a4647bb41241a677b5345fe3cd30db882c8281cf24fbb7645b6240
@ -115,7 +116,7 @@ I am Satoshi Nakamoto18 => 9989a401b2a3a318b01e9ca9a22b0f39d82e48bb51e0d324aaa44
I am Satoshi Nakamoto19 => cda56022ecb5b67b2bc93a2d764e75fc6ec6e6e79ff6c39e21d03b45aa5b303a
$
++++
----
====
Each phrase produces a completely different hash result. They seem completely random, but you can re-produce the exact results in this example on any computer with Python and see the same exact hashes.
@ -146,7 +147,7 @@ Running the code above, you can set the desired difficulty (in bits, how many of
[[pow_example_outputs]]
.Running the proof-of-work example for various difficulties
====
++++
----
$ python proof-of-work-example.py
Difficulty: 0
@ -197,7 +198,7 @@ Success with nonce 18779387
Hash is 000000a7e616c6968f22435687aae9e071cd5a8cb5b704ef2bff67bd258e4aab
Elapsed Time: 106.63 seconds
Hashing Power: 176122 hashes per second
++++
----
====
As you can see, increasing the difficulty by 4 bits causes an exponential increase in the time it takes to find a solution. If you think of the entire 256-bit number space, each time you constrain one more bit to zero, you decrease the search space by half. In the example above, it takes 18 million hash attempts to find a nonce that produces a hash with 24 leading bits as zero. Even at a speed of more than 170 thousand hashes per second, it still requires two minutes on a consumer laptop to find this solution.