secp256k1rb
This is a Ruby binding for Bitcoin Core's secp256k1 library.
Installation
Add this line to your application's Gemfile:
gem 'secp256k1rb', require: 'secp256k1'And then execute:
$ bundle install
Or install it yourself as:
$ gem install secp256k1rb
Usage
To use this library, you need to specify the path of the secp256k1 shared library in environment variable
SECP256K1_LIB_PATH, e.g: $ export SECP256K1_LIB_PATH=/var/local/lib/libsecp256k1.so.
Note: This library binds the recovery, ecdh, extrakeys, schnorrsig, musig and ellswift modules,
so the secp256k1 library must have been built with these modules enabled
(e.g. --enable-module-recovery --enable-module-musig --enable-module-ellswift; the others are enabled by default).
Loading fails with FFI::NotFoundError if one of them is missing.
The silentpayments module (--enable-module-silentpayments, experimental) is optional.
By including the Secp256k1 module, you can use the features provided by the libsepc256k1 library. For example:
require 'secp256k1'
include Secp256k1
generate_key_pair
=> ["e00c2ae99e59b5262be3d507d026081f0e6cf9972ffdd4f2d45a390f7a41b053", "027e0f70b540d627422cf7bb77d86ae1bb6829c80104dd48dc2539e6277ea25624"]See here for available methods. In addition, the following modules are also included, so you can use them as they are.
Compatibility
Since v0.8.0, the major and minor version of this gem matches the supported secp256k1 version (e.g. secp256k1rb v0.8.x supports secp256k1 v0.8.x). Patch releases are used for gem-side changes.
The gem also loads with older libsecp256k1 versions; features that require a newer
library (e.g. the silentpayments module) raise Secp256k1::Error when used.
Use silentpayments_available? to check availability at runtime.
Older versions:
| secp256k1 version | secp256k1rb version |
|---|---|
| v0.4.0 | v0.1.x |
| v0.6.0 | v0.2.x |
| v0.7.1 | v0.3.x |