Commit Graph

29 Commits

Author SHA1 Message Date
Tim Ruffing 0559fc6e41
Merge bitcoin-core/secp256k1#988: Make signing table fully static
7dfceceea6 build: Remove #undef hack for ASM in the precomputation programs (Tim Ruffing)
bb36fe9be0 ci: Test `make precomp` (Tim Ruffing)
d94a37a20c build: Remove CC_FOR_BUILD stuff (Tim Ruffing)
ad63bb4c29 build: Prebuild and distribute ecmult_gen table (Tim Ruffing)
ac49361ed0 prealloc: Get rid of manual memory management for prealloc contexts (Tim Ruffing)
6573c08f65 ecmult_gen: Tidy precomputed file and save space (Tim Ruffing)
5eba83f17c ecmult_gen: Precompute tables for all values of ECMULT_GEN_PREC_BITS (Tim Ruffing)
fdb33dd122 refactor: Make PREC_BITS a parameter of ecmult_gen_build_prec_table (Tim Ruffing)
a4875e30a6 refactor: Move default callbacks to util.h (Tim Ruffing)
4c94c55bce doc: Remove obsolete hint for valgrind stack size (Tim Ruffing)
5106226991 exhaustive_tests: Fix with ecmult_gen table with custom generator (Tim Ruffing)
e1a76530db refactor: Make generator a parameter of ecmult_gen_create_prec_table (Tim Ruffing)
9ad09f6911 refactor: Rename program that generates static ecmult_gen table (Tim Ruffing)
8ae18f1ab3 refactor: Rename file that contains static ecmult_gen table (Tim Ruffing)
00d2fa116e ecmult_gen: Make code consistent with comment (Tim Ruffing)
3b0c2185ea ecmult_gen: Simplify ecmult_gen context after making table static (Tim Ruffing)
e43ba02cfc refactor: Decouple table generation and ecmult_gen context (Tim Ruffing)
22dc2c0a0d ecmult_gen: Move table creation to new file and force static prec (Tim Ruffing)

Pull request description:

  This resolves #893,  resolves #692 (and also resolves bitcoin/bitcoin#22854).

  - [x] Extract table generation to separate function in separate file (to be used by generation script and exhaustive tests)
  - [x] Tidy up
    - [x] Remove code that deals with non-static tables
    - [x] Make functions that need ecmult_gen not depend on signing context
    - [x] Rename stuff to make it fit the new structure and consistent with how we hande verification tables (#956)
  - [x] Fix exhaustive tests
    - [x] Make table generation function take generator as input
    - [x] Overwrite the static tables with a table with custom generator in exhaustive tests
  - [x] Overhaul script that generates table files
    - [x] Make table generation function take PREC_BITS as input (I have some code already, just not yet in this branch)
    - [x] Change generation script to generate three tables (for all three values of ECMULT_GEN_PREC_BITS)
  - [x] Ship pre-built tables
    - [x] Add pregenerated table file to repo
    - [x] Remove generation of table file from build process (like in #956)
    - [x] Remove left-over stuff (e.g., detecting a compiler running on the build machine) from build system
  - [x] Final cleanups (copyright headers, commit, messages, etc.)
  - [ ] (separate PR:) Make sure link-time optimization remove corresponding static tables (and code) when no signing/verifcation function is called
  - [ ] (separate PR:) Compile precomputation as a separate object file and link it (https://github.com/bitcoin-core/secp256k1/pull/988#issuecomment-977813538)
  - [ ] (separate PR:) Document the backwards-compatible API changes made in this PR and in #956.
    - [ ] Maybe deprecate the static context

ACKs for top commit:
  sipa:
    ACK 7dfceceea6
  robot-dreams:
    ACK 7dfceceea6 (based on range-diff between 56284c7d44c0ed46e636588bfbf6c403b7dfa6c1 and 7dfceceea6)

Tree-SHA512: 6efb3f36f05efe3b79bbd877881fe1409f71fd6488d24c811b2e77d9f053bed78670dd1dcbb42ad780458a51c4ffa36de9cd6567271b22041dc7a122ceb677c5
2021-12-15 11:06:47 +01:00
Tim Ruffing d94a37a20c build: Remove CC_FOR_BUILD stuff 2021-12-09 20:52:28 +01:00
Hennadii Stepanov 7c7ce872a5
build: Add a check that Valgrind actually supports a host platform 2021-12-03 17:32:26 +02:00
Pieter Wuille bc08599e77 Remove OpenSSL testing support 2021-10-14 12:39:27 -04:00
Tim Ruffing 07256267ff build: Use own variable SECP_CFLAGS instead of touching user CFLAGS
Fixes one of the items in #923, namely the warnings of the form
    '_putenv' redeclared without dllimport attribute:
    previous dllimport ignored [-Wattributes]

This also cleans up the way we add CFLAGS, in particular flags enabling
warnings. Now we perform some more fine-grained checking for flag
support, which is not strictly necessary but the changes also help to
document autoconf.ac.
2021-07-01 19:58:44 +02:00
Pieter Wuille 1f233b3fa0 Remove num/gmp support
The whole "num" API and its libgmp-based implementation are now unused. Remove them.
2021-03-15 13:01:52 -07:00
Tim Ruffing 252c19dfc6 Ask brew for valgrind include path
Valgrind is typically installed using brew on macOS. This commit
makes ./configure detect this case set the appropriate include
directory (in the same way as we already do for openssl and gmp).
2021-01-08 14:24:34 +01:00
Dimitris Apostolou 07aa4c70ff
Fix insecure links 2020-12-18 00:24:22 +02:00
Elichai Turkel e6692778d3
Modify bitcoin_secp.m4's openssl check to call all the functions that we
use in the tests/benchmarks.
That way linking will fail if those symbols are missing
2020-10-25 13:42:25 +02:00
Pieter Wuille 79f1f7a4f1 Autodetect __int128 availability on the C side
Instead of supporting configuration of the field and scalar size independently,
both are now controlled by the availability of a 64x64->128 bit multiplication
(currently only through __int128). This is autodetected from the C code through
__SIZEOF_INT128__, but can be overridden using configure's
--with-test-override-wide-multiply, or by defining
USE_FORCE_WIDEMUL_{INT64,INT128} manually.
2020-08-10 14:56:39 -07:00
fanquake 84b5fc5bc3
build: fix OpenSSL EC detection on macOS 2020-04-09 17:14:06 +08:00
Jonas Nick 642cd062bd Remove Java Native Interface 2020-01-08 09:13:09 +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
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
Karl-Johan Alm e7daa9b3c2
[build] Tweak JNI macro to warn instead of error for JNI not found. 2017-07-06 18:06:51 +09:00
Karl-Johan Alm 5b22977922
[build] Update ax_jni_include_dir.m4 macro to deal with recent versions of macOS 2017-07-06 18:04:52 +09:00
Gregory Maxwell 12de86387f Make the libcrypto detection fail the newer API.
OpenSSL 1.1 makes ECDSA_SIG opaque and our tests need access
inside this object.

The comparison tests against OpenSSL aren't important for most
users, but the build failing is...
2016-12-12 07:56:01 +00:00
Pieter Wuille 7b549b1abc
Merge #373: build: fix x86_64 asm detection for some compilers
3f8fdfb build: fix x86_64 asm detection for some compilers (Cory Fields)
2016-02-16 20:44:41 +01:00
GreenAddress 3093576aa4 JNI library
Squashed and rebased. Thanks to @theuni and @faizkhan00 for doing
the majority of work here! Also thanks to @btchip for help with debugging
and review.
2016-02-01 14:07:18 +01:00
Cory Fields 3f8fdfbec1 build: fix x86_64 asm detection for some compilers
I Noticed this on OSX with clang, though it likely happens elsewhere as well.
The result is disabled x86_64 asm.

Due to missing escaping, this $0 was interpreted as the function name
SECP_64BIT_ASM_CHECK, causing the compile-check to be broken on some compilers.

The actual check looked like this:

int main()
{
  uint64_t a = 11, tmp;
  __asm__ __volatile__("movq SECP_64BIT_ASM_CHECKx100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
  return 0;
}

It seems even more odd that it compiled anywhere.
2016-01-04 11:40:00 -05:00
Pieter Wuille 85e3a2cc08
Merge pull request #112
2b4cf41 Use pkg-config always when possible, with failover to manual checks for libcrypto (Luke Dashjr)
2015-09-04 20:24:42 +02:00
Thomas Daede fbecc38a89 Add ability to use a statically generated ecmult context.
This vastly shrinks the size of the context required for signing on devices with
memory-mapped Flash.

Tables are generated by the new gen_context tool into a header.
2015-07-13 18:00:03 -07:00
Luke Dashjr 2b4cf416e7 Use pkg-config always when possible, with failover to manual checks for libcrypto 2015-02-13 23:44:07 +00:00
Pieter Wuille 1ba4a60a51 Configure options reorganization 2014-12-13 15:04:28 +01:00
Cory Fields 28ade27da1 build: nuke bashisms 2014-12-11 21:24:35 -05:00
Cory Fields 971fe8151b build: fix openssl detection for cross builds
Make sure that the detected openssl successfully links before enabling support.
2014-12-10 13:21:50 -05:00
Pieter Wuille 67935050e1 Convert YASM code into inline assembly 2014-12-04 13:54:01 +01:00
Cory Fields e2274c58e6 build: osx: attempt to work with homebrew keg-only packages 2014-11-24 11:49:22 -05:00
kiwigb 6fac238f03 Use same build template as bitcoin. Add bitcoin_secp.m4. 2014-11-07 01:55:27 +13:00