github.com/guiltylotus/go-ethereum@v1.9.7/crypto/secp256k1/libsecp256k1/README.md (about) 1 libsecp256k1 2 ============ 3 4 [![Build Status](https://travis-ci.org/bitcoin-core/secp256k1.svg?branch=master)](https://travis-ci.org/bitcoin-core/secp256k1) 5 6 Optimized C library for EC operations on curve secp256k1. 7 8 This library is a work in progress and is being used to research best practices. Use at your own risk. 9 10 Features: 11 * secp256k1 ECDSA signing/verification and key generation. 12 * Adding/multiplying private/public keys. 13 * Serialization/parsing of private keys, public keys, signatures. 14 * Constant time, constant memory access signing and pubkey generation. 15 * Derandomized DSA (via RFC6979 or with a caller provided function.) 16 * Very efficient implementation. 17 18 Implementation details 19 ---------------------- 20 21 * General 22 * No runtime heap allocation. 23 * Extensive testing infrastructure. 24 * Structured to facilitate review and analysis. 25 * Intended to be portable to any system with a C89 compiler and uint64_t support. 26 * Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.") 27 * Field operations 28 * Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1). 29 * Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys). 30 * Using 10 26-bit limbs. 31 * Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman). 32 * Scalar operations 33 * Optimized implementation without data-dependent branches of arithmetic modulo the curve's order. 34 * Using 4 64-bit limbs (relying on __int128 support in the compiler). 35 * Using 8 32-bit limbs. 36 * Group operations 37 * Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7). 38 * Use addition between points in Jacobian and affine coordinates where possible. 39 * Use a unified addition/doubling formula where necessary to avoid data-dependent branches. 40 * Point/x comparison without a field inversion by comparison in the Jacobian coordinate space. 41 * Point multiplication for verification (a*P + b*G). 42 * Use wNAF notation for point multiplicands. 43 * Use a much larger window for multiples of G, using precomputed multiples. 44 * Use Shamir's trick to do the multiplication with the public key and the generator simultaneously. 45 * Optionally (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones. 46 * Point multiplication for signing 47 * Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions. 48 * Access the table with branch-free conditional moves so memory access is uniform. 49 * No data-dependent branches 50 * 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. 51 52 Build steps 53 ----------- 54 55 libsecp256k1 is built using autotools: 56 57 $ ./autogen.sh 58 $ ./configure 59 $ make 60 $ ./tests 61 $ sudo make install # optional