Commit Graph

1203 Commits

Author SHA1 Message Date
Andrew Poelstra d5f8b2abff
Merge rust-bitcoin/rust-secp256k1#691: Check for API changes in CI
65d54e7bbe Add script to update-lock-files (Tobin C. Harding)
c61db1b44f CI: Check for API changes (Tobin C. Harding)
53d34d5ee0 Update the API files (Tobin C. Harding)
c3f2c59db1 just: Add a command to check for API changes (Tobin C. Harding)
1e22d74270 Add a justfile (Tobin C. Harding)

Pull request description:

  This PR is not just CI, it does a few clean up chores:
  - Add a `justfile` (including command to check the API)
  - Update the API files
  - Add a script to update the lock files

ACKs for top commit:
  apoelstra:
    ACK 65d54e7bbe

Tree-SHA512: c799200dc761cb4367904346024834caf52e9a549aed5741263429d0bd297858c5293bfdb4bdf83fffb063060f7f251c9c1956659bd50867b09fafddb3c54880
2024-03-27 18:34:14 +00:00
Tobin C. Harding 65d54e7bbe
Add script to update-lock-files
Copy the script from `rust-bitcoin`, also add a `just` command to call
it.
2024-03-27 11:17:12 +11:00
Tobin C. Harding c61db1b44f
CI: Check for API changes
Add a job to run the `contrib/check-for-api-changes.sh` script in CI.
2024-03-27 11:16:36 +11:00
Tobin C. Harding 53d34d5ee0
Update the API files
Run `just check-api` and commit the changes. We should have never gotten
to this state, upcoming patch will check for changes in CI.
2024-03-27 11:16:36 +11:00
Tobin C. Harding c3f2c59db1
just: Add a command to check for API changes
Add a command to run the `contrib/check-for-api-changes.sh` script.
2024-03-27 11:16:36 +11:00
Tobin C. Harding 1e22d74270
Add a justfile
The `just` command makes scripts and commands discoverable for new devs
and old devs alike when switching between repos.

Add a justfile copied from bitcoin with changes as required.
2024-03-27 11:09:57 +11:00
Andrew Poelstra 5fa3623acf
Merge rust-bitcoin/rust-secp256k1#689: Allow dead_code on AlignedType
873ad47343 Allow dead_code on AlignedType (Tobin C. Harding)

Pull request description:

  We use the `AlignedType` and take a pointer to its inner data, never access the data directly - this confuses clippy causing a "field is never used" warning.

  Shoosh the lint and add a code comment explaining why.

ACKs for top commit:
  apoelstra:
    ACK 873ad47343

Tree-SHA512: 2a383aed169edf247def5c291bc2d8177cc09412b82bb47bb514e0929ae89d689102e646dcbbffc6fd4caa1ce1430420a63c7ceb3428ad9b05230a93b7f14d16
2024-03-26 22:38:01 +00:00
Tobin C. Harding 873ad47343
Allow dead_code on AlignedType
We use the `AlignedType` and take a pointer to its inner data, never
access the data directly - this confuses clippy causing a "field is
never used" warning.

Shoosh the lint and add a code comment explaining why.
2024-03-26 09:33:38 +11:00
Andrew Poelstra fb676dcb1f
Merge rust-bitcoin/rust-secp256k1#678: schnorr: Change verify_schnorr error return type
adee34fe18 schnorr: Change verify_schnorr error return type (Steven Roose)

Pull request description:

  Bumped into this.

ACKs for top commit:
  Kixunil:
    ACK adee34fe18
  tcharding:
    ACK adee34fe18
  apoelstra:
    ACK adee34fe18

Tree-SHA512: 7ddad93fc69e36d7d33b54526b7c108df9fc69e6153eb583a69eca840c3bd095bcabe03c32ad21577e0fe1a12f1d191d7f5b7edd722fd20ecc200a30c8ee4d25
2024-01-31 21:32:38 +00:00
Steven Roose adee34fe18
schnorr: Change verify_schnorr error return type
From InvalidSignature to IncorrectSignature; the former prints the
message "malformed signature", which doesn't represent the correct
error.
2024-01-31 15:19:42 +00:00
Andrew Poelstra a1d8c90a46
Merge rust-bitcoin/rust-secp256k1#677: bump version to 0.28.2
1a162faf40 bump version to 0.28.2 (Andrew Poelstra)

Pull request description:

  Minor version which just adds some methods to various types.

ACKs for top commit:
  Kixunil:
    ACK 1a162faf40

Tree-SHA512: d93b1abc04d6165bf121f9385683178ada0103501a3de198772b992e2c01e8d9e742f7cd111fdaef825be4fd989d01b6928f2dece4fd78e286798ee905ce9e42
2024-01-31 14:26:06 +00:00
Andrew Poelstra 1a162faf40
bump version to 0.28.2 2024-01-31 13:33:21 +00:00
Andrew Poelstra 9bc110b7d2
Merge rust-bitcoin/rust-secp256k1#676: Add byte accessors to `ElligatorSwiftSharedSecret`
7fe89c488b Add byte accessors to `ElligatorSwiftSharedSecret` (Martin Habovstiak)

Pull request description:

  The inner bytes of `ElligatorSwiftSharedSecret` were almost inaccessible making the type almost useless, so this commit adds methods to access inner bytes.

  Closes #675

ACKs for top commit:
  apoelstra:
    ACK 7fe89c488b

Tree-SHA512: 5ec457401c83423b180f7a6f28048f93040c39129050707b981d1c113e3daa85a37b3f848e61cd3230cc26db4a783e561b77e09b766fd8193d8f7bf187214091
2024-01-30 18:15:11 +00:00
Martin Habovstiak 7fe89c488b Add byte accessors to `ElligatorSwiftSharedSecret`
The inner bytes of `ElligatorSwiftSharedSecret` were almost inaccessible
making the type almost useless, so this commit adds methods to access
inner bytes.

Closes #675
2024-01-30 17:01:23 +01:00
Andrew Poelstra 4dede134de
Merge rust-bitcoin/rust-secp256k1#611: Impl Ord and PartialOrd for RecoverableSignature
dbc546596f Impl Ord and PartialOrd for RecoverableSignature (benthecarman)

Pull request description:

ACKs for top commit:
  apoelstra:
    ACK dbc546596f oops, sorry!

Tree-SHA512: decda6b6e7a4929147f5ca00cb2802037c6a297aa816c253e181f1a85ec9e46958469b9d481e2b4aba2c6d86def80bba33a62c507459d82c86cfed4271a23eea
2024-01-22 18:45:45 +00:00
benthecarman dbc546596f
Impl Ord and PartialOrd for RecoverableSignature 2024-01-22 14:50:29 +00:00
Andrew Poelstra f96fcd8fcf
Merge rust-bitcoin/rust-secp256k1#674: Derive Hash for Scalar
f87dc91151 Derive Hash for Scalar (Jiri Jakes)

Pull request description:

  Unless there is some safety concern I cannot see, having Scalar implementing Hash would be useful.

ACKs for top commit:
  Kixunil:
    ACK f87dc91151
  apoelstra:
    ACK f87dc91151

Tree-SHA512: 276670a3d938fade3828123547b01e38b1a3c56775fb3c545d2c392622de808cf2bf8125925c7896ee27bacd5897d88908384d8c157dc8ec7d605781475964fd
2024-01-18 16:23:05 +00:00
Jiri Jakes f87dc91151
Derive Hash for Scalar 2024-01-18 19:23:31 +08:00
Andrew Poelstra a771f6c722
Merge rust-bitcoin/rust-secp256k1#672: release 0.28.1
0ed5a55829 release 0.28.1 (Andrew Poelstra)

Pull request description:

  We need a new rust-secp release to deal with the new rust-secp-sys release.

ACKs for top commit:
  sanket1729:
    utACK 0ed5a55829
  Kixunil:
    ACK 0ed5a55829

Tree-SHA512: 6d54acce52acc03d09272a20242e9a086783e471153d77d10f21bf8924595d43717fd85e8aa4a9b7075c93a04ad88404377e06ca5200b1c9b45c08c01d6f77a8
2024-01-03 19:58:02 +00:00
Andrew Poelstra 0ed5a55829
release 0.28.1 2024-01-03 19:54:01 +00:00
Andrew Poelstra 60a5e36c14
Merge rust-bitcoin/rust-secp256k1#670: fix incorrect FFI binding for pubkey_combine
3373cc930e secp256k1-sys: update all symbols from 0.9.1 to 0.9.2 (Andrew Poelstra)
484e5d8d5b fix incorrect FFI binding for pubkey_combine (Andrew Poelstra)

Pull request description:

  Fixes #669.

  Needs backport.

ACKs for top commit:
  Kixunil:
    ACK 3373cc930e

Tree-SHA512: 602a5baa8095cc744a341d64e300185bce26c8c56e7a538d3b17c7ca4c98cb3244217cd34169e1e69dc904a9f9f28ed75fe096ffa95ea42d1ad3456d395f7ce5
2024-01-03 19:12:05 +00:00
Andrew Poelstra 3373cc930e
secp256k1-sys: update all symbols from 0.9.1 to 0.9.2 2024-01-02 16:22:20 +00:00
Andrew Poelstra 484e5d8d5b
fix incorrect FFI binding for pubkey_combine 2023-12-18 21:28:27 +00:00
Andrew Poelstra 97dade5581
Merge rust-bitcoin/rust-secp256k1#668: secp256k1-sys: Bump version to 0.9.1
c1ccda18b6 secp256k1-sys: Bump version to 0.9.1 (Tobin C. Harding)

Pull request description:

  In preparation for doing a point release add a changelog entry, bump the version, and update all the `0_9_0` identifiers in the vendored code.

  Done so we can release the wasm-build bug fix.

  Fix: #667

ACKs for top commit:
  apoelstra:
    ACK c1ccda18b6

Tree-SHA512: 4fda58bd2d97b73280c00f06109d4ecf913e87ecbd1e31465efe94b96589c819ffda0ae5c622428f0a7f2e09ec45033a0e683dfd954cf06369aac6b9369471c1
2023-12-06 23:40:22 +00:00
Tobin C. Harding c1ccda18b6
secp256k1-sys: Bump version to 0.9.1
In preparation for doing a point release add a changelog entry, bump the
version, and update all the `0_9_0` identifiers in the vendored code.

Done so we can release the wasm-build bug fix.
2023-12-07 10:21:38 +11:00
Andrew Poelstra 023d50b4db
Merge rust-bitcoin/rust-secp256k1#663: Patch out any instances of printf in upstream
7a0c60edcd secp256k1-sys: patch out checked_malloc (Andrew Poelstra)
942a0e5e2c build.rs: patch out any calls to `printf` (Andrew Poelstra)
51dab7ac04 vendor-libsecp: remove util.h patch (Andrew Poelstra)

Pull request description:

  Rather than using a new patchfile, just `#define` it away. Also includes a commit which removes one of the existing patchfiles, which I discovered was out of date while auditing the others to see if they could be replaced by `#define`s. (No, they cannot.)

  Fixes #660

ACKs for top commit:
  tcharding:
    AFAICT this is right to go, ACK 7a0c60edcd
  Kixunil:
    ACK 7a0c60edcd

Tree-SHA512: 83ba70b000919fb8a929804c9d5929a9929b80515f0594925d3789ef896889d3c909f9fa920bac45470611607b84f509723544fa442ff1a51eefba0de75bf68f
2023-11-15 18:28:10 +00:00
Andrew Poelstra 4244fec9ad
Merge rust-bitcoin/rust-secp256k1#666: Remove unnecessary code comment
458712212d Improve code comments (Tobin C. Harding)

Pull request description:

  These comments say what the code is doing, they add no value.

ACKs for top commit:
  Kixunil:
    ACK 458712212d
  apoelstra:
    ACK 458712212d

Tree-SHA512: 0f31d36d7dfbde5bf32d622c3ba1845d5c6989c3eff0e520b77eeee595453299551172331851176e50aef4f78eacb7033c0ff798077e44e1c63313013b073f0b
2023-11-15 18:09:23 +00:00
Tobin C. Harding 458712212d
Improve code comments
"what" comments add no value. Remove one and make the other describe
"why" the cast is ok.
2023-11-15 10:13:50 +11:00
Andrew Poelstra 7a0c60edcd
secp256k1-sys: patch out checked_malloc 2023-11-06 14:50:13 +00:00
Andrew Poelstra fb280a3179
Merge rust-bitcoin/rust-secp256k1#664: Fix unit test import statements
dd6bf7c10d Fix unit test import statements (Tobin C. Harding)

Pull request description:

  In `lib.rs` unit tests we are getting build warnings because of how we are importing things, just import with `super::*` unconditionally and be done with it.

  This patch is the only good one out of #661.

ACKs for top commit:
  apoelstra:
    ACK dd6bf7c10d
  Kixunil:
    ACK dd6bf7c10d

Tree-SHA512: 3970f4c1374ec6de4798bfb52b561e9ac4611ec3a3885edc79639566f777e1fbb502cb36fa7abd015f3fd4a9ca4b6a4931b4ecb2e629e967b4e49391db97a97f
2023-11-03 19:33:50 +00:00
Andrew Poelstra 09810e7fd8
Merge rust-bitcoin/rust-secp256k1#659: Implement `Ord` for `SerializedSignature`
e55c1f0960 Implement `Ord` for `SerializedSignature` (Martin Habovstiak)

Pull request description:

ACKs for top commit:
  tcharding:
    ACK e55c1f0960
  apoelstra:
    ACK e55c1f0960

Tree-SHA512: b9a7529f44e5d38ab449af7ee06007f3d0480b31cb21c371190f71bea4e3d9142c6c249fcc5564aa21139c0bdcd3951823cea70f29a63f3ef6d35b7e9c7a8e8c
2023-11-02 11:53:21 +00:00
Andrew Poelstra 942a0e5e2c
build.rs: patch out any calls to `printf` 2023-11-01 17:34:21 +00:00
Andrew Poelstra 51dab7ac04
vendor-libsecp: remove util.h patch
This patch adds a declaration of the `ecdsa_parse_compact` function to
util.h. This function isn't called from within libsecp proper; it is
called in lax_der_parse.c (which we patch separately with a declaration)
and in example code (which we don't compile at all).
2023-11-01 17:01:04 +00:00
Tobin C. Harding dd6bf7c10d
Fix unit test import statements
In `lib.rs` unit tests we are getting build warnings because of how we
are importing things, just import with `super::*` unconditionally and be
done with it.
2023-11-01 09:06:16 +11:00
Martin Habovstiak e55c1f0960 Implement `Ord` for `SerializedSignature` 2023-10-31 20:23:27 +01:00
Andrew Poelstra fe2905d8e3
Merge rust-bitcoin/rust-secp256k1#658: Serialized signture improvements
62c839c9e0 Implement conversion traits (Martin Habovstiak)
dc3eab7aaa Implement `Borrow<[u8]>`, `PartialEq<[u8]>`, `Hash` (Martin Habovstiak)
7dac91d973 Deprecate `capacity` and `is_empty` (Martin Habovstiak)

Pull request description:

  This deprecates methods returning constants and impls a few traits.

ACKs for top commit:
  apoelstra:
    ACK 62c839c9e0

Tree-SHA512: 724a08af7dc915e166e3efcdc4be681a53ae14a55d9cbd62dd4c5240fa8c0f13110498d03ebb0edc1d56f969901f978aa33bae9df19376957ff7f51698ed9535
2023-10-31 15:12:35 +00:00
Martin Habovstiak 62c839c9e0 Implement conversion traits
Converting signature to serialized signature and back is natural, so the
conversion traits should be implemented.
2023-10-31 15:07:01 +01:00
Martin Habovstiak dc3eab7aaa Implement `Borrow<[u8]>`, `PartialEq<[u8]>`, `Hash`
These traits were missing and could be useful if e.g. one wants to store
serialized signatures in a set/map and access them using `[u8]`.
2023-10-31 15:06:20 +01:00
Martin Habovstiak 7dac91d973 Deprecate `capacity` and `is_empty`
These functions always return the same value so are not useful and
actually calling them is a red flag.
2023-10-31 14:12:39 +01:00
Andrew Poelstra 902150cc7c
Merge rust-bitcoin/rust-secp256k1#656: Check for changes to the public API
e9e17a0039 Check for changes to the public API (Tobin C. Harding)

Pull request description:

  We would like to get to a stage where we can commit to the public API. To help us achieve this add a script that generates the public API and checks it against three committed files, one for each feature set: no features, alloc, std.

  The idea is that with this applied any PR that changes the public API should include a final patch that is just the changes to the api/*.txt files, that way reviewers can discuss the changes without even needing to look at the code, quickly giving concept ACK/NACKs. We also run the script in CI to make sure we have not accidentally changed the public API so that we can be confident that don't break semver during releases. The script can also be used to diff between two release versions to get a complete list of API changes, useful for writing release notes and for users upgrading.

  There is a development burden involved if we apply this patch.

ACKs for top commit:
  apoelstra:
    ACK e9e17a0039

Tree-SHA512: 94a2cedb132db457b67b3c60cde8843d9db1d2bc8dba0530cd5c518ebed955bd66a1649c61e0cb96b6f293ce6b9b0395582877ce9f1de003e0020a66100d172f
2023-10-26 14:21:37 +00:00
Tobin C. Harding e9e17a0039
Check for changes to the public API
We would like to get to a stage where we can commit to the public API.
To help us achieve this add a script that generates the public API and
checks it against three committed files, one for each feature set: no
features, alloc, std.

The idea is that with this applied any PR that changes the public API
should include a final patch that is just the changes to the api/*.txt
files, that way reviewers can discuss the changes without even needing
to look at the code, quickly giving concept ACK/NACKs. We also run the
script in CI to make sure we have not accidentally changed the public
API so that we can be confident that don't break semver during releases.
The script can also be used to diff between two release versions to get
a complete list of API changes, useful for writing release notes and for
users upgrading.

There is a development burden involved if we apply this patch.
2023-10-26 10:56:54 +11:00
Andrew Poelstra 7de09c8050
Merge rust-bitcoin/rust-secp256k1#650: Tracking PR for release: `secp256k1 v0.28.0` and `secp256k-sys 0.10.0`
3dc5b16540 Bump version to v0.28.0 (Tobin C. Harding)

Pull request description:

  Bump the version of `secp256k1` ready for release.

  Includes changelog for the already-bumped `secp256k1-sys`, changelog for `secp256k1`, and the version bump for `secp256k1`.

ACKs for top commit:
  apoelstra:
    ACK 3dc5b16540

Tree-SHA512: 404a5512f7bb245cde12d11eb20f2e7bedfa5a8d4124101e04bf51010301fe7d186c3baedf8744006d1c56c0af1bf214f0226c71a54dc6677384ecc8dcc8fde0
2023-10-09 22:51:31 +00:00
Tobin C. Harding 3dc5b16540
Bump version to v0.28.0
Prepare for release by doing:

- Add changelog entry to `secp256k1-sys` for the recent version bump ready
  for release.
- Bump the version of secp256k1 to 0.28.0
- Add changelog entry to `secp256k1` for the imminent release.
2023-10-10 09:40:07 +11:00
Andrew Poelstra 3aada83180
Merge rust-bitcoin/rust-secp256k1#627: Add bindings to the ElligatorSwift implementation
39febcb866 Create rust-bidings (Davidson Souza)

Pull request description:

  ~**Marking as draft as this is an unreleased feature from libsecp**~

  From upstream:
  This implements encoding of curve points using the ElligatorSwift algorithm, using 4 new API calls:

      secp256k1_ellswift_encode, which converts a public key to a 64-byte pseudorandom encoding.
      secp256k1_ellswift_decode, the reverse operation to convert back to normal public keys.
      secp256k1_ellswift_create, which can be seen as a combination of secp256k1_ec_pubkey_create + secp256k1_ellswift_encode, but is somewhat safer.
      secp256k1_ellswift_xdh, which implements x-only Diffie-Hellman directly on top of 64-byte encoded public keys, and more efficiently than decoding + invoking normal ECDH.

  This algorithm allows mapping any pair of field elements (u, t) to a (valid) x coordinate in the curve. This allows representing a field element as a 64-bytes bit string that is indistinguishable from random. You can build a pair of (u, t) from any group element as well.
  We also have an integrated x-only ECDH that can be used to establish a shared secret between two parties. All algorithms are compatible with BIP324 and are tested against the BIP's test cases.

  I have a few questions about the rust side of the implementation:
  Should it be always on, or leave it behind a cargo feature? In `libsecp` this module is default on, but you can disable it.
  I'm not exposing the low-level functions, instead you can use high-level types to interact with ellswift. Is it reasonable to also expose a safe version of the functions above?

ACKs for top commit:
  tcharding:
    ACK 39febcb866
  apoelstra:
    ACK 39febcb866

Tree-SHA512: a3c06304a03af9509ff3ef16fd39ee56ec22fc12d1b36be4c20aaa2ad01e98dd34ea64c66db782d3a2c10c3a7b44c701762d45f8d82f45b62db3379710c89c42
2023-10-09 21:26:45 +00:00
Davidson Souza 39febcb866
Create rust-bidings
Create bindings for all methods and static types in ellswift.h in
secp256k1-sys and their respective safe-rust types.

All methods are extensively commented and tested using BIP324's
test vectors
2023-10-09 14:57:54 -03:00
Andrew Poelstra da4f67b274
Merge rust-bitcoin/rust-secp256k1#653: Update vendored lib secp256k1 to v0.4.0
80b2a8d4aa Update vendored libsecp to v0.4.0 (Davidson Souza)
d2285c929a ci: Remove MIPS* from CI (Davidson Souza)
0d58f50d52 ci: generalize grp in "illegal callback" test (Andrew Poelstra)
acf9ac13e9 delete `test_manual_create_destroy` test (Andrew Poelstra)
04ce50891b lib: fix bad unit test (Andrew Poelstra)
e4cca901ea gitignore: remove things that shouldn't be there (Andrew Poelstra)

Pull request description:

  Replaces  #645 and #652. Precedes #627.

  I'm basically using #652 but resolving the linking problems,

  My local CI is erring on windows cross-test, but I can compile without issue with `cargo build --target x86_64-pc-windows-gnu`. Some MIPS jobs failed before even installing cross, I think those aren't really related to this PR. Any ideas on what can be happening?

ACKs for top commit:
  apoelstra:
    ACK 80b2a8d4aa

Tree-SHA512: 62c2e04348110e3995111fa666f10dcc403b963770d047361f9209cf45b45db8744a7eb6d9ee3278d18007412dab5131ac3e1dd3e3d704963c6a6f232d57199a
2023-09-30 17:43:22 +00:00
Davidson Souza 80b2a8d4aa
Update vendored libsecp to v0.4.0 2023-09-30 12:04:45 -03:00
Davidson Souza d2285c929a
ci: Remove MIPS* from CI
MIPS was recently downgraded to Tier 3, which means it won't be installable by
rustup and may not work as expected. This commit removes all MIPS-related
CI jobs.
2023-09-30 12:04:45 -03:00
Andrew Poelstra 0d58f50d52
ci: generalize grp in "illegal callback" test 2023-09-30 12:04:45 -03:00
Andrew Poelstra acf9ac13e9
delete `test_manual_create_destroy` test
This is just a bad test. It constructs a preallocated context object by
starting from a non-preallocated context object, in a way that can't be
done by users (since it directly constructs a `Secp256k1` struct) and a
way that is very difficult to unwind, because you wind up with two
pointers to the same underlying context object, one a "preallocated" one
and one a normal one.

If you then drop the preallocated one, it will call
`secp256k1_context_destroy`, forcing you to manually deallocate the
other one. If you drop the normally-allocated one, you need to
mem::forget the preallocated one to avoid calling
`secp256k1_context_destroy` twice. The whole thing is pretty fragile.

There is another unit test, `test_raw_ctx`, which gets into the same
situation but using the public API, and demonstrates a few ways to get
out of it.
2023-09-30 12:04:45 -03:00