rust-bitcoin-unsafe-fast/fuzz
Andrew Poelstra 121db506fa
Merge rust-bitcoin/rust-bitcoin#1197: Add `Target` and `Work` types
02a2b43b2b Remove Default impl for Target and Work (Tobin C. Harding)
cb9893c4a9 Add Target and Difficulty types (Tobin C. Harding)

Pull request description:

  Ugh! 1600 lines of green and 1100 of red - my apologies.

  Currently we use the `Uint256` type for proof-of-work calculations. It was observed in #1181 that providing a public 256 bit integer type like this implies that it is a general  purpose integer type. We do not want to provide a general purpose integer type (see the 1000 arithmetic functions on stdlib integer types for why not :)

  Add two new opaque integer types `Target` and `Work`. These are the inverse of each other, both conceptually and mathematically.

  There is a lot of code in this PR, sorry about that. At a high level the PR does:

  - Add a `pow` module.
  - Put a modified version of  `Uint256` in `pow`, making it private.
  - Add two new wrapper types `Target` and `Work` that provide a very limited API specific to their use case. In particular there are methods on each to convert to the other.
  - Only implement methods that we use on each type.

  ### Note

  During development I got mixed up with the word "difficulty", I have discovered this has a very specific meaning in Bitcoin. Please see rustdocs on the `Target::difficulty` function for explanation of this term. For this reason we use the type `Work` defined as the inverse of target, and reserve "difficulty" for the Bitcoin concept.

ACKs for top commit:
  apoelstra:
    ACK 02a2b43b2b
  Kixunil:
    ACK 02a2b43b2b

Tree-SHA512: 4d701756a42b832f03b8d542f3a5278b4ca1d5983ffd7d4630577ebd4cc8f47029719f9018185e01fa459d8fb32426b5cb4d6b8d8b588ebbb7b65e4aeee94412
2022-10-17 18:24:11 +00:00
..
fuzz_targets Add Target and Difficulty types 2022-09-28 04:16:59 +10:00
hfuzz_input remove hfuzz input not used anymore 2021-09-24 11:51:40 +02:00
.gitignore Add fuzzing code 2017-06-07 09:19:25 +01:00
Cargo.toml Add Target and Difficulty types 2022-09-28 04:16:59 +10:00
cycle.sh Add script to launch fuzzing continuosly 2022-10-10 11:45:54 +02:00
travis-fuzz.sh fuzz: use travis-fuzz.sh in CI 2022-08-30 21:51:42 +00:00