LIBSECP256K1 Library compilation +jni Library compilation--bitcoin__secp256k1

Source: Internet
Author: User
Tags arithmetic generator scalar

Original: HTTPS://GITHUB.COM/BITCOIN-CORE/SECP256K1

Download the source file first.

Here is a excerpt:

Optimized C library for EC operations on Curve secp256k1.

This are a work in progress and are being used to the 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 is portable to no system with a C89 compiler and uint64_t support. Expose only higher level interfaces to minimize the API surface and improve security. ("is 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 Ten 26-bit limbs. The Field inverses and square roots using a sliding window over blocks of 1s (by Peter dettman). Scalar operations optimized implementation without data-dependent branches the arithmetic ' s order. Using 4 64-bit limbs (relying on __int128 support in the compiler). Using 8 32-bit limbs. 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. point/x comparison without a field inversion by comparison in the Jacobian. 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-si Zed ones. Point multiplication to signing use a precomputed table of multiples of powers of multiplied to the generator, so GE Neral 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 ke Y) is known,Preventing even an attacker the private key used to control the data internally. Linux Build Steps

LIBSECP256K1 is built using Autotools:

./autogen.sh
./configure
make
/tests
sudo make install  # Optional
The above is compiled standard library.

The Secp256k1-master/src/java includes a library file that generates JNI for Java calls to the SECP256K1 library, which requires compilation builds.

./autogen.sh
./sudo./configure  --enable-jni--ENABLE-MODULE_ECDH--enable-experimental
make
./ Tests
sudo make install  # Optional
The last generated file can be viewed in secp256k1-master/.libs

Windows Build Steps

LIBSECP256K1 Windows compilation; In the source file directory: E:\work\secp256k1-master\builds\msvc contains several paths


Here are several versions of Visual Studio's compilation environment (I am using Visual Studio 2012);


Open file see three projects,


The SECP256K1 is compiled first, and the build Secp256k1.dll,secp256k1.lib is saved in the \secp256k1-master\bin\win32\debug\v110\dynamic path.


Create a new DLL project, compile a JNI file, add a file from the \work\secp256k1-master\src\java to the project, and configure the path


Add the secp256k1.dll,secp256k1.lib to the project;


Finally, the dynamic library is generated.









Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.