GithubHelp home page GithubHelp logo

alexelvers / fast-ecc-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from user8547/fast-ecc-python

0.0 2.0 0.0 20 KB

Python bindings for general purpose elliptic curve point operations

Python 26.77% C 71.53% Shell 1.70%

fast-ecc-python's Introduction

Fast elliptic curve point operations in Python

Python bindings for general purpose elliptic curve point operations.

Supported curves and implementations:

  • secp256r1 (P-256/prime256v1) (OpenSSL)
  • secp256r1 (P-256/prime256v1) (Python)
  • secp256k1 (OpenSSL)
  • secp256k1 (Python)
  • secp256k1 (libsecp256k1)
  • Ed25519 (ed25519-donna)
  • Ed25519 (Python)

Example usage:

$ sh secp256k1_openssl.sh
$ python
>>> import secp256r1_openssl as curve
>>> curve.g
[48439561293906451759052585252797914202762949526041747995844080717082404635286L, 36134250956749795798585127919587881956611106672985015071877198253568414405109L]
>>> curve.mul(curve.g, 5)
[36794669340896883012101473439538929759152396476648692591795318194054580155373L, 101659946828913883886577915207667153874746613498030835602133042203824767462820L]
>>> curve.add(curve.g, curve.inv(curve.g))
[None, None]
>>> 
>>> curve.compress(curve.g).encode('hex')
'036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'
>>> curve.decompress('036b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'.decode('hex'))
[48439561293906451759052585252797914202762949526041747995844080717082404635286L, 36134250956749795798585127919587881956611106672985015071877198253568414405109L]
>>> curve.valid(curve.g)
1
>>> curve.valid([123,123])
0

Available methods:

  • mul(point, scalar) - returns point multiplied with a scalar
  • add(point, point) - returns addition of two points
  • inv(point) - returns inverse of point
  • valid(point) - returns 1 if point on curve, 0 otherwise
  • comress(point) - returns 33 bytes - sign of Y coordinate (0x02 or 0x03) and X coordinate (32 bytes)
  • decompress(bytestring33) - returns unpacked point

Point at infinity is represented as value [Null, Null] or 33 zero bytes (in compressed form).

Ed25519 does not have point at infinity. Neutral point is [0,1].

fast-ecc-python's People

Contributors

alexelvers avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.