Commit Graph

1013 Commits

Author SHA1 Message Date
Andrew Poelstra fb45ae4de9
Merge rust-bitcoin/rust-secp256k1#530: secp256k1: Improve docs on `Error`
42bf99f11b Add full stop (Tobin C. Harding)
96f9fd3e56 Link to MESSAGE_SIZE in Error docs (Tobin C. Harding)
036bd0d011 secp256k1: Generalize docs on Error (Tobin C. Harding)

Pull request description:

  The docs on `Error` currently mention ECDSA which is no longer correct since we use this error in `schnorr` as well.

  Fix the `Error` doc issue described above and do a couple trivial other fixes while we are touching the code.

ACKs for top commit:
  apoelstra:
    ACK 42bf99f11b

Tree-SHA512: e1658d909c3588736570517a351e85c85c014ee31efe09fd262654dad873b0dcd3dbb6c8ad40866a24ee8e2e9bf0be99e5eb35251f6640222b953a0eb2a732ca
2022-11-23 19:54:03 +00:00
Tobin C. Harding 42bf99f11b Add full stop
The docs on `Error` are almost perfect, add a missing full stop.
2022-11-24 05:27:50 +11:00
Tobin C. Harding 96f9fd3e56 Link to MESSAGE_SIZE in Error docs
We can help readers of the HTML docs by using a link to the constant.
While we are at it shorten the doc comment so it fits on one line (in
under 100 chars).
2022-11-24 05:27:39 +11:00
Tobin C. Harding 036bd0d011 secp256k1: Generalize docs on Error
The `Error` type is the main general error used by this lib, it is not
specific to ECDSA. Fix the docs to show this.
2022-11-24 05:23:59 +11:00
Andrew Poelstra 4864a33a62
Merge rust-bitcoin/rust-secp256k1#528: fix formatting on master
c0ae3e7d35 fix formatting on master (Andrew Poelstra)

Pull request description:

  Looks like I need to check formatting now before merging things :) master CI is broken because of cargo fmt.

ACKs for top commit:
  tcharding:
    ACK  c0ae3e7d35

Tree-SHA512: 9dc22eb5edfb565309cfd14cb9634abba196e46591da8c21d241bd686df8436a8af371c6520ea6ae688fcf81a835919a1bc9a3730f206ba6ef758087efa282e1
2022-11-23 00:01:16 +00:00
Andrew Poelstra c0ae3e7d35
fix formatting on master 2022-11-22 15:27:19 +00:00
Andrew Poelstra 17c8751d23
Merge rust-bitcoin/rust-secp256k1#527: Add constant time `SecretKey::eq`
b9eefea092 Add documentation on side channel attacks to SecretKey (Tobin C. Harding)
7cf3c6c8a4 Implement constant time comparison for SecretKey (Tobin C. Harding)
19039d9281 Remove `Ord`/`Hash` traits from SecretKey (Tobin C. Harding)
4a0c7fca6a Do not use impl_array_newtype for SecretKey (Tobin C. Harding)

Pull request description:

  Add constant time comparison implementation to `SecretKey`.

  This PR does as suggested [here](https://github.com/rust-bitcoin/rust-secp256k1/issues/471#issuecomment-1179783309) at the end of the issue discussion thread.

  Fix: #471

ACKs for top commit:
  apoelstra:
    ACK b9eefea092

Tree-SHA512: 217ed101b967cc048954547bcc0b3ab09e5ccf7c58e5dcb488370caf3f5567871152505a3bfb4558e59eea4849addaf1f11e1881b6744b0c90c633fa0157a5ae
2022-11-22 15:05:44 +00:00
Andrew Poelstra ba47a25295
Merge rust-bitcoin/rust-secp256k1#526: Run the formatter in CI
75f3886812 Add cargo fmt to pre-commit githook (Tobin C. Harding)
0516ddeb8d Add formatting check to CI (Tobin C. Harding)
c7807dff9c Run the formatter (Tobin C. Harding)

Pull request description:

  We recently introduced `rustfmt` to the codebase but I forgot to turn it on in CI.

  - Patch 1: Preparatory formatting fixes, introduced since we merged the [formatting PR](https://github.com/rust-bitcoin/rust-secp256k1/pull/499)
  - Patch 2: Enable formatting in CI
  - Patch 3: Add formatting to the pre-commit hook

ACKs for top commit:
  apoelstra:
    ACK 75f3886812

Tree-SHA512: 5ac4ab4015a9728ef890e0c4fe90afcb5e45ab7665da5a8ee289dc877c1ea5c6236e54b68b7122841597864b04606c8bfae7dec86c4b6be74d32437299057b5f
2022-11-22 14:34:27 +00:00
Andrew Poelstra 72bfdd3d8c
Merge rust-bitcoin/rust-secp256k1#525: ci: Check rustdocs build
d5294a182a ci: Check rustdocs build (Tobin C. Harding)

Pull request description:

  Currently we are not failing the docs build in CI if any warnings are generated.

  Exit the script with error code 1 if docs build throws any warnings.

ACKs for top commit:
  apoelstra:
    ACK d5294a182a

Tree-SHA512: cf8a8feda8cbb4ea741b31cd0fa0e728724c60fb688f4fafcd132e93ec1a278093c64d34bfcc7e692cc80d0871b71656fc83b670a59b5f3b76c4b8fc3815d200
2022-11-22 14:24:31 +00:00
Tobin C. Harding b9eefea092 Add documentation on side channel attacks to SecretKey
We recently added a constant time `eq` implementation however library
users can inadvertently bypass this protection if they use `AsRef`. To
help prevent this add documentation to the `SecretKey` and also to the
`AsRef` implementation.
2022-11-22 10:27:54 +11:00
Tobin C. Harding 7cf3c6c8a4 Implement constant time comparison for SecretKey
The current implementation of `PartialEq` leaks data because it is not
constant time.

Attempt to make the `PartialEq` implementation constant time.
2022-11-22 10:27:54 +11:00
Tobin C. Harding 19039d9281 Remove `Ord`/`Hash` traits from SecretKey
The current trait implementations of `Ord` and `PartialOrd` for
`SecretKey` leak data when doing the comparison i.e., they are not
constant time. Since there is no real usecase for ordering secret keys
remove the trait implementations all together.

Remove `Hash` at the same time because it does not make sense to
implement it if `Ord`/`PartialOrd` are not implemented.
2022-11-22 10:27:54 +11:00
Tobin C. Harding 4a0c7fca6a Do not use impl_array_newtype for SecretKey
In preparation for changing the logic of comparison trait (Ord, Eq)
implementations on the `SecretKey` copy all the code out of
`impl_array_newtype` and implement it directly in `key.rs`.

Refactor only, no logic changes (although I removed a few unneeded
references).
2022-11-22 10:27:47 +11:00
Tobin C. Harding 75f3886812 Add cargo fmt to pre-commit githook
To save devs getting frustrated by CI; add a call to `cargo +nightly
fmt` to our git pre-commit hook.
2022-11-22 08:59:09 +11:00
Tobin C. Harding 0516ddeb8d Add formatting check to CI
Add code to the CI script, guarded on env var `DO_FMT` to run the
formatter.

Add a formatting job to the nightly CI job as a separate step, in a
similar fashion to how the other nightly steps are done.
2022-11-22 08:54:24 +11:00
Tobin C. Harding c7807dff9c Run the formatter
Currently we are not running the formatter in CI, in preparation for
doing so run `cargo +nightly fmt` to clear all current formatting
issues.

No manual changes.
2022-11-22 08:53:23 +11:00
Tobin C. Harding d5294a182a ci: Check rustdocs build
Currently we are not failing the docs build in CI if any warnings are
generated.

Exit the script with error code 1 if docs build throws any warnings.
2022-11-22 08:50:27 +11:00
Andrew Poelstra d5065cc771
Merge rust-bitcoin/rust-secp256k1#518: Make comparison functions stable
9850550734 Move AsRef impl block next to Index (Tobin C. Harding)
4d42e8e906 Derive Copy and Clone (Tobin C. Harding)
b38ae97eaf Implement stable comparison functionality (Tobin C. Harding)
630fc1fcb6 Remove len and is_empty from impl_array_newtype macros (Tobin C. Harding)
9788b6df88 Remove leading colons from impl_array_newtype methods (Tobin C. Harding)
2bb08c21e5 Remove as_[mut_]ptr from impl_array_newtype macros (Tobin C. Harding)
3e28070187 Duplicate impl_array_newtype (Tobin C. Harding)
635890322a Add newline to end of file (Tobin C. Harding)

Pull request description:

  Supersedes #515

  The primary aim of this PR is to fix the fact that we currently implement various comparison traits (`Ord`, `PartialEq`) by comparing the inner byte arrays. These bytes are meant to be opaque and are not guaranteed across versions of `libsecp256k1`.

  This PR is a bit involved because I had to detangle all the various types (across both `secp256k1` and `secp256k1-sys`) that use the `impl_array_newtype` macro.

  - Patch 1: is trivial cleanup
  - Patch 2: Step one of the PR is duplicating the macro into both crates so we can tease them apart.
  - Patch 3-5: Are cleanup of the now duplicated `impl_array_newtype` macros
  - Patch 6: Is the meat and potatoes
  - Patch 7,8: Further minor clean ups to the macro

  I had a lot of fun with this PR, I hope you enjoy it too.

  Fix: #463

ACKs for top commit:
  apoelstra:
    ACK 9850550734

Tree-SHA512: 160381e53972ff882ceb1d2d47bac56a7301a2d13bfe75d3f6ff658ab2c6fbe516ad856587c4d23f98524205918ca1a5f9b737e35c23c7a01b476c92d8d1792f
2022-11-21 14:58:50 +00:00
Andrew Poelstra 29c0549e51
Merge rust-bitcoin/rust-secp256k1#520: Fix feature gating
9c748550b4 Fix feature gating (Tobin C. Harding)

Pull request description:

  Currently we have a few problems with our feature gating, attempt to audit all feature gating and fix it by doing:

  1. Do not enable features on optional dependencies (`rand` and `bitcoin-hashes`) in dev-dependencies, doing so hides broken feature gating in unit tests.
  2. Do not use unnecessary feature combinations when one feature enables another e.g. `any(feature = "std", feature = "alloc")`.
  3. Enable "std" from "rand-std" and "bitcoin-std" (and fix features gating as for point 2).
  4. Clean up code around `rand::thread_rng`, this is part of this patch because `thread_rng` requires the "rand-std" feature.
  5. Clean up CI test script to test each feature individually now that "rand-std" and "bitcoin-hashes-std" enable "std".

ACKs for top commit:
  apoelstra:
    ACK 9c748550b4
  Kixunil:
    ACK 9c748550b4

Tree-SHA512: 3f8e464eeab1fe279249b5097082774c3de076ec9537162f367013098bde45957b12067a7434389e520bfacd3b415274f897917bf000f332d52cf960b1d4aecf
2022-11-18 19:11:41 +00:00
Tobin C. Harding 9850550734 Move AsRef impl block next to Index
These two traits are related, in as much as they both give access to the
inner byte array. Put them next to each other to assist clarity.
2022-11-18 10:57:32 +11:00
Tobin C. Harding 4d42e8e906 Derive Copy and Clone
There is no obvious reason why not to derive `Copy` and `Clone` for
types that use the `impl_newtype_macro`. Derives are less surprising so
deriving makes the code marginally easier to read.
2022-11-18 10:56:24 +11:00
Tobin C. Harding b38ae97eaf Implement stable comparison functionality
Currently we rely on the inner bytes with types that are passed across
the FFI boundry when implementing comparison functions (e.g. `Ord`,
`PartialEq`), this is incorrect because the bytes are opaque, meaning
the byte layout is not guaranteed across versions of `libsecp26k1`.

Implement stable comparison functionality by doing:

- Implement `core::cmp` traits by first coercing the data into a stable
  form e.g., by serializing it.
- Add fast comparison methods to `secp256k1-sys` types that wrap types
  from libsecp, add similar methods to types in `secp256k1` that wrap
  `secp256k1-sys` types (just call through to inner type).
- In `secp256k1-sys` feature gate the new `core::cmp` impls on
  `not(fuzzing)`, when fuzzing just derive the impls instead.

Any additional methods added to `secp256k1-sys` types are private,
justified by the fact the -sys is meant to be just a thin wrapper around
libsecp256k1, we don't want to commit to supporting additional API
functions.

Please note, the solution presented in this patch is already present for
`secp256k1::PublicKey`, this PR removes that code in favour of deriving
traits that then call down to the same logic in `secp256k1-sys`.
2022-11-18 10:24:46 +11:00
Tobin C. Harding 9c748550b4 Fix feature gating
Currently we have a few problems with our feature gating, attempt to
audit all feature gating and fix it by doing:

1. Do not enable features on optional dependencies (`rand` and
   `bitcoin-hashes`) in dev-dependencies, doing so hides broken feature
   gating in unit tests.
2. Do not use unnecessary feature combinations when one feature enables
   another e.g. `any(feature = "std", feature = "alloc")`.
3. Enable "std" from "rand-std" and "bitcoin-std" (and fix features
   gating as for point 2).
4. Clean up code around `rand::thread_rng`, this is part of this patch
   because `thread_rng` requires the "rand-std" feature.
5. Clean up CI test script to test each feature individually now that
   "rand-std" and "bitcoin-hashes-std" enable "std".
2022-11-18 10:14:41 +11:00
Tobin C. Harding 630fc1fcb6 Remove len and is_empty from impl_array_newtype macros
An array in Rust has no concept of length, it is a fixed size data type.
Equally an array cannot be "empty", again since it is a fixed size data
type. These are methods/concepts seen in slices and vectors.

Remove the `len` and `is_empty` methods.
2022-11-18 07:57:39 +11:00
Tobin C. Harding 9788b6df88 Remove leading colons from impl_array_newtype methods
The leading colons are an artifact of Rust 1.29, remove them.
2022-11-18 07:57:39 +11:00
Tobin C. Harding 2bb08c21e5 Remove as_[mut_]ptr from impl_array_newtype macros
For interfacing with the FFI layer we implement `ffi::CPtr`, there is
not need to provide methods `as_ptr` and `as_mut_ptr` as well.
2022-11-18 07:57:39 +11:00
Tobin C. Harding 3e28070187 Duplicate impl_array_newtype
The two crates `secp256k1` and `secp256k1-sys` serve very different
purposes, having a macro defined in one that is used in both makes it
hard to get nuanced things correct in the macro, for example the
comparison implementations (`Ord`, `PartialEq` etc.) are semantically
different in each crate.

In an effort to decouple `secp256k1` and `secp256k1-sys` duplicate the
`impl_array_newtype` macro.
2022-11-18 07:57:39 +11:00
Tobin C. Harding 635890322a Add newline to end of file
Inline with UNIX convention add a trailing newline to file.
2022-11-18 07:57:39 +11:00
Andrew Poelstra a777942da1
Merge rust-bitcoin/rust-secp256k1#499: Introduce `rustfmt`
e0e575dde7 Run cargo fmt (Tobin C. Harding)
41449e455d Prepare codebase for formatting (Tobin C. Harding)
7e3c8935b6 Introduce rustfmt config file (Tobin C. Harding)

Pull request description:

  (Includes the patch from #504, I pulled it out of this to merge faster)

  Introduce `rustfmt` by doing:

  - Copy the `rustfmt` config file from `rust-bitcoin`
  - Prepare the codebase by adding `#[rustfmt::skip]` as needed and doing some manual format improvements.
  - Run the formatter: `cargo +nightly fmt`
  - Add formatting checks to CI and the pre-commit hook

  Thanks in advance for doing the painful review on patch 3.

ACKs for top commit:
  apoelstra:
    ACK e0e575dde7

Tree-SHA512: 1b6fdbaf81480c0446e660cc3f6ab7ac0697f272187f6fdfd6b95d894a418cde8cf1c423f1d18ebbe03ac5c43489630a35ad07912afaeb6107cfbe7338a9bed7
2022-11-17 15:00:00 +00:00
Andrew Poelstra 7a00b8310d
Merge rust-bitcoin/rust-secp256k1#516: Fix broken links
ade888e922 Check for broken links in CI (Tobin C. Harding)
e3f6d23b49 Fix incorrect method name in docs (Tobin C. Harding)

Pull request description:

  - Patch 1: Fix broken link (links to recently removed deprecated function)
  - Patch 2: Add `-- -D rustdoc::broken-intra-doc-links` to CI

  cc dpc, wasn't on this repo but you brought this to my attention, thanks man!

ACKs for top commit:
  apoelstra:
    ACK ade888e922

Tree-SHA512: febe4dc3d8831d59edcc6ae1e6b31c48bc1ab8765a7c074573657350e906cd877ef2ed486adc656b09f3e2471d11cd3e57072a33f2f0279eb9cd13b2102f1cd7
2022-11-17 03:04:33 +00:00
Tobin C. Harding ade888e922 Check for broken links in CI
Add `-- -D rustdoc::broken-intra-doc-links` to the docs build in CI to
check for broken links. In order to use this flag use `cargo rustdoc`
instead of `cargo doc`.
2022-11-17 09:49:28 +11:00
Tobin C. Harding e3f6d23b49 Fix incorrect method name in docs
We are currently not checking for broken doc links in CI. Recently we
removed a bunch of deprecated functions, one of which was still referred
to in rustdocs.

Fix the docs to use the correct new method name.
2022-11-17 09:44:52 +11:00
Andrew Poelstra ab9fdf006c
Merge rust-bitcoin/rust-secp256k1#510: Fix incorrect method call
cd7a6b316b Fix incorrect method call (Tobin C. Harding)

Pull request description:

  We have the following method on `SecretKey`

  ```
      pub fn sign_ecdsa(&self, msg: Message) -> ecdsa::Signature {
          SECP256K1.sign_ecdsa(&msg, self)
      }
  ```

  But we have a method call in rustdocs
  ```
  //! let (secret_key, public_key) = generate_keypair(&mut thread_rng());
  //! let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes());
  //!
  //! let sig = secret_key.sign_ecdsa(&message, &secret_key);
  ```

  This is incorrect, I have no idea why this code builds.

  (Also see https://github.com/rust-bitcoin/rust-secp256k1/issues/508.)

ACKs for top commit:
  apoelstra:
    ACK cd7a6b316b

Tree-SHA512: 5f22157798a4e4a21fff946dd930c62c7d82100a8e729309f6383709cb3fefdd935df1b7954fc545f1c2283a46b8c22f61e1c6d4534cb750eb7ab3b5036eedf5
2022-11-16 18:10:50 +00:00
Andrew Poelstra 4ff168bbbe
Merge rust-bitcoin/rust-secp256k1#512: Improve docs crate wide
ec47198a17 Remove ONE_KEY (Tobin C. Harding)
d546c16134 Remove cfg docs feature requirements (Tobin C. Harding)
5a7cedef00 doc: Fix preallocated memory grammar (Tobin C. Harding)

Pull request description:

  Read over and improve various parts of the crate documentation. Note this is an API breaking PR because it removes the public `ONE_KEY` type that we exposed when writing the docs for the `secret` module, exposing this type was, in my opinion, a mistake.

ACKs for top commit:
  apoelstra:
    ACK ec47198a17

Tree-SHA512: cf8573e58c9498093b0df3f240501d3ad0a9d65e07d2f7c3a9e4116bac6ba366d3d41ac695f4e79010597124512a43b32b4ecb02b08d81226c527d5f77a1a541
2022-11-16 13:46:20 +00:00
Tobin C. Harding e0e575dde7 Run cargo fmt
Run the command `cargo +nightly fmt` to fix formatting issues.

The formatter got confused in one place, adding an incorrect
indentation, this was manually fixed.
2022-11-16 11:06:12 +11:00
Tobin C. Harding 41449e455d Prepare codebase for formatting
In preparation for running the formatter do minor refactorings and add a
bunch of `rustfmt::skip` directives.
2022-11-16 10:56:25 +11:00
Tobin C. Harding 7e3c8935b6 Introduce rustfmt config file
As we did in `rust-bitcoin` introduced a `rustfmt` configuration file
that is palatable to devs.

Do not run formatter, that is done as a separate patch to assist review.
2022-11-16 10:47:50 +11:00
Tobin C. Harding cd7a6b316b Fix incorrect method call
We have the following method on `SecretKey`

```
    pub fn sign_ecdsa(&self, msg: Message) -> ecdsa::Signature {
        SECP256K1.sign_ecdsa(&msg, self)
    }
```

But we have a method call in rustdocs
```
//! let (secret_key, public_key) = generate_keypair(&mut thread_rng());
//! let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes());
//!
//! let sig = secret_key.sign_ecdsa(&message, &secret_key);
```

This is incorrect and is currently not running because the feature guard
is incorrectly spelled, it contains the word "features" instead of
"feature".
2022-11-15 12:25:31 +11:00
Tobin C. Harding ec47198a17 Remove ONE_KEY
The `ONE_KEY` is only used in two rustdoc examples, as such it
unnecessarily pollutes the crate root namespace. We can use
`SecretKey::from_str()` with no loss of clarity and remove the
`ONE_KEY`.

While we are touching the import statements in `secret.rs` elect to
remove the hide (use of `#`) for import statements relating to this
library. Doing so gives devs all the information they need in one place
if they are using the examples to copy code. It is also in line with the
rest of the codebase.
2022-11-15 12:14:29 +11:00
Tobin C. Harding d546c16134 Remove cfg docs feature requirements
The `alloc_only` module already has a docs guard on the "alloc" feature,
using an additional docs guard on the `SignOnly`, `VerifyOnly`, `All`
enums leads to a redundant feature combination "alloc" and "alloc or
std" - we really only require "alloc".
2022-11-15 12:14:29 +11:00
Tobin C. Harding 5a7cedef00 doc: Fix preallocated memory grammar
The grammar on structs that implement `Context` using preallocated
memory is slightly incorrect. Attempt to improve the grammar.
2022-11-15 12:14:29 +11:00
Andrew Poelstra 5a546945ad
Merge rust-bitcoin/rust-secp256k1#488: Support non-WASM platforms that are missing `string.h`
92b733386f Support non-WASM platforms that are missing `string.h` (Matt Corallo)

Pull request description:

  Dunno why we haven't seen this elsewhere, but when trying to build locally for an ARM embedded target `secp256k1-sys` failed to compile as it was missing `string.h`, just like WASM.

  This patch adds a trivial fallback - if we fail to compile initially we unconditionally retry with the wasm-sysroot, giving us a valid `string.h`.

ACKs for top commit:
  tcharding:
    ACK 92b733386f
  apoelstra:
    ACK 92b733386f

Tree-SHA512: 81cbc5023f349681a3bef138506d9314be948b8b7b78bb2b2ffacf43b0c97d92ea67238105009a94b05a0a3adbd4113ed68f79a0a303708d95c6a7f520d5170e
2022-11-14 14:40:56 +00:00
Andrew Poelstra 8508680c79
Merge rust-bitcoin/rust-secp256k1#509: Improve feature usage bitcoin-hashes[-std]
b0d0b2afcb Improve feature usage bitcoin-hashes[-std] (Tobin C. Harding)

Pull request description:

  Currently we have a feature `bitcoin-hashes-std` and a dependency `bitcoin_hashes`, this means one has to think about and change the `_` and `-` when coding. The underscore in `bitcoin_hashes` is an artifact of days gone by and we cannot fix it but we can cover it up and make our lives easier, especially now we have `bitcoin-hashes-std`.

  Improve feature usage of the `bitcoin_hashes` library by:

  - Add a feature `bitcoin-hashes` that enables `bitcoin_hashes`.
  - Use the new feature in all feature gated code
  - Use `bitcoin-hashes-std` in feature gated code that includes other `std` features (e.g. `rand-std`)

ACKs for top commit:
  apoelstra:
    ACK b0d0b2afcb

Tree-SHA512: e6a86fe2c5b249a6c32b0fdedaeb8e25c47a30a4709f4fc4020cc1762747fe5d25883e2340ff77698079c9ee397491984889d3c1aaf195ca27eec09a77f62978
2022-11-14 14:19:57 +00:00
Andrew Poelstra 432f2939c6
Merge rust-bitcoin/rust-secp256k1#507: Minimise FFI in the public API
68c73850d8 Minimise FFI in the public API (Tobin C. Harding)

Pull request description:

  Normal users should never need to directly interact with the FFI layer.

  Audit and reduce the use of `ffi` types in the public API of various types. Leave only the implementation of `CPtr`, and document this clearly as not required by normal users. Done for:

  - PublicKey
  - XOnlyPublicKey
  - KeyPair
  - ecdsa::Signature
  - ecdsa::RecoverableSignature

ACKs for top commit:
  apoelstra:
    ACK 68c73850d8

Tree-SHA512: 8242527837872f9aba2aab19b02c2280ca1eb1dfd33c8ca619726d981811d72de3e5a57cbde2fbe621eb8e50e43f488804cd51d27949459da1c0ceb03fca35e3
2022-11-14 14:13:22 +00:00
Andrew Poelstra 191184539c
Merge rust-bitcoin/rust-secp256k1#511: Remove deprecated code
8c7c5e7394 Remove deprecated code (Tobin C. Harding)
e779e5dc05 doc: Use add_tweak in example code (Tobin C. Harding)
eedbd0b7e4 secp256k1-sys: Remove deprecated code (Tobin C. Harding)

Pull request description:

  Remove deprecated code from `secp256k1-sys` and `secp256k1`.

ACKs for top commit:
  apoelstra:
    ACK 8c7c5e7394

Tree-SHA512: 830d4459cf21fba98e75e1c099c96316c9db1c1fb87dd28343cea066544ac8568685ec9fc85969caee3d35014f64c3f42b5a5afbf4f4d16221a57a204e6a3524
2022-11-13 01:03:58 +00:00
Andrew Poelstra 72918bf5f7
Merge rust-bitcoin/rust-secp256k1#506: Manually implement `PartialEq`, `Eq`, and `Hash` for `PublicKey`
5ccf0c8db7 Manually implement PartialEq, Eq, and Hash for PublicKey (Tobin C. Harding)

Pull request description:

  `PartialEq` and `Eq` should agree with `PartialOrd` and `Ord` but we are deriving `PartialEq`/`Eq` and doing a custom implementation of `PartialOrd` and `Ord` (that calls down to ffi functions).

  If two keys are equal their hashes should be equal so, we should add a custom implementation of `Hash` also. In order to guarantee the digest will be the same across library versions first serialize the key before hashing it.

  Add custom implementation of `PartialEq`, `Eq`, and `Hash` when not fuzzing.

  Please note, this is for the main `PublicKey` type, the patch does not effect the `ffi::PublicKey`, nor do we call methods on the `ffi::PublicKey`.

  EDIT: Please note the comment below by apoelstra about the possible performance hit introduced by this PR.

ACKs for top commit:
  apoelstra:
    ACK 5ccf0c8db7

Tree-SHA512: 1464308238411d259bb0493dc1eca775ec235036eef10b91f70ef17816174f452d5911ecae3b40434b71f9866be1db54d69e8ed9475a4f2801c07a800aead2b2
2022-11-12 22:49:01 +00:00
Tobin C. Harding 8c7c5e7394 Remove deprecated code
We are currently on version 0.24.1 (i.e., next release is 0.25.0), we
can comfortably remove any code deprecated in 0.23.x or earlier.
2022-11-10 11:30:40 +11:00
Tobin C. Harding e779e5dc05 doc: Use add_tweak in example code
In preparation for removing the deprecated `tweak_add_check` use the new
version `add_tweak` instead.
2022-11-10 11:30:31 +11:00
Tobin C. Harding eedbd0b7e4 secp256k1-sys: Remove deprecated code
We are currently on release 0.6.1, code deprecated since v0.2.0 can
comfortably be removed.
2022-11-10 11:14:24 +11:00
Tobin C. Harding b0d0b2afcb Improve feature usage bitcoin-hashes[-std]
Currently we have a feature `bitcoin-hashes-std` and a dependency
`bitcoin_hashes`, this means one has to think about and change the `_`
and `-` when coding. The underscore in `bitcoin_hashes` is an artifact
of days gone by and we cannot fix it but we can cover it up and make our
lives easier, especially now we have `bitcoin-hashes-std`.

Improve feature usage of the `bitcoin_hashes` library by:

- Add a feature `bitcoin-hashes` that enables `bitcoin_hashes`.
- Use the new feature in all feature gated code
- Use `bitcoin-hashes-std` in feature gated code that includes other
  `std` features (e.g. `rand-std`)
2022-11-10 10:56:14 +11:00