]> Git Repo - secp256k1.git/log
secp256k1.git
4 years agoMerge #708: Constant-time behaviour test using valgrind memtest.
Tim Ruffing [Tue, 3 Mar 2020 15:49:20 +0000 (16:49 +0100)]
Merge #708: Constant-time behaviour test using valgrind memtest.

08fb6c49261f8aefaaa8ea2ca6d84a53e037e812 Run valgrind_ctime_test in travis (Jonas Nick)
3d2302257f19533932cd53547e9745b6283a907d Constant-time behaviour test using valgrind memtest. (Gregory Maxwell)

Pull request description:

  Valgrind does bit-level tracking of the "uninitialized" status of memory,
   property tracks memory which is tainted by any uninitialized memory, and
   warns if any branch or array access depends on an uninitialized bit.

  That is exactly the verification we need on secret data to test for
   constant-time behaviour. All we need to do is tell valgrind our
   secret key is actually uninitialized memory.

  This adds a valgrind_ctime_test which is compiled if valgrind is installed:

  Run it with libtool --mode=execute:
  $ libtool --mode=execute valgrind ./valgrind_ctime_test

ACKs for top commit:
  sipa:
    ACK 08fb6c49261f8aefaaa8ea2ca6d84a53e037e812
  real-or-random:
    ACK 08fb6c49261f8aefaaa8ea2ca6d84a53e037e812
  jonasnick:
    ACK 08fb6c49261f8aefaaa8ea2ca6d84a53e037e812

Tree-SHA512: d2eb829fb09f43ad1af70898e0eb9cf3f002c6bc418eca9e3e01a9c2c6e87c092aed23d6b0f311ddccbce1cce5f8ef39162cf9b2e68b83d160bc3d249e881493

4 years agoRun valgrind_ctime_test in travis
Jonas Nick [Wed, 12 Feb 2020 10:20:38 +0000 (10:20 +0000)]
Run valgrind_ctime_test in travis

4 years agoConstant-time behaviour test using valgrind memtest.
Gregory Maxwell [Wed, 8 Jan 2020 11:56:15 +0000 (11:56 +0000)]
Constant-time behaviour test using valgrind memtest.

Valgrind does bit-level tracking of the "uninitialized" status of memory,
 property tracks memory which is tainted by any uninitialized memory, and
 warns if any branch or array access depends on an uninitialized bit.

That is exactly the verification we need on secret data to test for
 constant-time behaviour. All we need to do is tell valgrind our
 secret key is actually uninitialized memory.

This adds a valgrind_ctime_test which is compiled if valgrind is installed:

Run it with libtool --mode=execute:
$ libtool --mode=execute valgrind ./valgrind_ctime_test

4 years agoMerge #710: Eliminate harmless non-constant time operations on secret data.
Tim Ruffing [Mon, 24 Feb 2020 13:02:44 +0000 (14:02 +0100)]
Merge #710: Eliminate harmless non-constant time operations on secret data.

7b50483ad789081ba158799e5b94330f62932607 Adds a declassify operation to aid constant-time analysis. (Gregory Maxwell)
34a67c773b0871e5797c7ab506d004e80911f120 Eliminate harmless non-constant time operations on secret data. (Gregory Maxwell)

Pull request description:

  There were several places where the code was non-constant time
   for invalid secret inputs.  These are harmless under sane use
   but get in the way of automatic const-time validation.

  (Nonce overflow in signing is not addressed, nor is s==0 in signing)

ACKs for top commit:
  sipa:
    utACK 7b50483ad789081ba158799e5b94330f62932607
  real-or-random:
    ACK 7b50483ad789081ba158799e5b94330f62932607 I read the code carefully and tested it
  jonasnick:
    reACK 7b50483ad789081ba158799e5b94330f62932607

Tree-SHA512: 0776c3a86e723d2f97b9b9cb31d0d0e59dfcf308093b3f46fbc859f73f9957f3fa977d03b57727232040368d058701ef107838f9b1ec98f925ec78ddad495c4e

4 years agoMerge #718: Clarify that a secp256k1_ecdh_hash_function must return 0 or 1
Tim Ruffing [Sun, 23 Feb 2020 08:20:47 +0000 (09:20 +0100)]
Merge #718: Clarify that a secp256k1_ecdh_hash_function must return 0 or 1

eb45ef33842ead425137d589521dc231ee92a10d Clarify that a secp256k1_ecdh_hash_function must return 0 or 1 (Tim Ruffing)

Pull request description:

  and improve style of the ECDH docs.

ACKs for top commit:
  sipa:
    utACK eb45ef33842ead425137d589521dc231ee92a10d
  jonasnick:
    ACK eb45ef33842ead425137d589521dc231ee92a10d
  elichai:
    ACK eb45ef33842ead425137d589521dc231ee92a10d
  apoelstra:
    utACK https://github.com/bitcoin-core/secp256k1/pull/718/commits/eb45ef33842ead425137d589521dc231ee92a10d

Tree-SHA512: fa1e34fbbe2fd53b633c48c70fbd9d6eec4be1303b660ff87945d49333264ef5c28a4db9407161907697f37ca657a1ee7b50e58861689de526ad4d685dedeae6

4 years agoAdds a declassify operation to aid constant-time analysis.
Gregory Maxwell [Sat, 11 Jan 2020 13:31:50 +0000 (13:31 +0000)]
Adds a declassify operation to aid constant-time analysis.

ECDSA signing has a retry loop for the exceptionally unlikely case
 that S==0.  S is not a secret at this point and this case is so
 rare that it will never be observed but branching on it will trip
 up tools analysing if the code is constant time with respect to
 secrets.

Derandomized ECDSA can also loop on k being zero or overflowing,
 and while k is a secret these cases are too rare (1:2^255) to
 ever observe and are also of no concern.

This adds a function for marking memory as no-longer-secret and
 sets it up for use with the valgrind memcheck constant-time
 test.

4 years agoEliminate harmless non-constant time operations on secret data.
Gregory Maxwell [Sat, 11 Jan 2020 01:01:05 +0000 (01:01 +0000)]
Eliminate harmless non-constant time operations on secret data.

There were several places where the code was non-constant time
 for invalid secret inputs.  These are harmless under sane use
 but get in the way of automatic const-time validation.

(Nonce overflow in signing is not addressed, nor is s==0 in
 signing)

4 years agoClarify that a secp256k1_ecdh_hash_function must return 0 or 1
Tim Ruffing [Mon, 10 Feb 2020 11:55:30 +0000 (12:55 +0100)]
Clarify that a secp256k1_ecdh_hash_function must return 0 or 1

and improve style of the ECDH docs.

4 years agoMerge #714: doc: document the length requirements of output parameter.
Tim Ruffing [Mon, 10 Feb 2020 11:06:17 +0000 (12:06 +0100)]
Merge #714: doc: document the length requirements of output parameter.

4b48a431060948dc5e29aa590d646a72aa138968 doc: document the length requirements of output parameter. (Rusty Russell)

Pull request description:

  It's subtle, since it is actually only touched by hashfp (though
  we assert it's non-NULL), but give explicit advice in the default
  case.

Signed-off-by: Rusty Russell <[email protected]>
ACKs for top commit:
  jonasnick:
    ACK 4b48a431060948dc5e29aa590d646a72aa138968
  real-or-random:
    ACK 4b48a431060948dc5e29aa590d646a72aa138968 diff inspection

Tree-SHA512: d6bedb495e46b27ac9b558e77d814884d782ea78569a2296688eccf374bc880d13846546ad449c2a677865cf6ed56fcbc8be58c21f9daca5084831074e20d769

4 years agoMerge #682: Remove Java Native Interface
Tim Ruffing [Mon, 10 Feb 2020 10:59:06 +0000 (11:59 +0100)]
Merge #682: Remove Java Native Interface

642cd062bdd2d28a8a84d4cb6dedbfe435ee5869 Remove Java Native Interface (Jonas Nick)

Pull request description:

  This was discussed in #508. The main reasons are that the existing Java Native Interface (JNI) bindings would need way more work to remain useful to Java developers but the maintainers and regular contributors of libsecp are not very familiar with Java (and evidently are motivated enough to improve the situation). We don't know who relies on these bindings with the exception of ACINQ who have their own fork at https://github.com/ACINQ/secp256k1/tree/jni-embed/src/java (@sstone). Bitcoinj can optionally use the libsecp bindings.

  Ideally, there would be a separate repository owned by Java developers with just the bindings. Until this exists, Java developers relying on libsecp can use ACINQs fork or an older commit of libsecp.

ACKs for top commit:
  real-or-random:
    ACK 642cd062bdd2d28a8a84d4cb6dedbfe435ee5869 I read the diff
  real-or-random:
    ACK 642cd062bdd2d28a8a84d4cb6dedbfe435ee5869 I read the diff, and I verified that the diff to 7d9066a66c0f13cabb0c4f71aca30edd3494f0d5, which has been ACKed by sipa, is only the additonal removal of ax_jni_include_dir.m4

Tree-SHA512: 9e573f2b01897bd5f301707062b41de53424517b537ce0834d9049d003cfd73fa1bcc024b543256016e4c9a1126f7c7fef559b84dc4914083b5a2d0ad5e57ea8

4 years agodoc: document the length requirements of output parameter.
Rusty Russell [Mon, 10 Feb 2020 00:41:11 +0000 (11:11 +1030)]
doc: document the length requirements of output parameter.

It's subtle, since it is actually only touched by hashfp (though
we assert it's non-NULL), but give explicit advice in the default
case.

Signed-off-by: Rusty Russell <[email protected]>
4 years agoMerge #713: Docstrings
Jonas Nick [Fri, 24 Jan 2020 12:34:50 +0000 (12:34 +0000)]
Merge #713: Docstrings

dabfea7e217b129d10f0f787722626f388dddb5a field: extend docstring of secp256k1_fe_normalize (Marko Bencun)
dc7d8fd9e2576c399a7ed25aa98b0f23ffac6766 scalar: extend docstring of secp256k1_scalar_set_b32 (Marko Bencun)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK dabfea7e217b129d10f0f787722626f388dddb5a
  jonasnick:
    ACK dabfea7

Tree-SHA512: aeed17dad281296e46d94007c864ba07f41a347525b049385a0a71640de84c3094bcc51d2fb4132b2a8f575acfe8ae53d7e28790bf328cac1892d040a9c50f70

5 years agofield: extend docstring of secp256k1_fe_normalize
Marko Bencun [Thu, 16 Jan 2020 15:52:09 +0000 (16:52 +0100)]
field: extend docstring of secp256k1_fe_normalize

5 years agoscalar: extend docstring of secp256k1_scalar_set_b32
Marko Bencun [Thu, 16 Jan 2020 15:48:49 +0000 (16:48 +0100)]
scalar: extend docstring of secp256k1_scalar_set_b32

5 years agoMerge #704: README: add a section for test coverage
Pieter Wuille [Wed, 15 Jan 2020 15:55:20 +0000 (07:55 -0800)]
Merge #704: README: add a section for test coverage

acb7f97eb82dfbbdb797354e1550b910055b4422 README: add a section for test coverage (Marko Bencun)

Pull request description:

  It is a hassle to figure out the exact commands to create a good
  report.

ACKs for top commit:
  real-or-random:
    ACK acb7f97eb82dfbbdb797354e1550b910055b4422
  sipa:
    ACK acb7f97eb82dfbbdb797354e1550b910055b4422

Tree-SHA512: d39f3e0b289229b2ce085406f6d716fdd54038df9ee5273a18a05140d1eddd4149149e881cc7a13f2126347217b9c56a0c12adf558c49879c5f556695242afc6

5 years agoREADME: add a section for test coverage
Marko Bencun [Sun, 29 Dec 2019 20:52:01 +0000 (21:52 +0100)]
README: add a section for test coverage

It is a hassle to figure out the exact commands to create a good
report.

5 years agoMerge #709: Remove secret-dependant non-constant time operation in ecmult_const.
Pieter Wuille [Tue, 14 Jan 2020 21:24:52 +0000 (13:24 -0800)]
Merge #709: Remove secret-dependant non-constant time operation in ecmult_const.

d567b779fe446fd18820a9d2968ecb703c8dea19 Clarify comments about use of rzr on ge functions and abs function. (Gregory Maxwell)
2241ae6d14df187e2c8d6fe5b44e3d850474af38 Remove secret-dependant non-constant time operation in ecmult_const. (Gregory Maxwell)

Pull request description:

  ECMULT_CONST_TABLE_GET_GE was branching on its secret input.

  Also makes secp256k1_gej_double_var implemented as a wrapper
   on secp256k1_gej_double_nonzero instead of the other way
   around.  This wasn't a constant time bug but it was fragile
   and could easily become one in the future if the double_var
   algorithm is changed.

ACKs for top commit:
  real-or-random:
    ACK d567b779fe446fd18820a9d2968ecb703c8dea19 I read the diff carefully and tested the code with ECDH enabled and various settings, also on valgrind
  sipa:
    ACK d567b779fe446fd18820a9d2968ecb703c8dea19

Tree-SHA512: f00a921dcc6cc024cfb3ac1a34c1be619b96f1f17ec0ee0f3ff4ea02035ee288e55469491ed3183e2c4e5560cc068c10aafb657dff95a610706e5b9a8cd13966

5 years agoClarify comments about use of rzr on ge functions and abs function.
Gregory Maxwell [Thu, 9 Jan 2020 13:07:36 +0000 (13:07 +0000)]
Clarify comments about use of rzr on ge functions and abs function.

5 years agoRemove secret-dependant non-constant time operation in ecmult_const.
Gregory Maxwell [Wed, 8 Jan 2020 14:58:28 +0000 (14:58 +0000)]
Remove secret-dependant non-constant time operation in ecmult_const.

ECMULT_CONST_TABLE_GET_GE was branching on its secret input.

Also makes secp256k1_gej_double_var implemented as a wrapper
 on secp256k1_gej_double_nonzero instead of the other way
 around.  This wasn't a constant time bug but it was fragile
 and could easily become one in the future if the double_var
 algorithm is changed.

5 years agoRemove Java Native Interface
Jonas Nick [Tue, 29 Oct 2019 12:23:32 +0000 (12:23 +0000)]
Remove Java Native Interface

5 years agoMerge #703: Overhaul README.md
Pieter Wuille [Sun, 29 Dec 2019 15:00:39 +0000 (07:00 -0800)]
Merge #703: Overhaul README.md

2e759ec753446aab0272ba32c5f1b7dc3a4dc75c Overhaul README.md (Tim Ruffing)

Pull request description:

  * Update feature list
  * Be more positive about the state and quality of the library
  * Mention ECDSA key operations explicitly in short library description
  * Say "secret key" instead of "private key"

  cc @gmaxwell who suggested a similar wording for the disclaimer.

ACKs for top commit:
  sipa:
    ACK 2e759ec753446aab0272ba32c5f1b7dc3a4dc75c
  jonasnick:
    ACK 2e759ec753446aab0272ba32c5f1b7dc3a4dc75c

Tree-SHA512: 2e1c87e7fa28d9dab682af227f845e7d48ac79a9fbe10be47ae4567abc2e066ba2f852c000db7d697ece8e4bbeeb851ea647465f870ac29dc3654031bf15a1ad

5 years agoOverhaul README.md
Tim Ruffing [Fri, 20 Dec 2019 16:25:14 +0000 (17:25 +0100)]
Overhaul README.md

  * Update feature list
  * Be more positive about the state and quality of the library
  * Mention ECDSA key operations explicitly in short library description
  * Say "secret key" instead of "private key
  * Define "experimental"

Co-Authored-By: Gregory Maxwell <[email protected]>
5 years agoMerge #689: Remove "except in benchmarks" exception for fp math
Tim Ruffing [Fri, 13 Dec 2019 12:16:29 +0000 (13:16 +0100)]
Merge #689: Remove "except in benchmarks" exception for fp math

bde2a32286c697dd1056aa3eb1ea2a5353f0bede Convert bench.h to fixed-point math (Wladimir J. van der Laan)

Pull request description:

  Convert `bench.h` to fixed-point math, removing all use of float math from the repository:

  - Use 64-bit integer microsecond timestamps
  - Use decimal fixed-point math for formatting numbers

  It turned out to be a little trickier than I expected because of formatting and rounding. But, output should be the same before and after.

  I used the following to test the number formatting: https://gist.github.com/laanwj/f971bfbe018e39c19677a21ff954d0c7

ACKs for top commit:
  real-or-random:
    ACK bde2a32286c697dd1056aa3eb1ea2a5353f0bede I've read the code in detail and I've tested it. I haven't explicitly tested the formatting function with known/hardcoded inputs.

Tree-SHA512: 41ab6024b88c65a4b194272097c70d527bedb396dc7ab9d3d93165f1a19d31092798370f66399443a8d5393d0a6dcf5825679de5a325550865cfdef3586bf64c

5 years agoConvert bench.h to fixed-point math
Wladimir J. van der Laan [Tue, 5 Nov 2019 13:05:56 +0000 (14:05 +0100)]
Convert bench.h to fixed-point math

- Use 64-bit integer microsecond timestamps
- Use fixed-point math for formatting numbers

Then, remove "except in benchmarks" exception from `README.md`.

5 years agoMerge #679: Add SECURITY.md
Jonas Nick [Tue, 26 Nov 2019 19:10:02 +0000 (19:10 +0000)]
Merge #679: Add SECURITY.md

78c38363412db3ea1cd1f0cc42dd1624c078ee32 Add SECURITY.md (Jonas Nick)

Pull request description:

  Fixes #646

  WIP because the [email protected] email address doesn't exist yet. But it seems like the right place for vulnerability reports. [email protected] would have the downside that it perhaps reaches more people than necessary. Ideally secp256k1-security would just forward to the three maintainers listed in SECURITY.md. @sipa @apoelstra is it okay to put you there? Fwiw I'm opting out for now because three people should be enough.

  @sipa do you know who to talk to about adding [email protected] and the specifics about how it would work?

ACKs for top commit:
  real-or-random:
    ACK 78c38363412db3ea1cd1f0cc42dd1624c078ee32 I looked at the diff and verified my fingerprint

Tree-SHA512: 53a989615665cf8cf0c6a70d3bc2c4b71b68178cae40b2a7881aa9eba24732d126ba1e258a9fc127c69b47bb3025943097300cfcbbe18736cbf92ff4f3a901e0

5 years agoMerge #685: Fix issue where travis does not show the ./tests seed…
Tim Ruffing [Mon, 25 Nov 2019 14:03:15 +0000 (15:03 +0100)]
Merge #685: Fix issue where travis does not show the ./tests seed…

a0771d1 Explicitly disable buffering for stderr in tests (Jonas Nick)
fb424fb Make travis show the ./tests seed by removing stdout buffering and always cat tests.log after a travis run. (Jonas Nick)

Pull request description:

  …by removing stdout buffering and always cat tests.log after a travis run. Fixes #645.

  I noticed that according to the [doc](https://www.gnu.org/software/automake/manual/html_node/Parallel-Test-Harness.html) tests.log should contain stdout as well as stderr. But it doesn't because stdout isn't flushed. I removed buffering completely to avoid having to call `fflush` twice.

  Travis is instructed to always show the seed which seems helpful with `after_script` by `cat`ing `./tests.log`. In case the tests fail it looks like https://travis-ci.org/jonasnick/secp256k1/jobs/606446234.

ACKs for commit a0771d:
  real-or-random:
    ACK a0771d15e67d3fe6ac1791f81d9731f73c550e5e I looked at the diff and checked that it does not break the tests

Tree-SHA512: 3ba37c2d9169867112981bba3d56680000651ef22ef684c3703f26ed3f71bf415fb23875d30059c8247ea9520c9cfad2c9207badf1b33da8fa3b7b7235a8bf16

5 years agoExplicitly disable buffering for stderr in tests
Jonas Nick [Mon, 25 Nov 2019 10:17:02 +0000 (10:17 +0000)]
Explicitly disable buffering for stderr in tests

5 years agoMake travis show the ./tests seed by removing stdout buffering and always cat tests...
Jonas Nick [Sat, 2 Nov 2019 14:06:36 +0000 (14:06 +0000)]
Make travis show the ./tests seed by removing stdout buffering and always cat tests.log after a travis run.

5 years agoMerge #690: Add valgrind check to travis
Jonas Nick [Mon, 25 Nov 2019 10:18:44 +0000 (10:18 +0000)]
Merge #690: Add valgrind check to travis

dd98cc988f0fb3a0ab10bf1a4e28d2fbffd6c1e7 travis: Added a valgrind test without endro and enabled recovery+ecdh (Elichai Turkel)
b4c1382a87dde22d0a5075e56fb7f5d2a09f7cc7 Add valgrind check to travis (Elichai Turkel)

Pull request description:

  As discussed in https://github.com/bitcoin-core/secp256k1/pull/687
  This adds valgrind check to the repo.

  It doesn't run on recovery+ecdh because of the time.
  No openssl because of uninitialized mem.
  I debated between with and without ASM, but decided with ASM because it might be more fragile(?).

  I wasn't sure if I should pass `-DVALGRIND` via `CFLAGS` or `CPPFLAGS`, it seems like because this is only C then there shouldn't even be `CPPFLAGS` but looks like we use `CPPFLAGS` in other places for the preprocessor definitions.

  If people are worried about the time it takes we can mark it as `allow_failure` although I don't think it's a problem here because there's only a handful of PRs and they're usually open for weeks.

ACKs for top commit:
  real-or-random:
    ACK dd98cc988f0fb3a0ab10bf1a4e28d2fbffd6c1e7 I looked at the diff
  jonasnick:
    ACK dd98cc988f0fb3a0ab10bf1a4e28d2fbffd6c1e7

Tree-SHA512: 72d7f1f4c8dd4c58501ac1003b28296d6fd140a8f7711e9e3b3c04a3fbce358ff1c89d2e1d1c5489d7668d3019981264c5cadecae3d9b48cd38c9463e287d8ad

5 years agoMerge #678: Preventing compiler optimizations in benchmarks without a memory fence
Jonas Nick [Mon, 18 Nov 2019 20:09:05 +0000 (20:09 +0000)]
Merge #678: Preventing compiler optimizations in benchmarks without a memory fence

362bb25608dbcd724a07dd5170c4ebe081c3dd84 Modified bench_scalar_split so it won't get optimized out (Elichai Turkel)
73a30c6b58f078b42a03a222c55bfe8b4dd86a2b Added accumulators and checks on benchmarks so they won't get optimized out (Elichai Turkel)

Pull request description:

  As asked https://github.com/bitcoin-core/secp256k1/pull/667#issuecomment-546885951 this is the parts of #667 that don't require an assembly memory fence.

  I splitted them to 2 commits, one with obvious easy ones. and another that changes the logic a bit to achieve this (See https://github.com/bitcoin-core/secp256k1/pull/667#discussion_r337248398 )

ACKs for top commit:
  jonasnick:
    ACK 362bb256
  real-or-random:
    ACK 362bb25608dbcd724a07dd5170c4ebe081c3dd84 I read the diff and I ran the benchmarks

Tree-SHA512: d5e47f5d64c3b035155276f057671ceb7f5852f24c7102fee4d0141aabebf882039f3eae0d152bae89d0603bc09fa6ad9f7bc6b8c0f74a668ee252c727517804

5 years agotravis: Added a valgrind test without endro and enabled recovery+ecdh
Elichai Turkel [Sat, 9 Nov 2019 11:40:45 +0000 (13:40 +0200)]
travis: Added a valgrind test without endro and enabled recovery+ecdh

5 years agoAdd valgrind check to travis
Elichai Turkel [Thu, 7 Nov 2019 19:31:59 +0000 (21:31 +0200)]
Add valgrind check to travis

5 years agoMerge #688: Fix ASM setting in travis
Tim Ruffing [Tue, 5 Nov 2019 11:27:36 +0000 (12:27 +0100)]
Merge #688: Fix ASM setting in travis

5c5f71e Fix ASM setting in travis (Jonas Nick)

Pull request description:

  Without this PR the `ASM` setting isn't taken into account in travis.

ACKs for commit 5c5f71:
  real-or-random:
    ACK 5c5f71eea5167b0dd9dbef246fc70132c50c9af3 I read the diff

Tree-SHA512: 741650e4b9163e0e7341fa59b9859da85d0e34fa59980e68eacf59388879281b640836532acb3d8121da18d8e75a7c2993defada6329df830a99472b71cc17fe

5 years agoFix ASM setting in travis
Jonas Nick [Tue, 5 Nov 2019 10:56:02 +0000 (10:56 +0000)]
Fix ASM setting in travis

5 years agoMerge #684: Make no-float policy explicit
Jonas Nick [Fri, 1 Nov 2019 10:21:09 +0000 (10:21 +0000)]
Merge #684: Make no-float policy explicit

bae1bea3c4b46a2fb5ca76ff6bf1e98d43cff52f Make no-float policy explicit (Tim Ruffing)

Pull request description:

  We don't want floating types for various reasons, e.g.,
   - Their representation and often their behavior is implementation-defined.
   - Many targets don't support them.

  Closes #683.

ACKs for top commit:
  jonasnick:
    ACK bae1bea3c4b46a2fb5ca76ff6bf1e98d43cff52f

Tree-SHA512: e0027d6dda1a3e4b7d146fd3bea04e05473e08e25c0d0730018768be00351dfcf51b87b47b9e27953a21d42e0621433f13cbe55e4c20a7f7086e0191dff607a6

5 years agoMake no-float policy explicit
Tim Ruffing [Fri, 1 Nov 2019 09:39:41 +0000 (10:39 +0100)]
Make no-float policy explicit

We don't want floating types for various reasons, e.g.,
 - Their representation and often their behavior is implementation-defined.
 - Many targets don't support them.

5 years agoAdd SECURITY.md
Jonas Nick [Mon, 28 Oct 2019 14:59:05 +0000 (14:59 +0000)]
Add SECURITY.md

5 years agoModified bench_scalar_split so it won't get optimized out
Elichai Turkel [Mon, 28 Oct 2019 14:27:44 +0000 (16:27 +0200)]
Modified bench_scalar_split so it won't get optimized out

5 years agoAdded accumulators and checks on benchmarks so they won't get optimized out
Elichai Turkel [Mon, 28 Oct 2019 14:27:16 +0000 (16:27 +0200)]
Added accumulators and checks on benchmarks so they won't get optimized out

5 years agoMerge #677: Remove note about heap allocation in secp256k1_ecmult_odd_multiples_table...
Tim Ruffing [Mon, 28 Oct 2019 12:23:35 +0000 (13:23 +0100)]
Merge #677: Remove note about heap allocation in secp256k1_ecmult_odd_multiples_table_storage_var

b76142f Remove note about heap allocation in secp256k1_ecmult_odd_multiples_table_storage_var which was removed in 47045270fa90f81205d989f7107769bce1e71c4d (Jonas Nick)

Pull request description:

  ...which was removed in 47045270fa90f81205d989f7107769bce1e71c4d. h/t @roconnor-blockstream

ACKs for commit b76142:

Tree-SHA512: 05fcd7aa5d765f1f5d31b93d40c2621e1dd9674a0db136a1e1cb216d6c01f5be1580275700cbdc08feda8f165b3b349640472d0bdec770bebb23f952225e3f52

5 years agoRemove note about heap allocation in secp256k1_ecmult_odd_multiples_table_storage_var...
Jonas Nick [Mon, 28 Oct 2019 12:21:36 +0000 (12:21 +0000)]
Remove note about heap allocation in secp256k1_ecmult_odd_multiples_table_storage_var which was removed in 47045270fa90f81205d989f7107769bce1e71c4d

5 years agoMerge #647: Increase robustness against UB in secp256k1_scalar_cadd_bit
Tim Ruffing [Mon, 28 Oct 2019 10:53:46 +0000 (11:53 +0100)]
Merge #647: Increase robustness against UB in secp256k1_scalar_cadd_bit

0d82732 Improve VERIFY_CHECK of overflow in secp256k1_scalar_cadd_bit. This added check ensures that any curve order overflow doesn't go undetected due a uint32_t overflow. (Russell O'Connor)
8fe63e5 Increase robustness against UB. Thanks to elichai2 who noted that the literal '1' is a signed integer, and that shifting a signed 32-bit integer by 31 bits causes an overflow and yields undefined behaviour. While 'scalar_low_impl''s 'secp256k1_scalar_cadd_bit' is only used for testing purposes and currently the 'bit' parameter is only 0 or 1, it is better to avoid undefined behaviour in case the used domain of 'secp256k1_scalar_cadd_bit' expands. (roconnor-blockstream)

Pull request description:

  Avoid possible, but unlikely undefined behaviour in `scalar_low_impl`'s `secp256k1_scalar_cadd_bit`.
  Thanks to elichai2 who noted that the literal `1` is a signed integer, and that shifting a signed 32-bit integer by 31 bits causes an overflow and yields undefined behaviour.

  Using the unsigned literal `1u` addresses the issue.

ACKs for commit 0d8273:
  real-or-random:
    ACK 0d82732a9a16cecc445e61c718ce9bdc2d228e76
  jonasnick:
    ACK 0d82732a9a16cecc445e61c718ce9bdc2d228e76

Tree-SHA512: 905be3b8b00aa5cc9bd6dabb543745119da8f34181d37765071f28abbc1d6ff3659e3f195b72c2f2d003006678823919668bc0d169ac8b8d4bcc5da671813c99

5 years agoMerge #664: Remove mention of ec_privkey_export because it doesn't exist
Jonas Nick [Fri, 11 Oct 2019 17:31:26 +0000 (17:31 +0000)]
Merge #664: Remove mention of ec_privkey_export because it doesn't exist

59782c68b41e4262f003135717705990b3fdc3ae Remove mention of ec_privkey_export because it doesn't exist (Jonas Nick)

Pull request description:

  Fixes #663
  There is `ec_privkey_export_der` but it takes `0` for uncompressed and not `SECP256K1_EC_UNCOMPRESSED` (which is `2`).

ACKs for top commit:
  real-or-random:
    ACK https://github.com/bitcoin-core/secp256k1/pull/664/commits/59782c68b41e4262f003135717705990b3fdc3ae
  apoelstra:
    utACK https://github.com/bitcoin-core/secp256k1/commit/59782c68b41e4262f003135717705990b3fdc3ae

Tree-SHA512: 6167581df74264be576f921d04bb8e23e16fa3b823bac4b45299079ceee38d6c74dd14a55b7b976a2cee9bdbd74dd6e3b39c0482808c1b8e65c8c80743f113a2

5 years agoRemove mention of ec_privkey_export because it doesn't exist
Jonas Nick [Sun, 15 Sep 2019 11:27:17 +0000 (11:27 +0000)]
Remove mention of ec_privkey_export because it doesn't exist

5 years agoMerge #337: variable sized precomputed table for signing
Tim Ruffing [Thu, 5 Sep 2019 13:25:47 +0000 (15:25 +0200)]
Merge #337: variable sized precomputed table for signing

dcb2e3b3fff0b287d576842aabe5c79f2fe4df30 variable signing precompute table (djb)

Pull request description:

  This pull request gives an option to reduce the precomputed table size for the signing context (`ctx`) by setting `#define ECMULT_GEN_PREC_BITS [N_BITS]`.

  Motivation: Per #251 and #254, the static table can be reduced to 64kB. However, this is still too big for some of my embedded applications. Setting `#define ECMULT_GEN_PREC_BITS 2` produces a 32kB table at a tradeoff of about 75% of the signing speed. Not defining this value will default to the existing implementation of 4 bits. Statistics:

  ```
  ECMULT_GEN_PREC_BITS = 1
  Precomputed table size: 32kB
  ./bench_sign
  ecdsa_sign: min 195us / avg 200us / max 212us

  ECMULT_GEN_PREC_BITS = 2
  Precomputed table size: 32kB
  ./bench_sign
  ecdsa_sign: min 119us / avg 126us / max 134us

  ECMULT_GEN_PREC_BITS = 4 (default)
  Precomputed table size: 64kB
  ./bench_sign
  ecdsa_sign: min 83.5us / avg 89.6us / max 95.3us

  ECMULT_GEN_PREC_BITS = 8
  Precomputed table size: 512kB
  ./bench_sign
  ecdsa_sign: min 96.4us / avg 99.4us / max 104us
  ```

  Only values of 2 and 4 make sense. 8 bits causes a larger table size with no increase in speed. 1 bit runs, actually, but does not reduce table size and is slower than 2 bits.

ACKs for top commit:
  real-or-random:
    ACK dcb2e3b3fff0b287d576842aabe5c79f2fe4df30 verified that all changes to the previous ACKed 1d26b27ac90092306bfbc9cdd5123e8a5035202a were due to the rebase
  jonasnick:
    ACK dcb2e3b3fff0b287d576842aabe5c79f2fe4df30 read the code and tested various configurations with valgrind

Tree-SHA512: ed6f68ca23ffdc4b59d51525336b34b25521233537edbc74d32dfb3eafd8196419be17f01cbf10bd8d87ce745ce143085abc6034727f742163f7e5f13f26f56e

5 years agovariable signing precompute table
djb [Sun, 18 Oct 2015 08:35:16 +0000 (10:35 +0200)]
variable signing precompute table

make ECMULT_GEN_PREC_BITS configurable

ecmult_static_context.h: add compile time config assertion (#3) - Prevents accidentally using a file which was generated with a
different configuration.

README: mention valgrind issue

With --with-ecmult-gen-precision=8, valgrind needs a max stack size
adjustment to not run into a stack switching heuristic:

http://valgrind.org/docs/manual/manual-core.html

> -max-stackframe= [default: 2000000]
> The maximum size of a stack frame. If the stack pointer moves by more than this amount then Valgrind will assume that the program is switching to a different stack.
You may need to use this option if your program has large stack-allocated arrays.

basic-config: undef ECMULT_WINDOW_SIZE before (re-)defining it

5 years agoMerge #661: Make ./configure string consistent
Jonas Nick [Wed, 4 Sep 2019 22:22:39 +0000 (22:22 +0000)]
Merge #661: Make ./configure string consistent

a467047e110fb55186df173afa3d5f330f6fa47c Make ./configure string consistent (Tim Ruffing)

Pull request description:

  This was forgotten in some PR rebase.

ACKs for top commit:
  jonasnick:
    ACK a467047e110fb55186df173afa3d5f330f6fa47c

Tree-SHA512: 5aa67e886c165afa97a1e34ccfbd6bb0158ba4d4e5a4aacf6ac8b17ad9ee55132061957fd5ec383a79ad72ec7c92c745d7ad4fddca743b53e4b0e635616b29dc

5 years agoMake ./configure string consistent
Tim Ruffing [Wed, 4 Sep 2019 16:53:08 +0000 (18:53 +0200)]
Make ./configure string consistent

This was forgotten in some PR rebase.

5 years agoMerge #657: Fix a nit in the recovery tests
Jonas Nick [Thu, 22 Aug 2019 08:49:34 +0000 (08:49 +0000)]
Merge #657: Fix a nit in the recovery tests

b64a2e2597b66b57e23f3cb34f9c88809e34d93f Fix a nit in the recovery tests (Elichai Turkel)

Pull request description:

  this signature is only valid under recid 1 not 0.

  Source: https://github.com/bitcoin-core/secp256k1/blob/master/src/modules/recovery/tests_impl.h#L247
  (it passes only when the sig is parsed with recid 1)

ACKs for top commit:
  real-or-random:
    ACK b64a2e2597b66b57e23f3cb34f9c88809e34d93f I only looked at the diff
  jonasnick:
    ACK b64a2e2597b66b57e23f3cb34f9c88809e34d93f read the code

Tree-SHA512: 8e6744fe87c4078181dd1b334641784bf4fee37eb87346ecf8149482a9ea2c321bbe068e6a9199d836430b54b73848d94473a9aa6b59b4a68921a6321f449736

5 years agoFix a nit in the recovery tests
Elichai Turkel [Wed, 21 Aug 2019 14:07:22 +0000 (10:07 -0400)]
Fix a nit in the recovery tests

5 years agoMerge #650: secp256k1/src/tests.c: Properly handle sscanf return value
Jonas Nick [Sun, 18 Aug 2019 22:49:23 +0000 (22:49 +0000)]
Merge #650: secp256k1/src/tests.c:  Properly handle sscanf return value

a11c76c59a431e3492994f71a968a838e398fb58 secp256k1/src/tests.c:  Properly handle sscanf return value (Mustapha Abiola)

Pull request description:

  This pull request fixes a bug which allows the `sh` variable to be used uninitialised
  when sscanf(3) returns EOF.

Signed-off-by: Mustapha Abiola <[email protected]>
ACKs for top commit:
  sipa:
    ACK a11c76c59a431e3492994f71a968a838e398fb58.
  practicalswift:
    utACK a11c76c59a431e3492994f71a968a838e398fb58
  real-or-random:
    ACK a11c76c59a431e3492994f71a968a838e398fb58 I looked at the code

Tree-SHA512: fd9660a18e39ecf9366db94ccbcec2682b020223f4f982a4356ddf56c2fbdafa5edcd830db37be12b661c1ec0b15c57b9f34ba59ef4460187c9c2478376fbc88

5 years agoMerge #654: Fix typo (∞)
Tim Ruffing [Sat, 17 Aug 2019 14:17:50 +0000 (16:17 +0200)]
Merge #654: Fix typo (∞)

271582b3b7aadf6dc00e7a5e88a251dcf15a6c1a Fix typo (practicalswift)

Pull request description:

  Fix ∞ typo :-)

ACKs for top commit:
  real-or-random:
    ACK 271582b3b7aadf6dc00e7a5e88a251dcf15a6c1a

Tree-SHA512: 41b8134e2572707d8a1ea1e5a79fffcc206b6093ec761ee1f93e4529506553c9cc8e3839b046210468f6c4c0d7af9d78a3e7e546bb0026656f1db1c793244296

5 years agoMerge pull request #656 from real-or-random/patch-1
Andrew Poelstra [Sat, 10 Aug 2019 13:08:06 +0000 (13:08 +0000)]
Merge pull request #656 from real-or-random/patch-1

Fix typo in docs for _context_set_illegal_callback

5 years agoFix typo in docs for _context_set_illegal_callback
Tim Ruffing [Fri, 9 Aug 2019 09:25:09 +0000 (11:25 +0200)]
Fix typo in docs for _context_set_illegal_callback

5 years agoImprove VERIFY_CHECK of overflow in secp256k1_scalar_cadd_bit.
Russell O'Connor [Fri, 5 Jul 2019 04:30:36 +0000 (00:30 -0400)]
Improve VERIFY_CHECK of overflow in secp256k1_scalar_cadd_bit.
This added check ensures that any curve order overflow doesn't go undetected due a uint32_t overflow.

5 years agoMerge #583: JNI: fix use sig array
Pieter Wuille [Tue, 6 Aug 2019 22:32:20 +0000 (15:32 -0700)]
Merge #583: JNI: fix use sig array

74e2dbd JNI: fix use sig array (liuyujun)

Pull request description:

ACKs for commit 74e2db:
  sipa:
    ACK 74e2dbd68e07f752ac326a578e3071f9efa55e55. This is clearly an improvement.
  real-or-random:
    ACK 74e2dbd68e07f752ac326a578e3071f9efa55e55 I've read the code but haven't tested it

Tree-SHA512: 850b32e893463be4be28185dcc127d429afe4b6076036a078b7c61d590e0f4ea89127e448760b71c087cf70ffbefc52d87db77a5131bee81f3e4f95cfbd3bd3e

5 years agoMerge #644: Avoid optimizing out a verify_check
Pieter Wuille [Tue, 6 Aug 2019 22:28:48 +0000 (15:28 -0700)]
Merge #644: Avoid optimizing out a verify_check

94ae7cb Moved a dereference so the null check will be before the dereferencing (Elichai Turkel)

Pull request description:

  Before that even on debug the compiler could've assumed `a` isn't null and optimized `VERIFY_CHECK(a != NULL);` out.
  This put the dereference after the check
  Resolves #643

ACKs for commit 94ae7c:
  sipa:
    ACK 94ae7cbf83a34456e5cad721f61ea77fcc023a3f

Tree-SHA512: 8b986f202ede5bde1f14a8ecf25e339d64ee6cd5cb391c5f18b4ff58f946c3845902d1230bc80d110a0a33b37025d281bd4532afbdf03b1c9ca321097374eb8e

5 years agoMerge #652: README.md: update instruction to run tests
Pieter Wuille [Tue, 6 Aug 2019 22:04:26 +0000 (15:04 -0700)]
Merge #652: README.md: update instruction to run tests

ce6d438 README.md: update instruction to run tests (Marko Bencun)

Pull request description:

  Reflecting what Travis does.

ACKs for commit ce6d43:
  real-or-random:
    ACK ce6d438266e075b22a955b3205b2d8279bfa04e7
  sipa:
    ACK ce6d438266e075b22a955b3205b2d8279bfa04e7

Tree-SHA512: c0a36772a5d8571bb503f83111e89181acc1eec080cf7efa64ab922f6136138234555a9d47120e2126ae958a60864b0479c3037bff74895dd488015f25a05c10

5 years agoMerge #651: Fix typo in secp256k1_preallocated.h
Pieter Wuille [Tue, 6 Aug 2019 22:02:51 +0000 (15:02 -0700)]
Merge #651: Fix typo in secp256k1_preallocated.h

b1e68cb Fix typo in secp256k1_preallocated.h (Jan Xie)

Pull request description:

ACKs for commit b1e68c:
  sipa:
    ACK b1e68cb8e68d5d7ef8ba15c8d8a608c42b7803f6
  real-or-random:
    ACK b1e68cb8e68d5d7ef8ba15c8d8a608c42b7803f6

Tree-SHA512: ccd51ac687193cb8be34f7388b20d002773df574a52ba6dd85cf6fd69241c079eed0f624f2e72d5e8922edc07d51923831057377a9c6550e8e072bff43854bda

5 years agoMerge #640: scalar_impl.h: fix includes
Pieter Wuille [Tue, 6 Aug 2019 22:01:16 +0000 (15:01 -0700)]
Merge #640: scalar_impl.h: fix includes

2cb73b1 scalar_impl.h: fix includes (Marko Bencun)

Pull request description:

  group.h functions are not referenced.
  utils.h added as functions like VERIFY_CHECK are used.

ACKs for commit 2cb73b:
  sipa:
    ACK 2cb73b1064c796f5902189e0850066299e87aa93

Tree-SHA512: b9c7367061c2a22d2c9266c61261edd47798551b03b878ecd2e005d858701487145589793406cb4e88e85cd3c769007132efac9c228d5ee288e487e7d308e1c2

5 years agoMerge #655: jni: Use only Guava for hex encoding and decoding
Pieter Wuille [Tue, 6 Aug 2019 19:54:31 +0000 (12:54 -0700)]
Merge #655: jni: Use only Guava for hex encoding and decoding

2abcf95 jni: Use only Guava for hex encoding and decoding (Tim Ruffing)

Pull request description:

  This removes a dependency on javax.xml.bind, which is no longer
  available in JDK >= 11, see
  https://openjdk.java.net/jeps/320#Java-EE-modules .

ACKs for commit 2abcf9:
  sipa:
    ACK 2abcf951af6a9e8aff7398eb9588a50339b720c7, tests pass.

Tree-SHA512: bae4d1285b4a4a0ad62323c25eabcad5f800ddb2d97f2e15085b39982e29248b21e2e8de0d4c07a33a64f071dcdba653f72415558c0f8b619227bc6f6d71eda3

5 years agojni: Use only Guava for hex encoding and decoding
Tim Ruffing [Mon, 5 Aug 2019 15:02:29 +0000 (17:02 +0200)]
jni: Use only Guava for hex encoding and decoding

This removes a dependency on javax.xml.bind, which is no longer
available in JDK >= 11, see
https://openjdk.java.net/jeps/320#Java-EE-modules .

5 years agoFix typo
practicalswift [Mon, 5 Aug 2019 13:47:23 +0000 (13:47 +0000)]
Fix typo

5 years agoREADME.md: update instruction to run tests
Marko Bencun [Fri, 19 Jul 2019 11:50:16 +0000 (13:50 +0200)]
README.md: update instruction to run tests

Reflecting what Travis does.

5 years agoFix typo in secp256k1_preallocated.h
Jan Xie [Thu, 18 Jul 2019 00:35:42 +0000 (08:35 +0800)]
Fix typo in secp256k1_preallocated.h

5 years agosecp256k1/src/tests.c: Properly handle sscanf return value
Mustapha Abiola [Sun, 14 Jul 2019 15:02:58 +0000 (17:02 +0200)]
secp256k1/src/tests.c:  Properly handle sscanf return value

This pull request fixes a bug which allows the `sh` variable to be used uninitialized when sscanf returns EOF.

Signed-off-by: Mustapha Abiola <[email protected]>
5 years agoIncrease robustness against UB.
roconnor-blockstream [Wed, 3 Jul 2019 15:23:20 +0000 (11:23 -0400)]
Increase robustness against UB.
Thanks to elichai2 who noted that the literal '1' is a signed integer, and that shifting a signed 32-bit integer by 31 bits causes an overflow and yields undefined behaviour.
While 'scalar_low_impl''s 'secp256k1_scalar_cadd_bit' is only used for testing purposes and currently the 'bit' parameter is only 0 or 1, it is better to avoid undefined behaviour in case the used domain of 'secp256k1_scalar_cadd_bit' expands.

5 years agoMoved a dereference so the null check will be before the dereferencing
Elichai Turkel [Tue, 2 Jul 2019 23:18:56 +0000 (19:18 -0400)]
Moved a dereference so the null check will be before the dereferencing

5 years agoscalar_impl.h: fix includes
Marko Bencun [Thu, 20 Jun 2019 15:33:47 +0000 (17:33 +0200)]
scalar_impl.h: fix includes

group.h functions are not referenced.
utils.h added as functions like VERIFY_CHECK are used.

5 years agoMerge #634: Add a descriptive comment for secp256k1_ecmult_const.
Gregory Maxwell [Tue, 4 Jun 2019 23:05:07 +0000 (23:05 +0000)]
Merge #634: Add a descriptive comment for secp256k1_ecmult_const.

ee9e68c Add a descriptive comment for secp256k1_ecmult_const. (Gregory Maxwell)

Pull request description:

  Helps issue #633

ACKs for commit ee9e68:

Tree-SHA512: 552bebbd99bf8e8225ef6028e6a3bd188d412977d9c6caa90515041622accd2ea43e320217bf097180343921e967f4627a76c73e4529097bca50be414503e63b

5 years agoAdd a descriptive comment for secp256k1_ecmult_const.
Gregory Maxwell [Tue, 4 Jun 2019 01:52:44 +0000 (01:52 +0000)]
Add a descriptive comment for secp256k1_ecmult_const.

5 years agoMerge #631: typo in comment for secp256k1_ec_pubkey_tweak_mul ()
Gregory Maxwell [Sat, 1 Jun 2019 17:42:50 +0000 (17:42 +0000)]
Merge #631: typo in comment for secp256k1_ec_pubkey_tweak_mul ()

6914c25 typo in comment for secp256k1_ec_pubkey_tweak_mul () (philsmd)

Pull request description:

  Fixes a typo in secp256k1.h documentation

ACKs for commit 6914c2:

Tree-SHA512: 9b95209b7decab4624054b5e3476e99468f84f84eb270bba997abf73a78acbbf2eaa094dfa367ebfe0b1e553329071e9a0ca8a1e2b31ea7fbc4aad3fb0665e88

5 years agotypo in comment for secp256k1_ec_pubkey_tweak_mul ()
philsmd [Sat, 1 Jun 2019 10:21:20 +0000 (12:21 +0200)]
typo in comment for secp256k1_ec_pubkey_tweak_mul ()

Fixes a typo in secp256k1.h documentation

5 years agoMerge #629: Avoid calling _is_zero when _set_b32 fails.
Gregory Maxwell [Wed, 29 May 2019 21:46:31 +0000 (21:46 +0000)]
Merge #629: Avoid calling _is_zero when _set_b32 fails.

cd473e0 Avoid calling secp256k1_*_is_zero when secp256k1_*_set_b32 fails. (Gregory Maxwell)

Pull request description:

  Most of the codebase correctly used short-cutting to avoid calling
   _is_zero on possibly incompletely initialized elements, but a few
   places were missed.

ACKs for commit cd473e:
  sipa:
    utACK cd473e02c372217c3a6608ce5afaa543ed78f891
  jonasnick:
    utACK cd473e02c372217c3a6608ce5afaa543ed78f891

Tree-SHA512: d6af2863f6795d2df26f2bd05a4e33085e88c45f7794601ea57e67238a2073ef1ee3ba0feab62a7fcbc0636c48dfd80eea07d0ca4f194414127f914b0478c732

5 years agoMerge #630: Note intention of timing sidechannel freeness.
Gregory Maxwell [Wed, 29 May 2019 20:30:27 +0000 (20:30 +0000)]
Merge #630: Note intention of timing sidechannel freeness.

8d1563b Note intention of timing sidechannel freeness. (Gregory Maxwell)

Pull request description:

  Resolves #238

ACKs for commit 8d1563:

Tree-SHA512: 2b0ca945d70e5975291ed9a0884eddfd771fd06dfed37c9711f8b57d431c28b974e5a5d86ae6e70e5e37c5f208bcb74e9ab18fcf9d7b78849fcf3cff9ba7623b

5 years agoNote intention of timing sidechannel freeness.
Gregory Maxwell [Wed, 29 May 2019 12:23:20 +0000 (12:23 +0000)]
Note intention of timing sidechannel freeness.

Resolves #238

5 years agoMerge #628: Fix ability to compile tests without -DVERIFY.
Gregory Maxwell [Wed, 29 May 2019 14:24:22 +0000 (14:24 +0000)]
Merge #628: Fix ability to compile tests without -DVERIFY.

dcf3920 Fix ability to compile tests without -DVERIFY. (Gregory Maxwell)

Pull request description:

  Broken by 3f3964e4.

  It's important that the tests are also run without -DVERIFY due to
   the possibility that side-effects of a VERIFY_CHECK fix a bug that
   would otherwise be detected.

  Use of the verify_check macro in tests isn't sufficient.

ACKs for commit dcf392:

Tree-SHA512: ff7ca0e89e33f845656a4d7d18c0195d1378b020d67f89e900b18cf3d702aa81dd91ffd05a98953a481b83e4247eaf0c484bea12eab020efb3c966a456e8129f

5 years agoMerge #627: Guard memcmp in tests against mixed size inputs.
Gregory Maxwell [Wed, 29 May 2019 14:23:45 +0000 (14:23 +0000)]
Merge #627: Guard memcmp in tests against mixed size inputs.

248bffb Guard memcmp in tests against mixed size inputs. (Gregory Maxwell)

Pull request description:

  Reported by real-or-random.

  Fixes #623.

ACKs for commit 248bff:
  practicalswift:
    utACK 248bffb0526ce8d829ce22f4d63d0d4a9ccfe137

Tree-SHA512: 29867c79d2d6852f495334a5a9129c7feac2df639dd7f752067380689b0ce9f9b35e94524834c01e698df5c0b83dc9855204ec09f5dfe488a388b509c9b861d9

5 years agoMerge #578: Avoid implementation-defined and undefined behavior when dealing with...
Gregory Maxwell [Wed, 29 May 2019 10:35:10 +0000 (10:35 +0000)]
Merge #578: Avoid implementation-defined and undefined behavior when dealing with sizes

14c7dbd Simplify control flow in DER parsing (Tim Ruffing)
ec8f20b Avoid out-of-bound pointers and integer overflows in size comparisons (Tim Ruffing)
01ee1b3 Parse DER-enconded length into a size_t instead of an int (Tim Ruffing)
3cb057f Fix possible integer overflow in DER parsing (Tim Ruffing)

Pull request description:

  This is a result of auditing the code for overflow issues at random places. None of this is critical but I think all of it should be fixed.

  I know this touches "red" code. I double-checked and triple-checked this but I can understand if some of the changes are not desirable because they change well-tested code.

  Best reviewed in individual commits.

ACKs for commit 14c7db:

Tree-SHA512: 312dd3f961739752e1a861e75bd755920f634f87ee9668793e102c224434e8d21367452e114de729322c71a89f4fa82126aa5d32742f2bbbc091777c99515e10

5 years agoMerge #595: Allow to use external default callbacks
Gregory Maxwell [Mon, 27 May 2019 07:30:33 +0000 (07:30 +0000)]
Merge #595: Allow to use external default callbacks

e49f799 Add missing #(un)defines to base-config.h (Tim Ruffing)
77defd2 Add secp256k1_ prefix to default callback functions (Tim Ruffing)
908bdce Include stdio.h and stdlib.h explicitly in secp256k1.c (Tim Ruffing)
5db782e Allow usage of external default callbacks (Tim Ruffing)
6095a86 Replace CHECKs for no_precomp ctx by ARG_CHECKs without a return (Tim Ruffing)

Pull request description:

  This is intended for environments without implementations for `abort()`, `fprintf()`, and `stderr`. e.g., embedded systems. Those can provide their own implementations of `default_illegal_callback_fn` and `default_error_callback_fn` at compile time.

  If you want to use your own default callback, things will be somewhat inconsistent unfortunately: We cannot make the callback data `extern` too, because then the initialization lists for `default_illegal_callback` won't contain only constants. (`const` variables are not compile-time constants). So you cannot take callback data in your own default callback function.

  As a more drastic/breaking alternative I suggest to remove the callback data entirely. I don't think it's a big loss and I would be surprised if anyone uses it. Additionally, we could even remove the possibility to set the callback function at runtime after this PR. This will simplify things a lot, and again I don't think it's a big loss.

  Note that `abort()`, `fprintf()`, and `stderr` are also used in `CHECK`, which is still used in production code if we rely on gmp for scalar and field inversions (e.g.,  https://github.com/bitcoin-core/secp256k1/blob/master/src/scalar_impl.h#L240). This is not an issue for embedded system which probably don't want to use gmp anyway, but it is probably an issue for the reasons explained in https://github.com/bitcoin-core/secp256k1/pull/566#issuecomment-469111901.

  (related downstream: https://github.com/rust-bitcoin/rust-secp256k1/pull/100 @elichai)

ACKs for commit e49f79:

Tree-SHA512: 4dec0821eef4156cbe162bd8cdf0531c1fae8c98cd9db8438170ff1aa0e59b199739eeab293695bb582246812bea5309959f02f1fb74bb57872da54ebc52313f

5 years agoAdd missing #(un)defines to base-config.h
Tim Ruffing [Mon, 18 Mar 2019 15:20:07 +0000 (16:20 +0100)]
Add missing #(un)defines to base-config.h

5 years agoAdd secp256k1_ prefix to default callback functions
Tim Ruffing [Sat, 9 Mar 2019 10:41:21 +0000 (11:41 +0100)]
Add secp256k1_ prefix to default callback functions

5 years agoInclude stdio.h and stdlib.h explicitly in secp256k1.c
Tim Ruffing [Mon, 4 Mar 2019 15:11:35 +0000 (16:11 +0100)]
Include stdio.h and stdlib.h explicitly in secp256k1.c

5 years agoAllow usage of external default callbacks
Tim Ruffing [Mon, 4 Mar 2019 14:36:35 +0000 (15:36 +0100)]
Allow usage of external default callbacks

5 years agoReplace CHECKs for no_precomp ctx by ARG_CHECKs without a return
Tim Ruffing [Mon, 4 Mar 2019 12:09:45 +0000 (13:09 +0100)]
Replace CHECKs for no_precomp ctx by ARG_CHECKs without a return

5 years agoAvoid calling secp256k1_*_is_zero when secp256k1_*_set_b32 fails.
Gregory Maxwell [Sun, 26 May 2019 10:22:38 +0000 (10:22 +0000)]
Avoid calling secp256k1_*_is_zero when secp256k1_*_set_b32 fails.

Most of the codebase correctly used short-cutting to avoid calling
 _is_zero on possibly incompletely initialized elements, but a few
 places were missed.

5 years agoMerge #600: scratch space: use single allocation
Gregory Maxwell [Sun, 26 May 2019 07:37:54 +0000 (07:37 +0000)]
Merge #600: scratch space: use single allocation

98836b1 scratch: replace frames with "checkpoint" system (Andrew Poelstra)
7623cf2 scratch: save a couple bytes of unnecessarily-allocated memory (Andrew Poelstra)
a7a164f scratch: rename `max_size` to `size`, document that extra will actually be allocated (Andrew Poelstra)
5a4bc0b scratch: unify allocations (Andrew Poelstra)
c2b028a scratch space: thread `error_callback` into all scratch space functions (Andrew Poelstra)
0be1a4a scratch: add magic bytes to beginning of structure (Andrew Poelstra)
92a48a7 scratch space: use single allocation (Andrew Poelstra)

Pull request description:

ACKs for commit 98836b:

Tree-SHA512: 6e251f704644a5f61b24aa05c6f7a31ad8c58d147195079d52fe45daacd28a9fd2f4aaf71273183b99b3795a01a88f8389170d4280489b2a28a14a56e03153d7

5 years agoscratch: replace frames with "checkpoint" system
Andrew Poelstra [Sat, 25 May 2019 14:15:38 +0000 (14:15 +0000)]
scratch: replace frames with "checkpoint" system

5 years agoscratch: save a couple bytes of unnecessarily-allocated memory
Andrew Poelstra [Fri, 15 Mar 2019 15:41:09 +0000 (15:41 +0000)]
scratch: save a couple bytes of unnecessarily-allocated memory

5 years agoscratch: rename `max_size` to `size`, document that extra will actually be allocated
Andrew Poelstra [Thu, 14 Mar 2019 14:41:03 +0000 (14:41 +0000)]
scratch: rename `max_size` to `size`, document that extra will actually be allocated

5 years agoscratch: unify allocations
Andrew Poelstra [Thu, 14 Mar 2019 14:37:53 +0000 (14:37 +0000)]
scratch: unify allocations

5 years agoscratch space: thread `error_callback` into all scratch space functions
Andrew Poelstra [Wed, 13 Mar 2019 23:30:51 +0000 (23:30 +0000)]
scratch space: thread `error_callback` into all scratch space functions

Use it when checking magic bytes

5 years agoscratch: add magic bytes to beginning of structure
Andrew Poelstra [Wed, 13 Mar 2019 22:35:08 +0000 (22:35 +0000)]
scratch: add magic bytes to beginning of structure

5 years agoscratch space: use single allocation
Andrew Poelstra [Wed, 13 Mar 2019 22:19:41 +0000 (22:19 +0000)]
scratch space: use single allocation

5 years agoMerge #592: Use trivial algorithm in ecmult_multi if scratch space is small
Gregory Maxwell [Sat, 25 May 2019 22:34:47 +0000 (22:34 +0000)]
Merge #592: Use trivial algorithm in ecmult_multi if scratch space is small

9ab96f7 Use trivial algorithm in ecmult_multi if scratch space is small (Jonas Nick)

Pull request description:

  `ecmult_multi` already selects the trivial algorithm if the scratch space is NULL. With this PR the trivial algorithm is also selected if the scratch space is too small to use pippenger or strauss instead of returning 0. That makes it more easier to avoid consensus relevant inconsistencies just because scratch space construction was messed up.

ACKs for commit 9ab96f:
  real-or-random:
    utACK 9ab96f7

Tree-SHA512: aa451adf8880af15cf167a59cb07fc411edc43f26c8eb0873bdae2774382ba182e2a1c54487912f8f2999cb0402d554b9d293e2fb9483234471348a1f43c6653

5 years agoFix ability to compile tests without -DVERIFY.
Gregory Maxwell [Sat, 25 May 2019 21:49:45 +0000 (21:49 +0000)]
Fix ability to compile tests without -DVERIFY.

Broken by 3f3964e4.

It's important that the tests are also run without -DVERIFY due to
 the possibility that side-effects of a VERIFY_CHECK fix a bug that
 would otherwise be detected.

Use of the verify_check macro in tests isn't sufficient.

5 years agoMerge #566: Enable context creation in preallocated memory
Gregory Maxwell [Sat, 25 May 2019 21:16:07 +0000 (21:16 +0000)]
Merge #566: Enable context creation in preallocated memory

0522caa Explain caller's obligations for preallocated memory (Tim Ruffing)
238305f Move _preallocated functions to separate header (Tim Ruffing)
695feb6 Export _preallocated functions (Tim Ruffing)
814cc78 Add tests for contexts in preallocated memory (Tim Ruffing)
ba12dd0 Check arguments of _preallocated functions (Tim Ruffing)
5feadde Support cloning a context into preallocated memory (Tim Ruffing)
c4fd5da Switch to a single malloc call (Tim Ruffing)
ef020de Add size constants for preallocated memory (Tim Ruffing)
1bf7c05 Prepare for manual memory management in preallocated memory (Tim Ruffing)

Pull request description:

  @apoelstra

  This builds on #557.

  Manually managing memory is always a pain in the ass in some way. I tried to keep the pain manageable. I'm open to suggestions to make this less ugly or error-prone.

  to do:
   * tests
   * export functions

ACKs for commit 0522ca:

Tree-SHA512: 8ddb5b70219b6f095e780a9812d2387ab2a7f399803ce4101e27da504b479a61ebe08b6380568c7ba6f1e73d7d0b1f58a3c0a66fa0fdec7a64cd0740e156ce38

5 years agoExplain caller's obligations for preallocated memory
Tim Ruffing [Fri, 29 Mar 2019 21:27:01 +0000 (22:27 +0100)]
Explain caller's obligations for preallocated memory

5 years agoMove _preallocated functions to separate header
Tim Ruffing [Tue, 27 Nov 2018 15:48:57 +0000 (16:48 +0100)]
Move _preallocated functions to separate header

5 years agoExport _preallocated functions
Tim Ruffing [Tue, 27 Nov 2018 15:47:46 +0000 (16:47 +0100)]
Export _preallocated functions

This page took 0.086482 seconds and 4 git commands to generate.