fixes and index

pull/2/head
Andreas M. Antonopoulos 11 years ago
parent 9070b146e7
commit 3431139282

@ -22,4 +22,6 @@ include::ch07.asciidoc[]
include::ch08.asciidoc[]
include::appdx01.asciidoc[]
include::appdx01.asciidoc[]
include::index.asciidoc[]

@ -197,15 +197,13 @@ With SHA-256, the output is always 256 bits long, regardless of the size of the
[[sha256_example1]]
.SHA256 Example
++++
<screen>
$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> print hashlib.sha256("I am Satoshi Nakamoto").hexdigest()
Python 2.7.1
>>> <userinput>import hashlib</userinput>
>>> <userinput>print hashlib.sha256("I am Satoshi Nakamoto").hexdigest()</userinput>
5d7c7ba21cbbcd75d14800b100252d5b428e5b1213d27c385bc141ca6b47989e
</screen>
++++
@ -227,9 +225,9 @@ 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
++++
<screen>
$ <userinput>python hash_example.py</userinput>
I am Satoshi Nakamoto0 => a80a81401765c8eddee25df36728d732acb6d135bcdee6c2f87a3784279cfaed
I am Satoshi Nakamoto1 => f7bc9a6304a4647bb41241a677b5345fe3cd30db882c8281cf24fbb7645b6240
I am Satoshi Nakamoto2 => ea758a8134b115298a1583ffb80ae62939a2d086273ef5a7b14fbfe7fb8a799e
@ -250,9 +248,8 @@ I am Satoshi Nakamoto16 => 8fa4992219df33f50834465d30474298a7d5ec7c7418e642ba6ea
I am Satoshi Nakamoto17 => dca9b8b4f8d8e1521fa4eaa46f4f0cdf9ae0e6939477e1c6d89442b121b8a58e
I am Satoshi Nakamoto18 => 9989a401b2a3a318b01e9ca9a22b0f39d82e48bb51e0d324aaa44ecaba836252
I am Satoshi Nakamoto19 => cda56022ecb5b67b2bc93a2d764e75fc6ec6e6e79ff6c39e21d03b45aa5b303a
$
----
</screen>
++++
====
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.
@ -283,8 +280,9 @@ 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
++++
<screen>
$ <userinput>python proof-of-work-example.py</userinput>
Difficulty: 0
Starting search...
@ -334,7 +332,8 @@ Success with nonce 18779387
Hash is 000000a7e616c6968f22435687aae9e071cd5a8cb5b704ef2bff67bd258e4aab
Elapsed Time: 106.63 seconds
Hashing Power: 176122 hashes per second
----
</screen>
++++
====
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.

@ -0,0 +1 @@
== Index
Loading…
Cancel
Save