0.03
No release in over a year
Native extension gem for secp256k1 ECDSA and Schnorr signatures. Wraps libsecp256k1 natively without any need for FFI.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
~> 3.8
= 0.78
~> 0.9
~> 1.3

Runtime

 Project Readme

rbsecp256k1

Spec Gem Version Maintainability

Native extension gem for secp256k1 ECDSA and Schnorr signatures. Wraps libsecp256k1 without the need for FFI.

Features

  • Native extension gem wrapping libsecp256k1, no FFI.
  • Schnorr signature support.

Why wrap libsecp256k1?

libsecp256k1 is an extremely optimized implementation of public key derivation, signing, and verification with the secp256k1 elliptic curve. It comes with its own set of benchmarks, but from benchmarking done by Peter Wuille it is ~4.9x faster than the OpenSSL implementation of the same curve. It is the only library that provides constant time signing of this curve and has been deployed as part of Bitcoin since v0.10.0

Natively wrapping the library in an extension gem means users don't have to worry about compiling or locating the library, unlike many FFI based gems.

Installation

The simplest installation:

gem install rbsecp256k1

Requirements

If you want to use your system version of libsecp256k1 rather than the bundled version use the --with-system-libraries flag:

gem install rbsecp256k1 -- --with-system-libraries

Linux

Install the dependencies for building libsecp256k1 and this library:

sudo apt-get install build-essential automake pkg-config libtool \
  libffi-dev libssl-dev libgmp-dev python3-dev

NOTE: If you have installed libsecp256k1 but the gem cannot find it. Ensure you have run ldconfig so that your library load paths have been updated.

macOS

Dependencies for building libsecp256k1 and this library:

brew install automake openssl libtool pkg-config gmp libffi

Features

See rbsecp256k1 documentation for examples and complete list of supported functionality.

Development

Cloning

To clone the repository and its submodules you'll need to the following:

git clone git@github.com:etscrivner/rbsecp256k1.git

Setup

Development is largely facilitated by a makefile. After download you should run the following command to set up your local environment:

make setup

Compiling Extension

To compile the extension gem run the following (this is required to run tests):

make build

Running Tests

make test

To test with recovery functionality disabled run:

make test WITH_RECOVERY=0

Uninstall Gem Locally

You can similarly uninstall the local gem by running the following:

make uninstall

Cleaning Up

To clean up and do a fresh build:

make clean

Running YARD Documentation Server

To run the YARD documentation server:

make docserver