Giter VIP home page Giter VIP logo

ecdsa-node-1's Introduction

ECDSA Node

Description

This project is an example of using a client and server to facilitate transfers between different addresses. We use Elliptic Curve Digital Signatures to make sure transfers are done by the sender address only.

How is the logic built

  • Use generateKeys.js script to generate a private/public key pair. As an example wwe generate 3 users and assigned an initial balance to them. Addresses with their respective private/public keys are mentioned at the end of the script.
  • Use signTransaction.js script to sign a transfer transaction using your private key. Make sure to replace the 2nd sign parameter by your private key, and msg by the transfer to be done. the message follows this format : address1,address2,amount,nonce. You can get the nonce to be used by putting your address in the frontEnd and reading the Next Nonce field.
  • User should pass in the recoveryBit, message and signature in the frontEnd ( the signature ad recoveryBit are returned by signTransaction script). Then hit the Submit botton.
  • The server will recover the public key of the signer, and his address:
    • if the signer address is different from the sender of funds, an error is returned.
    • if not and the sender has enough funds, the transfer is executed.
    • we return the amount, sender address and receipent address to the frontend to be shown.
  • The private key of the user is never sent to the app ( neither client nor server side) which prevent it from being compromised.
  • It is not possible to transfer funds from a different account, as the signer of the transaction should be the same as the sender of funds.
  • We introduce a nonce for each user, to prevent signature to be re-used by an attacker (replay attack). For every new transaction sent by a user, he should use the nextNonce.

How to run the project

Client

  1. Open up a terminal in the /client folder
  2. Run npm install to install all the depedencies
  3. Run npm run dev to start the application

Server

  1. Open a terminal within the /server folder
  2. Run npm install to install all the depedencies
  3. Run node index to start the server

ecdsa-node-1's People

Contributors

dan-nolan avatar yasmine9 avatar elanh 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.