Commit Graph

541 Commits

Author SHA1 Message Date
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
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
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
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 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
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 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 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
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 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
Tobin C. Harding 5ccf0c8db7 Manually implement PartialEq, Eq, and Hash for PublicKey
`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`.
2022-11-09 06:31:23 +11:00
Tobin C. Harding 68c73850d8 Minimise FFI in the public API
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
2022-11-08 15:03:20 +11:00
Andrew Poelstra 497654ea23
Merge rust-bitcoin/rust-secp256k1#504: Add array constants
603f441548 Add array constants (Tobin C. Harding)

Pull request description:

  In multiple places we use array constants for zero and one. Add two constants and use them throughout the codebase. Note the endian-ness of `ONE` in the docs.

ACKs for top commit:
  apoelstra:
    ACK 603f441548

Tree-SHA512: 70c455ee42f8a04feec37c3963b030c0f2c07b83801caf818dbb1661b7a0f65c4b92ff6a5df496a4dd6a917d13af4d60624a072c6f8a083293db9cd80d194232
2022-11-06 15:14:55 +00:00
Tobin C. Harding 603f441548 Add array constants
In multiple places we use array constants for zero and one. Add two
constants and use them throughout the codebase. Note the endian-ness of
`ONE` in the docs.
2022-11-06 05:21:16 +11:00
Andrew Poelstra dfb51e5d14
Merge rust-bitcoin/rust-secp256k1#497: Fix typo in public method
76a0804ca5 Fix typo in public method (Tobin C. Harding)

Pull request description:

  We have a method called `from_raw_signining_only`, I'm guessing this should be `from_raw_signing_only`.

ACKs for top commit:
  apoelstra:
    ACK 76a0804ca5

Tree-SHA512: ee03dbf3f69f0b348a483fa928fab9fba73bfdea383aee385a853b99998a882695c6839fff6433784ad097709ca31c67fc0a4e1a948caae7356be2eab7e332e5
2022-11-04 23:34:54 +00:00
Tobin C. Harding 76a0804ca5 Fix typo in public method
We have a method called `from_raw_signining_only`, I'm guessing this
should be `from_raw_signing_only`.
2022-11-01 15:25:50 +11:00
Tobin C. Harding 5417fad7cb Add method SecretKey::from_hashed_data
Analogous to the method on `Message`; add a constructor method on
`SecretKey` that hashes the input data.

While we are at it improve the rustdocs on `Message::from_hashed_data`
so docs on both methods are uniform.
2022-10-28 12:16:15 +11:00
elsirion 53c1354cc5
Fix broken `serde::Deserialize` and `FromStr` impl of `keyPair`
Fixes #491
2022-10-24 16:54:13 +02:00
Andrew Poelstra 0f29348b6c move some unsafe code inside an unsafe{} boundary
An internal function had a non-unsafe signature but could be called
with data that would cause it to exhibit UB. Move the unsafety inside
of the function so that the function signature now enforces soundness.

Fixes #481
2022-08-12 16:02:55 +00:00
Tobin C. Harding 6e98ec0475 Fix clippy warnings
Clippy default settings seemed to have changed introducing a few new
warnings.

warning: variable does not need to be mutable
warning: deref on an immutable reference
warning: returning the result of a `let` binding from a block

Fix them all in a single patch because CI has to pass for each patch.
2022-08-12 12:58:00 +10:00
Andrew Poelstra 71b47d1273
Merge rust-bitcoin/rust-secp256k1#473: Create configuration conditional "bench"
a431edb86a Create configuration conditional bench (Tobin C. Harding)
2a1c9ab4b8 Remove rand-std feature from unstable (Tobin C. Harding)
ddc108c117 Increase heading size (Tobin C. Harding)
596adff8ba Remove unneeded whitespace (Tobin C. Harding)

Pull request description:

  As we did in rust-bitcoin [0] create a configuration conditional `bench`
  that we can use to guard bench mark code. This has the benefit of
  making our features additive i.e., we can now test with `--all-features`
  with a stable toolchain (currently this fails because of our use of the
  `test` crate).

  Please note, this patch maintains the current behaviour of turning on
  the `recovery` and `rand-std` features when benching although I was
  unable to ascertain why this is needed.

  [0] - https://github.com/rust-bitcoin/rust-bitcoin/pull/1092

ACKs for top commit:
  sanket1729:
    ACK a431edb86a.
  apoelstra:
    ACK a431edb86a

Tree-SHA512: 913f5fbe0da08ec649081bf237c1d31cee58dacdac251d6030afabb99d455286c6d1dbdb6b2ac892b5d3c24584933254d1cfeec8e12f531cc420bd9d455a6531
2022-07-19 21:11:13 +00:00
Andrew Poelstra b01337cfb5 context: unconditionally disable auto-rerandomization on wasm
This causes panics. We can't add catch the panic, we can't change its output, we
can't detect if it'll happen, etc. Rather than dealing with confused bug reports
let's just drop this.

If users want to rerandomize their contexts they can do so manually.

There is probably a better solution to this but it is still under debate, even
upstream in the C library, what this should look like. Meanwhile we have bug
reports now.
2022-07-14 14:08:04 +00:00
Andrew Poelstra 748284633b apply `global-context-not-secure` logic to Secp256k1::new
Disable auto-rerandomization for both global and local contexts.
2022-07-14 14:06:41 +00:00
Tobin C. Harding a431edb86a Create configuration conditional bench
As we did in rust-bitcoin [0] create a configuration conditional `bench`
that we can use to guard bench mark code. This has the benefit of
making our features additive i.e., we can now test with `--all-features`
with a stable toolchain (currently this fails because of our use of the
`test` crate).

[0] - https://github.com/rust-bitcoin/rust-bitcoin/pull/1092
2022-07-14 09:35:23 +10:00
Tobin C. Harding 596adff8ba Remove unneeded whitespace
We do not customarily put two lines of whitespace before modules.

Remove unneeded whitespace from before the `benches` module.
2022-07-13 14:30:17 +10:00
Tobin C. Harding d2c97d43d8 Remove unnecessary instances of must_use
`Result` is already `must_use`, adding the compiler directive to
functions that return `Result` is unnecessary.
2022-07-11 07:56:47 +10:00
Tobin C. Harding 5f611f6f7f Conditionally compile the hex macro
We only use this macro when not fuzzing, add a cfg attribute to build it
in only when needed.
2022-06-29 11:11:39 +10:00
Andrew Poelstra 5f59820a8a
Merge rust-bitcoin/rust-secp256k1#465: Add must_use for mut self key manipulation methods
56f18430ff Add must_use for mut self key manipulation methods (Tobin C. Harding)
5b86e38aea Put compiler attributes below rustdocs (Tobin C. Harding)

Pull request description:

  We recently added a bunch of key tweaking methods that take `mut self`
  and return the tweaked/negated keys. These functions are pure and as
  such the returned result is expected to be used. To help downstream
  users use the API correctly add `must_use` attributes with a descriptive
  error string for each of the methods that takes `mut self`.

  Patch 1 is preparatory cleanup.

ACKs for top commit:
  apoelstra:
    ACK 56f18430ff

Tree-SHA512: 95ee63d5d0a34a9915551471d2f71de1963875eda04bf4217544076be0ed2836dcdee1875432dba5e02678556af86d7487e39daac6e928083807661430ddbcd6
2022-06-28 14:56:58 +00:00
Tobin C. Harding 0c15c01eb1 Use fuzzing not feature = "fuzzing"
Currently the following command fails

`RUSTFLAGS='--cfg=fuzzing' RUSTDOCFLAGS='--cfg=fuzzing' cargo test --all --all-features`

This is because `fuzzing` is not a feature, we should be using `fuzzing`
directly not `feature = "fuzzing"`.

I have no idea how this got past CI.
2022-06-28 13:30:33 +10:00
Tobin C. Harding 56f18430ff Add must_use for mut self key manipulation methods
We recently added a bunch of key tweaking methods that take `mut self`
and return the tweaked/negated keys. These functions are pure and as
such the returned result is expected to be used. To help downstream
users use the API correctly add `must_use` attributes with a descriptive
error string for each of the methods that takes `mut self`.
2022-06-28 13:18:57 +10:00
Andrew Poelstra 2b8297a468
Merge rust-bitcoin/rust-secp256k1#462: derive Hash for RecoverableSignature
e275166652 derive Hash for RecoverableSignature (NicolaLS)

Pull request description:

  It would be nice to also derive Hash for `RecoverableSignature` so data structures containing it don't have to implement it themself if they need to derive Hash

ACKs for top commit:
  apoelstra:
    ACK e275166652

Tree-SHA512: 418337e16e82a5e736c54d123450fdb164f4776db68952cf8095b36c501436446542821d554fa781dffa0f9067fc2464833a6c461897e655ff4449018da12ca2
2022-06-27 14:02:41 +00:00
NicolaLS e275166652 derive Hash for RecoverableSignature 2022-06-27 14:16:49 +02:00
Martin Habovstiak b18f5d0454 Removed `Default` from `SerializedSignature`
`Default` was pointless, so it was replaced with internal
`from_raw_parts` method which also checks the length.

This commit also documents changes to `SerializedSignature`.

Closes #454
2022-06-22 00:29:57 +02:00
Andrew Poelstra 7975be53cf
Merge rust-bitcoin/rust-secp256k1#456: `SerializedSignature` improvements
0e0fa06e41 Simplify `Display` impl of `SerializedSignature` (Martin Habovstiak)
5d51b9d94b Added `MAX_LEN` constant to `serialized_signature` (Martin Habovstiak)
e642a52e7d Add `#[inline]` to methods of `SerializedSignatre` (Martin Habovstiak)
e92540beb8 `impl IntoIterator for SerializedSignature` (Martin Habovstiak)
7f2d3d2452 Move `SerializedSignature` into its own module (Martin Habovstiak)
901d5ffeb9 `impl<'a> IntoIterator for &'a SerializedSignature` (Martin Habovstiak)
1d2a1c3fee Deduplicate `self.data[..self.len]` expressions (Martin Habovstiak)

Pull request description:

  This

  * Deduplicates slicing operations
  * Implements `IntoIterator` (owned and borrowed)
  * Reorganizes the code for better clarity
  * Adds `#[inline]`s
  * Checks length set by libsep256k1

  Closes #367
  Closes #368

  Individual commits are hopefully easier to review.

ACKs for top commit:
  apoelstra:
    ACK 0e0fa06e41

Tree-SHA512: bbc759af767c8b84bfd6720456efc1e86da501aa193641dae3c99847a3c882f7d4aa7e5cbec074fdd9c2595f1f65e5fbb4c80620539a6357927149e5c2fbc734
2022-06-21 20:46:42 +00:00