Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ECDSA-Exchange
A Simple Exchange

Installing the Dependencies

To install the dependencies, simply navigate to the folder you cloned the ECDSA-Exchange into and use either yarn or npm to install the dependencies listed in the package.json.

Running the Server

To run the server, navigate to the /server folder in a terminal window and run 'node index'. Alternatively, use 'nodemon index' to restart the server any time your server code changes.

Running the Client

To run the client, go to the /client folder in the repository and use parceljs on the index.html:

'npx parcel index.html' and copy this url on any browser: http://localhost:1234

Run a Simple Simulations

In the server terminal, there will be 3 public & private address generated and each of these public address will have a separate funds to commit a transactions.

Each of these transactions will require it's own private key for authentications. Each sender will need to insert their own private key in the Password field before clicking the Submit button.

1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h1> Your Wallet </h1>
<h1> Send Amount </h1>
<input type="text" id="send-amount" placeholder="Send Amount" />
<input type="text" id="recipient" placeholder="Recipient" />
<input type="password" id="private-key" placeholder="Password">
<div class="button" id="transfer-amount">
Transfer Amount
</div>
Expand Down
34 changes: 29 additions & 5 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const EC = require("elliptic").ec;
const SHA256 = require("crypto-js/sha256");
const ec = new EC("secp256k1");

import "./index.scss";

const server = "http://localhost:3042";
Expand All @@ -9,8 +13,9 @@ document.getElementById("exchange-address").addEventListener('input', ({ target:
}

fetch(`${server}/balance/${value}`).then((response) => {
return response.json();
}).then(({ balance }) => {
return response.json();
})
.then(({ balance }) => {
document.getElementById("balance").innerHTML = balance;
});
});
Expand All @@ -19,16 +24,35 @@ document.getElementById("transfer-amount").addEventListener('click', () => {
const sender = document.getElementById("exchange-address").value;
const amount = document.getElementById("send-amount").value;
const recipient = document.getElementById("recipient").value;
const password = document.getElementById("private-key").value;



// set up signing with the private key
const key = ec.keyFromPrivate(password.toString(16));
const msg = "Signing Message From Sender";
const msgHash = SHA256(msg);
const signature = key.sign(msgHash.toString());

const transaction = {
msg,
signature: {
r: signature.r.toString(16),
s: signature.s.toString(16),
}
}

console.log(transaction);

const body = JSON.stringify({
sender, amount, recipient
sender, amount, recipient, transaction
});

const request = new Request(`${server}/send`, { method: 'POST', body });

fetch(request, { headers: { 'Content-Type': 'application/json' }}).then(response => {
fetch(request, { headers: { "Content-Type": "application/json" }}).then(response => {
return response.json();
}).then(({ balance }) => {
document.getElementById("balance").innerHTML = balance;
});
});
});
1 change: 1 addition & 0 deletions node_modules/.bin/ansi-html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/astring

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/browserslist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/cssesc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/detect-libc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/ejs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/is-docker

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jsesc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/miller-rabin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nanoid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/ncp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-gyp-build

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-gyp-build-optional

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-gyp-build-test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/parcel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/parser

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/rimraf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sass

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sha.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/svgo

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/terser

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading