Skip to content

Commit 2620cc2

Browse files
committed
update readme
1 parent 340e6b8 commit 2620cc2

File tree

2 files changed

+159
-155
lines changed

2 files changed

+159
-155
lines changed

README-orig.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
libsecp256k1
2+
============
3+
4+
[![Build Status](https://api.cirrus-ci.com/github/bitcoin-core/secp256k1.svg?branch=master)](https://cirrus-ci.com/github/bitcoin-core/secp256k1)
5+
![Dependencies: None](https://img.shields.io/badge/dependencies-none-success)
6+
[![irc.libera.chat #secp256k1](https://img.shields.io/badge/irc.libera.chat-%23secp256k1-success)](https://web.libera.chat/#secp256k1)
7+
8+
Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.
9+
10+
This library is intended to be the highest quality publicly available library for cryptography on the secp256k1 curve. However, the primary focus of its development has been for usage in the Bitcoin system and usage unlike Bitcoin's may be less well tested, verified, or suffer from a less well thought out interface. Correct usage requires some care and consideration that the library is fit for your application's purpose.
11+
12+
Features:
13+
* secp256k1 ECDSA signing/verification and key generation.
14+
* Additive and multiplicative tweaking of secret/public keys.
15+
* Serialization/parsing of secret keys, public keys, signatures.
16+
* Constant time, constant memory access signing and public key generation.
17+
* Derandomized ECDSA (via RFC6979 or with a caller provided function.)
18+
* Very efficient implementation.
19+
* Suitable for embedded systems.
20+
* No runtime dependencies.
21+
* Optional module for public key recovery.
22+
* Optional module for ECDH key exchange.
23+
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
24+
25+
Implementation details
26+
----------------------
27+
28+
* General
29+
* No runtime heap allocation.
30+
* Extensive testing infrastructure.
31+
* Structured to facilitate review and analysis.
32+
* Intended to be portable to any system with a C89 compiler and uint64_t support.
33+
* No use of floating types.
34+
* Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.")
35+
* Field operations
36+
* Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
37+
* Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys).
38+
* Using 10 26-bit limbs (including hand-optimized assembly for 32-bit ARM, by Wladimir J. van der Laan).
39+
* This is an experimental feature that has not received enough scrutiny to satisfy the standard of quality of this library but is made available for testing and review by the community.
40+
* Scalar operations
41+
* Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
42+
* Using 4 64-bit limbs (relying on __int128 support in the compiler).
43+
* Using 8 32-bit limbs.
44+
* Modular inverses (both field elements and scalars) based on [safegcd](https://gcd.cr.yp.to/index.html) with some modifications, and a variable-time variant (by Peter Dettman).
45+
* Group operations
46+
* Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7).
47+
* Use addition between points in Jacobian and affine coordinates where possible.
48+
* Use a unified addition/doubling formula where necessary to avoid data-dependent branches.
49+
* Point/x comparison without a field inversion by comparison in the Jacobian coordinate space.
50+
* Point multiplication for verification (a*P + b*G).
51+
* Use wNAF notation for point multiplicands.
52+
* Use a much larger window for multiples of G, using precomputed multiples.
53+
* Use Shamir's trick to do the multiplication with the public key and the generator simultaneously.
54+
* Use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones.
55+
* Point multiplication for signing
56+
* Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions.
57+
* Intended to be completely free of timing sidechannels for secret-key operations (on reasonable hardware/toolchains)
58+
* Access the table with branch-free conditional moves so memory access is uniform.
59+
* No data-dependent branches
60+
* Optional runtime blinding which attempts to frustrate differential power analysis.
61+
* The precomputed tables add and eventually subtract points for which no known scalar (secret key) is known, preventing even an attacker with control over the secret key used to control the data internally.
62+
63+
Building with Autotools
64+
-----------------------
65+
66+
$ ./autogen.sh
67+
$ ./configure
68+
$ make
69+
$ make check # run the test suite
70+
$ sudo make install # optional
71+
72+
To compile optional modules (such as Schnorr signatures), you need to run `./configure` with additional flags (such as `--enable-module-schnorrsig`). Run `./configure --help` to see the full list of available flags.
73+
74+
Building with CMake (experimental)
75+
----------------------------------
76+
77+
To maintain a pristine source tree, CMake encourages to perform an out-of-source build by using a separate dedicated build tree.
78+
79+
### Building on POSIX systems
80+
81+
$ mkdir build && cd build
82+
$ cmake ..
83+
$ make
84+
$ make check # run the test suite
85+
$ sudo make install # optional
86+
87+
To compile optional modules (such as Schnorr signatures), you need to run `cmake` with additional flags (such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON`). Run `cmake .. -LH` to see the full list of available flags.
88+
89+
### Cross compiling
90+
91+
To alleviate issues with cross compiling, preconfigured toolchain files are available in the `cmake` directory.
92+
For example, to cross compile for Windows:
93+
94+
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake
95+
96+
To cross compile for Android with [NDK](https://developer.android.com/ndk/guides/cmake) (using NDK's toolchain file, and assuming the `ANDROID_NDK_ROOT` environment variable has been set):
97+
98+
$ cmake .. -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=28
99+
100+
### Building on Windows
101+
102+
To build on Windows with Visual Studio, a proper [generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators) must be specified for a new build tree.
103+
104+
The following example assumes using of Visual Studio 2022 and CMake v3.21+.
105+
106+
In "Developer Command Prompt for VS 2022":
107+
108+
>cmake -G "Visual Studio 17 2022" -A x64 -S . -B build
109+
>cmake --build build --config RelWithDebInfo
110+
111+
Usage examples
112+
-----------
113+
Usage examples can be found in the [examples](examples) directory. To compile them you need to configure with `--enable-examples`.
114+
* [ECDSA example](examples/ecdsa.c)
115+
* [Schnorr signatures example](examples/schnorr.c)
116+
* [Deriving a shared secret (ECDH) example](examples/ecdh.c)
117+
118+
To compile the Schnorr signature and ECDH examples, you also need to configure with `--enable-module-schnorrsig` and `--enable-module-ecdh`.
119+
120+
Test coverage
121+
-----------
122+
123+
This library aims to have full coverage of the reachable lines and branches.
124+
125+
To create a test coverage report, configure with `--enable-coverage` (use of GCC is necessary):
126+
127+
$ ./configure --enable-coverage
128+
129+
Run the tests:
130+
131+
$ make check
132+
133+
To create a report, `gcovr` is recommended, as it includes branch coverage reporting:
134+
135+
$ gcovr --exclude 'src/bench*' --print-summary
136+
137+
To create a HTML report with coloured and annotated source code:
138+
139+
$ mkdir -p coverage
140+
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
141+
142+
Benchmark
143+
------------
144+
If configured with `--enable-benchmark` (which is the default), binaries for benchmarking the libsecp256k1 functions will be present in the root directory after the build.
145+
146+
To print the benchmark result to the command line:
147+
148+
$ ./bench_name
149+
150+
To create a CSV file for the benchmark result :
151+
152+
$ ./bench_name | sed '2d;s/ \{1,\}//g' > bench_name.csv
153+
154+
Reporting a vulnerability
155+
------------
156+
157+
See [SECURITY.md](SECURITY.md)

README.md

Lines changed: 2 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,4 @@
1-
libsecp256k1
2-
============
1+
# secp256k1-export
32

4-
[![Build Status](https://api.cirrus-ci.com/github/bitcoin-core/secp256k1.svg?branch=master)](https://cirrus-ci.com/github/bitcoin-core/secp256k1)
5-
![Dependencies: None](https://img.shields.io/badge/dependencies-none-success)
6-
[![irc.libera.chat #secp256k1](https://img.shields.io/badge/irc.libera.chat-%23secp256k1-success)](https://web.libera.chat/#secp256k1)
3+
The Bitcoin [secp256k1](https://github.com/bitcoin-core/secp256k1) library, modified to export scalar and point manipulation functions.
74

8-
Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.
9-
10-
This library is intended to be the highest quality publicly available library for cryptography on the secp256k1 curve. However, the primary focus of its development has been for usage in the Bitcoin system and usage unlike Bitcoin's may be less well tested, verified, or suffer from a less well thought out interface. Correct usage requires some care and consideration that the library is fit for your application's purpose.
11-
12-
Features:
13-
* secp256k1 ECDSA signing/verification and key generation.
14-
* Additive and multiplicative tweaking of secret/public keys.
15-
* Serialization/parsing of secret keys, public keys, signatures.
16-
* Constant time, constant memory access signing and public key generation.
17-
* Derandomized ECDSA (via RFC6979 or with a caller provided function.)
18-
* Very efficient implementation.
19-
* Suitable for embedded systems.
20-
* No runtime dependencies.
21-
* Optional module for public key recovery.
22-
* Optional module for ECDH key exchange.
23-
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
24-
25-
Implementation details
26-
----------------------
27-
28-
* General
29-
* No runtime heap allocation.
30-
* Extensive testing infrastructure.
31-
* Structured to facilitate review and analysis.
32-
* Intended to be portable to any system with a C89 compiler and uint64_t support.
33-
* No use of floating types.
34-
* Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.")
35-
* Field operations
36-
* Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
37-
* Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys).
38-
* Using 10 26-bit limbs (including hand-optimized assembly for 32-bit ARM, by Wladimir J. van der Laan).
39-
* This is an experimental feature that has not received enough scrutiny to satisfy the standard of quality of this library but is made available for testing and review by the community.
40-
* Scalar operations
41-
* Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
42-
* Using 4 64-bit limbs (relying on __int128 support in the compiler).
43-
* Using 8 32-bit limbs.
44-
* Modular inverses (both field elements and scalars) based on [safegcd](https://gcd.cr.yp.to/index.html) with some modifications, and a variable-time variant (by Peter Dettman).
45-
* Group operations
46-
* Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7).
47-
* Use addition between points in Jacobian and affine coordinates where possible.
48-
* Use a unified addition/doubling formula where necessary to avoid data-dependent branches.
49-
* Point/x comparison without a field inversion by comparison in the Jacobian coordinate space.
50-
* Point multiplication for verification (a*P + b*G).
51-
* Use wNAF notation for point multiplicands.
52-
* Use a much larger window for multiples of G, using precomputed multiples.
53-
* Use Shamir's trick to do the multiplication with the public key and the generator simultaneously.
54-
* Use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones.
55-
* Point multiplication for signing
56-
* Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions.
57-
* Intended to be completely free of timing sidechannels for secret-key operations (on reasonable hardware/toolchains)
58-
* Access the table with branch-free conditional moves so memory access is uniform.
59-
* No data-dependent branches
60-
* Optional runtime blinding which attempts to frustrate differential power analysis.
61-
* The precomputed tables add and eventually subtract points for which no known scalar (secret key) is known, preventing even an attacker with control over the secret key used to control the data internally.
62-
63-
Building with Autotools
64-
-----------------------
65-
66-
$ ./autogen.sh
67-
$ ./configure
68-
$ make
69-
$ make check # run the test suite
70-
$ sudo make install # optional
71-
72-
To compile optional modules (such as Schnorr signatures), you need to run `./configure` with additional flags (such as `--enable-module-schnorrsig`). Run `./configure --help` to see the full list of available flags.
73-
74-
Building with CMake (experimental)
75-
----------------------------------
76-
77-
To maintain a pristine source tree, CMake encourages to perform an out-of-source build by using a separate dedicated build tree.
78-
79-
### Building on POSIX systems
80-
81-
$ mkdir build && cd build
82-
$ cmake ..
83-
$ make
84-
$ make check # run the test suite
85-
$ sudo make install # optional
86-
87-
To compile optional modules (such as Schnorr signatures), you need to run `cmake` with additional flags (such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON`). Run `cmake .. -LH` to see the full list of available flags.
88-
89-
### Cross compiling
90-
91-
To alleviate issues with cross compiling, preconfigured toolchain files are available in the `cmake` directory.
92-
For example, to cross compile for Windows:
93-
94-
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake
95-
96-
To cross compile for Android with [NDK](https://developer.android.com/ndk/guides/cmake) (using NDK's toolchain file, and assuming the `ANDROID_NDK_ROOT` environment variable has been set):
97-
98-
$ cmake .. -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=28
99-
100-
### Building on Windows
101-
102-
To build on Windows with Visual Studio, a proper [generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators) must be specified for a new build tree.
103-
104-
The following example assumes using of Visual Studio 2022 and CMake v3.21+.
105-
106-
In "Developer Command Prompt for VS 2022":
107-
108-
>cmake -G "Visual Studio 17 2022" -A x64 -S . -B build
109-
>cmake --build build --config RelWithDebInfo
110-
111-
Usage examples
112-
-----------
113-
Usage examples can be found in the [examples](examples) directory. To compile them you need to configure with `--enable-examples`.
114-
* [ECDSA example](examples/ecdsa.c)
115-
* [Schnorr signatures example](examples/schnorr.c)
116-
* [Deriving a shared secret (ECDH) example](examples/ecdh.c)
117-
118-
To compile the Schnorr signature and ECDH examples, you also need to configure with `--enable-module-schnorrsig` and `--enable-module-ecdh`.
119-
120-
Test coverage
121-
-----------
122-
123-
This library aims to have full coverage of the reachable lines and branches.
124-
125-
To create a test coverage report, configure with `--enable-coverage` (use of GCC is necessary):
126-
127-
$ ./configure --enable-coverage
128-
129-
Run the tests:
130-
131-
$ make check
132-
133-
To create a report, `gcovr` is recommended, as it includes branch coverage reporting:
134-
135-
$ gcovr --exclude 'src/bench*' --print-summary
136-
137-
To create a HTML report with coloured and annotated source code:
138-
139-
$ mkdir -p coverage
140-
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
141-
142-
Benchmark
143-
------------
144-
If configured with `--enable-benchmark` (which is the default), binaries for benchmarking the libsecp256k1 functions will be present in the root directory after the build.
145-
146-
To print the benchmark result to the command line:
147-
148-
$ ./bench_name
149-
150-
To create a CSV file for the benchmark result :
151-
152-
$ ./bench_name | sed '2d;s/ \{1,\}//g' > bench_name.csv
153-
154-
Reporting a vulnerability
155-
------------
156-
157-
See [SECURITY.md](SECURITY.md)

0 commit comments

Comments
 (0)