{"id":17447824,"url":"https://github.com/pmuens/ecc-ts","last_synced_at":"2025-05-15T10:34:35.959Z","repository":{"id":231528929,"uuid":"781950044","full_name":"pmuens/ecc-ts","owner":"pmuens","description":"Elliptic Curve Cryptography implementation of ECDH and ECDSA on curve secp256k1","archived":false,"fork":false,"pushed_at":"2024-04-16T09:16:54.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T10:47:53.063Z","etag":null,"topics":["cryptography","cryptography-algorithms","cryptography-library","ecdh","ecdsa","elliptic-curve","elliptic-curve-cryptography","elliptic-curve-diffie-hellman","elliptic-curve-digital-signature-algorithm","secp256k1"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/pmuens.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-04T10:56:03.000Z","updated_at":"2024-11-17T21:24:59.000Z","dependencies_parsed_at":"2024-10-20T00:09:24.331Z","dependency_job_id":"080345f5-b35f-4508-8c4a-aa8cfc84384f","html_url":"https://github.com/pmuens/ecc-ts","commit_stats":null,"previous_names":["pmuens/ecc-ts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuens%2Fecc-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuens%2Fecc-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuens%2Fecc-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuens%2Fecc-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmuens","download_url":"https://codeload.github.com/pmuens/ecc-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254323129,"owners_count":22051726,"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","cryptography-algorithms","cryptography-library","ecdh","ecdsa","elliptic-curve","elliptic-curve-cryptography","elliptic-curve-diffie-hellman","elliptic-curve-digital-signature-algorithm","secp256k1"],"created_at":"2024-10-17T19:52:50.224Z","updated_at":"2025-05-15T10:34:35.932Z","avatar_url":"https://github.com/pmuens.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elliptic Curve Cryptography\n\nA \"from scratch\" [Elliptic Curve Cryptography](https://en.wikipedia.org/wiki/Elliptic-curve_cryptography) implementation in [TypeScript](https://www.typescriptlang.org) using the [Deno](https://deno.com) JavaScript runtime.\n\nThis repository includes code for the [Elliptic-Curve Diffie-Hellman (ECDH)](https://muens.io/elliptic-curve-diffie-hellman) key agreement protocol as well as the [Elliptic-Curve Digital Signature Algorithm (ECDSA)](https://muens.io/elliptic-curve-digital-signature-algorithm). Both are implemented on top of the [secp256k1](https://en.bitcoin.it/wiki/Secp256k1) curve that's also used in Bitcoin and Ethereum.\n\nIn addition to a \"raw\" ECDSA implementation there's also one that can be used to sign messages and transact on the [Ethereum](https://ethereum.org) Blockchain. To do so easily, an [Ethers](https://github.com/ethers-io/ethers.js) v6 compliant [Signer](https://docs.ethers.org/v6/api/providers/#Signer) was implemented which wraps the ECDSA functionalities.\n\nNote that the code you'll find here **wasn't audited** and is definitely **not constant time**. You should therefore use this codebase as an educational resource which was my intention when I wrote it.\n\nThe best way to understand the code is to dive into the [`*.test.ts`](./src) or [script](./src/scripts) files and see how different parts of the code interact.\n\nAll the resources I've studied to write this implementation can be found in the [Useful Resources](#useful-resources) section.\n\n## Setup\n\n1. `git clone \u003curl\u003e`\n2. `deno test`\n3. `deno task dev`\n\n## Scripts\n\nThe following are scripts you can run to test the implementation.\n\nSome scripts require you to get some test ETH on Sepolia. There are various faucets available online you can use to get access to testnet ETH.\n\n```sh\n# Generate a new private- and public key pair.\ndeno task keys\n\n# Display information for an existing key pair.\nPRIVATE_KEY=0x1234567890 deno task keys\n\n# Get the account balance on the Sepolia test network.\nPRIVATE_KEY=0x1234567890 deno task balance\n\n# Sign a message.\nPRIVATE_KEY=0x1234567890 deno task sign\n\n# Send ETH to another address on the Sepolia test network.\nPRIVATE_KEY=0x1234567890 deno task send\n```\n\n## Useful Commands\n\n```sh\ndeno init\n\ndeno info\ndeno doc [\u003cpath\u003e]\ndeno repl\ndeno bench \u003cpath\u003e\ndeno compile [-A] \u003cpath\u003e\n\ndeno fmt [\u003cpath\u003e]\ndeno lint [\u003cpath\u003e]\ndeno test [\u003cpath\u003e]\n\ndeno run \u003cpath\u003e\n\ndeno task dev\n```\n\n## Useful Resources\n\n- [Wikipedia - Elliptic Curve Cryptography](https://en.wikipedia.org/wiki/Elliptic-curve_cryptography)\n- [Wikipedia - Elliptic-Curve Diffie-Hellman](https://en.wikipedia.org/wiki/Elliptic-curve_Diffie–Hellman)\n- [Wikipedia - Elliptic Curve Digital Signature Algorithm](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)\n- [Philipp Muens - Elliptic-Curve Diffie-Hellman](https://muens.io/elliptic-curve-diffie-hellman)\n- [Anirudha Bose - Roll your own crypto\\*](https://onyb.gitbook.io/roll-your-own-crypto)\n- [Andrea Corbellini - Elliptic Curve Cryptography: a gentle introduction](https://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction)\n- [Andrea Corbellini - Elliptic Curve Cryptography: finite fields and discrete logarithms](https://andrea.corbellini.name/2015/05/23/elliptic-curve-cryptography-finite-fields-and-discrete-logarithms)\n- [Andrea Corbellini - Elliptic Curve Cryptography: ECDH and ECDSA](https://andrea.corbellini.name/2015/05/30/elliptic-curve-cryptography-ecdh-and-ecdsa)\n- [Andrea Corbellini - Elliptic Curve Cryptography: breaking security and a comparison with RSA](https://andrea.corbellini.name/2015/06/08/elliptic-curve-cryptography-breaking-security-and-a-comparison-with-rsa)\n- [Paul Miller - Learning fast elliptic-curve cryptography](https://paulmillr.com/posts/noble-secp256k1-fast-ecc)\n- [Hyperelliptic - Short Weierstrass curves](http://hyperelliptic.org/EFD/g1p/auto-shortw.html)\n- [Bitcoin Wiki - Secp256k1](https://en.bitcoin.it/wiki/Secp256k1)\n- [Lucas Henning - The Dark Side of the Elliptic Curve - Signing Ethereum Transactions with AWS KMS in JavaScript](https://luhenning.medium.com/the-dark-side-of-the-elliptic-curve-signing-ethereum-transactions-with-aws-kms-in-javascript-83610d9a6f81)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmuens%2Fecc-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmuens%2Fecc-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmuens%2Fecc-ts/lists"}