Skip to main content

Fast elliptic curve digital signatures

Project description

https://travis-ci.org/AntonKueltz/fastecdsa.svg?branch=master

About

This is a python package for doing fast elliptic curve cryptography, specifically digital signatures.

Supported Primitives

Curves

  • P192 (fastecdsa.curve.P192)

  • P224 (fastecdsa.curve.P224)

  • P256 (fastecdsa.curve.P256)

  • P384 (fastecdsa.curve.P384)

  • P521 (fastecdsa.curve.P521)

  • secp256k1 (bitcoin curve) (fastecdsa.curve.secp256k1)

Hash Functions

  • SHA1 (hashlib.sha1)

  • SHA224 (hashlib.sha224)

  • SHA256 (SHA2) (hashlib.sha256)

  • SHA384 (hashlib.sha384)

  • SHA512 (hashlib.sha512)

Performance

Currently it does basic point multiplication significantly faster than the ecdsa package. You can see the times for 1,000 signature and verification operations below, fast.py corresponding to this package and regular.py corresponding to ecdsa package.

http://i.imgur.com/oNOfnG6.png?1

As you can see, this package in this case is ~25x faster.

Installing

You can use pip: $ pip install fastecdsa or clone the repo and use $ python setup.py install. Note that you need to have a C compiler. You also need to have GMP on your system as the underlying C code in this package includes the gmp.h header (and links against gmp via the -lgmp flag). On debian you can install all dependencies as follows:

$ sudo apt-get install python-dev libgmp3-dev

Usage

Some basic usage is shown below:

from fastecdsa import curve, ecdsa
from hashlib import sha384

m = "a message to sign via ECDSA"  # some message

''' use default curve and hash function (P256 and SHA2) '''
private_key, public_key = ecdsa.gen_keypair()
# standard signature, returns two integers
r, s = ecdsa.sign(m, private_key)
# should return True as the signature we just generated is valid.
valid = ecdsa.verify((r, s), m, public_key)


''' specify a different curve to use with ECDSA '''
private_key, public_key = ecdsa.gen_keypair(curve=curve.P224)
r, s = ecdsa.sign(m, private_key, curve=curve.P224)
valid = ecdsa.verify((r, s), m, public_key, curve=curve.P224)

''' specify a different hash function to use with ECDSA '''
private_key, public_key = ecdsa.gen_keypair()
r, s = ecdsa.sign(m, private_key, hashfunc=sha384)
valid = ecdsa.verify((r, s), m, public_key, hashfunc=sha384)

Security

No known current issues. Timing side challenges are mitigated via Montgomery point multiplication. Nonces are generated per RFC6979.

Project details


Download files

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

Source Distribution

fastecdsa-1.1.2.tar.gz (14.1 kB view details)

Uploaded Source

File details

Details for the file fastecdsa-1.1.2.tar.gz.

File metadata

  • Download URL: fastecdsa-1.1.2.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fastecdsa-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3c237999749657666f655c4d9962dbcbe6b65be57d5ad516eb25751e97e0cda6
MD5 1eea31d451eb82b4aeee607ffed8164e
BLAKE2b-256 45a3972113bfd797da99694262cd7af1625c8f92e22bebf549715f50de554ec7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page