This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Project Description

This library provides well-tested Python CFFI bindings for libsecp256k1, the heavily optimized C library used by Bitcoin Core for operations on elliptic curve secp256k1.

Coincurve replaces secp256k1-py.

New features include:

  • Cleaner API
  • Uses newest version of libsecp256k1
  • Support for Windows
  • Linux, macOS, and Windows all have binary packages for both 64 and 32-bit architectures
  • Linux & macOS use GMP for faster computation
  • Endomorphism optimization is enabled
  • A global context is used by default, drastically increasing performance
  • Fixed ECDH
  • A fix to remove CFFI warnings
  • Implements a fix for https://bugs.python.org/issue28150 to support Python 3.6+ on macOS

Installation

Coincurve is distributed on PyPI and is available on Linux/macOS and Windows and supports Python 2.7/3.5+ and PyPy3.5-v5.7.1+.

$ pip install coincurve

If you are on a system that doesn’t have a precompiled binary wheel (e.g. FreeBSD) then pip will fetch source to build yourself. You must have the necessary packages.

On Debian/Ubuntu for example the necessary packages are:

  • build-essential
  • automake
  • pkg-config
  • libtool
  • libffi-dev
  • libgmp-dev

API

Coincurve provides a simple API.

coincurve.verify_signature

verify_signature(signature, message, public_key, hasher=sha256, context=GLOBAL_CONTEXT)

Verifies some message was signed by the owner of a public key.

  • Parameters:

    • signature (bytes) - The signature to verify.
    • message (bytes) - The message that was supposedly signed.
    • public_key (bytes) - A public key in compressed or uncompressed form.
    • hasher - The hash function to use. hasher(message) must return 32 bytes.
    • context (coincurve.Context)
  • Returns: bool

coincurve.PrivateKey

All instances have a public_key of type coincurve.PublicKey

PrivateKey(secret=None, context=GLOBAL_CONTEXT)

  • Parameters:

    • secret (bytes) - The secret to use.
    • context (coincurve.Context)

Methods

classmethod from_hex(hexed, context=GLOBAL_CONTEXT)

classmethod from_int(num, context=GLOBAL_CONTEXT)

classmethod from_pem(pem, context=GLOBAL_CONTEXT)

classmethod from_der(der, context=GLOBAL_CONTEXT)

sign(message, hasher=sha256)

  • Parameters:

    • message (bytes) - The message to sign.
    • hasher - The hash function to use. hasher(message) must return 32 bytes.
  • Returns: bytes. 71 <= len(signature) <= 72

sign_recoverable(message, hasher=sha256)

  • Parameters:

    • message (bytes) - The message to sign.
    • hasher - The hash function to use. hasher(message) must return 32 bytes.
  • Returns: bytes

ecdh(public_key)

Computes a Diffie-Hellman secret in constant time.

  • Parameters:

    • public_key (bytes) - Another party’s public key in compressed or uncompressed form.
  • Returns: bytes

add(scalar, update=False)

  • Parameters:

    • scalar (bytes) - The scalar to add.
    • update - If True, will update and return self.
  • Returns: coincurve.PrivateKey

multiply(scalar, update=False)

  • Parameters:

    • scalar (bytes) - The scalar to multiply.
    • update - If True, will update and return self.
  • Returns: coincurve.PrivateKey

to_hex()

to_int()

to_pem()

to_der()

coincurve.PublicKey

PublicKey(data, context=GLOBAL_CONTEXT)

  • Parameters:

    • data (bytes) - The public key in compressed or uncompressed form.
    • context (coincurve.Context)

Methods

classmethod from_secret(secret, context=GLOBAL_CONTEXT)

classmethod from_valid_secret(secret, context=GLOBAL_CONTEXT)

classmethod from_point(x, y, context=GLOBAL_CONTEXT)

classmethod from_signature_and_message(serialized_sig, message, hasher=sha256, context=GLOBAL_CONTEXT)

format(compressed=True)

  • Parameters:

    • compressed (bool)
  • Returns: The public key serialized to bytes.

point()

  • Returns: (x, y)

verify(signature, message, hasher=sha256)

Verifies some message was signed by the owner of this public key.

  • Parameters:

    • signature (bytes) - The signature to verify.
    • message (bytes) - The message that was supposedly signed.
    • hasher - The hash function to use. hasher(message) must return 32 bytes.
  • Returns: bool

add(scalar, update=False)

  • Parameters:

    • scalar (bytes) - The scalar to add.
    • update - If True, will update and return self.
  • Returns: coincurve.PublicKey

multiply(scalar, update=False)

  • Parameters:

    • scalar (bytes) - The scalar to multiply.
    • update - If True, will update and return self.
  • Returns: coincurve.PublicKey

Release History

Release History

4.5.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

4.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

4.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

4.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

4.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

4.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
coincurve-4.5.1-cp27-cp27m-macosx_10_6_intel.whl (154.8 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Apr 29, 2017
coincurve-4.5.1-cp27-cp27m-manylinux1_i686.whl (534.0 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Apr 29, 2017
coincurve-4.5.1-cp27-cp27m-manylinux1_x86_64.whl (526.7 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Apr 29, 2017
coincurve-4.5.1-cp27-cp27mu-manylinux1_i686.whl (534.0 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Apr 29, 2017
coincurve-4.5.1-cp27-cp27mu-manylinux1_x86_64.whl (526.7 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Apr 29, 2017
coincurve-4.5.1-cp35-cp35m-macosx_10_6_intel.whl (154.9 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Apr 29, 2017
coincurve-4.5.1-cp35-cp35m-manylinux1_i686.whl (531.0 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Apr 29, 2017
coincurve-4.5.1-cp35-cp35m-manylinux1_x86_64.whl (523.5 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Apr 29, 2017
coincurve-4.5.1-cp36-cp36m-macosx_10_6_intel.whl (154.9 kB) Copy SHA256 Checksum SHA256 cp36 Wheel Apr 29, 2017
coincurve-4.5.1-cp36-cp36m-manylinux1_i686.whl (531.0 kB) Copy SHA256 Checksum SHA256 cp36 Wheel Apr 29, 2017
coincurve-4.5.1-cp36-cp36m-manylinux1_x86_64.whl (523.5 kB) Copy SHA256 Checksum SHA256 cp36 Wheel Apr 29, 2017
coincurve-4.5.1-pp357-pp357-manylinux1_x86_64.whl (206.9 kB) Copy SHA256 Checksum SHA256 pp357 Wheel Apr 29, 2017
coincurve-4.5.1-py2.py3-none-win32.whl (270.8 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Apr 29, 2017
coincurve-4.5.1-py2.py3-none-win_amd64.whl (255.8 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Apr 29, 2017
coincurve-4.5.1.tar.gz (875.4 kB) Copy SHA256 Checksum SHA256 Source Apr 29, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting