Coder Social home page Coder Social logo

hazmat-math's Introduction

hazmat-math

Hazmat ECC arithmetic for Cryptography.io

Hazmat math implements some basic ECC arithmetic for use with Cryptography.io objects using the OpenSSL backend. Specifically, _EllipticCurvePrivateKey and _EllipticCurvePublicKey.

Any operations with EC_POINT will return an _EllipticCurvePublicKey and any operations with BN will return an _EllipticCurvePrivateKey.

Usage:

from cryptography.hazmat.backends import default_backend()
from cryptography.hazmat.primitives.asymmetric import ec

from hazmat_math import operations as ops


priv_a = ec.generate_private_keys(ec.SECP256K1(), default_backend())
priv_b = ec.generate_private_keys(ec.SECP256K1(), default_backend())

pub_a = priv_a.public_key()
pub_b = priv_b.public_key()

# Multiplication
priv_c = ops.BN_MOD_MUL(priv_a, priv_b)
pub_c = ops.EC_POINT_MUL(pub_a, priv_a)

# Division
priv_c = ops.BN_DIV(priv_a, priv_b)

# Inversion
inv_a_priv = ops.BN_MOD_INVERSE(priv_a)
inv_a_pub = ops.EC_POINT_INVERT(pub_a)

# Addition
priv_c = ops.BN_MOD_ADD(priv_a, priv_b)
pub_c = ops.EC_POINT_ADD(pub_a, pub_b)

# Subtraction
priv_c = ops.BN_MOD_SUB(priv_a, priv_b)
pub_c = ops.EC_POINT_SUB(pub_a, pub_b)

# Get generator point from curve
gen_point = ops.CURVE_GET_GENERATOR(ec.SECP256K1())

# Get order of curve
order = ops.CURVE_GET_ORDER(ec.SECP256K1())

Installation:

  1. Clone or download the repository
  2. Ensure that you have cryptography.io install (pip install cryptography)
  3. python setup.py install

TODO:

  1. Testing!
  2. Get setup on pypy.

hazmat-math's People

Contributors

tuxxy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.