{"id":23270792,"url":"https://github.com/mcxxmc/simple-implementation-ecc","last_synced_at":"2025-04-06T09:44:23.710Z","repository":{"id":43710732,"uuid":"461428430","full_name":"mcxxmc/simple-implementation-ecc","owner":"mcxxmc","description":"A simple implementation for Elliptic Curve Cryptography.","archived":false,"fork":false,"pushed_at":"2022-02-26T13:33:38.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T15:19:54.084Z","etag":null,"topics":["cryptography","elliptic-curves","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcxxmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-20T08:33:52.000Z","updated_at":"2022-02-27T10:52:48.000Z","dependencies_parsed_at":"2022-08-22T03:10:11.912Z","dependency_job_id":null,"html_url":"https://github.com/mcxxmc/simple-implementation-ecc","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fsimple-implementation-ecc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fsimple-implementation-ecc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fsimple-implementation-ecc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxxmc%2Fsimple-implementation-ecc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcxxmc","download_url":"https://codeload.github.com/mcxxmc/simple-implementation-ecc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247463805,"owners_count":20942942,"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","elliptic-curves","golang"],"created_at":"2024-12-19T18:55:29.168Z","updated_at":"2025-04-06T09:44:23.693Z","avatar_url":"https://github.com/mcxxmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-implementation-ecc\n\n\n A simple implementation for Elliptic Curve Cryptography. \n \n\nIt implements the algorithm of 2D points over a finite field\n(e.g., addition, doubling, multiplication and inverse),\nthe elliptic curve (in the form: y^2 = x^3 + ax + b), and the ECDH\n(Elliptic Curve Diffie–Hellman) key exchange algorithm, including \ntest cases for verification.\n\nGenerally speaking, it consists of the following 3 parts: \nthe calculations over finite field, the elliptic curve and the \nECDH key exchange.\n\n\nI learnt many of concepts regarding ECC and ECDH here:\n\n\nhttps://cryptobook.nakov.com/asymmetric-key-ciphers/elliptic-curve-cryptography-ecc\n\n\n### Calculations Over Finite Field\nThis is in the \"galois\" package as the finite field is also called \"galois field\".\n\n\nThe implementation are inspired by the online discussions here:\n\n\nhttps://math.stackexchange.com/questions/67171/calculating-the-modular-multiplicative-inverse-without-all-those-strange-looking/67190#67190\n\n\nhttps://math.stackexchange.com/questions/1340484/addition-of-points-on-elliptic-curves-over-a-finite-field\n\n\nNote that, different from my common practice, the \"Point\" object is passed as a struct\ninstead of a pointer. This will cause higher memory cost, but it simulates the ECC \nprocess in a better way, as public keys are distributed across the net as real copies \n(a stream of 0s and 1s) instead of a shared reference (usually 8-byte) to a single being.\n\n\n### The Elliptic Curve\n\n\n\"elliptic.go\" defines a struct for the elliptic curve. Most of its functions are \nbased on \"galois-field.go\" in the \"galois\" package.\n\n\n### ECDH Key Exchange\n\n\nImplements the encryption and decryption process of the ECDH key exchange, using\nthe GCM cipher.\n\n\nIncluding files \"ecdh.go\" and \"gcm.go\".\n\n\n### Testing\n\n\nThe testing is based on the curve y^2 = x^3 + 0x + 7 (mod 17), with a generator\npoint (15, 13). This is a very small sample used only for testing. Details of this curve\ncan be found in the first link. \n\n\nAnother testcase is y^2 = x^3 + 1 x + 1 (mod 23), with a generator point (3, 10),\nwhich is slightly bigger.\n\n\nExample of how to use my codes to simulate the ECDH key exchange process can be\nfound in the test file \"ecdh_test.go\".\n\n\n### TODO\n\n\n1. Better coding in \"galois\".\n2. Currently, my codes assume all integers are at most 64 bits and there is \nno overflow during the process; however, in the real world most keys are 256+\nbits. Since my codes are just experimental and not intended for production use,\nthis may not be a concern; however, consider an update in the future.\n3. Implement ECIES (Elliptic Curve Integrated Encryption Scheme).\n4. Introduce auth tag for the encryption / decryption process to fully simulate\nECDH and ECIES.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxxmc%2Fsimple-implementation-ecc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcxxmc%2Fsimple-implementation-ecc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxxmc%2Fsimple-implementation-ecc/lists"}