{"id":19397322,"url":"https://github.com/tuxxy/hazmat-math","last_synced_at":"2025-04-24T05:31:04.796Z","repository":{"id":93196811,"uuid":"113229323","full_name":"tuxxy/hazmat-math","owner":"tuxxy","description":"Hazmat ECC arithmetic for Cryptography.io ","archived":false,"fork":false,"pushed_at":"2020-04-15T09:40:32.000Z","size":38,"stargazers_count":28,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T23:41:32.267Z","etag":null,"topics":["cryptography","ecc","elliptic-curve-arithmetic","elliptic-curves","secp256k1"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuxxy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-05T20:25:17.000Z","updated_at":"2024-11-21T22:27:28.000Z","dependencies_parsed_at":"2023-04-10T09:32:26.795Z","dependency_job_id":null,"html_url":"https://github.com/tuxxy/hazmat-math","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuxxy%2Fhazmat-math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuxxy%2Fhazmat-math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuxxy%2Fhazmat-math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuxxy%2Fhazmat-math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuxxy","download_url":"https://codeload.github.com/tuxxy/hazmat-math/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250572226,"owners_count":21452326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","ecc","elliptic-curve-arithmetic","elliptic-curves","secp256k1"],"created_at":"2024-11-10T10:42:23.609Z","updated_at":"2025-04-24T05:31:04.515Z","avatar_url":"https://github.com/tuxxy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hazmat-math\nHazmat ECC arithmetic for Cryptography.io\n\nHazmat math implements some basic ECC arithmetic for use with Cryptography.io objects using the OpenSSL backend.\nSpecifically, `_EllipticCurvePrivateKey` and `_EllipticCurvePublicKey`.\n\nAny operations with `EC_POINT` will return an `_EllipticCurvePublicKey` and any operations with `BN` will return an `_EllipticCurvePrivateKey`.\n\n# Usage:\n```\nfrom cryptography.hazmat.backends import default_backend()\nfrom cryptography.hazmat.primitives.asymmetric import ec\n\nfrom hazmat_math import operations as ops\n\n\npriv_a = ec.generate_private_keys(ec.SECP256K1(), default_backend())\npriv_b = ec.generate_private_keys(ec.SECP256K1(), default_backend())\n\npub_a = priv_a.public_key()\npub_b = priv_b.public_key()\n\n# Multiplication\npriv_c = ops.BN_MOD_MUL(priv_a, priv_b)\npub_c = ops.EC_POINT_MUL(pub_a, priv_a)\n\n# Division\npriv_c = ops.BN_DIV(priv_a, priv_b)\n\n# Inversion\ninv_a_priv = ops.BN_MOD_INVERSE(priv_a)\ninv_a_pub = ops.EC_POINT_INVERT(pub_a)\n\n# Addition\npriv_c = ops.BN_MOD_ADD(priv_a, priv_b)\npub_c = ops.EC_POINT_ADD(pub_a, pub_b)\n\n# Subtraction\npriv_c = ops.BN_MOD_SUB(priv_a, priv_b)\npub_c = ops.EC_POINT_SUB(pub_a, pub_b)\n\n# Get generator point from curve\ngen_point = ops.CURVE_GET_GENERATOR(ec.SECP256K1())\n\n# Get order of curve\norder = ops.CURVE_GET_ORDER(ec.SECP256K1())\n```\n\n# Installation:\n1. Clone or download the repository\n2. Ensure that you have cryptography.io install (`pip install cryptography`)\n3. `python setup.py install`\n\n# TODO:\n1. Testing!\n2. Get setup on pypy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuxxy%2Fhazmat-math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuxxy%2Fhazmat-math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuxxy%2Fhazmat-math/lists"}