Git Product home page Git Product logo

ecc-ts's Introduction

Elliptic Curve Cryptography

A "from scratch" Elliptic Curve Cryptography implementation in TypeScript using the Deno JavaScript runtime.

This repository includes code for the Elliptic-Curve Diffie-Hellman (ECDH) key agreement protocol as well as the Elliptic-Curve Digital Signature Algorithm (ECDSA). Both are implemented on top of the secp256k1 curve that's also used in Bitcoin and Ethereum.

In addition to a "raw" ECDSA implementation there's also one that can be used to sign messages and transact on the Ethereum Blockchain. To do so easily, an Ethers v6 compliant Signer was implemented which wraps the ECDSA functionalities.

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

The best way to understand the code is to dive into the *.test.ts or script files and see how different parts of the code interact.

All the resources I've studied to write this implementation can be found in the Useful Resources section.

Setup

  1. git clone <url>
  2. deno test
  3. deno task dev

Scripts

The following are scripts you can run to test the implementation.

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

# Generate a new private- and public key pair.
deno task keys

# Display information for an existing key pair.
PRIVATE_KEY=0x1234567890 deno task keys

# Get the account balance on the Sepolia test network.
PRIVATE_KEY=0x1234567890 deno task balance

# Sign a message.
PRIVATE_KEY=0x1234567890 deno task sign

# Send ETH to another address on the Sepolia test network.
PRIVATE_KEY=0x1234567890 deno task send

Useful Commands

deno init

deno info
deno doc [<path>]
deno repl
deno bench <path>
deno compile [-A] <path>

deno fmt [<path>]
deno lint [<path>]
deno test [<path>]

deno run <path>

deno task dev

Useful Resources

ecc-ts's People

Contributors

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