26 Commits

Author SHA1 Message Date
Pieter Wuille
c47917bbd6 Add ellswift module implementing ElligatorSwift
The scheme implemented is described below, and largely follows the paper
"SwiftEC: Shallue–van de Woestijne Indifferentiable Function To Elliptic Curves",
by Chavez-Saab, Rodriguez-Henriquez, and Tibouchi
(https://eprint.iacr.org/2022/759).

A new 64-byte public key format is introduced, with the property that *every*
64-byte array is an encoding for a non-infinite curve point. Each curve point
has roughly 2^256 distinct encodings. This permits disguising public keys as
uniformly random bytes.

The new API functions:
* secp256k1_ellswift_encode: convert a normal public key to an ellswift 64-byte
  public key, using additional entropy to pick among the many possible
  encodings.
* secp256k1_ellswift_decode: convert an ellswift 64-byte public key to a normal
  public key.
* secp256k1_ellswift_create: a faster and safer equivalent to calling
  secp256k1_ec_pubkey_create + secp256k1_ellswift_encode.
* secp256k1_ellswift_xdh: x-only ECDH directly on ellswift 64-byte public keys,
  where the key encodings are fed to the hash function.

The scheme itself is documented in secp256k1_ellswift.h.
2023-06-20 11:31:58 -04:00
Hennadii Stepanov
1549db0ca5
build: Level up MSVC warnings 2023-05-25 09:43:55 +01:00
Pieter Wuille
95448ef2f8 release cleanup: bump version after 0.3.2 2023-05-13 13:54:32 -04:00
Hennadii Stepanov
c6bb29b303
build: Rename 64bit to x86_64 2023-05-12 10:50:18 +01:00
Hennadii Stepanov
ed4ba238e2
cmake: Add check_arm32_assembly function 2023-05-12 10:38:50 +01:00
Hennadii Stepanov
e5cf4bf3ff
build: Rename arm to arm32 2023-05-11 10:03:23 +01:00
Tim Ruffing
222ecaf661
Merge bitcoin-core/secp256k1#1284: cmake: Some improvements using PROJECT_IS_TOP_LEVEL variable
71f746c057a66d5ae0dfdb5d439bc49592c0d16e cmake: Include `include` directory for subtree builds (Hennadii Stepanov)
5431b9decdbbdf30c5c5f2aed4b59662f5c681a2 cmake: Make `SECP256K1_INSTALL` default depend on `PROJECT_IS_TOP_LEVEL` (Hennadii Stepanov)
162608cc982538906e775d0c549aff2de5dee413 cmake: Emulate `PROJECT_IS_TOP_LEVEL` for CMake<3.21 (Hennadii Stepanov)

Pull request description:

  This PR:
  1. Emulates [`PROJECT_IS_TOP_LEVEL`](https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html) variable for CMake versions where it is not available.
  2. Makes the `SECP256K1_INSTALL` option dependent on `PROJECT_IS_TOP_LEVEL` (a [follow up](https://github.com/bitcoin-core/secp256k1/pull/1263#issuecomment-1516564300) of https://github.com/bitcoin-core/secp256k1/pull/1263).
  3. Makes integration of this project as a subtree easier. A top project can `#include <secp256k1.h>` with no additional `target_include_directories()` commands. For example, see https://github.com/hebasto/secp256k1-CMake-example/tree/subtree.

ACKs for top commit:
  theuni:
    utACK 71f746c057a66d5ae0dfdb5d439bc49592c0d16e.

Tree-SHA512: 8ccdbcc94b26f36e772611ebaab0f2846debd6ad20f9e361be31a8d2128a14273acb692b0631026e12cc6cdef6d445dce0fd3beb4f71af47b46dfcf840a18879
2023-04-27 15:17:38 +01:00
Hennadii Stepanov
a8d059f76c
cmake, doc: Document compiler flags 2023-04-27 14:41:13 +01:00
Hennadii Stepanov
6ece1507cb
cmake, refactor: Rename try_add_compile_option to try_append_cflags
Actually, `try_append_cflags()` can handle a list of flags, and the new
name is similar to the one used in `configure.ac`.
2023-04-27 14:41:13 +01:00
Hennadii Stepanov
5431b9decd
cmake: Make SECP256K1_INSTALL default depend on PROJECT_IS_TOP_LEVEL
Also full stops have been added to the option help texts for consistency
in cmake-gui.
2023-04-21 12:03:04 +01:00
Hennadii Stepanov
162608cc98
cmake: Emulate PROJECT_IS_TOP_LEVEL for CMake<3.21 2023-04-20 23:12:28 +01:00
Hennadii Stepanov
a273d74b2e
cmake: Improve version comparison 2023-04-20 17:03:42 +01:00
Hennadii Stepanov
2445808c02
cmake: Use dedicated GENERATOR_IS_MULTI_CONFIG property
Available in CMake 3.9+.
2023-04-20 17:00:10 +01:00
Hennadii Stepanov
8c2017035a
cmake: Use recommended add_compile_definitions command
Available in CMake 3.12+.
2023-04-20 17:00:10 +01:00
Hennadii Stepanov
04d4cc071a
cmake: Add DESCRIPTION and HOMEPAGE_URL options to project command
`DESCRIPTION` is available in CMake 3.9+.
`HOMEPAGE_URL` is available in CMake 3.12+.
2023-04-20 17:00:10 +01:00
Anna “CyberTailor”
47ac3d63cd
cmake: Make installation optional
Useful for embedding secp256k1 in a subproject.
2023-04-20 19:20:33 +05:00
Tim Ruffing
04bf3f6778
Merge bitcoin-core/secp256k1#1230: Build: allow static or shared but not both
ef49a11d29601e09e94134975c968e92c0214102 build: allow static or shared but not both (Cory Fields)
36b0adf1b90139a41fdcb94390d0bb06e9224795 build: remove warning until it's reproducible (Cory Fields)

Pull request description:

  Continuing from here: https://github.com/bitcoin-core/secp256k1/issues/1224#issuecomment-1460438227

  Unfortunately it wasn't really possible to keep a clean diff here because of the nature of the change. I suggest reviewing the lib creation stuff in its entirety, sorry about that :\

  Rather than allowing for shared and static libs to be built at the same time like autotools, this PR switches to the CMake convention of allowing only 1.

  A new `BUILD_SHARED_LIBS` option is added to match CMake convention, as well as a `SECP256K1_DISABLE_SHARED` option which overrides it. That way even projects which have `BUILD_SHARED_LIBS=1` can opt-into a static libsecp in particular.

  Details:

  Two object libraries are created: `secp256k1_asm` and `secp256k1_precomputed_objs`. Some tests/benchmarks use the object libraries directly, some link against the real lib: `secp256k1`.

  Because the objs don't know what they're going to be linked into, they need to be told how to deal with PIC.

  The `DEFINE_SYMBOL` property sets the `DLL_EXPORT` define as necessary (when building a shared lib)

ACKs for top commit:
  hebasto:
    re-ACK ef49a11d29601e09e94134975c968e92c0214102, only [suggested](https://github.com/bitcoin-core/secp256k1/pull/1230#pullrequestreview-1388191165) changes since my recent [review](https://github.com/bitcoin-core/secp256k1/pull/1230#pullrequestreview-1352125381).
  real-or-random:
    ACK ef49a11d29601e09e94134975c968e92c0214102

Tree-SHA512: 8870de305176fdb677caff0fdfc6f8c59c0e906489cb72bc9980e551002812685e59e20d731f2a82e33628bdfbb7261eafd6f228038cad3ec83bd74335959600
2023-04-18 12:54:03 +02:00
Cory Fields
ef49a11d29 build: allow static or shared but not both 2023-04-17 16:25:27 +00:00
Jonas Nick
656c6ea8d8
release cleanup: bump version after 0.3.1 2023-04-10 19:50:27 +00:00
Jonas Nick
afd8b23b27
Merge bitcoin-core/secp256k1#1244: Suppress -Wunused-parameter when building for coverage analysis
5bb03c29116409ace8855e64bf2e2b2d45871469 Replace `SECP256K1_ECMULT_TABLE_VERIFY` macro by a function (Hennadii Stepanov)
4429a8c218d7bf7bc6de1de88bc31c834f771385 Suppress `-Wunused-parameter` when building for coverage analysis (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK 5bb03c29116409ace8855e64bf2e2b2d45871469
  jonasnick:
    ACK 5bb03c29116409ace8855e64bf2e2b2d45871469

Tree-SHA512: 19a395434ecefea201a03fc45b3f0b88f1520908926ac1207bbc6570034b1141b49c3c98e66819dcd9069dfdd28c7c6fbe957f13fb6bd178fd57ce65bfbb8fbd
2023-03-28 07:18:23 +00:00
Hennadii Stepanov
4429a8c218
Suppress -Wunused-parameter when building for coverage analysis 2023-03-14 20:03:42 +00:00
Cory Fields
96dd062511 build: bump CMake minimum requirement to 3.13
Among other things this allows us to link against object libraries.
2023-03-12 19:03:39 +00:00
Jonas Nick
28e63f7ea7
release cleanup: bump version after 0.3.0 2023-03-08 22:07:11 +00:00
Jonas Nick
b40adf2360
release: prepare for 0.3.0 2023-03-08 22:00:43 +00:00
Hennadii Stepanov
8be82d4362
cmake: Rename project to "libsecp256k1" 2023-03-08 21:22:24 +00:00
Hennadii Stepanov
5468d70964
build: Add CMake-based build system
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2023-03-08 13:33:16 +00:00