mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-11 08:06:06 +01:00
87bddb7a3a83aaad96b5b54b4bac34d8a71b3810
b0210a9Merge pull request #135ee3eb4bFix a memory leak and add a number of small tests.4d879a3Merge pull request #134d5e8362Merge pull request #1277b92cf6Merge pull request #1320bf70a5Merge pull request #13329ae131Make scalar_add_bit test's overflow detection exact9048defAvoid undefined shift behaviourefb7d4bUse constant-time conditional moves instead of byte slicingd220062Merge pull request #13182f9254Fix typo601ca04Merge pull request #12935399e0Bugfix: b is restricted, not rc35ff1eConvert lambda splitter to pure scalar code.cc604e9Avoid division when decomposing scalarsff8746dAdd secp256k1_scalar_mul_shift_varbd313f7Merge pull request #119276f987Merge pull request #12425d125eMerge pull request #12624b3c65Add a test case for ECDSA recomputing infinity32600e5Add a test for r >= order signature handling4d4eeeaMake secp256k1_fe_mul_inner use the r != propertybe82e92Require that r and b are different for field multiplication.597128dMake num optional659b554Make constant initializers independent from num0af5b47Merge pull request #120e2e8a36Merge pull request #117c76be9eRemove unused num functions4285a98Move lambda-splitting code to scalar.f24041dSwitch all EC/ECDSA logic from num to scalar6794be6Add scalar splitting functionsd1502ebAdd secp256k1_scalar_inverse_var which delegates to GMPb5c9ee7Make test_point_times_order test meaningful again0b73059Switch wnaf splitting from num-based to scalar-based1e6c77cGeneralize secp256k1_scalar_get_bits5213207Add secp256k1_scalar_add_bit3c0ae43Merge pull request #1226e05287Do signature recovery/verification with 4 possible recid casee3d692fExplain why no y=0 check is necessary for doublingf7dc1c6Optimize doubling: secp256k1 has no y=0 point666d3b5Merge pull request #1212a54f9bCorrect typo in comment9d64145Merge pull request #11499f0728Fix secp256k1_num_set_bin handling of 0d907ebcAdd bounds checking to field element settersbb2cd94Merge pull request #116665775bDon't split the g factor when not using endomorphism9431d6bMerge pull request #115e2274c5build: osx: attempt to work with homebrew keg-only packages git-subtree-dir: src/secp256k1 git-subtree-split:b0210a95da
libsecp256k1
Optimized C library for EC operations on curve secp256k1.
This library is experimental, so use at your own risk.
Features:
- Low-level field and group operations on secp256k1.
- ECDSA signing/verification and key generation.
- Adding/multiplying private/public keys.
- Serialization/parsing of private keys, public keys, signatures.
- Very efficient implementation.
Implementation details
- General
- Avoid dynamic memory usage almost everywhere.
- Field operations
- Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
- Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys).
- Using 10 26-bit limbs.
- Using GMP.
- Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman).
- Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
- Scalar operations
- Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
- Using 4 64-bit limbs (relying on __int128 support in the compiler).
- Using 8 32-bit limbs.
- Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
- Group operations
- Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7).
- Use addition between points in Jacobian and affine coordinates where possible.
- Use a unified addition/doubling formula where necessary to avoid data-dependent branches.
- Point multiplication for verification (aP + bG).
- Use wNAF notation for point multiplicands.
- Use a much larger window for multiples of G, using precomputed multiples.
- Use Shamir's trick to do the multiplication with the public key and the generator simultaneously.
- Optionally use secp256k1's efficiently-computable endomorphism to split the multiplicands into 4 half-sized ones first.
- Point multiplication for signing
- Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions.
- Slice the precomputed table in memory per byte, so memory access to the table becomes uniform.
- No data-dependent branches
- The precomputed tables add and eventually subtract points for which no known scalar (private key) is known, preventing even an attacker with control over the private key used to control the data internally.
Build steps
libsecp256k1 is built using autotools:
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install # optional
Description
Languages
C++
64.5%
Python
18.9%
C
12.9%
CMake
1.2%
Shell
0.8%
Other
1.6%