Commit Graph

876 Commits

Author SHA1 Message Date
Gregory Maxwell ba698f883b
Merge #539: Assorted minor corrections
52ab96f clean dependendies in field_*_impl.h (Russell O'Connor)
deff5ed Correct math typos in field_*.h (Russell O'Connor)
4efb3f8 Add check that restrict pointers don't alias with all parameters. (Russell O'Connor)

Pull request description:

  * add more checks for restrict pointers.
  * correct math typos.
  * refine dependencies on "num.h"

Tree-SHA512: c368f577927db2ace3e7f46850cb2fdf9d7d169b698a9697767e1f82e9e7091f2b2fea0f7cf173048eb4c1bb56824c884fa849c04c595ee97766c01f346a54ec
2019-02-21 04:20:35 +00:00
Gregory Maxwell 949e85b009
Merge #550: Optimize secp256k1_fe_normalize_weak calls.
9bd89c8 Optimize secp256k1_fe_normalize_weak calls. Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead. (Russell O'Connor)

Pull request description:

  Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead.

Tree-SHA512: 7bbb1aca8e37a268a26d7061bd1f390db129e697792f1d5ddd10ea34927616edc26ef118b500c3e5e14d1d463196033ef64e4d34b765380325c24835458b7a9b
2019-02-21 04:14:40 +00:00
Pieter Wuille b408c6a8b2
Merge #579: Use __GNUC_PREREQ for detecting __builtin_expect
c663397 Use __GNUC_PREREQ for detecting __builtin_expect (Tim Ruffing)

Pull request description:

Tree-SHA512: 659a721da835eb15966a2a5386d6ae4c3defbb6ad473905f14161a3cf36d1556d44d887602019c89ebeffdfd82ed469ff27914dc2aaee6648d1e0c8a22151c27
2019-02-04 14:33:03 -08:00
Tim Ruffing c663397f46 Use __GNUC_PREREQ for detecting __builtin_expect 2018-12-17 11:47:25 +01:00
Pieter Wuille e34ceb333b
Merge #557: Eliminate scratch memory used when generating contexts
b3bf5f9 ecmult_impl: expand comment to explain how effective affine interacts with everything (Andrew Poelstra)
efa783f Store z-ratios in the 'x' coord they'll recover (Peter Dettman)
ffd3b34 add `secp256k1_ge_set_all_gej_var` test which deals with many infinite points (Andrew Poelstra)
84740ac ecmult_impl: save one fe_inv_var (Andrew Poelstra)
4704527 ecmult_impl: eliminate scratch memory used when generating context (Andrew Poelstra)
7f7a2ed ecmult_gen_impl: eliminate scratch memory used when generating context (Andrew Poelstra)

Pull request description:

  Builds on #553

Tree-SHA512: 6031a601a4a476c1d21fc8db219383e7930434d2f199543c61aca0118412322dd814a0109c385ff1f83d16897170dd0c25051697b0f88f15234b0059b661af41
2018-11-26 09:14:58 -08:00
Andrew Poelstra b3bf5f99a3 ecmult_impl: expand comment to explain how effective affine interacts with everything 2018-11-10 14:01:13 +00:00
Peter Dettman efa783f8f0 Store z-ratios in the 'x' coord they'll recover 2018-11-10 13:14:43 +00:00
Andrew Poelstra ffd3b346fe add `secp256k1_ge_set_all_gej_var` test which deals with many infinite points 2018-11-09 00:20:53 +00:00
Andrew Poelstra 84740acd2a ecmult_impl: save one fe_inv_var 2018-11-09 00:20:53 +00:00
Andrew Poelstra 47045270fa ecmult_impl: eliminate scratch memory used when generating context 2018-11-09 00:20:51 +00:00
Andrew Poelstra 7f7a2ed3a8 ecmult_gen_impl: eliminate scratch memory used when generating context 2018-11-09 00:16:06 +00:00
Pieter Wuille 314a61d724
Merge #553: add static context object which has no capabilities
40fde61 prevent attempts to modify `secp256k1_context_no_precomp` (Andrew Poelstra)
ed7c084 add static context object which has no capabilities (Andrew Poelstra)

Pull request description:

Tree-SHA512: a843ed7ba00a00a46eec3146ce428d4b49eb440af766f44d731b1f51553d08de8cc9a0af5ed114d0dfdca6f4bf4a2ede4dbd6a37d6bd818b81630089424a0ba5
2018-11-05 18:25:56 -08:00
Pieter Wuille 1086fda4c1
Merge #354: [ECDH API change] Support custom hash function
c8fbc3c [ECDH API change] Allow pass arbitrary data to hash function (Kirill Fomichev)
b00be65 [ECDH API change] Support custom hash function (Kirill Fomichev)

Pull request description:

  Solve #352

Tree-SHA512: f5985874d03e976cdb3d59036af7720636ad1488da40fd3bd7881b1fb71b05036a952013d519baa84c4ce4b558bdef25c4ce76b384b297e4d0aece9e37e78a01
2018-10-17 12:14:48 -07:00
Andrew Poelstra 40fde611bd prevent attempts to modify `secp256k1_context_no_precomp` 2018-10-04 15:16:38 +00:00
Andrew Poelstra ed7c08417a add static context object which has no capabilities 2018-10-04 15:16:34 +00:00
Russell O'Connor 9bd89c836b Optimize secp256k1_fe_normalize_weak calls.
Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead.
2018-08-12 23:47:38 -04:00
Russell O'Connor 52ab96fedb clean dependendies in field_*_impl.h 2018-07-06 08:40:35 -04:00
Russell O'Connor deff5edd42 Correct math typos in field_*.h 2018-07-06 08:40:35 -04:00
Russell O'Connor 4efb3f8dd1 Add check that restrict pointers don't alias with all parameters. 2018-07-06 08:40:34 -04:00
Pieter Wuille 1e6f1f5ad5
Merge #529: fix tests.c in the count == 0 case
95e99f1 fix tests.c in the count == 0 case (Andrew Poelstra)

Pull request description:

  Fixes #528

Tree-SHA512: 8b28d84f95bcd1337fbd7fb187dee2a9bad2b6b595eaf42a2d855e5784f48a1f3ad5739881b22eea115d32c4525feb69b41958699a165c847fcfb8096cc4903a
2018-05-31 12:00:47 -07:00
Kirill Fomichev c8fbc3c397 [ECDH API change] Allow pass arbitrary data to hash function 2018-05-17 00:38:58 +03:00
Kirill Fomichev b00be65056 [ECDH API change] Support custom hash function 2018-05-17 00:05:09 +03:00
Andrew Poelstra 95e99f196f fix tests.c in the count == 0 case 2018-04-10 19:32:04 +00:00
Pieter Wuille 452d8e4d2a
Merge #523: scratch: add stack frame support
6fe5043 scratch: add stack frame support (Andrew Poelstra)

Pull request description:

  Replaces the single-blob stack space ith one that internally manages multiple blobs, which are exposed to the user as "frames". Users allocate new blobs with `secp256k1_scratch_allocate_frame` and deallocate them with `secp256k1_scratch_deallocate_frame`. Then any calls to `secp256k1_scratch_alloc` use the frame at the top of the stack. This is guaranteed to succeed, assuming that the frame allocation succeeded and that the user is not requesting more memory than the frame was allocated with.

Tree-SHA512: 0b2072c5b9df8f3b40fb6d76e94fcfcc6a03a7da33e31249b5f24b02eb8a3311f282f6a4732153d6101968de8f9a568009a72735a1cc688a0f3040055799a09d
2018-04-05 16:35:27 -07:00
Andrew Poelstra 6fe50439ae scratch: add stack frame support 2018-04-05 22:49:29 +00:00
Pieter Wuille 9bc2e26502
Merge #522: parameterize ecmult_const over input size
7c1b91b parameterize ecmult_const over input size (Andrew Poelstra)

Pull request description:

Tree-SHA512: 0afd0c0156add54209e79c623d780559dfd85910ef0a0c476bcabd1074ad468d7983b7b6bb6e8bd3fe6e9b8bc703d78d09c3b99f8da990dfe004bbdc65496e66
2018-04-05 14:09:14 -07:00
Andrew Poelstra 7c1b91ba4b parameterize ecmult_const over input size 2018-04-05 21:05:13 +00:00
Pieter Wuille dbc3ddd5e2
Merge #513: Increase sparsity of pippenger fixed window naf representation
ec0a7b3 Don't touch leading zeros in wnaf_fixed. (Jonas Nick)
9e36d1b Fix bug in wnaf_fixed where the wnaf array is not completely zeroed when given a 0 scalar. (Jonas Nick)
96f68a0 Don't invert scalar in wnaf_fixed when it is even because a caller might intentionally give a scalar with many leading zeros. (Jonas Nick)
6dbb007 Increase sparsity of pippenger fixed window naf representation (Jonas Nick)

Pull request description:

  Fixes #506

Tree-SHA512: 49a237a7d09c0c376ba4e6b1f522b9aff2517e420dfef9df810fd5ba920e0b98be8fe3f730b32e41b4aef475bc4cf3b13220024bd8d6f40c2744e6f392ff97a8
2018-04-05 09:46:08 -07:00
Pieter Wuille fb9271dcf0
Merge #510: add a couple missing `const`s to ecmult_pippenger_wnaf
9b3ff03 add a couple missing `const`s to ecmult_pippenger_wnaf (Andrew Poelstra)

Pull request description:

Tree-SHA512: a58458bb4cb1af357b13a506ce8720ce9ecd0c1771a49d9f3ce9398ba7afc56977d722bbd30a63c7c76e63e659ed956d5e82ff762efc4b49488adf0756dc656a
2018-03-26 18:28:56 -07:00
Pieter Wuille cd5f6028e5
Merge #515: Fix typo
9b7c47a Fix typo (Dimitris Apostolou)

Pull request description:

Tree-SHA512: d61f3451152ed6094368456e1c57d7a7ff85f975045bedff4fcb5c446894d9c9029f6ff4bfe724eba8501843316bd965bff1a302a7ea4d1b9c3e4de2059cadd0
2018-03-26 17:18:42 -07:00
Pieter Wuille 09146ae854
Merge #512: secp256k1_ec_privkey_negate - fix documentation
1646ace secp256k1_ec_privkey_negate - fix documentation (Thomas Kerin)

Pull request description:

Tree-SHA512: 711973d3fc4c790cdc469ed5500f857d68fe186d41b97fbbddbc90723b2db60f3ee9fa01b44bcc1a70f246096b85b50ae2139602b98924ddecbcbc6adc7bd217
2018-03-26 17:18:12 -07:00
Jonas Nick ec0a7b3ae3 Don't touch leading zeros in wnaf_fixed. 2018-03-23 14:52:13 +00:00
Jonas Nick 9e36d1bfe2 Fix bug in wnaf_fixed where the wnaf array is not completely zeroed when given a 0 scalar. 2018-03-23 14:52:02 +00:00
Jonas Nick 96f68a0afc Don't invert scalar in wnaf_fixed when it is even because a caller might
intentionally give a scalar with many leading zeros.
2018-03-23 14:51:53 +00:00
Dimitris Apostolou 9b7c47a21e
Fix typo 2018-03-05 18:53:33 +02:00
Jonas Nick 6dbb007869 Increase sparsity of pippenger fixed window naf representation 2018-03-01 18:20:36 +00:00
Thomas Kerin 1646ace4d5
secp256k1_ec_privkey_negate - fix documentation 2018-02-28 14:10:07 +01:00
Andrew Poelstra 9b3ff0309d add a couple missing `const`s to ecmult_pippenger_wnaf 2018-02-24 17:29:34 +00:00
Gregory Maxwell cd329dbc3e
Merge #460: [build] Update ax_jni_include_dir.m4 macro
e7daa9b [build] Tweak JNI macro to warn instead of error for JNI not found. (Karl-Johan Alm)
5b22977 [build] Update ax_jni_include_dir.m4 macro to deal with recent versions of macOS (Karl-Johan Alm)

Pull request description:

  Prior to this patch, this macro fails to find a working directory for the JNI headers, and results in compile failure when doing
  ```
  ./configure --enable-experimental --enable-module-ecdh --enable-jni
  ```
  on more recent macOS versions. The relevant commit upstream is [here](http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=commit;h=ab23d25b1f1ae544fffdaa0a94a794798695c672) from the [GNU.org page for the macro](https://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html). The original (identical to the version in this commit) is [here](http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_jni_include_dir.m4).

  The compile failure:
  ```Bash
  $ make
  gcc -I. -g -O2 -Wall -Wextra -Wno-unused-function -c src/gen_context.c -o gen_context.o
  gcc gen_context.o -o gen_context
  ./gen_context
    CC       src/libsecp256k1_la-secp256k1.lo
    CC       src/java/libsecp256k1_jni_la-org_bitcoin_NativeSecp256k1.lo
  In file included from src/java/org_bitcoin_NativeSecp256k1.c:4:
  In file included from src/java/org_bitcoin_NativeSecp256k1.h:2:
  /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Headers/jni.h:45:10: fatal error:
        'jni_md.h' file not found
  #include "jni_md.h"
           ^
  1 error generated.
  make: *** [src/java/libsecp256k1_jni_la-org_bitcoin_NativeSecp256k1.lo] Error 1
  ```

Tree-SHA512: 9a8305b3ed67eba0de728f91cf435857a676ba10507ab8481a3c03b50e1ce0469a3d79e751d0a697018789f21e2aa48b7eccca4d225520a3863fcf23f1fd487a
2018-02-06 23:08:50 +00:00
Gregory Maxwell 7f9c1a1565
Merge #498: tests: Avoid calling fclose(...) with an invalid argument
5aae5b5 Avoid calling fclose(...) with an invalid argument (practicalswift)

Pull request description:

  Avoid calling `fclose(...)` with an invalid argument.

Tree-SHA512: f1a057b8c52089a3af1d9bfe97b751a4003b944d293147855eca452d1766c4ead5701d06f546153e654c9cb07b3fe2bcc4e28c8a54a27263d1e2434be123ca3b
2018-02-06 23:04:51 +00:00
Gregory Maxwell f99aa8d4d3
Merge #499: tests: Make sure we get the requested number of bytes from /dev/urandom
82a96e4 tests: Make sure we get the requested number of bytes from /dev/urandom (practicalswift)

Pull request description:

  Make sure we get the requested number of bytes from `/dev/urandom`.

Tree-SHA512: 1b035942fd2a6ee2423fb2a2a0a0f294682c51434f86e5c106fb493d77f45aa8070662190aca6441fe389b8cdcc132d432517b8e826be2ac530a1511cd0c8919
2018-02-06 23:00:25 +00:00
Gregory Maxwell b549d3d5f7
Merge #472: [build] Set --enable-jni to no by default instead of auto.
57752d2 [build] Set --enable-jni to no by default instead of auto. (Karl-Johan Alm)

Pull request description:

  Having `--enable-jni` be `auto` doesn't make a lot of sense, and results in things like https://github.com/bitcoin/bitcoin/pull/11056.

Tree-SHA512: 27d6ea041f5d6e249857869ab87b8f7b1f6d18ec5ec82d2c46e692cd690b9f5c5857886725901a29d3539d427d8b6154d0c7909cfa2ce30bb3d4460c05708386
2018-02-06 22:54:03 +00:00
Gregory Maxwell d333521516
Merge #494: Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS
31abd3a Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS (Alexander Block)

Pull request description:

  The only reason OpenSSL 1.1 was not supported was the removal of direct
  access to r and s in ECDSA_SIG. This commit adds a simplified version of
  ECDSA_SIG_get0 for < 1.1 that can be used like ECDSA_SIG_get0 in >= 1.1

Tree-SHA512: 7ee49cd8424086bb96968c632b5babce50af98e13c414c4d5028a30fb86896956f829415a92c66387cde57941ab6999b0db823752cb36dd8932d15dd32980763
2018-02-06 22:49:16 +00:00
Gregory Maxwell 2ef8ea5d21
Merge #495: Add bench_ecmult to .gitignore
cb32940 Add bench_ecmult to .gitignore (Tony Rizko)

Pull request description:

Tree-SHA512: d346d3e99c9bd34a29741652e0f961dfdfce2c97aa8b26744a631a4eebfdf58afa127252b8a1c0772a89db74d1e26f55037794e9c2ab697511a66bffb5991909
2018-02-06 22:30:09 +00:00
practicalswift 82a96e4587 tests: Make sure we get the requested number of bytes from /dev/urandom 2018-01-12 11:24:43 +01:00
practicalswift 5aae5b5bb2 Avoid calling fclose(...) with an invalid argument 2018-01-12 11:18:25 +01:00
Tony Rizko cb32940df3 Add bench_ecmult to .gitignore 2017-12-30 19:59:17 -08:00
Alexander Block 31abd3ab8d Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS
The only reason OpenSSL 1.1 was not supported was the removal of direct
access to r and s in ECDSA_SIG. This commit adds a simplified version of
ECDSA_SIG_get0 for < 1.1 that can be used like ECDSA_SIG_get0 in >= 1.1
2017-12-28 11:36:24 +01:00
Pieter Wuille c95f6f1360
Merge #487: fix tests typo, s/changed/unchanged
0e96cdc fix typo, s/changed/unchanged (Daniel Cousens)

Pull request description:

Tree-SHA512: 023f04d3743318123977d1c4600d664e2b7578ad973db54b9e65629344be087949540b3450ba467de33d319738304a46aa4caae084cfe387fdf87ed8242ac9ce
2017-12-21 14:29:57 -08:00
Pieter Wuille fb46c83881
Merge #463: Reduce usage of hardcoded size constants
c7680e5 Reduce usage of hardcoded size constants (Thomas Snider)

Pull request description:

  In particular the usage of keylen in nonce_function_rfc6979 seemed precarious - in one conditional it was unconditionally set, then in the next it was added to.  While it was clearly correct as written, I think this change makes it easier to reason about for new eyes and more resistant to breakage if there is any future change to what gets fed into the PRNG.

Tree-SHA512: 2241c183acc0f318f85a11ccff7fe28de7777bc53dea93ab8308bad15871047a268c6a2b36f77a599dce536fca48ab305ea746223840bc10953c893daffa0a50
2017-12-21 14:10:50 -08:00