Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Installing the libsecp256k1 binding

Adam Gibson edited this page Aug 29, 2016 · 5 revisions

NOTE: This applies to version 0.2.0+. The other instructions will be deprecated soon.

Installing the libsecp256k1 binding on Linux/OSX

Start by following the README: pip install -r requirements.txt.

In some cases, this will work (if you already have the libsecp256k1 shared library). For the large majority of people, this will not be the case, and you will see an installation failure. In that case, you have to prepare the packages required to build it; although, once you have, the pip installation will do the actual build under the hood. The requirements are listed at the project homepage here; you shouldn't need the env variable settings mentioned. They are:

On Debian / Ubuntu: build-essential automake pkg-config libtool libffi-dev libgmp-dev

On OS X the necessary homebrew packages are: automake pkg-config libtool libffi gmp

Installing the libsecp256k1 binding on Windows

Start by following the instructions from the README: pip install -r requirements-windows.txt.

After you've done so, you will probably need one more step. To check, try the command python and then import secp256k1. If you see no error message, you can proceed.

In the likely case that you see an Import Error: failed to load DLL, this is because the libsecp256k1 binding for Windows depends on a libgcc dll shipped with MinGW. The name of the dll is libgcc_s_dw2-1.dll. You can solve the problem by simply getting a copy of that dll and putting it into your working joinmarket directory. I'd suggest installing MinGW itself from here or go to their website. There are some options here; this basic setup was reported working:

From "Basic Setup":

  • mingw-developer-toolkit
  • mingw32-base
  • mingw32-gcc-g++
  • msys-base

From "All Packages"

  • msys-crypt

Once that is complete, you should have this dll in the folder C:\MinGW\bin (default location).

Next, you can either make sure C:\MinGW\bin is added to your PATH variable, or you can simply copy libgcc_s_dw2-1.dll into your local joinmarket folder, as described for libsodium.

Sanity check: start python at a command prompt (in your joinmarket folder, so the dll gets picked up, if you copied it there), and type:

```
>>> import secp256k1
>>>
```

i.e. you should see no warning or error message. This will guarantee that Joinmarket picks up the libsecp256k1 binding, and so Joinmarket will no longer show a warning message about it on startup.

Installing the libsecp256k1 binding on TAILS

These instructions are for those who want to run joinmarket scripts (as opposed to -Qt) on TAILS and use the libsecp256k1 binding.

Tests have been done on 2.3 and 1.7.8. It's recommended to run the latest TAILS version for security reasons.

##For TAILS 2.3

Here is the result of experiments done on a new TAILS 2.3 instance.

sudo apt-get update

required to install packages on a fresh TAILS instance.

sudo apt-get install build-essential automake libtool pkg-config libffi-dev python-dev python-pip

development dependencies required to do the building of the underlying libsecp256k1 dynamic library (and make the Python binding)

sudo torsocks pip install secp256k1

this part does the actual build and installs the Python binding in /usr/local/lib/python2.7/dist-packages. Again, sudo is needed.

sudo chmod -R ugo+rX /usr/local/lib/python2.7/dist-packages/

This unpleasant hack is required because for some reason the files are created without permissions for non-root user. I would appreciate any advice in fixing this in whatever way is most sensible.

After this, secp256k1 should be available: to check, type python (as amnesia) and then type import secp256k1 at the Python prompt. There should be no error message. If so, joinmarket scripts will pick it up.

##For TAILS 1.7.8

Here is the result of experiments done on a new TAILS 1.7.8 instance.

sudo apt-get update

required to install packages on a fresh TAILS instance.

sudo apt-get install build-essential automake libtool pkg-config libffi5 libffi-dev python-dev

development dependencies required to do the building of the underlying libsecp256k1 dynamic library (and make the Python binding)

torify curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo torify python get-pip.py

recommended way to update pip. However something is slightly "off" about the permissions after doing this (see chmod command below). Note that I tried to do this part without sudo and it doesn't work.

sudo torify pip install secp256k1

this part does the actual build and installs the Python binding in /usr/local/lib/python2.7/dist-packages. Again, sudo is needed.

sudo chmod -R ugo+rX /usr/local/lib/python2.7/dist-packages/

This unpleasant hack is required because for some reason the files are created without permissions for non-root user (again, the whole process without sudo fails). I would appreciate any advice in fixing this.

After this, secp256k1 should be available: to check, type python (as amnesia) and then type import secp256k1 at the Python prompt. There should be no error message.