129 Commits

Author SHA1 Message Date
Jonas Nick
aa3dd5280b
include: make doc about ctx more consistent
Replaces "ctx: a secp256k1 context object" with "ctx: pointer to a context
object". Also removes the word "existing".
2024-01-04 17:15:03 +00:00
Tim Ruffing
9e6d1b0e9b
Merge bitcoin-core/secp256k1#1367: build: Improvements to symbol visibility logic on Windows (attempt 3)
c6cd2b15a007ad0a2d5c4656ae641ba442d8b2fe ci: Add task for static library on Windows + CMake (Hennadii Stepanov)
020bf69a44ba700624d09de0c18ceb867369d24e build: Add extensive docs on visibility issues (Tim Ruffing)
0196e8ade16e2b2d8efadac01d8520205553ee39 build: Introduce `SECP256k1_DLL_EXPORT` macro (Hennadii Stepanov)
9f1b1904a358e4ce7248c6542e8c7ac143ba0e3f refactor: Replace `SECP256K1_API_VAR` with `SECP256K1_API` (Hennadii Stepanov)
ae9db95ceaa2605138fac9c237c640acea3f3bd6 build: Introduce `SECP256K1_STATIC` macro for Windows users (Hennadii Stepanov)

Pull request description:

  Previous attempts:
  - https://github.com/bitcoin-core/secp256k1/pull/1346
  - https://github.com/bitcoin-core/secp256k1/pull/1362

  The result is as follows:
  1. Simple, concise and extensively documented code.
  2. Explicitly documented use cases with no ambiguities.
  3. No workarounds for linker warnings.
  4. Solves one item in https://github.com/bitcoin-core/secp256k1/issues/1235.

ACKs for top commit:
  real-or-random:
    utACK c6cd2b15a007ad0a2d5c4656ae641ba442d8b2fe

Tree-SHA512: d58694452d630aefbd047916033249891bc726b7475433aaaa7c3ea2a07ded8f185a598385b67c2ee3440ec5904ff9d9452c97b0961d84dcb2eb2cf46caa171e
2023-07-03 18:53:38 +02:00
Jonas Nick
fb758fe8d6
Merge bitcoin-core/secp256k1#1323: tweak_add: fix API doc for tweak=0
05873bb6b1041227f413626717b7af69fb6176ef tweak_add: fix API doc for tweak=0 (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 05873bb6b1041227f413626717b7af69fb6176ef

Tree-SHA512: ef587a680c3355c6328dd61e0f5fcac80ea995f6045b4392fe35f3ee1c04ee1bd941662c120758ad641588670c1f0f53bfb17a802821f54100f1385b8bb7375a
2023-07-03 13:11:20 +00:00
Tim Ruffing
020bf69a44
build: Add extensive docs on visibility issues 2023-07-03 13:57:17 +01:00
Hennadii Stepanov
0196e8ade1
build: Introduce SECP256k1_DLL_EXPORT macro
This change provides a way to build a shared library that is not tired
to the Libtool-specific `DLL_EXPORT` macro.
2023-07-03 13:57:17 +01:00
Hennadii Stepanov
9f1b1904a3
refactor: Replace SECP256K1_API_VAR with SECP256K1_API 2023-07-03 13:57:16 +01:00
Hennadii Stepanov
ae9db95cea
build: Introduce SECP256K1_STATIC macro for Windows users
It is a non-Libtool-specific way to explicitly specify the user's
intention to consume a static `libseck256k1`.

This change allows to get rid of MSVC linker warnings LNK4217 and
LNK4286. Also, it makes possible to merge the `SECP256K1_API` and
`SECP256K1_API_VAR` into one.
2023-07-03 13:57:11 +01:00
Jonas Nick
05873bb6b1
tweak_add: fix API doc for tweak=0 2023-05-24 13:48:42 +00:00
Jonas Nick
3ad1027a40
Revert "Remove unused scratch space from API"
This reverts commit 712e7f8722eba5dec2bc6b37d75aadeb6f6e633b.
2023-05-12 15:05:57 +00:00
Jonas Nick
712e7f8722
Remove unused scratch space from API 2023-05-11 13:39:56 +00:00
Cory Fields
bc7c8db179 abi: Use dllexport for mingw builds
This should fix mingw exports, specifically hiding the following:
secp256k1_pre_g_128
secp256k1_pre_g
secp256k1_ecmult_gen_prec_table

This changes our visibility macros to look more like gcc's recommendation:
https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support
2023-05-08 15:25:26 +00:00
Tim Ruffing
a6f4bcf6e1
Merge bitcoin-core/secp256k1#1231: Move SECP256K1_INLINE macro definition out from include/secp256k1.h
8e142ca4102ade1b90dcb06d6c78405ef3220599 Move `SECP256K1_INLINE` macro definition out from `include/secp256k1.h` (Hennadii Stepanov)
77445898a5852ecd38ab95cfb329333a82673115 Remove `SECP256K1_INLINE` usage from examples (Hennadii Stepanov)

Pull request description:

  From [IRC](https://gnusha.org/secp256k1/2023-01-31.log):
  > 06:29 \< hebasto\> What are reasons to define the `SECP256K1_INLINE` macro in user's `include/secp256k1.h` header, while it is used internally only?
  > 06:32 \< hebasto\> I mean, any other (or a new dedicated) header in `src` looks more appropriate, no?
  > 06:35 \< sipa\> I think it may just predate any "utility" internal headers.
  > 06:42 \< sipa\> I think it makes sense to move it to util.h

  Pros:
  - it is a step in direction to better organized headers (in context of #924, #1039)

  Cons:
  - code duplication for `SECP256K1_GNUC_PREREQ` macro

ACKs for top commit:
  sipa:
    utACK 8e142ca4102ade1b90dcb06d6c78405ef3220599
  real-or-random:
    utACK 8e142ca410

Tree-SHA512: 180e0ba7c2ef242b765f20698b67d06c492b7b70866c21db27c18d8b2e85c3e11f86c6cb99ffa88bbd23891ce3ee8a24bc528f2c91167ec2fddc167463f78eac
2023-04-20 18:18:11 +02:00
Jonas Nick
3d1f430f9f
Make position of * in pointer declarations in include/ consistent 2023-03-28 19:39:02 +00:00
Hennadii Stepanov
8e142ca410
Move SECP256K1_INLINE macro definition out from include/secp256k1.h 2023-03-09 15:29:56 +00:00
Tim Ruffing
914276e4d2 build: Add SECP256K1_API_VAR to fix importing variables from DLLs
This fixes a build issue with MSVC. While MSVC imports *functions*
from DLLs automatically when building a consumer of the DLL, it does
not import *variables* automatically. In these cases, we need an
explicit __declspec(dllimport).

This commit simply changes our logic to what the libtool manual
suggests, which has a very comprehensive writeup on the topic. Note
that in particular, this solution is carefully designed not to break
static linking. However, as described in the libtool manual,
statically linking the library with MSVC will output warning LNK4217.
This is still the best solution overall, because the warning is
merely a cosmetic issue.
2023-02-06 21:44:56 +01:00
Tim Ruffing
61841fc9ee contexts: Forbid randomizing secp256k1_context_static 2023-01-18 16:47:31 +01:00
Tim Ruffing
4b6df5e33e contexts: Forbid cloning/destroying secp256k1_context_static 2023-01-18 16:39:31 +01:00
Tim Ruffing
a49e0940ad docs: Fix typo 2022-12-08 16:31:00 +01:00
Tim Ruffing
7289b51d31 docs: Use doxygen style if and only if comment is user-facing
and improve phrasing slightly.
2022-12-05 11:26:44 +01:00
Tim Ruffing
e7d0185c90 docs: Get rid of "initialized for signing" terminology 2022-12-05 11:26:44 +01:00
Tim Ruffing
06126364ad docs: Tidy and improve docs about contexts and randomization 2022-12-05 11:26:44 +01:00
Tim Ruffing
e02d6862bd selftest: Expose in public API 2022-12-05 11:26:44 +01:00
Tim Ruffing
53796d2b24 contexts: Rename static context 2022-12-05 11:26:44 +01:00
Tim Ruffing
72fedf8a6c docs: Improve docs for static context 2022-12-05 11:26:39 +01:00
Tim Ruffing
316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 2022-12-05 11:26:02 +01:00
Tim Ruffing
1a553ee8be docs: Change signature "validation" to "verification" 2022-11-25 23:26:15 +01:00
Tim Ruffing
ee7341fbac docs: Never require a verification context 2022-11-25 23:26:15 +01:00
Cory Fields
6f6cab9989 abi: Don't export symbols in static Windows libraries
libtool takes care of building both object versions, we just need to pick the
right one to export symbols.
2022-05-04 20:12:21 +00:00
Tim Ruffing
b8f8b99f0f docs: Fix return value for functions that don't have invalid inputs
_tagged_sha256 simply cannot have invalid inputs.

The other functions could in some sense have invalid inputs but only in
violation of the type system. For example, a pubkey could be invalid but
invalid objects of type secp256k1_pubkey either can't be obtained
via the API or will be caught by an ARG_CHECK when calling pubkey_load.

This is consistent with similar functions in the public API, e.g.,
_ec_pubkey_negate or _ec_pubkey_serialize.
2022-03-18 11:33:23 +01:00
Tim Ruffing
fc94a2da44 Use SECP256K1_DEPRECATED for existing deprecated API functions 2022-03-17 22:41:36 +01:00
Tim Ruffing
3db0560606 Add SECP256K1_DEPRECATED attribute for marking API parts as deprecated 2022-03-17 22:41:36 +01:00
fanquake
812ff5c747
doc: remove use of 0xa0 "no break space" 2021-11-24 08:11:49 +08:00
Elichai Turkel
adec5a1638 Add missing null check for ctx and input keys in the public API 2021-07-04 12:47:46 +03:00
Elichai Turkel
f4edfc7581 Improve consistency for NULL arguments in the public interface 2021-07-04 12:47:45 +03:00
Jonas Nick
5a8e4991ad Add secp256k1_tagged_sha256 as defined in BIP-340
Gives users the ability to hash messages to 32 byte before they are signed while
allowing efficient domain separation through the tag.
2021-06-27 20:26:15 +00:00
Jonas Nick
202a030f7d
Merge #850: add secp256k1_ec_pubkey_cmp method
6eceec6d566898a5c157630e47f95b260767026b add `secp256k1_xonly_pubkey_cmp` method (Andrew Poelstra)
0d9561ae879848191a14bcc67db87cbfd44fb69a add `secp256k1_ec_pubkey_cmp` method (Andrew Poelstra)

Pull request description:

ACKs for top commit:
  elichai:
    Code review ACK 6eceec6d566898a5c157630e47f95b260767026b
  jonasnick:
    ACK 6eceec6d566898a5c157630e47f95b260767026b
  real-or-random:
    ACK 6eceec6d566898a5c157630e47f95b260767026b

Tree-SHA512: f95cbf65f16c88a4adfa1ea7cc6ddabab14baa3b68fa069e78e6faad4852cdbfaea42ee72590d2e0b8f3159cf9b37969511550eb6b2d256b101e2147711cc817
2021-05-13 19:17:53 +00:00
Tim Ruffing
69394879b6
Merge #926: secp256k1.h: clarify that by default arguments must be != NULL
0881633dfd0c530a915cf63be295f00841c94cc4 secp256k1.h: clarify that by default arguments must be != NULL (Jonas Nick)

Pull request description:

  The same file says that the illegal callback will only triger for violations
  explicitly mentioned, which is not true without this commit because we often
  don't mention that an argument is not allowed to be NULL.

  This line is extracted from #783 in the hope that it gets merged faster because other PRs depend on it.

ACKs for top commit:
  gmaxwell:
    ACK 0881633dfd0c530a915cf63be295f00841c94cc4
  real-or-random:
    ACK 0881633dfd0c530a915cf63be295f00841c94cc4

Tree-SHA512: ecdc6954a1c21c333da5b03db51f50a0e53984aaef69cc697adaddc96b276da23e342037f476d21742632f6ec02bfa0574f837a5b5791f5985f4c355037176fa
2021-05-07 23:21:19 +02:00
Andrew Poelstra
0d9561ae87 add secp256k1_ec_pubkey_cmp method 2021-05-06 18:36:41 +00:00
Gregory Maxwell
ae9e648526 Define SECP256K1_BUILD in secp256k1.c directly.
This avoids building without it and makes it safer to use a custom
 building environment.  Test harnesses need to #include secp256k1.c
 first now.
2021-05-01 19:27:27 +00:00
Jonas Nick
0881633dfd secp256k1.h: clarify that by default arguments must be != NULL
The same file says that the illegal callback will only triger for violations
explicitly mentioned, which is not true without this commit because we often
don't mention that an argument is not allowed to be NULL.
2021-04-29 10:21:26 +00:00
Ferdinando M. Ametrano
b7bc3a4aaa
fixed typo 2020-12-22 22:31:29 +01:00
Jonas Nick
6e85d675aa Rename tweak to tweak32 in public API 2020-12-04 14:16:43 +00:00
Jonas Nick
f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 2020-12-04 14:12:38 +00:00
Gregory Maxwell
1309c03c45 Fix some compile problems on weird/old compilers.
The visibility attribute is a GCC 4+ feature.
GCC 2.95 also warns about the unsigned/signed comparision.
2020-07-26 05:26:56 +00:00
Jonas Nick
7e3952ae82 Clarify documentation of tweak functions.
In particular, mention that the functions return 0 if seckey or tweak are
invalid (as opposed to saying "should" or "must" be valid).
2020-03-30 20:51:47 +00:00
Jonas Nick
89853a0f2e Make tweak function documentation more consistent.
Do this by adding a newline after the first sentence and aligning the rest.
2020-03-30 20:51:47 +00:00
Jonas Nick
41fc785602 Make ec_privkey functions aliases for ec_seckey_negate, ec_seckey_tweak_add and ec_seckey_mul 2020-03-30 20:51:47 +00:00
Jonas Nick
22911ee6da Rename private key to secret key in public API (with the exception of function names) 2020-03-30 20:51:47 +00:00
Jonas Nick
5a73f14d6c Mention that value is unspecified for In/Out parameters if the function returns 0 2020-03-30 20:51:47 +00:00
Jonas Nick
f03df0e6d7 Define valid ECDSA keys in the documentation of seckey_verify 2020-03-30 20:51:47 +00:00