Skip to main content

Libsecp256k1-0

This is a compiled libsecp256k1 python package that allows you to use secp256k1 in your python projects. Secp256k1 is an optimized C library for ECDSA signatures and secret/public key operations. This library is intended to be the highest quality publicly available library for cryptography on the secp256k1 curve. See this for more details on secp256k1: https://github.com/bitcoin-core/secp256k1. Libsecp256k1-0 contains the pre-compiled modules of secp256k1 compatible for multiple platforms (unix, windows 32 and 64 bits). Most importantly, you can use the dockerized compiler in this package to compile these modules directly from source. That way you don't need to put your trust the pre-compiled versions in this package or anyone else's versions of libsecp256k1.

Prerequisites

  • Python3 (version >= 3.10) - Install Python3 here: https://www.python.org/downloads/. Check version with: python3 --version
  • Pip3 (version >= 23.0) - Python3 should come with pip3. Check version with: pip3 --version
  • Docker (version >= 20.10.7) - Docker is only required if you wish to use the compiler in this package to compile libsecp256k1 for yourself.
  • Linux or Windows - This application works out of the box for Linux and is compatible with Windows.
  • MacOS - This application works for MacOS using the pre-compiled binary that comes with the app. However, this app is not able compile a new binary for MacOS. If you wish to compile your own, the Electrum wallet has a compiler that can be used. The simpliest way is to install the Electrum wallet and access the libsecp256k1.0.dylib binary file located in the app: ~/Applications/Electrum.app/Contents/MacOS/libsecp256k1.0.dylib. Then replace the ../compiled/darwin/libsecp256k1.0.dylib file with your new binary.

Installation

There are a couple of options to install this package:

  • Pip Install - This package is hosted on PyPi and can be installed with the following command:
pip3 install libsecp256k1-0
  • Local Install - Alternatively, you can download or git clone the Github repo and install it locally with the following:
git clone https://github.com/ArcticTechnology/libsecp256k1-0.git
cd libsecp256k1-0
pip3 install -e .

Usage

After installation, you can simply import the package resources and use them in your own project:

from libsecp256k1_0 import *

Once imported, you should be able to all the modules in the package. For example, this is how you verify ecdsa with secp256k1:

Secp256k1._libsecp256k1.secp256k1_ecdsa_verify(<ctx>, <sig>, <msg_hash>, <pubkey>)

Compile

You can use the dockerized compiler of this package to compile libsecp256k1 for yourself. The compiler builds directly from this source: https://github.com/bitcoin-core/secp256k1.git. It is recommended that you build libsecp256k1 for yourself that way you don't need to put your trust the pre-compiled versions in this package or any other versions of libsecp256k1. By default, running the compiler will overwrite the pre-compiled modules with the newly compiled ones. In order to use the compiler you will need to have Docker (version >= 20.10.7), see "Instructions for Docker" section for more details.

There are a couple ways you can run the compiler:

  • Simply use the following command in Docker:
libsecp-compile
  • You can also run it with the python command python3 -m:
python3 -m libsecp-compile
  • You can also access the compiler in the package resources. Here you have the option to specify where you want the compiled files to output to.
from libsecp256k1_0 import Libsecp256k1
Libsecp256k1.docker_compile(outpath='/home/example')
  • You can also run the compiler from a Linux terminal without Docker by calling the "local_compiler.sh" file. This will automatically compile to your working directory.
./local_compiler.sh

Troubleshooting

This section goes over some of the common issues found and how to resolve them.

"Command Not Found" Error When Running the Compiler

On Linux, if you are getting a command not found error when trying to run the compiler, you may need to add ~/.local/bin/ to PATH. See this thread for details: https://stackoverflow.com/a/34947489. To add ~/.local/bin/ to PATH do the following:

  1. Add export PATH=~/.local/bin:$PATH to ~/.bash_profile.
echo export PATH=~/.local/bin:$PATH > ~/.bash_profile
  1. Execute command.
source ~/.bash_profile

Instructions for Docker

  1. To install Docker, use the following command:
sudo apt-get update
sudo apt install docker.io
sudo docker version
  1. Make sure you are able to run docker will the following command:
sudo docker run --name test-docker-instance test-docker
sudo docker images
  1. To remove the docker image use:
sudo docker stop test-docker-instance
sudo docker kill --signal=9 test-docker-instance
sudo docker rmi test-docker

Support and Contributions

Our software is open source and free for public use. If you found any of these repos useful and would like to support this project financially, feel free to donate to our bitcoin address.

Bitcoin Address 1: 1GZQY6hMwszqxCmbC6uGxkyD5HKPhK1Pmf

alt text

Metadata

Release files for libsecp256k1-0 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libsecp256k1-0 0.3.0
File Size Uploaded
libsecp256k1-0-0.3.0.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for libsecp256k1-0 0.3.0
File Interpreter ABI Platform
libsecp256k1_0-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.3 MB

Release files / libsecp256k1-0-0.3.0.tar.gz

Download URL libsecp256k1-0-0.3.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
3dccce11b4ee8a451d500176240709c5351a7c384b3697bbdd90cf05a8645806
BLAKE2b-256 checksum
How to use checksums
5e052dfaaf7f015636a7fb175b7e5c683588b50fdf7d932b504d04d94809d6ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release files / libsecp256k1_0-0.3.0-py3-none-any.whl

Download URL libsecp256k1_0-0.3.0-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3bcba49778f538a62a11bdd3554e7867918e35e8662cc6e8b6926b880bbe1177
BLAKE2b-256 checksum
How to use checksums
d9dccf49181cdc0112d4d48d1f2a3cf5af55dae2a52af37d6f647c48a6a660b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page