Skip to content

Latest commit

 

History

History
718 lines (531 loc) · 11.9 KB

appa.asciidoc

File metadata and controls

718 lines (531 loc) · 11.9 KB

Programming Bitcoin

Appendix A: Solutions

class FieldElement:
...
link:code-ch01/answers.py[role=include]
link:code-ch01/answers.py[role=include]
class FieldElement:
...
link:code-ch01/answers.py[role=include]
link:code-ch01/answers.py[role=include]
link:code-ch01/answers.py[role=include]

When sorted, the results are always the same set.

class FieldElement:
...
link:code-ch01/answers.py[role=include]
link:code-ch01/answers.py[role=include]
link:code-ch01/answers.py[role=include]
class FieldElement:
...
link:code-ch01/answers.py[role=include]

[chapter_elliptic_curves]: Elliptic Curves

link:code-ch02/answers.py[role=include]
class Point:
...
link:code-ch02/answers.py[role=include]
class Point:
...
link:code-ch02/answers.py[role=include]
link:code-ch02/answers.py[role=include]
class Point:
...
    def __add__(self, other):
    ...
link:code-ch02/answers.py[role=include]
link:code-ch02/answers.py[role=include]
class Point:
...
    def __add__(self, other):
    ...
link:code-ch02/answers.py[role=include]

[chapter_elliptic_curve_cryptography]: Elliptic Curve Cryptography

link:code-ch03/answers.py[role=include]
link:code-ch03/answers.py[role=include]
link:code-ch03/answers.py[role=include]
link:code-ch03/answers.py[role=include]
link:code-ch03/answers.py[role=include]
link:code-ch03/answers.py[role=include]
link:code-ch03/answers.py[role=include]
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]
class ECCTest(TestCase):
...
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]
link:code-ch04/answers.py[role=include]

[chapter_tx_parsing]: Transactions

class Tx:
...
link:code-ch05/answers.py[role=include]
class Tx:
...
link:code-ch05/answers.py[role=include]
...

class TxIn:
...
link:code-ch05/answers.py[role=include]
class Tx:
...
link:code-ch05/answers.py[role=include]
...

class TxOut:
...
link:code-ch05/answers.py[role=include]
class Tx:
...
link:code-ch05/answers.py[role=include]
link:code-ch05/answers.py[role=include]
class Tx:
...
link:code-ch05/answers.py[role=include]
link:code-ch06/answers.py[role=include]
link:code-ch06/answers.py[role=include]
link:code-ch06/answers.py[role=include]

OP_2 or 52 will satisfy the equation x2+x-6=0.

link:code-ch06/answers.py[role=include]
  1. collision1 and collision2 are from the sha1 preimages that were found to collide from Google. (https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html)

This is looking for a sha1 Collision. The only way to satisfy this script is to give x and y such that x≠y but sha1(x)=sha1(y).

[chapter_tx]: Transaction Creation and Validation

class Tx:
...
link:code-ch07/answers.py[role=include]
class Tx:
...
link:code-ch07/answers.py[role=include]
class Tx:
...
link:code-ch07/answers.py[role=include]
link:code-ch07/answers.py[role=include]
link:code-ch07/answers.py[role=include]

[chapter_p2sh]: Pay To Script Hash

link:code-ch08/answers.py[role=include]
link:code-ch08/answers.py[role=include]
link:code-ch08/answers.py[role=include]
link:code-ch08/answers.py[role=include]
class Tx:
...
link:code-ch08/answers.py[role=include]
class Tx:
...
link:code-ch09/answers.py[role=include]
class Tx:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
class Block:
...
link:code-ch09/answers.py[role=include]
link:code-ch09/answers.py[role=include]
link:code-ch09/answers.py[role=include]
link:code-ch10/answers.py[role=include]
class NetworkEnvelope:
...
link:code-ch10/answers.py[role=include]
class NetworkEnvelope:
...
link:code-ch10/answers.py[role=include]
class VersionMessage:
...
link:code-ch10/answers.py[role=include]
class SimpleNode:
...
link:code-ch10/answers.py[role=include]
class GetHeadersMessage:
...
link:code-ch10/answers.py[role=include]
link:code-ch11/answers.py[role=include]
link:code-ch11/answers.py[role=include]
link:code-ch11/answers.py[role=include]
class Block:
...
link:code-ch11/answers.py[role=include]
link:code-ch11/answers.py[role=include]
class MerkleBlock:
...
link:code-ch11/answers.py[role=include]
class MerkleBlock:
...
link:code-ch11/answers.py[role=include]
link:code-ch12/answers.py[role=include]
link:code-ch12/answers.py[role=include]
class BloomFilter:
...
link:code-ch12/answers.py[role=include]
class BloomFilter:
...
link:code-ch12/answers.py[role=include]
class GetDataMessage:
...
link:code-ch12/answers.py[role=include]
link:code-ch12/answers.py[role=include]

A more thoroughly commented answer is in code-ch12/broadcast.py