mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 23:16:16 +01:00
1d84107924ab36e38092cae43f6ad50dd5ead9ed
2bfb82bMerge pull request #35106aeea5Turn secp256k1_ec_pubkey_serialize outlen to in/out970164dMerge pull request #3486466625Improvements for coordinate decompressione2100adMerge pull request #3478e48787Change secp256k1_ec_pubkey_combine's count argument to size_t.c69dea0Clear output in more cases for pubkey_combine, adds tests.269d422Comment copyediting.b4d17daMerge pull request #3444709265Merge pull request #34526abce7Adds 32 static test vectors for scalar mul, sqr, inv.5b71a3fBetter error case handling for pubkey_create & pubkey_serialize, more tests.3b7bc69Merge pull request #343eed87afChange contrib/laxder from headers-only to files compilable as standalone Cd7eb1aeMerge pull request #3427914a6eMake lax_der_privatekey_parsing.h not depend on internal code73f64ffMerge pull request #3399234391Overhaul flags handling1a36898Make flags more explicit, add runtime checks.1a3e03aMerge pull request #34096be204Add additional tests for eckey and arg-checks.bb5aa4dMake the tweak function zeroize-output-on-fail behavior consistent.4a243daMove secp256k1_ec_privkey_import/export to contrib.1b3efc1Move secp256k1_ecdsa_sig_recover into the recovery module.e3cd679Eliminate all side-effects from VERIFY_CHECK() usage.b30fc85Avoid nonce_function_rfc6979 algo16 argument emulation.70d4640Make secp256k1_ec_pubkey_create skip processing invalid secret keys.6c476a8Minor comment improvements.131afe5Merge pull request #3340c6ab2fIntroduce explicit lower-S normalizationfea19e7Add contrib/lax_der_parsing.h3bb9c44Rewrite ECDSA signature parsing codefa57f1bUse secp256k1_rand_int and secp256k1_rand_bits more49b3749Add new tests for the extra testrand functionsf684d7dFaster secp256k1_rand_int implementation251b1a6Improve testrand: add extra random functions31994c8Merge pull request #338f79aa88Bugfix: swap arguments to noncefpc98df26Merge pull request #31967f7da4Extensive interface and operations tests for secp256k1_ec_pubkey_parse.ee2cb40Add ARG_CHECKs to secp256k1_ec_pubkey_parse/secp256k1_ec_pubkey_serialize 7450ef1 Merge pull request #32868a3c76Merge pull request #32998135eeMerge pull request #33237100d7improve ECDH header-docb13d749Fix couple of typos in API comments7c823e3travis: fixup module configscc3141aMerge pull request #325ee58faeMerge pull request #326213aa67Do not force benchmarks to be statically linked.338fc8bAdd API exports to secp256k1_nonce_function_default and secp256k1_nonce_function_rfc6979.52fd03fMerge pull request #3209f6993fRemove some dead code.357f8cdMerge pull request #314118cd82Use explicit symbol visibility.4e64608Include public module headers when compiling modules.1f41437Merge pull request #316fe0d463Merge pull request #317cfe0ed9Fix miscellaneous style nits that irritate overactive static analysis.2b199deUse the explicit NULL macro for pointer comparisons.9e90516Merge pull request #294dd891e0Get rid of _t as it is POSIX reserved201819bMerge pull request #313912f203Eliminate a few unbraced statements that crept into the code.eeab823Merge pull request #299486b9bbUse a flags bitfield for compressed option to secp256k1_ec_pubkey_serialize and secp256k1_ec_privkey_export05732c5Callback data: Accept pointers to either const or non-const data1973c73Bugfix: Reinitialise buffer lengths that have been used as outputs788038dUse size_t for lengths (at least in external API)c9d7c2asecp256k1_context_set_{error,illegal}_callback: Restore default handler by passing NULL as function argument9aac008secp256k1_context_destroy: Allow NULL argument as a no-op64b730bsecp256k1_context_create: Use unsigned type for flags bitfieldcb04ab5Merge pull request #309a551669Merge pull request #29581e45ffUpdate group_impl.h85e3a2cMerge pull request #112b2eb63bMerge pull request #293dc0ce9f[API BREAK] Change argument order to out/outin/in6d947caMerge pull request #298c822693Merge pull request #3016d04350Merge pull request #3037ab311cMerge pull request #3045fb3229Fixes a bug where bench_sign would fail due to passing in too small a buffer.263dcbcremove unused assignmentb183b41bugfix: "ARG_CHECK(ctx != NULL)" makes no sense6da1446build: fix parallel build5eb4356Merge pull request #291c996d53Print success9f443beMove pubkey recovery code to separate moduled49abbdSeparate ECDSA recovery tests439d34aSeparate recoverable and normal signaturesa7b046eMerge pull request #289f66907fImprove/reformat API documentation secp256k1.h2f77487Add context building benchmarkscc623d5Merge pull request #287de7e398small typo fix9d96e36Merge pull request #280432e1ceMerge pull request #28314727fdUse correct name in gitignore356b0e9Actually test static precomputation in Travisff3a5dfMerge pull request #2842587208Merge pull request #212a5a66c7Add support for custom EC-Schnorr-SHA256 signaturesd84a378Merge pull request #25272ae443Improve perf. of cmov-based table lookup92e53fcImplement endomorphism optimization for secp256k1_ecmult_consted35d43Make `secp256k1_scalar_add_bit` conditional; make `secp256k1_scalar_split_lambda_var` constant time91c0ce9Add benchmarks for ECDH and const-time multiplication0739bbbAdd ECDH module which works by hashing the output of ecmult_const4401500Add constant-time multiply `secp256k1_ecmult_const` for ECDHe4ce393build: fix hard-coded usage of "gen_context"b8e39acbuild: don't use BUILT_SOURCES for the static context headerbaa75datests: add a couple testsae4f0c6Merge pull request #278995c548Introduce callback functions for dealing with errors.c333074Merge pull request #28218c329cRemove the internal secp256k1_ecdsa_sig_t type74a2acdAdd a secp256k1_ecdsa_signature_t type23cfa91Introduce secp256k1_pubkey_t type4c63780Merge pull request #2693e6f1e2Change rfc6979 implementation to be a generic PRNGed5334aUpdate configure.ac to make it build on OpenBSD1b68366Merge pull request #274a83bb48Make ecmult static precomputation default166b32fMerge pull request #276c37812fAdd gen_context src/ecmult_static_context.h to CLEANFILES to fix distclean.125c15dMerge pull request #27576f6769Fix build with static ecmult altroot and make dist.5133f78Merge pull request #254b0a60e6Merge pull request #258733c1e6Add travis build to test the static context.fbecc38Add ability to use a statically generated ecmult context.4fb174dMerge pull request #263 4ab8990 Merge pull request #270bdf0e0cMerge pull request #27131d0c1fMerge pull request #273eb2c8ffAdd missing casts to SECP256K1_FE_CONST_INNER55399c2Further performance improvements to _ecmult_wnaf99fd963Add secp256k1_ec_pubkey_compress(), with test similar to the related decompress() function.145cc6eImprove performance of _ecmult_wnaf36b305aVerify the result of GMP modular inverse using non-GMP code0cbc860Merge pull request #26606ff7feMerge pull request #2675a43124Save 1 _fe_negate since s1 == -s2a5d796eUpdate code comments3f3964eAdd specific VERIFY tests for _fe_cmov7d054cdRefactor to save a _fe_negateb28d02aRefactor to remove a local var55e7fc3Perf. improvement in _gej_add_gea0601cdFix VERIFY calculations in _fe_cmov methods17f7148Merge pull request #2617657420Add tests for adding P+Q with P.x!=Q.x and P.y=-Q.y8c5d5f7tests: Add failing unit test for #257 (bad addition formula)5de4c5dgej_add_ge: fix degenerate case when computing P + (-lambda)Pbcf2fcfgej_add_ge: rearrange algebrae2a07c7Fix compilation with C++873a453Merge pull request #25091eb0daMerge pull request #247210ffedUse separate in and out pointers in `secp256k1_ec_pubkey_decompress`a1d5ae1Tiny optimization729badfMerge pull request #2102d5a186Apply effective-affine trick to precomp4f9791aEffective affine addition in EC multiplication2b4cf41Use pkg-config always when possible, with failover to manual checks for libcrypto git-subtree-dir: src/secp256k1 git-subtree-split:2bfb82b10e
libsecp256k1
Optimized C library for EC operations on curve secp256k1.
This library is a work in progress and is being used to research best practices. Use at your own risk.
Features:
- secp256k1 ECDSA signing/verification and key generation.
- Adding/multiplying private/public keys.
- Serialization/parsing of private keys, public keys, signatures.
- Constant time, constant memory access signing and pubkey generation.
- Derandomized DSA (via RFC6979 or with a caller provided function.)
- Very efficient implementation.
Implementation details
- General
- No runtime heap allocation.
- Extensive testing infrastructure.
- Structured to facilitate review and analysis.
- Intended to be portable to any system with a C89 compiler and uint64_t support.
- Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.")
- 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.
- 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/x comparison without a field inversion by comparison in the Jacobian coordinate space.
- 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 (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones.
- 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.
- Access the table with branch-free conditional moves so memory access is 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
$ ./tests
$ sudo make install # optional
Description
Languages
C++
64.6%
Python
18.8%
C
12.9%
CMake
1.2%
Shell
0.8%
Other
1.4%