2748 Commits

Author SHA1 Message Date
Tim Ruffing
77af1da9f6
Merge bitcoin-core/secp256k1#1455: doc: improve secp256k1_fe_set_b32_mod doc
3928b7c38367947756b7d506f431bfb7bbbac5d0 doc: improve secp256k1_fe_set_b32_mod doc (Coding Enthusiast)

Pull request description:

  As discussed in #1453
  This only changes the `secp256k1_fe_impl_set_b32_mod` comment since I think `secp256k1_fe_set_b32_limit` doc is clear enough.

ACKs for top commit:
  sipa:
    ACK 3928b7c38367947756b7d506f431bfb7bbbac5d0
  theStack:
    ACK 3928b7c38367947756b7d506f431bfb7bbbac5d0

Tree-SHA512: ad62c1b72d6a487473b182e6aadc7765711385add8c6576bf15c2015db82721f19e3d635f7a29316c2ee7e3c73bc55e2cd4f46ec13180be93d6fe8641f47e7d2
2023-12-11 09:20:12 +01:00
Coding Enthusiast
3928b7c383 doc: improve secp256k1_fe_set_b32_mod doc 2023-12-08 14:58:38 +03:30
Tim Ruffing
5e9a4d7aec
Merge bitcoin-core/secp256k1#990: Add comment on length checks when parsing ECDSA sigs
e02f313b1f251ccb363ae1ac24016d87c1be9009 Add comment on length checks when parsing ECDSA sigs (Tim Ruffing)

Pull request description:

  I claim the check can be removed but I don't want to touch this
  stable and well-tested code.

  On the way, we fix grammar in another comment.

ACKs for top commit:
  sipa:
    ACK e02f313b1f251ccb363ae1ac24016d87c1be9009
  RandyMcMillan:
    ACK e02f313

Tree-SHA512: f82691a8f5db82a1e9683e52ce8e952ebd56b476a2817c5a876ce4638254b7b4ac93175318fb59598ed5532f33433951d75afea03724ef4419c3e1bd12ca8c20
2023-12-07 09:26:38 +01:00
Tim Ruffing
4197d667ec
Merge bitcoin-core/secp256k1#1431: Add CONTRIBUTING.md
0e5ea6220707d9c96e06efc43bce3d5a3b3a06f2 CONTRIBUTING: add some coding and style conventions (Jonas Nick)
1a432cb98220f29ac47639d30a6dbb3aa679a441 README: update first sentence (Jonas Nick)
0922a047fb2a225fd89802bbd6f2d0919cd50bca docs: move coverage report instructions to CONTRIBUTING (Jonas Nick)
76880e40151ddb18d0cd0549502d5ade95f501d6 Add CONTRIBUTING.md including scope and guidelines for new code (Jonas Nick)

Pull request description:

  Following offline discussions, this PR documents the scope of the library and the requirements for adding new modules. I think this fixes most of #997. It also updates the README very slightly.

  In addition, I added some coding conventions that I remembered explaining to new contributors in the past year. Even though it's far from exhaustive, I think this is an easy improvement to the CONTRIBUTING.md. Feel free to suggest more conventions.

ACKs for top commit:
  sipa:
    ACK 0e5ea6220707d9c96e06efc43bce3d5a3b3a06f2
  real-or-random:
    ACK 0e5ea6220707d9c96e06efc43bce3d5a3b3a06f2

Tree-SHA512: ffdbab22982fd632de92e81bd135f141ac86e24cc0dcfc0e1ae12b0d2a2e4f91377ab2c0cc440cb919889eaed8bfc1447b880fa1430fd771b956f2af0fe3766e
2023-12-07 09:16:50 +01:00
Jonas Nick
0e5ea62207
CONTRIBUTING: add some coding and style conventions 2023-12-06 17:20:09 +00:00
Tim Ruffing
e2c9888eee
Merge bitcoin-core/secp256k1#1451: changelog: add entry for "field: Remove x86_64 asm"
d2e36a2b81c0ba9d28425ea14c1ff6523156ee52 changelog: add entry for "field: Remove x86_64 asm" (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK d2e36a2b81c0ba9d28425ea14c1ff6523156ee52

Tree-SHA512: c4bffb921c58185b0a43546977449f3c53c21230d6d32cf5d5ccf563b196ec3d0370a0b87de5b334e5190ff91da598dd0bbebbb5c9d7bef9ec8c0679c3b6c702
2023-12-06 18:16:41 +01:00
Jonas Nick
d2e36a2b81
changelog: add entry for "field: Remove x86_64 asm" 2023-12-05 20:51:24 +00:00
Jonas Nick
1a432cb982
README: update first sentence
libsecp256k1 has become more than a library for just ECDSA and key tweaking.
2023-12-05 20:48:12 +00:00
Jonas Nick
0922a047fb
docs: move coverage report instructions to CONTRIBUTING 2023-12-04 20:08:33 +00:00
Jonas Nick
76880e4015
Add CONTRIBUTING.md including scope and guidelines for new code 2023-12-04 20:08:25 +00:00
Tim Ruffing
d3e29db8bb
Merge bitcoin-core/secp256k1#1450: Add group.h ge/gej equality functions
04af0ba162b152073455a5ccbb2c5833ae6d1d57 Replace ge_equals_ge[,j] calls with group.h equality calls (Pieter Wuille)
60525f6c14ad37719c6ea2deee19ec7b3654f061 Add unit tests for group.h equality functions (Pieter Wuille)
a47cd97d51e37c38ecf036d04e48518f6b0063f7 Add group.h ge/gej equality functions (Pieter Wuille)

Pull request description:

  This pull requests removes the test-only functions `ge_equals_ge` and `ge_equals_gej`, and replaces them with proper group.h functions `secp256k1_ge_eq_var` and `secp256k1_gej_eq_ge_var` (mimicking the existing `secp256k1_gej_eq_var` function).

  This drops some of the arbitrary and undocumented magnitude restristrictions these functions have, makes them properly tested on their own, and makes their semantics cleaner (I'm always left checking whether `ge_equals_ge` does a `CHECK` internally or whether it returns a value...).

ACKs for top commit:
  real-or-random:
    utACK 04af0ba162b152073455a5ccbb2c5833ae6d1d57
  stratospher:
    ACK 04af0ba.

Tree-SHA512: 49bc409ffa980144d1305c9389a846af45f0a97bfec19d016929056aa918c6a9f020dbe8549f5318fa8e6a4108621cc3cce60331aa0634f84619a1104d20a62a
2023-12-02 10:18:05 +01:00
Pieter Wuille
04af0ba162 Replace ge_equals_ge[,j] calls with group.h equality calls 2023-12-01 16:10:20 -05:00
Pieter Wuille
60525f6c14 Add unit tests for group.h equality functions 2023-12-01 16:10:15 -05:00
Pieter Wuille
a47cd97d51 Add group.h ge/gej equality functions 2023-12-01 16:06:29 -05:00
Jonas Nick
10e6d29b60
Merge bitcoin-core/secp256k1#1446: field: Remove x86_64 asm
f07cead0ca96e26356466b635ce6e7fe3834c949 build: Don't call assembly an optimization (Tim Ruffing)
2f0762fa8fd30b457bc5dcf53403123212091df5 field: Remove x86_64 asm (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    utACK f07cead0ca96e26356466b635ce6e7fe3834c949
  theStack:
    ACK f07cead0ca96e26356466b635ce6e7fe3834c949
  jonasnick:
    ACK f07cead0ca96e26356466b635ce6e7fe3834c949

Tree-SHA512: df7f895ab8ab924c5f8f01c35d0cd2f65d5c947c5ab5325787d169c5b202834ab8aa5d85dedb25839fff3f518097fe8cf8e837d3c1918e5f039ddd6ddf4187da
2023-12-01 18:49:48 +00:00
Tim Ruffing
07687e811d
Merge bitcoin-core/secp256k1#1393: Implement new policy for VERIFY_CHECK and #ifdef VERIFY (issue #1381)
bb4672342efce7fae1cfd30e007c6835a25286a7 remove VERIFY_SETUP define (Sebastian Falbesoner)
a3a3e11acdb473f96a8972ed40cd3310057aec23 remove unneeded VERIFY_SETUP uses in ECMULT_CONST_TABLE_GET_GE macro (Sebastian Falbesoner)
a0fb68a2e7db14c6b27f92217bf2307681b6b6ea introduce and use SECP256K1_SCALAR_VERIFY macro (Sebastian Falbesoner)
cf25c86d05bbaacd37f42a190e39eab4863cdaf7 introduce and use SECP256K1_{FE,GE,GEJ}_VERIFY macros (Sebastian Falbesoner)
5d89bc031b25dc0aaba8c7d2eeba88ae92facb09 remove superfluous `#ifdef VERIFY`/`#endif` preprocessor conditions (Sebastian Falbesoner)
c2688f8de9fb9a44dc953d2f8a0e9226d8e19349 redefine VERIFY_CHECK to empty in production (non-VERIFY) mode (Sebastian Falbesoner)

Pull request description:

  As suggested in #1381, this PR reworks the policy for VERIFY_CHECK and when to use #ifdef VERIFY, by:
  - redefining VERIFY_CHECK to empty in production (non-VERIFY) mode
  - removing many then superflous #ifdef VERIFY blocks (if they exclusively contained VERIFY_CHECKs)
  - introducing uppercase macros around verify_ functions and using them for better readabiliy

  What is _not_ included yet is the proposed renaming from "_check" to "_assert":
  > And while we're touching this anyway, we could consider renaming "check" to "assert", which is a more precise term. (In fact, if we redefine VERIFY_CHECK to be empty in production, we have almost reimplemented assert.h...)

  This should be easy to achieve with simple search-and-replace (e.g. using sed), but I was hesitant as this would probably case annoying merge conflicts on some of the open PRs. Happy to add this if the rename if desired (#1381 didn't get any feedback about the renaming idea yet).

ACKs for top commit:
  stratospher:
    ACK bb46723.
  real-or-random:
    utACK bb4672342efce7fae1cfd30e007c6835a25286a7

Tree-SHA512: 226ca609926dea638aa3bb537d29d4fac8b8302dcd9da35acf767ba9573e5221d2dae04ea26c15d80a50ed70af1ab0dca10642c21df7dbdda432fa237a5ef2cc
2023-12-01 12:59:41 +01:00
Sebastian Falbesoner
bb4672342e remove VERIFY_SETUP define
This define was seemingly introduced for VERIFY mode code with side
effects (for setup purposes), that should just be executed without any
checks. The same can be achieved by putting it in an `#if VERIFY` block,
so we can remove it.
2023-12-01 01:36:32 +01:00
Sebastian Falbesoner
a3a3e11acd remove unneeded VERIFY_SETUP uses in ECMULT_CONST_TABLE_GET_GE macro
As the fields r->x and r->y are set immediately after (three lines
below), there is no need to clear them.
2023-12-01 01:36:32 +01:00
Sebastian Falbesoner
a0fb68a2e7 introduce and use SECP256K1_SCALAR_VERIFY macro
By providing an uppercase variant of these verification functions,
it is better visible that it is test code.
2023-12-01 01:36:29 +01:00
Sebastian Falbesoner
cf25c86d05 introduce and use SECP256K1_{FE,GE,GEJ}_VERIFY macros
By providing an uppercase variant of these verification functions, it is
better visible that it is test code and surrounding `#ifdef VERIFY`
blocks can be removed (if there is no other code around that could
remain in production mode), as they don't serve their purpose any more.

At some places intentional blank lines are inserted for grouping and
better readadbility.
2023-12-01 00:54:58 +01:00
Sebastian Falbesoner
5d89bc031b remove superfluous #ifdef VERIFY/#endif preprocessor conditions
Now that the `VERIFY_CHECK` compiles to empty in non-VERIFY mode, blocks
that only consist of these macros don't need surrounding `#ifdef VERIFY`
conditions anymore.

At some places intentional blank lines are inserted for grouping and
better readadbility.
2023-12-01 00:54:41 +01:00
Sebastian Falbesoner
c2688f8de9 redefine VERIFY_CHECK to empty in production (non-VERIFY) mode
As suggested in issue #1381, this will make things simpler and
improve code readability, as we don't need to force omitting of
evaluations on a case-by-case basis anymore and hence can remove
lots of `#ifdef VERIFY`/`#endif` lines (see next commit). Plus,
VERIFY_CHECK behaves now identical in both non-VERIFY and coverage mode,
making the latter not special anymore and hopefully decreasing
maintenance burden. The idea of "side-effect safety" is given up.

Note that at two places in the ellswift module void-casts of return
values have to be inserted for non-VERIFY builds, in order to avoid
   "variable ... set but not used [-Wunused-but-set-variable]"
warnings.
2023-12-01 00:22:40 +01:00
Tim Ruffing
5814d8485c
Merge bitcoin-core/secp256k1#1438: correct assertion for secp256k1_fe_mul_inner
dcdda31f2cda13839a4285d8601118c041b18c13 Tighten secp256k1_fe_mul_inner's VERIFY_BITS checks (Russell O'Connor)
8e2a5fe908faa2ad0b847b3e5c42662614c8fa88 correct assertion for secp256k1_fe_mul_inner (roconnor-blockstream)

Pull request description:

  Based on the surrounding asserts, 112 bits before this line, and 61 bits after this line, this assertion should be 113 bits.  Notably the commensurate line in secp256k1_fe_sqr_inner is correctly assert to be 113 bits.

ACKs for top commit:
  real-or-random:
    ACK dcdda31f2cda13839a4285d8601118c041b18c13 tested with asm disabled

Tree-SHA512: c35170e37d9a6d1413dd625032028129ab2eccee7da86697ab9641b68ad78efd7251953d51e7acaefd14888d3fd61877f9f05349c44f6fc0133ce9b3921b0e1a
2023-11-27 09:45:09 +01:00
Tim Ruffing
c1b4966410
Merge bitcoin-core/secp256k1#1445: bench: add --help option to bench_internal
1ddd76af0a735b7fcbec7f37c0d99a7db9893ac1 bench: add --help option to bench_internal (Sebastian Falbesoner)

Pull request description:

  While coming up with commands for running the benchmarks for issue https://github.com/bitcoin-core/secp256k1/issues/726#issuecomment-1824625653, I noticed that in contrast to `bench{_ecmult}`, `bench_internal` doesn't have a help option yet and figured it would be nice to have one. A comparable past PR is https://github.com/bitcoin-core/secp256k1/pull/1008. Benchmark categories appear in the same order as they are executed, the concrete benchmark names in parantheses per category are listed in alphabetical order.

ACKs for top commit:
  real-or-random:
    utACK 1ddd76af0a735b7fcbec7f37c0d99a7db9893ac1
  siv2r:
    ACK 1ddd76a, tested the `--help` option locally, and it works as expected.

Tree-SHA512: d117641a5f25a7cbf83881f3acceae99624528a0cbb2405efdbe1a3a2762b4d6b251392e954aaa32f6771069d31143743770fccafe198084c12258dedb0856fc
2023-11-24 14:50:05 +01:00
Tim Ruffing
f07cead0ca build: Don't call assembly an optimization
because we don't know whether it's an optimization.
2023-11-24 08:11:33 +01:00
Tim Ruffing
2f0762fa8f field: Remove x86_64 asm
Widely available versions of GCC and Clang beat our field asm on -O2.
In particular, GCC 10.5.0, which is Bitcoin Core's current compiler
for official x86_64 builds, produces code that is > 20% faster for
fe_mul and > 10% faster for signature verification (see #726).

These are the alternatives to this PR:

We could replace our current asm with the fastest compiler output
that we can find. This is potentially faster, but it has multiple
drawbacks:
 - It's more coding work because it needs detailed benchmarks (e.g.,
   with many compiler/options).
 - It's more review work because we need to deal with inline asm
   (including clobbers etc.) and there's a lack of experts reviewers
   in this area.
 - It's not unlikely that we'll fall behind again in a few compiler
   versions, and then we have to deal with this again, i.e., redo the
   benchmarks. Given our history here, I doubt that we'll revolve
   this timely.

We could change the default of the asm build option to off. But this
will also disable the scalar asm, which is still faster.

We could split the build option into two separate options for field
and scalar asm and only disable the field asm by default. But this
adds complexity to the build and to the test matrix.

My conclusion is that this PR gets the low-hanging fruit in terms of
performance. It simplifies our code significantly. It's clearly an
improvement, and it's very easy to review. Whether re-introducing
better asm (whether from a compiler or from CryptOpt) is worth the
hassle can be evaluated separately, and should not hold up this
improvement.

Solves #726.
2023-11-24 08:11:08 +01:00
Sebastian Falbesoner
1ddd76af0a bench: add --help option to bench_internal 2023-11-24 02:33:40 +01:00
Tim Ruffing
eb4fb6db05
Merge ElementsProject/secp256k1-zkp#276: Typo in shallue_van_de_woestijne description
c33d2241cb6ac8d0e04d4f4de912ee560fd14305 Typo in shallue_van_de_woestijne description (roconnor-blockstream)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK c33d2241cb6ac8d0e04d4f4de912ee560fd14305

Tree-SHA512: b008b3d64856e4ccf472e97749695bec42e0bf137d7cfe2d8eeed0ba1a27f8fbdafbe20cda550c4931f80a1585c4893ae155e624f3d2ce9e3caf5e955c3dbbf4
2023-11-17 23:39:31 +01:00
roconnor-blockstream
c33d2241cb Typo in shallue_van_de_woestijne description 2023-11-17 14:58:35 -05:00
Tim Ruffing
e72103932d
Merge bitcoin-core/secp256k1#1441: asm: add .note.GNU-stack section for non-exec stack
33dc7e4d3e1947af4c84c09ecc75ea2eeed3f7e0 asm: add .note.GNU-stack section for non-exec stack (fanquake)

Pull request description:

  With this in place, we no-longer see warnings like the following:
  ```bash
  /usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/bin/ld: warning: field_10x26_arm.o: missing .note.GNU-stack section implies executable stack
  /usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
  ```

  Should close #1434.

ACKs for top commit:
  sipa:
    utACK 33dc7e4d3e1947af4c84c09ecc75ea2eeed3f7e0
  real-or-random:
    utACK 33dc7e4d3e1947af4c84c09ecc75ea2eeed3f7e0

Tree-SHA512: f75ded8d971f54d1e871bcc4d815ba367b3e154eea2f18309ecaf9053e22f986bfffcf28418367f8055b65a5a0b245fee045adfcb63a2196df5e2f3aa6c97b89
2023-11-16 09:46:16 +01:00
Tim Ruffing
ea47c82e01
Merge bitcoin-core/secp256k1#1442: Return temporaries to being unsigned in secp256k1_fe_sqr_inner
10271356c8fc34395850ac70df5902571945fbea Return temporaries to being unsigned in secp256k1_fe_sqr_inner (roconnor-blockstream)

Pull request description:

  These temporaries seem to been inadvertently changed to signed during a refactoring.  Generally, bit shifting is frowned upon for signed values.

ACKs for top commit:
  sipa:
    utACK 10271356c8fc34395850ac70df5902571945fbea
  real-or-random:
    utACK 10271356c8fc34395850ac70df5902571945fbea

Tree-SHA512: a9fefe4b146163209662cd435422beb3c9561eb9e83110454184f70df2292992f39ec1971143428e039a80cad2f6285db74de2f059e877ad8756ff739269b67a
2023-11-16 09:45:49 +01:00
Russell O'Connor
dcdda31f2c Tighten secp256k1_fe_mul_inner's VERIFY_BITS checks
These changes bring the checks to the same values used at the corresponding positions in secp256k1_fe_sqr_inner.
2023-11-14 12:07:00 -05:00
roconnor-blockstream
10271356c8
Return temporaries to being unsigned in secp256k1_fe_sqr_inner
These temporaries seem to been inadvertently changed to signed during a refactoring.  Generally, bit shifting is frowned upon for signed values.
2023-11-14 09:29:21 -05:00
fanquake
33dc7e4d3e
asm: add .note.GNU-stack section for non-exec stack
With this in place, we no-longer see warnings like the following:
```bash
/usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/bin/ld: warning: field_10x26_arm.o: missing .note.GNU-stack section implies executable stack
/usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
```

Should close #1434.
2023-11-13 14:49:35 +00:00
Tim Ruffing
c891c5c2f4
Merge bitcoin-core/secp256k1#1437: ci: Ignore internal errors of snapshot compilers
8185e72d299bc77de9c06cc92fd1988676df3bc1 ci: Ignore internal errors in snapshot compilers (Hennadii Stepanov)

Pull request description:

  It was discussed on today's IRC meeting.

ACKs for top commit:
  real-or-random:
    ACK 8185e72d299bc77de9c06cc92fd1988676df3bc1

Tree-SHA512: 0f41ca8303bd3d6efefcd3a544c7bd7dfcf464c57c779c876da4a77cacd262e6c963449d493fdf5a641b0d10b655c8c67fe8a147145b6533328d7bf5344313e1
2023-11-08 20:50:55 +01:00
Hennadii Stepanov
8185e72d29
ci: Ignore internal errors in snapshot compilers 2023-11-08 17:51:52 +00:00
Tim Ruffing
40f50d0fbd
Merge bitcoin-core/secp256k1#1184: Signed-digit based ecmult_const algorithm
355bbdf38a2f932daadd02325a0d90d902cb2af4 Add changelog entry for signed-digit ecmult_const algorithm (Pieter Wuille)
21f49d9bec518a769029f809817444a984e735ab Remove unused secp256k1_scalar_shr_int (Pieter Wuille)
115fdc7232a80872c99f88589a5a3608ba757f1d Remove unused secp256k1_wnaf_const (Pieter Wuille)
aa9f3a3c004469033709dc8138892e66adf0b030 ecmult_const: add/improve tests (Jonas Nick)
4d16e90111c050de3b7e25ac451d87cd4e3f874e Signed-digit based ecmult_const algorithm (Pieter Wuille)
ba523be067d6e45957d154838cb9da942704f01a make SECP256K1_SCALAR_CONST reduce modulo exhaustive group order (Pieter Wuille)
2140da9cd5d490d8462d5c7cc909755edc10c1e6 Add secp256k1_scalar_half for halving scalars (+ tests/benchmarks). (Pieter Wuille)

Pull request description:

  Using some insights learned from #1058, this replaces the fixed-wnaf ecmult_const algorithm with a signed-digit based one. Conceptually both algorithms are very similar, in that they boil down to summing precomputed odd multiples of the input points. Practically however, the new algorithm is simpler because it's just using scalar operations, rather than relying on wnaf machinery with skew terms to guarantee odd multipliers.

  The idea is that we can compute $q \cdot A$ as follows:
  * Let $s = f(q)$, for some function $f()$.
  * Compute $(s_1, s_2)$ such that $s = s_1 + \lambda s_2$, using `secp256k1_scalar_lambda_split`.
  * Let $v_1 = s_1 + 2^{128}$ and $v_2 = s_2 + 2^{128}$ (such that the $v_i$ are positive and $n$ bits long).
  * Computing the result as $$\sum_{i=0}^{n-1} (2v_1[i]-1) 2^i A + \sum_{i=0}^{n-1} (2v_2[i]-1) 2^i \lambda A$$ where $x[i]$ stands for the *i*'th bit of $x$, so summing positive and negative powers of two times $A$, based on the bits of $v_1.$

  The comments in `ecmult_const_impl.h` show that if $f(q) = (q + (1+\lambda)(2^n - 2^{129} - 1))/2 \mod n$, the result will equal $q \cdot A$.

  This last step can be performed in groups of multiple bits at once, by looking up entries in a precomputed table of odd multiples of $A$ and $\lambda A$, and then multiplying by a power of two before proceeding to the next group.

  The result is slightly faster (I measure ~2% speedup), but significantly simpler as it only uses scalar arithmetic to determine the table lookup values. The speedup is due to the fact that no skew corrections at the end are needed, and less overhead to determine table indices. The precomputed table sizes are also made independent from the `ecmult` ones, after observing that the optimal table size is bigger here (which also gives a small speedup).

ACKs for top commit:
  jonasnick:
    ACK 355bbdf38a2f932daadd02325a0d90d902cb2af4
  siv2r:
    ACK 355bbdf
  real-or-random:
    ACK 355bbdf38a2f932daadd02325a0d90d902cb2af4

Tree-SHA512: 13db572cb7f9be00bf0931c65fcd8bc8b5545be86a8c8700bd6a79ad9e4d9e5e79e7f763f92ca6a91d9717a355f8162204b0ea821b6ae99d58cb400497ddc656
2023-11-07 23:18:59 +01:00
roconnor-blockstream
8e2a5fe908
correct assertion for secp256k1_fe_mul_inner
Based on the surrounding asserts, 112 bits before this line, and 61 bits after this line, this assertion should be 113 bits.  Notably the commensurate line in secp256k1_fe_sqr_inner is correctly assert to be 113 bits.
2023-11-06 17:40:17 -05:00
Pieter Wuille
355bbdf38a Add changelog entry for signed-digit ecmult_const algorithm 2023-11-04 15:55:12 -04:00
Pieter Wuille
21f49d9bec Remove unused secp256k1_scalar_shr_int 2023-11-04 15:55:12 -04:00
Pieter Wuille
115fdc7232 Remove unused secp256k1_wnaf_const 2023-11-04 15:55:12 -04:00
Jonas Nick
aa9f3a3c00 ecmult_const: add/improve tests
* add test case for a=infinity

  The corresponding ecmult_const branch was not tested before this commit.

* add test for edge cases
2023-11-04 15:55:12 -04:00
Pieter Wuille
4d16e90111 Signed-digit based ecmult_const algorithm 2023-11-04 15:55:12 -04:00
Pieter Wuille
ba523be067 make SECP256K1_SCALAR_CONST reduce modulo exhaustive group order 2023-11-04 15:54:08 -04:00
Pieter Wuille
2140da9cd5 Add secp256k1_scalar_half for halving scalars (+ tests/benchmarks).
Co-authored-by: Jonas Nick <jonasd.nick@gmail.com>
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2023-11-04 15:54:08 -04:00
Jonas Nick
2192e9d051
Merge elementsproject/secp256k1-zkp#272: surjectionproof: remove unused include
fcc0299fa50c19438d13a34c9281c9ca437633f3 surjectionproof: remove unused include (Jon Griffiths)

Pull request description:

ACKs for top commit:
  delta1:
    ACK fcc0299fa50c19438d13a34c9281c9ca437633f3
  jonasnick:
    ACK fcc0299fa50c19438d13a34c9281c9ca437633f3

Tree-SHA512: dbd5dd982796b99871f2fbd3ab8404c6817bd4970d8775a83bd3a3fd916a683ff9da70c334a377870063eaa5c8cfb73481edfdd0bd7279fc7dc7f8b5368bb5aa
2023-10-31 07:38:41 +00:00
Jon Griffiths
fcc0299fa5
surjectionproof: remove unused include
Following the merge of b627ba7050b608e869515a8ef622d71bf8c13b54 from
upstream, this include should have been deleted as well.
2023-10-31 16:53:26 +13:00
Tim Ruffing
1f1bb78b7f
Merge bitcoin-core/secp256k1#1430: README: remove CI badge
5dab0baa80d763b1de599e64307c090d1a3fb04d README: remove CI badge (Jonas Nick)

Pull request description:

ACKs for top commit:
  sipa:
    utACK 5dab0baa80d763b1de599e64307c090d1a3fb04d
  real-or-random:
    utACK 5dab0baa80d763b1de599e64307c090d1a3fb04d

Tree-SHA512: 56730fa8067cc48b8e5af6fc21b0cd6c47f615c5ebba9edcf29ca5eaf7b2359662a9af219612e80688d8f8939649c7c3c26136c0442ba47d56251a0d92cf984a
2023-10-23 17:49:43 +02:00
Jonas Nick
5dab0baa80
README: remove CI badge
We're not solely using cirrus anymore and github already displays the CI status
at a different location.
2023-10-22 11:50:09 +00:00
Tim Ruffing
d575ef9aca
Merge ElementsProject/secp256k1-zkp#270: Upstream PRs 1391, 1290, 1389, 1397, 1399, 1400, 1348, 1402, 1274, 1394, 1404, 1062, 1401, 1373, 1403, 1398, 1405, 1396, 1406, 1410, 1409, 1411, 1412, 1414, 1413, 1415, 1417, 1390, 1416, 1422, 1424, 1395
b41caaafd2f7308f99245bc833158cdc5836c52d bppp: replace memcmp in tests with secp256k1_memcmp_var (Jonas Nick)
6a3aae8f1de9d693cfcaa583a558148e1aa3b0a3 group_parse: use secp256k1_memcmp_var instead of memcmp (Jonas Nick)
e9d522fc6443a81a613fbb89c72f790d181e8d77 ci: turn on -zkp modules in macos-native job (Jonas Nick)
c45b7c4fbbf41b011f138c465a58322a36664fd3 refactor: introduce testutil.h (deduplicate `random_fe_`, `ge_equals_` helpers) (Sebastian Falbesoner)
dc5514144fb9d412aa3845432b053ee06a27da37 tests: simplify `random_fe_non_zero` (remove loop limit and unneeded normalize) (Sebastian Falbesoner)
d9d80fd155cd1eb26c1334ceb0d4cecdef640085 ci: Bump major versions for docker actions (Hennadii Stepanov)
421d84855aeb9324b4f131c3e6c7ee8cf4f5f4e5 ci: Align Autotools/CMake `CI_INSTALL` directory names (Hennadii Stepanov)
9f005c60d6067d94279a3e3e81ec178bf4e2f227 cmake: Install `libsecp256k1.pc` file (Hennadii Stepanov)
b0f7bfedc9fcb4f49fe965b16ae49d0e36c1d32b doc: Do not mention soname in CHANGELOG.md "ABI Compatibility" section (Hennadii Stepanov)
bd9d98d353e169eadb9b2fdba074417407442230 doc: Align documented scripts with CI ones (Hennadii Stepanov)
70303643cf42d18acbf1c020480c6bb23072dbd9 tests: add CHECK_ERROR_VOID and use it in scratch tests (Jonas Nick)
f8d7ea68dfb1a3cad1fbec2242e9affdf803fbbe tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID (Jonas Nick)
a1d52e3e125bb46dac2cf6daa699e9f15167e8d4 tests: remove unnecessary test in run_ec_pubkey_parse_test (Jonas Nick)
875b0ada2526be92100034c4c7de045203de7e3f tests: remove unnecessary set_illegal_callback (Jonas Nick)
9b118bc7fb12203e9bf98eb23bfdd5746adde2b3 release cleanup: bump version after 0.4.0 (Jonas Nick)
16339804c906a99a0b9bbe192d3de9fde021ff19 release: Prepare for 0.4.0 (Tim Ruffing)
d9a85065a91d07660559b4be3388139dccb39e1d changelog: Catch up in preparation of release (Tim Ruffing)
8659a01714c1b4fcd349ee1a7d733f6934c5d184 ci: Add `release` job (Hennadii Stepanov)
f9b38894baee6b726217e28a4d4591ffdf233e47 ci: Update `actions/checkout` version (Hennadii Stepanov)
2635068abf93ebcf7f200eef14acafc3300e32f7 ci/gha: Let MSan continue checking after errors in all jobs (Tim Ruffing)
e78c7b68eb7e91cf9b88408c053867f148d62ffa ci/Dockerfile: Reduce size of Docker image further (Tim Ruffing)
2f0d3bbffb288621f4232c90424f77d44cc69166 ci/Dockerfile: Warn if `ulimit -n` is too high when running Docker (Tim Ruffing)
4b8a647ad3a59c2421d1d4c6e653f21d453e2612 ci/gha: Add ARM64 QEMU jobs for clang and clang-snapshot (Tim Ruffing)
6ebe7d2bb39978e70d85a718919d4af31cc00bc2 ci/Dockerfile: Always use versioned clang packages (Tim Ruffing)
c223d7e33d50b1da0b3ba617c83534185428b3d5 ci: Switch macOS from Ventura to Monterey and add Valgrind (Hennadii Stepanov)
cce045630407e662c90279abb2b0e71161f24e74 ci: Make repetitive command the default one (Hennadii Stepanov)
317a4c48f058755019475de79896230dadc6474c ci: Move `git config ...` to `run-in-docker-action` (Hennadii Stepanov)
676ed8f9cf001ebaadf53d5c11e32f7a6b1e5649 ci: Move "C++ (public headers)" from Cirrus to GitHub Actions (Hennadii Stepanov)
61fc3a2dc883a5ffda43658337ec94d3306eb77f ci: Move "C++ -fpermissive..." from Cirrus to GitHub Actions (Hennadii Stepanov)
d51fb0a533e5ae34b216527ea32281ff498310dc ci: Move "MSan" from Cirrus to GitHub Actions (Hennadii Stepanov)
c22ac27529003e828d8a873ca6439f6978e2e1be ci: Move sanitizers task from Cirrus to GitHub Actions (Hennadii Stepanov)
ee1be62d84bf6d81e0ed574ef98e980d61a19227 ci: Use concurrency for pull requests only (Hennadii Stepanov)
fc3dea29eacc46926fed6428caf8355f732bdf5b ci: Move "ppc64le: Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
7782dc827657288e90fd4fdca5fbf077e50b06c5 ci: Move "ARM64: Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
0a16de671c0cb15cbdd31d56635d21ec95ed788d ci: Move "ARM32: Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
ea33914e00ef1d4117cdb608c96dd3d2d969aa72 ci: Move "s390x (big-endian): Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
880be8af99480e36f3af77b1ee1da17465a91df5 ci: Move "i686: Linux (Debian stable)" from Cirrus to GiHub Actions (Hennadii Stepanov)
e10878f58e4022dbac6e215a89c980a17b95044b ci, gha: Drop `driver-opts.network` input for `setup-buildx-action` (Hennadii Stepanov)
4ad4914bd15bd856eddb306d86588bdacabb1184 ci, gha: Add `retry_builder` Docker image builder (Hennadii Stepanov)
6617a620d95743f51486daf6c33be9cead89a32a ci: Remove "x86_64: Linux (Debian stable)" task from Cirrus CI (Hennadii Stepanov)
03c9e6508ccfaf2ed4150caa5d2d7e92abca5d5d ci, gha: Add "x86_64: Linux (Debian stable)" GitHub Actions job (Hennadii Stepanov)
ad3e65d9fed5ad65391447781c7997f137c8e3a7 ci: Remove GCC build files and sage to reduce size of Docker image (Tim Ruffing)
ef9fe959deb638228bca8f1068f078e87e271b02 ci: Drop no longer needed workaround (Hennadii Stepanov)
87d35f30c0a322e9b4bc5ee1addc1d0cd463562a ci: Rename `cirrus.sh` to more general `ci.sh` (Hennadii Stepanov)
d6281dd0086a37c77311b4acbbacad89738163c7 ci: Remove Windows tasks from Cirrus CI (Hennadii Stepanov)
2b6f9cd546ce688005184f1400bfded7a4a4bbf0 ci, gha: Add Windows jobs based on Linux image (Hennadii Stepanov)
b0886fd35c0ad05adee3fb8008e4315bf2f91f1f ci, gha: Ensure only a single workflow processes `github.ref` at a time (Hennadii Stepanov)
d23da6d55714271c720fee58fbff5e5ef2fe193f use secp256k1_scalar_verify checks (stratospher)
c7d0454932b42a9728b55033c94e000b1dbbb6f2 add verification for scalars (stratospher)
ad152151b06a40aaf6cd90561356ff451996455d update max scalar in scalar_cmov_test and fix schnorrsig_verify exhaustive test (stratospher)
d78bec7001fe6f5ed8d5b215bf61e7b74e3369ca ci: Remove Windows MSVC tasks from Cirrus CI (Hennadii Stepanov)
3545dc2b9bdbf856c1e0288120ef1cde99daa7ec ci, gha: Run all MSVC tests on Windows natively (Hennadii Stepanov)
54058d16feaa431520029335e2d56252859d3260 field: remove `secp256k1_fe_equal_var` (siv2r)
bb4efd6404960f9e8f93c15d7d001af068e5b5a4 tests: remove unwanted `secp256k1_fe_normalize_weak` call (siv2r)
c2f6435802dfaea43fa589fa72804e344c08cd6e ci: Add comment about switching macOS to M1 on GHA later (Tim Ruffing)
4a24fae0bc82738b4d6d44d378da8f15d4fce03e ci: Remove "arm64: macOS Ventura" task from Cirrus CI (Hennadii Stepanov)
8e54a346d2fa5aeedd6ba5201fcb084c281cf6a7 ci, gha: Run "x86_64: macOS Ventura" job on GitHub Actions (Hennadii Stepanov)
747ada35877d4392c453b7c7249465fb382125ea test: Silent noisy clang warnings about Valgrind code on macOS x86_64 (Hennadii Stepanov)
d62db57427f60da57f936cbe049ee27b10c3f8d4 ci: Use Homebrew's gcc in native macOS task (Hennadii Stepanov)
b7c685e74adbd83937990e90f076600fabf8ccf0 Save _normalize_weak calls in group add methods (Peter Dettman)
c83afa66e0c324e42d13adff0e4f7db9b2868788 Tighten group magnitude limits (Peter Dettman)
173e8d061a8d1526f80d9ae79dd7f0371d38f7e0 Implement current magnitude assumptions (Peter Dettman)
49afd2f5d8c323d32a21f2fe182823b6d7704eb2 Take use of _fe_verify_magnitude in field_impl.h (Sebastian Falbesoner)
4e9661fc426c6068b2472f52a772c312bc26acc9 Add _fe_verify_magnitude (no-op unless VERIFY is enabled) (Peter Dettman)
690b0fc05abd76cb7f6bd87e88bf7b8b0fd1ab70 add missing group element invariant checks (Sebastian Falbesoner)
9c91ea41b1987d73b9cbb7e569bb1f1e640a4110 ci: Enable ellswift module where it's missing (Tim Ruffing)
db32a247612d3d48c7c617b9dedf067649f82083 ctimetests: Use new SECP256K1_CHECKMEM macros also for ellswift (Tim Ruffing)
8408dfdc4cfcc5cf87ac0a7d229f8a1c1d63128a Revert "ci: Run sage prover on CI" (Hennadii Stepanov)
c8d9914fb1bf2790e6837794111614b640757ea3 ci, gha: Run "SageMath prover" job on GitHub Actions (Hennadii Stepanov)
f1774e5ec4a49db5762ecccbabd7fb5db0a7fb2b ci, gha: Make MSVC job presentation more explicit (Hennadii Stepanov)
5ee039bb58962745e5f861ae6603b5961adcd1e3 ci: Remove "Windows (VS 2022)" task from Cirrus CI (Hennadii Stepanov)
a2f7ccdecc4721d972f36d6aacc5f0c85ce0557d ci: Run "Windows (VS 2022)" job on GitHub Actions (Hennadii Stepanov)
175db31149fff4b3dc3d3dab021f289d7e98381c ci: Drop no longer needed `PATH` variable update on Windows (Hennadii Stepanov)
116d2ab3df630455f23a7b21f50237689879ecc0 cmake: Set `ENVIRONMENT` property for examples on Windows (Hennadii Stepanov)
cef373997c29c5e6077b9367c92812bcc99bc8bf cmake, refactor: Use helper function instead of interface library (Hennadii Stepanov)
a1bd4971d6c6113f140143275141adb336fc3702 refactor: take use of `secp256k1_scalar_{zero,one}` constants (part 2) (Sebastian Falbesoner)

Pull request description:

  [bitcoin-core/secp256k1#1391]: refactor: take use of `secp256k1_scalar_{zero,one}` constants (part 2)
  [bitcoin-core/secp256k1#1290]: cmake: Set `ENVIRONMENT` property for examples on Windows
  [bitcoin-core/secp256k1#1389]: ci: Run "Windows (VS 2022)" job on GitHub Actions
  [bitcoin-core/secp256k1#1397]: ci: Remove "Windows (VS 2022)" task from Cirrus CI
  [bitcoin-core/secp256k1#1399]: ci, gha: Run "SageMath prover" job on GitHub Actions
  [bitcoin-core/secp256k1#1400]: ctimetests: Use new SECP256K1_CHECKMEM macros also for ellswift
  [bitcoin-core/secp256k1#1348]: tighten group magnitude limits, save normalize_weak calls in group add methods (revival of #1032)
  [bitcoin-core/secp256k1#1402]: ci: Use Homebrew'\''s gcc in native macOS task
  [bitcoin-core/secp256k1#1274]: test: Silent noisy clang warnings about Valgrind code on macOS x86_64
  [bitcoin-core/secp256k1#1394]: ci, gha: Run "x86_64: macOS Ventura" job on GitHub Actions
  [bitcoin-core/secp256k1#1404]: ci: Remove "arm64: macOS Ventura" task from Cirrus CI
  [bitcoin-core/secp256k1#1062]: Removes `_fe_equal_var`, and unwanted `_fe_normalize_weak` calls (in tests)
  [bitcoin-core/secp256k1#1401]: ci, gha: Run all MSVC tests on Windows natively
  [bitcoin-core/secp256k1#1373]: Add invariant checking for scalars
  [bitcoin-core/secp256k1#1403]: ci, gha: Ensure only a single workflow processes `github.ref` at a time
  [bitcoin-core/secp256k1#1398]: ci, gha: Add Windows jobs based on Linux image
  [bitcoin-core/secp256k1#1405]: ci: Drop no longer needed workaround
  [bitcoin-core/secp256k1#1396]: ci, gha: Add "x86_64: Linux (Debian stable)" GitHub Actions job
  [bitcoin-core/secp256k1#1406]: ci, gha: Move more non-x86_64 tasks from Cirrus CI to GitHub Actions
  [bitcoin-core/secp256k1#1410]: ci: Use concurrency for pull requests only
  [bitcoin-core/secp256k1#1409]: ci: Move remained task from Cirrus to GitHub Actions
  [bitcoin-core/secp256k1#1411]: ci: Make repetitive command the default one
  [bitcoin-core/secp256k1#1412]: ci: Switch macOS from Ventura to Monterey and add Valgrind
  [bitcoin-core/secp256k1#1414]: ci/gha: Add ARM64 QEMU jobs for clang and clang-snapshot
  [bitcoin-core/secp256k1#1413]: ci: Add `release` job
  [bitcoin-core/secp256k1#1415]: release: Prepare for 0.4.0
  [bitcoin-core/secp256k1#1417]: release cleanup: bump version after 0.4.0
  [bitcoin-core/secp256k1#1390]: tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID
  [bitcoin-core/secp256k1#1416]: doc: Align documented scripts with CI ones
  [bitcoin-core/secp256k1#1422]: cmake: Install `libsecp256k1.pc` file
  [bitcoin-core/secp256k1#1424]: ci: Bump major versions for docker actions
  [bitcoin-core/secp256k1#1395]: tests: simplify `random_fe_non_zero` (remove loop limit and unneeded normalize)

  This PR can be recreated with `./contrib/sync-upstream.sh -b master range ee7aaf213ea3eb42fc8960c7d178b5ffb286440f`.
  Tip: Use `git show --remerge-diff` to show the changes manually added to the merge commit.' --web

  - Replace fe_equal_var with fe_equal
  - Use CHECK_ILLEGAL instead of CHECK/ecount
  - Turn on secp256k1-zkp specific modules in CI

ACKs for top commit:
  real-or-random:
    ACK b41caaafd2f7308f99245bc833158cdc5836c52d

Tree-SHA512: e8994fa2590d6e277d60a130d3f11b0256dc7fbe67e8a2b85463d9849d3f9fbfccf366b17b3904f1974f8b7b27a24128d2a04a3337c1b8409d000d136714bf90
2023-10-12 17:14:20 +02:00