libsecp256k1 库编译+jni库编译--bitcoin

原文:https://github.com/bitcoin-core/secp256k1

先下载源文件。

以下是摘抄:

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).
  • 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.
  • 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.

Linux Build steps

libsecp256k1 is built using autotools:

./autogen.sh
./configure
make
./tests
sudo make install  # optional
上面是编译标准库的。

在secp256k1-master/src/java中包括生成java调用secp256k1库的jni的库文件,需要编译生成。

./autogen.sh
./ sudo ./configure  --enable-jni --enable-module_ecdh --enable-experimental
make
./tests
sudo make install  # optional
最后生成的文件在secp256k1-master/.libs中可以查看

Windows Build steps

libsecp256k1 Windows下编译;在源文件目录中:E:\work\secp256k1-master\builds\msvc包含几个路径


这里有几个Visual Studio版本的编译环境(我使用的是Visual Studio 2012);


打开文件看到三个工程,


首先编译secp256K1,生成secp256k1.dll,secp256k1.lib保存在\secp256k1-master\bin\Win32\Debug\v110\dynamic路径中。


新建dll工程,编译jni文件;将\work\secp256k1-master\src\java中的文件添加到工程中;配置好路径


secp256k1.dll,secp256k1.lib添加到工程中;


最后生成动态库。









  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
### 回答1: linux-android-韦根驱动 jni.rar 是一个文件名,其中包含了与韦根驱动相关的文件。 Linux是一种开源的操作系统,广泛应用于各种计算机设备。它具有优秀的稳定性、安全性和可定制性。Android是基于Linux内核开发的移动操作系统,目前在智能手机等智能设备上广泛使用。 韦根(Wiegand)驱动是一种用于读取磁卡、感应卡等卡片数据的驱动程序。它使用韦根协议来传输卡片的数据。韦根协议是一种串行通信协议,常用于门禁系统、考勤系统等场景中。这个驱动程序可以使得Linux系统和Android系统能够读取和处理韦根卡片的数据。 JNI(Java Native Interface)是一种Java编程语言的编程框架,用于在Java程序中调用其他语言(如C/C++)编写的本地代码。在这里,JNI用来链接Linux或Android系统的驱动程序和Java程序之间的接口。通过JNI,Java程序可以调用韦根驱动的功能,读取韦根卡片的数据并进行相应的处理。 而 ".rar" 则是一种常见的文件压缩格式,它可以将多个文件或文件夹压缩成一个单独的文件,以方便传输和存储。所以,"linux-android-韦根驱动 jni.rar" 这个文件可能是包含了与韦根驱动功能相关的Linux和Android系统驱动程序以及JNI接口的压缩文件。 ### 回答2: "linux-android-韦根驱动 jni.rar" 是一个压缩文件,包含了用于在 Linux 和 Android 系统上支持韦根驱动的 JNI(Java Native Interface)代码。 Linux 是一个开源的操作系统内核,Android 则是基于 Linux 内核开发的移动设备操作系统。韦根驱动是一种用于读取条码信息的通信协议,常用于条码扫描仪等设备。 这个压缩文件包含了 JNI 的相关代码,JNI 是 Java 提供的机制,用于在 Java 程序中调用本地(C/C++)代码。由于韦根驱动是由本地代码实现的,所以需要使用 JNI 将其与 Java 程序进行交互。 在 Linux 系统上,可以使用这个 JNI 文件来编译并生成与韦根驱动相关的动态链接(.so 文件),以便在 Java 程序中调用。在 Android 系统上,可以将这个 JNI 文件与其它 Android 项目一起编译,并将生成的 .so 文件集成到 Android 应用中,以实现对韦根驱动的调用。 这个压缩文件的具体内容可能包括 JNI 源代码、头文件以及必要的编译脚本。如果你想使用这个韦根驱动,你可能需要先解压这个压缩文件,然后参考其中的文档或指南,按照指导进行相应的编译和集成工作。 总之,"linux-android-韦根驱动 jni.rar" 是一个提供了在 Linux 和 Android 系统上支持韦根驱动的 JNI 代码文件,通过使用它,你可以将韦根驱动融入到你的 Java 或 Android 项目中,并实现对该驱动的功能调用。 ### 回答3: Linux是一种开源的操作系统,广泛用于服务器、桌面电脑和嵌入式设备。而Android是基于Linux内核开发的移动操作系统,主要运行于智能手机、平板电脑和其他便携式设备上。韦根驱动是一种用于与韦根协议进行通信的驱动程序,通过JNI(Java Native Interface)将Java代码与本地代码进行交互。 在开发Android应用程序时,我们经常会使用JNI技术来调用C/C++编写的本地代码,以实现一些特定功能或与底层进行交互。在这个过程中,我们需要将本地代码打包成文件,然后从Java层进行调用。 韦根驱动JNI.rar可能是一个包含了韦根协议通信所需的本地代码的压缩文件。其中可能包含了以C/C++语言编写的代码和一些与之相关的资源文件。通过解压缩这个文件,我们可以得到驱动程序所需的源代码和资源文件,从而进行进一步的开发和调试。 这个韦根驱动JNI.rar文件可能为开发者提供了一种在Android平台上与韦根协议设备进行通信的解决方案。通过将相关的代码集成到Android应用程序中,开发者可以实现与韦根协议设备之间的数据交互,从而实现特定的功能或满足特定的需求。 总之,Linux是操作系统,Android是基于Linux的移动操作系统,韦根驱动是用于与韦根协议进行通信的驱动程序,而韦根驱动JNI.rar可能是一个包含了韦根驱动的本地代码的压缩文件,用于在Android平台上实现与韦根协议设备的通信。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值