From cd66a12ed3dbcbc8ec921ac7918327f43c47c6a0 Mon Sep 17 00:00:00 2001 From: Gordon Hall Date: Mon, 2 Jun 2014 17:00:24 -0400 Subject: [PATCH 1/7] made some adjustments to copay for copay shell integration --- README.md | 74 ++++++++++++++++++---------------------- app.js | 21 +++++++----- index.html | 96 ++++++++++++++++++++++++++-------------------------- js/app.js | 1 - js/shell.js | 60 ++++++++++++++++++++++++++++++++ launch.js | 3 +- package.json | 2 ++ server.js | 6 ++++ 8 files changed, 161 insertions(+), 102 deletions(-) create mode 100644 js/shell.js create mode 100644 server.js diff --git a/README.md b/README.md index 80dd940dc..3d179c8d9 100644 --- a/README.md +++ b/README.md @@ -26,23 +26,23 @@ cp config.template.js config.js Open Copay: ``` -node app.js +npm start ``` Then visit localhost:3000 in your browser. To run on a different port: ``` -PORT=3001 node app.js +PORT=3001 npm start ``` To open up five different instances to test 3-of-5 multisig with yourself, then run this in 5 different terminals: ``` -PORT=3001 node app.js -PORT=3002 node app.js -PORT=3003 node app.js -PORT=3004 node app.js -PORT=3005 node app.js +PORT=3001 npm start +PORT=3002 npm start +PORT=3003 npm start +PORT=3004 npm start +PORT=3005 npm start ``` To open n different instances just run: @@ -59,22 +59,22 @@ General *Copay* implements a multisig wallet using p2sh addresses. It supports multiple wallet configurations, such as 3-of-5 (3 required signatures from 5 participant peers) or 2-of-3. To create a multisig wallet shared between multiple participants, -*Copay* needs the public keys of all the wallet participants. Those public keys are incorporated into the +*Copay* needs the public keys of all the wallet participants. Those public keys are incorporated into the wallet configuration and are combined to generate a payment address with which funds can be sent into the wallet. -To unlock the payment and spend the wallet's funds, a quorum of participant signatures must be collected +To unlock the payment and spend the wallet's funds, a quorum of participant signatures must be collected and assembled in the transaction. The funds cannot be spent without at least the minimum number of -signatures required by the wallet configuration (2 of 3, 3 of 5, 6 of 6, etc). -Each participant manages their own private key, and that private key is never transmitted anywhere. -Once a transaction proposal is created, the proposal is distributed among the -wallet participants for each participant to sign the transaction locally. -Once the transaction is signed, the last signing participant will broadcast the +signatures required by the wallet configuration (2 of 3, 3 of 5, 6 of 6, etc). +Each participant manages their own private key, and that private key is never transmitted anywhere. +Once a transaction proposal is created, the proposal is distributed among the +wallet participants for each participant to sign the transaction locally. +Once the transaction is signed, the last signing participant will broadcast the transaction to the Bitcoin network using a public API (defaults to the Insight API). -*Copay* also implements BIP32 to generate new addresses for the peers. The public key each participant contributes -to the wallet is a BIP32 extended public key. As additional public keys are needed for wallet operations (to produce -new addresses to receive payments into the wallet, for example) new public keys can be derived from the participants' -original extended public keys. Each participant keeps their own private keys locally. Private keys are not shared. +*Copay* also implements BIP32 to generate new addresses for the peers. The public key each participant contributes +to the wallet is a BIP32 extended public key. As additional public keys are needed for wallet operations (to produce +new addresses to receive payments into the wallet, for example) new public keys can be derived from the participants' +original extended public keys. Each participant keeps their own private keys locally. Private keys are not shared. Private keys are used to sign transaction proposals to make a payment from the shared wallet. Serverless web @@ -83,17 +83,17 @@ Serverless web JavaScript. For persistent storage, the client browser's *localStorage* is used. Locally stored data is encrypted using a password provided by the local user. Data kept in browser local storage should be backed up for safekeeping using one of the methods provided by *Copay*, such as downloading the data into a file. -Without a proper backup of the user's private key data, all funds stored in the -wallet may be lost or inaccessible if the browser's localStorage is deleted, the browser uninstalled, +Without a proper backup of the user's private key data, all funds stored in the +wallet may be lost or inaccessible if the browser's localStorage is deleted, the browser uninstalled, the local hard disk fails, etc. Peer communications ------------------- -*Copay* uses peer-to-peer (p2p) networking to communicate between wallet participants. Participants exchange transaction -proposals, public keys, nicknames and information about the wallet configuration. Private keys are *not* shared with anyone. +*Copay* uses peer-to-peer (p2p) networking to communicate between wallet participants. Participants exchange transaction +proposals, public keys, nicknames and information about the wallet configuration. Private keys are *not* shared with anyone. *Copay* network communications use the webRTC protocol. A p2p facilitator server is needed to enable the peers to find each other. - *Copay* uses the open-sourced *peerjs* server implementation for p2p discovery. Wallet participants can use a + *Copay* uses the open-sourced *peerjs* server implementation for p2p discovery. Wallet participants can use a public peerjs server or install their own. Once the peers find each other, a true p2p connection is established between the peers and there is no further flow of information to the p2p discovery server. @@ -102,19 +102,19 @@ certificate. Security model -------------- -On top of webRTC, *Copay* peers authenticate as part of the "wallet ring"(WR) using an identity -key and a network key. +On top of webRTC, *Copay* peers authenticate as part of the "wallet ring"(WR) using an identity +key and a network key. -The *identity key* is a ECDSA public key derived from the participant's extended public +The *identity key* is a ECDSA public key derived from the participant's extended public key using a specific BIP32 branch. This special public key is never used for Bitcoin address creation, and -should only be known by members of the WR. -In *Copay* this special public key is named *copayerId*. The copayerId is hashed and the hash is used to +should only be known by members of the WR. +In *Copay* this special public key is named *copayerId*. The copayerId is hashed and the hash is used to register with the peerjs server. Registering with a hash avoids disclosing the copayerId to parties outside of the WR. Peer discovery is accomplished using only the hashes of the WR members' copayerIds. All members of the WR know the full copayerIds of all the other members of the WR. -The *network key* is a random key generated and distributed among the wallet members during wallet creation. -The network key is stored by each peer in the wallet configuration. The network key is used in establishing a CCM/AES +The *network key* is a random key generated and distributed among the wallet members during wallet creation. +The network key is stored by each peer in the wallet configuration. The network key is used in establishing a CCM/AES authenticated encrypted channel between all members of the WR, on top of webRTC. Use of this *network key* prevents man-in-the-middle attacks from a compromised peerjs server. @@ -132,16 +132,6 @@ The string is encoded using Bitcoin's Base58Check encoding, to prevent transmiss Peer Authentication ------------------- -It is important to note that - except for private keys - *all data* in the wallet is shared with *all members of the wallet*. -Private keys are never shared with anyone and are never sent over the network. There are no *private* messages between +It is important to note that - except for private keys - *all data* in the wallet is shared with *all members of the wallet*. +Private keys are never shared with anyone and are never sent over the network. There are no *private* messages between individual members of the wallet. All members of a wallet see everything that happens in that wallet. - - - - - - - - - - diff --git a/app.js b/app.js index 543f33e01..69407cdcb 100644 --- a/app.js +++ b/app.js @@ -1,12 +1,15 @@ -var express=require("express"); -var http=require("http"); +var express = require('express'); +var http = require('http'); +var app = express(); -var app=express(); +app.start = function(port, callback) { -var port = process.env.PORT || 3000; -app.set("port", port); -app.use(express.static(__dirname)); + app.set('port', port); + app.use(express.static(__dirname)); -app.listen(port, function(){ - console.log("Listening at: http://localhost:" + port); -}); + app.listen(port, function() { + callback('http://localhost:' + port); + }); +}; + +module.exports = app; diff --git a/index.html b/index.html index 0c020d33a..a040366e0 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
-
+
@@ -23,15 +23,15 @@
- Balance: + Balance: @@ -48,7 +48,7 @@
- +
@@ -63,14 +63,14 @@
- +
@@ -86,19 +86,19 @@
- - Not all copayers have joined your wallet yet. + + Not all copayers have joined your wallet yet. - {{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} people have + {{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} people have - One person has + One person has - yet to join. + yet to join.
- -
+ +

Share this secret with your other copayers for them to join your wallet @@ -132,7 +132,7 @@
- Copay + Copay v{{version}}
@@ -150,18 +150,18 @@

-
- -
@@ -229,7 +229,7 @@
- + - + @@ -413,7 +413,7 @@
-
+
@@ -441,17 +441,17 @@
{{$root.wallet.publicKeyRing.nicknameForCopayer(cId)}}
-
+
-
+
@@ -460,7 +460,7 @@
- +
Transaction finally rejected @@ -470,20 +470,20 @@ Sent
- Transaction ID: + Transaction ID: {{tx.sentTxid}}
-

+

One signature missing

-

+

{{tx.missingSignatures}} signatures missing

-
+
Fee: {{tx.fee}} - Proposal ID: {{tx.ntxid}} + Proposal ID: {{tx.ntxid}}
@@ -546,7 +546,7 @@
-
+ @@ -600,11 +600,11 @@
-