Commit Graph

145 Commits

Author SHA1 Message Date
Elichai Turkel 26a52bc8c8
Update secp256k1-sys to edition 2018 and fix imports 2022-06-07 23:59:40 +03:00
Tibo-lg 0b27bde60b Bump secp256k1-sys minor version 2022-05-07 20:32:08 +09:00
Tibo-lg 4beebd168e Add secp256k1_schnorrsig_sign_custom to sys crate 2022-05-06 12:16:53 +09:00
Andrew Poelstra 3ed7fb044c release minor version of secp-sys with WASM fix 2022-04-30 16:14:52 +00:00
Tobin C. Harding dc1e377d4e Improve docs on rustsecp256k1_v0_4_1_context_create
In preparation for [someone] adding a `# Safety` section to this
function, clean up the docs.
2022-04-27 10:23:42 +10:00
Tobin C. Harding ad153d82f7 Add safety rustdoc headings
Clippy warns about unsafe code without a `# Safety` section. A bunch of
these warnings are for functions that do actually have safety docs.

Follow rustdoc convention and add a `# Safety` section for the already
existing explanations.
2022-04-27 10:23:42 +10:00
Tobin Harding bfd88dbd6c Move WASM const definitions to a source file
Currently we are defining the WASM integer size and alignments in the
`stdio.h` header file, this is wrong because this file is included in
the build by way of `build.rs` as well as by upstream `libsecp256k1`.

Move WASM integer definitions to a `C` source file and build the file
into the binary if target is WASM.
2022-03-30 10:22:37 +11:00
Andrew Poelstra d06dd2023b update fuzzdummy API to match normal API 2022-03-08 19:45:43 +00:00
Andrew Poelstra 8294ea3f50 secp256k1-sys: update upstream library
Two API changes needed to be reflected: schnorrsig_sign and schnorrsig_verify.

Also bump both Cargo.toml files
2022-03-08 19:45:41 +00:00
Andrew Poelstra 2932179bd6 secp256k1-sys: update secp256k1.h.patch 2022-03-08 19:44:57 +00:00
Tobin Harding 4c43d5e20f
Add custom Debug impl for RecoverableSignature
Currently when debug printing the `RecoverableSignature` we do so byte
by byte, this means that the output differs depending on the endianess
of the machine. If instead we serialize the signature in compact form
then the output is the same irrespective of the endianess.

With this applied the following two commands now pass:

```
cargo test test_debug_output --features=recovery

```
cross test --target powerpc-unknown-linux-gnu test_debug_output --features=recovery
```

Fixes: #375
2022-02-08 08:14:30 +00:00
Tobin Harding 632ecc4530 Use fully qualified path for mem
When building with --no-default-features the compiler emits:

  warning: unused import: `mem`

The call site is feature gated so we either need to feature gate the
import or use a fully qualified path. Since 'core' is quite short elect
to use the fully qualified path.
2022-01-26 13:25:33 +11:00
Tobin Harding f6a19290fc Use hyperlinks
Clippy emits two warnings of type:

 warning: this URL is not a hyperlink

As suggested, add pointy brackets to the links.
2022-01-11 17:41:11 +11:00
Andrew Poelstra 88f6baee73
Merge rust-bitcoin/rust-secp256k1#353: Documented features
18f74d5242 Clarify what does "less security" mean (Martin Habovstiak)
94c55b4d09 Fixed typos/grammar mistakes (Martin Habovštiak)
1bf05523f0 Documented features (Martin Habovstiak)

Pull request description:

  This documents the Cargo features making sure docs.rs shows warning for
  feature-gated items. They are also explicitly spelled out in the crate
  documentation.

  The PR is similar in spirit to https://github.com/rust-bitcoin/rust-bitcoin/pull/633

ACKs for top commit:
  apoelstra:
    ACK 18f74d5242

Tree-SHA512: 8aac3fc5fd8ee887d6b13606d66b3d11ce44662afb92228c4f8da6169e3f70ac6a005b328f427a91d307f8d36d091dcf24bfe4d17dfc034d02b578258719a90a
2022-01-06 15:42:32 +00:00
Andrew Poelstra c50411f798 release secp256k1-sys 0.4.2; make new `ZERO` type publically accessible 2022-01-05 15:56:49 +00:00
Martin Habovstiak 1bf05523f0 Documented features
This documents the Cargo features making sure docs.rs shows warning for
feature-gated items. They are also explicitly spelled out in the crate
documentation.
2022-01-04 16:55:01 +01:00
Andrew Poelstra 6a893208f8
Merge rust-bitcoin/rust-secp256k1#345: Add a static immutable zero aligned type
5e6d0f1363 Switch to associated constant (Jonathan Underwood)
9cf552e240 Add a static immutable zero aligned type (junderw)

Pull request description:

  The `zeroed` fn can not be used in static assignments.

  In environments where it is no_std and no allocator are present, the only way to get a slice of AlignedTypes is dynamically, so `preallocated_gen_new` can't be used.

  By offering this as a static, it can be used in static assignments as such:

  ```rust
  #[cfg(target_pointer_width = "32")]
  static mut CONTEXT_BUFFER: [AlignedType; 69645] = [ZERO_ALIGNED; 69645];
  #[cfg(target_pointer_width = "64")]
  static mut CONTEXT_BUFFER: [AlignedType; 69646] = [ZERO_ALIGNED; 69646];
  static mut SECP256K1: Option<Secp256k1<AllPreallocated>> = None;

  pub fn get_context(seed: Option<&[u8; 32]>) -> &'static Secp256k1<AllPreallocated<'static>> {
      unsafe {
          if SECP256K1.is_none() {
              SECP256K1 = Some(
                  Secp256k1::preallocated_gen_new(&mut CONTEXT_BUFFER)
                      .expect("CONTEXT_BUFFER size is wrong"),
              );
          }
          if let Some(seed) = seed {
              SECP256K1.as_mut().unwrap().seeded_randomize(seed);
          }
          SECP256K1.as_ref().unwrap()
      }
  }
  ```

ACKs for top commit:
  apoelstra:
    ACK 5e6d0f1363

Tree-SHA512: fc800f8c5c637fc7f81312da17f0a96d17cd087a2e6876f4dedbefffbe92b3625deb93636265f334f9fbd7ac38baa529d4ec72857dae662e26d753f32f91d394
2022-01-02 23:31:34 +00:00
Jonathan Underwood 5e6d0f1363
Switch to associated constant 2021-12-23 12:30:43 -07:00
junderw 9cf552e240
Add a static immutable zero aligned type 2021-12-04 13:38:34 +09:00
Andrew Poelstra 96d2242f6a
Merge rust-bitcoin/rust-secp256k1#335: Implement `Hash` for `schnorrsig::Signature`
75b49efb3d Implement `Hash` for all array newtypes (elsirion)

Pull request description:

  I pondered putting the impl into the array type macro together with `(Partial)Eq`, but that would have meant removing other implementations and potentially implementing it for types where it is not wanted. The drawback of the separate impl is that it is more disconnected from the `(Partial)Eq` impl and could theoretically diverge (although unlikely in case of such a simple type) which would break the trait's contract.

ACKs for top commit:
  apoelstra:
    ACK 75b49efb3d

Tree-SHA512: 44d1bebdd3437dfd86de8b475f12097c4a2f872905c822a9cde624089fdc20f68f59a7734fdcc6f3a17ed233f70f63258dfd204ca269d2baf8002ffc325ddc87
2021-11-05 14:29:50 +00:00
elsirion 75b49efb3d
Implement `Hash` for all array newtypes
* implements `Hash` as part of the newtype macro
* removes type-specific implementations
2021-11-04 22:16:42 +01:00
junderw 24d6f62603
Use explicit u8 when assigning a byte slice 2021-10-17 10:07:51 +09:00
Riccardo Casatta 505b04df49
Reduce size of precomputed signing table (ECMULT_GEN_PREC_BITS) for lowmemory 2021-07-21 11:34:47 +02:00
Elichai Turkel 70847e6165
Remove SECP256K1_BUILD as its no longer needed 2021-06-30 16:56:12 +03:00
Dr Maxim Orlovsky 455ee57ba4
Bump sys version to 0.4.1 2021-06-18 23:47:24 +02:00
Dr Maxim Orlovsky aa6bdaff3c
Creating SecretKey and PublicKey from BIP-340 KeyPair 2021-06-16 10:56:59 +02:00
Dr. Maxim Orlovsky 4652ab6116 Updating secp256k1 version to 1758a92ffd896af533b142707e9892ea6e15e5db 2021-06-14 17:55:38 +03:00
Matt Corallo 79119e8123 Skip context randomization in fuzzing to improve performance 2021-06-08 19:17:08 +00:00
Matt Corallo c486ca10c7 Use a global static context in fuzzing, reducing overhead 2021-06-08 19:17:08 +00:00
Matt Corallo 940a51c2c6 Reduce cryptography usage in --cfg=fuzzing
This reduces the usage of real cryptography in --cfg=fuzzing,
specifically replacing the secret->public key derivation with a
simple copy and ECDH with XOR of the public and private parts
(plus a stream of 1s to make a test pass that expected non-0
output).

It leaves secret tweak addition/multiplication as-is.

It also changes the context creation to over-allocate and store
the context flags at the end of the context buffer, allowing us
to easily test context flags in each function.

While it would be nice to have something fancier (eg XOR-based),
its not immediately obvious how to accomplish this, and better to
fix the issues I have than spend too much time on it.

Fixes #271.

This partially reverts b811ec133a
2021-06-08 19:17:08 +00:00
Matt Corallo ee1103a1f3 Reduce visibility on secp-sys symbols
cc-rs builds C dependencies with reduced visibility to avoid
exporting the C symbols all the way out to any rust-built shared
libraries however we override it with SECP256K1_API. We should
avoid doing this, allowing LTO/DCE to do its work.
2021-04-07 11:21:16 -04:00
Kirill Fomichev 0a91f2ba2b
Use CARGO_CFG_TARGET_ARCH instead TARGET in build.rs 2021-03-08 22:54:21 +03:00
Gregory Hill c86808fac7
use core instead of std for wasm sanity checks
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
2021-01-20 14:55:48 +00:00
Andrew Poelstra 65ff814a39 rename `rust_secp_fuzz` to `fuzzing` 2021-01-11 19:14:42 +00:00
Andrew Poelstra d12be7966c drop unnecessary no_mangle annotations on non-exported functions 2020-12-29 19:30:59 +00:00
Andrew Poelstra 58f946fcc8 secp-sys: remove now-unneeded endianness check from build.rs 2020-12-29 17:15:56 +00:00
Andrew Poelstra e687622a81 bump secp-sys version; drop endomorphism flag 2020-12-29 17:15:56 +00:00
Andrew Poelstra a93d671d05 update libsecp to 98dac87839838b86094f1bccc71cc20e67b146cc 2020-12-29 17:15:51 +00:00
Andrew Poelstra e5d9e088cf secp-sys: update scratch_impl.patch for upstream changes 2020-12-29 17:15:21 +00:00
Andrew Poelstra a9049f8eb2
Merge pull request #266 from junderw/patch-1
Fix link_name for secp256k1_ec_seckey_negate
2020-12-29 17:12:36 +00:00
Andrew Poelstra 75d717729a fuzz: fix elichai's nits 2020-12-28 19:01:12 +00:00
Andrew Poelstra 96862b6a74 fuzz: implement recoverable signatures, get all tests passing, run them in CI 2020-12-28 18:42:46 +00:00
Jonathan Underwood 51bc0b1c0c
Fix link_name for secp256k1_ec_seckey_negate 2020-12-28 15:06:18 +09:00
Andrew Poelstra b811ec133a fuzz: only replace signing and verification, leave everything else alone
We can now run unit tests with the fuzz feature on, and they'll pass,
which is some assurance that fuzzing with the feature on won't lead to
spurious failures due to the fuzz harness inadequately simulating message
signing.
2020-12-23 17:59:52 +00:00
Andrew Poelstra 40c31342f2 ffi: make function types nullable 2020-12-23 17:59:52 +00:00
Andrew Poelstra 29316efff5 add warning about fuzzing being enabled 2020-12-22 17:34:50 +00:00
Andrew Poelstra 85075a654c replace `fuzztarget` Cargo feature with a rustc --cfg flag
It's super dangerous to use Cargo features for this, since they can be set
accidentally (or maliciously by any crate in a user's entire dep tree). Instead
we can just require users set `RUSTFLAGS` appropriately, which we can easily
do in our fuzzing scripts.
2020-12-22 15:42:02 +00:00
Andrew Poelstra d77483f00e replace cargo `external-symbols` feature with a rustc --cfg flag
This feature was not useful for Cargo users, since Cargo does not give you
the kind of fine-grained control over C library linkage that you need. So
it was just unnecessarily confusing and would cause the build to break if
you enabled it accidentally, say, with --all-features.
2020-12-22 15:35:16 +00:00
Tobin Harding 02dec3eb9b
Implement AsRef instead of custom method
Clippy emits a warning since we define a method that has the same name
as a standard trait. Implement the trait `AsRef` instead of using a
custom method.
2020-12-22 12:56:11 +11:00
Tobin Harding 3afc172096
Conditionally compile fn strlen
`strlen` is only used under certain feature flags, use `cfg` to
conditionally build it in.

Clears clippy warning.
2020-12-22 12:55:37 +11:00
Tobin Harding 617bff9df3
Conditionally include ALIGN_TO
This const is only used under specific features, use `cfg` to
conditionally build it in.

Removes clippy warning.
2020-12-22 12:54:08 +11:00
Tobin Harding f67081a01c
Allow unnecessary parentheses
Clippy emits:

	warning: unnecessary parentheses around assigned value

Add a attribute to allow unnecessary parentheses.
2020-12-22 12:53:29 +11:00
Elichai Turkel 7b99784837
Add AligneType and redo secp256k1_context_create with alloc 2020-12-18 12:48:16 +02:00
Andrew Poelstra 0ec8fab82c stop explicitly casting references to rawptrs 2020-11-30 02:47:34 +00:00
Andrew Poelstra 12b0abbcf8 make `ffi::Type::new` functions all unsafe, expand documentation 2020-11-27 18:42:12 +00:00
Tibo-lg 45a4459baf Update secp256k1-sys to add schnorr/extra-keys 2020-11-09 16:00:28 +09:00
Tibo-lg cfb565126a Update depend folder to latest master 2020-10-12 21:35:28 +09:00
Matt Corallo 3a2dba0e7f Use wasm sysroot for wasm32-wasi target as well 2020-10-05 16:14:36 -04:00
Elichai Turkel 6511fad231
Sort Cargo.toml files 2020-08-27 22:58:00 +03:00
Elichai Turkel 48dd77e47b
Remove old deprecated blank functions 2020-08-27 22:52:16 +03:00
Elichai Turkel 9e5a351ea7
remove redundant code after MSRV bump 2020-08-27 22:51:36 +03:00
Andrew Poelstra 19f5138925 Update MSRV to 1.29; increase version to 0.19 and -sys version to 0.3 2020-08-27 14:18:06 +00:00
Elichai Turkel 1605bde420 replace privkey functions with seckey functions, deprecate privkey functions 2020-08-26 20:55:18 +00:00
Andrew Poelstra f19c6bbece bump secp-sys version to 0.2.0 2020-08-26 18:07:44 +00:00
Andrew Poelstra 1a9aece312 secp256k1-sys: update upstream to 670cdd3f8be25f81472b2d16dcd228b0d24a5c45 2020-08-26 18:07:41 +00:00
Andrew Poelstra 89541ec4b2
Merge pull request #215 from rust-bitcoin/real-or-random-patch-1
Define ECMULT_GEN_PREC_BITS
2020-08-26 17:46:39 +00:00
Andrew Poelstra 3692c94a0f
Merge pull request #220 from rantan/add_negate_support
Add negate support
2020-08-26 17:43:46 +00:00
Kohei Taniguchi 1742973a1f Add fuzztarget for negation 2020-06-09 11:06:11 +09:00
Kohei Taniguchi d45f709cd4 Add negation support 2020-06-09 10:05:07 +09:00
Matt Corallo 0052bc92fb Expose the underlying array in addition to a ptr to the same 2020-06-01 14:35:31 -04:00
Andrew Poelstra e6a82fa089
Merge pull request #204 from ordian/master
secp256k1-sys: remove restriction on cc version
2020-05-13 18:56:23 +00:00
Tim Ruffing 489e3ff8d2
Define ECMULT_GEN_PREC_BITS
This is configurable in upstream now.

Fixes #214.

So far, this just sets it to `4`. It's tempting to set it to `2` when `lowmemory` is enabled
but `lowmemory` is about RAM and not about binary size. This is better addressed by
a resolution of #193.
2020-05-13 10:40:39 +02:00
Elichai Turkel affc6b4027 Add sanity checks for wasm32 for size and alignment of types 2020-04-29 15:32:57 -04:00
Elichai Turkel 931253d41e Add a size_t type to types 2020-04-29 15:32:57 -04:00
Matt Corallo d9d398ccc9 Re-support WASM via simple stub headers
libsecp256k1 really only barely uses libc at all, and in practice,
things like memcpy/memcmp get optimized into something other than a
libc call. Thus, if we provide simple stub headers, things seem to
work with wasm-pack just fine.
2020-04-29 15:32:54 -04:00
Andronik Ordian b22b9e5709
Merge remote-tracking branch 'rust-bitcoin/master'
* rust-bitcoin/master:
  Fix no-std raw test, after removal of lang items
  Fix broken benchmarks
  Disable emscripten tests until they work again https://github.com/rust-lang/rust/issues/66916 https://github.com/rustwasm/team/issues/291
  Add constant of the prime of the curve field.
  Simplify callback logic to returning raw coordinates
  Removed no longer used dont_replace_c_symbols feature
  Fix wrong feature name external-symbols
  Fix missing return c_int in NonceFn
2020-04-09 15:13:43 +02:00
Andrew Poelstra 9aa768df10
Merge pull request #195 from elichai/patch-1
Missing return c_int in NonceFn
2020-04-06 14:49:58 +00:00
Andronik Ordian ba013945d5
readme: add an example for travis 2020-03-17 22:33:29 +01:00
Andronik Ordian 37b9e2dfe9
move the note to the main readme 2020-03-16 11:46:53 +01:00
Andronik Ordian fd8b3ff572
secp256k1-sys: remove restriction on cc version 2020-03-14 20:46:26 +01:00
Elichai Turkel 2f897d8a93
Removed no longer used dont_replace_c_symbols feature 2020-02-09 16:37:59 +02:00
Elichai Turkel 889e9a8740
Fix wrong feature name external-symbols 2020-02-09 16:37:39 +02:00
Elichai Turkel f277530669
Fix missing return c_int in NonceFn 2020-01-26 14:20:26 +02:00
Elichai Turkel 6bcb510d9a
Bump secp256k1-sys to 0.1.2 2020-01-09 18:10:12 +02:00
Elichai Turkel 89271c9c3c
Fix fuzztarget symbols 2020-01-09 16:56:10 +02:00
Steven Roose ebc660bf94
Bump to v0.17.1 2019-12-11 18:57:21 +01:00
Steven Roose 987d556a67
Bump secp256k1-sys to v0.1.1 2019-12-11 15:55:00 +00:00
Steven Roose 65fe733ad0
Update Cargo.toml link in vendor script 2019-12-11 15:54:30 +00:00
Andrew Poelstra 72b9ec17fa remove some keywoards from secp-sys Cargo.toml 2019-12-10 19:48:29 +00:00
Elichai Turkel ca8ea92418
Fixed secp256k1_ecdh fuzztarget 2019-12-05 18:05:36 +02:00
Elichai Turkel 9759cb07f5
Replace SharedSecret with a more generic alternative 2019-12-05 17:45:24 +02:00
Steven Roose bf3fba71cb
Add external-symbols feature to support external libsecp
This feature disables using the bundles sources and will link into
existing libsecp256k1 symbols.
2019-11-27 21:04:32 +00:00
Steven Roose 55fab77029
Add vendor script to prefix secp256k1 sources 2019-11-27 21:03:48 +00:00
Steven Roose 80e1935ca0
Add secp256k1-sys README and LICENSE files 2019-11-27 21:02:44 +00:00
Steven Roose 724c49fff9
Add secp256k1-sys 2019-11-27 21:02:42 +00:00