diff --git a/README.md b/README.md index 18c30ea..357c9e2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,20 @@ # blockchainIDsystem A blockchain based anonymous distributed login system +### Warning! Academical version +This version is only for academical purposes, is not a version to run in production. Everything has been developed from scratch (the p2p network, the blockchain, the RSA library, ...) to learn it deeply. +Also this version is not finished. + +A new version of this project, being developed using libaries and Ethereum network, is in https://github.com/arnaucode/darkID + ### Main concept The objective is to guarantee a decentralized login system, but making sure that registered users are real ones and there are no bots generating large amounts of accounts. Only the verified (by email or phone) users can generate an anonymous ID (the Public-Key blind signed). + +![screenshot](https://raw.githubusercontent.com/arnaucode/blockchainIDsystem/master/documentation/screenshot01.png "screenshot") + +![screenshot](https://raw.githubusercontent.com/arnaucode/blockchainIDsystem/master/documentation/screenshot02.png "screenshot") + ## How it works? diff --git a/clientApp/GUI/main.js b/clientApp/GUI/main.js index 8c0fbf3..4125803 100644 --- a/clientApp/GUI/main.js +++ b/clientApp/GUI/main.js @@ -17,9 +17,9 @@ function createWindow () { mainWindow = new BrowserWindow({ width: 850, height: 600, - icon: 'icon.png' + icon: 'img/blockchainIDsystem-logo-white.png' }) - tray = new Tray('icon.png') + tray = new Tray('img/blockchainIDsystem-logo-white.png') const contextMenu = Menu.buildFromTemplate([ {label: 'Obre la finestra', type: 'radio'}, {label: 'javascript madness', type: 'radio'}, @@ -29,7 +29,7 @@ function createWindow () { tray.setToolTip('Panopticon, projectNSA') tray.setContextMenu(contextMenu) - //mainWindow.setMenu(null); + mainWindow.setMenu(null); // and load the index.html of the app. mainWindow.loadURL(`file://${__dirname}/index.html`) diff --git a/clientApp/GUI/views/login/login.html b/clientApp/GUI/views/login/login.html index 19b90d2..3261fdc 100755 --- a/clientApp/GUI/views/login/login.html +++ b/clientApp/GUI/views/login/login.html @@ -1,9 +1,9 @@ -
+
-
+
-
+
@@ -12,15 +12,20 @@ - - -
Login
+
+
+
Signup
+
+
+
Login
+
+
-
+
diff --git a/clientApp/GUI/views/main/main.html b/clientApp/GUI/views/main/main.html index 1889245..6ea76a7 100755 --- a/clientApp/GUI/views/main/main.html +++ b/clientApp/GUI/views/main/main.html @@ -6,26 +6,33 @@
-

- blockchainIDsystem -

-

- Generate new ID -

Create new ID
-

+
Create new ID
+

- Current IDs + My IDs

-
+
Public Key: {{id.pubK}} -
Private Key: {{id.privK}} +
Date of creation: {{id.date}} + +
+

-
Blind & Send to serverIDsigner
+
+ Not verified + Verified +
+
+ Not signed + Signed +
+
Send to serverIDsigner
+
Verify
diff --git a/clientApp/GUI/views/main/main.js b/clientApp/GUI/views/main/main.js index 7591b0d..1563896 100755 --- a/clientApp/GUI/views/main/main.js +++ b/clientApp/GUI/views/main/main.js @@ -33,8 +33,19 @@ angular.module('app.main', ['ngRoute']) }); }; - $scope.blindAndVerify = function(pubK) { - $http.get(clientapi + 'blindandverify/' + pubK) + $scope.blindAndSendToSign = function(pubK) { + $http.get(clientapi + 'blindandsendtosign/' + pubK) + .then(function(data) { + console.log('data success'); + console.log(data); + $scope.ids = data.data; + + }, function(data) { + console.log('data error'); + }); + }; + $scope.verify = function(pubK) { + $http.get(clientapi + 'verify/' + pubK) .then(function(data) { console.log('data success'); console.log(data); diff --git a/clientApp/clientAppRESTFunctions.go b/clientApp/clientAppRESTFunctions.go index f185390..44208f2 100644 --- a/clientApp/clientAppRESTFunctions.go +++ b/clientApp/clientAppRESTFunctions.go @@ -50,7 +50,7 @@ type AskBlindSign struct { M string `json:"m"` } -func BlindAndVerify(w http.ResponseWriter, r *http.Request) { +func BlindAndSendToSign(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) packPubK := vars["pubK"] color.Green(packPubK) @@ -61,9 +61,6 @@ func BlindAndVerify(w http.ResponseWriter, r *http.Request) { var key ownrsa.RSA //search for complete key for _, k := range keys { - fmt.Println(k.PubK) - fmt.Println(packPubK) - fmt.Println("") if k.PubK == packPubK { key = ownrsa.UnpackKey(k) } @@ -104,10 +101,69 @@ func BlindAndVerify(w http.ResponseWriter, r *http.Request) { sigma := ownrsa.StringToArrayInt(askBlindSign.M, "_") fmt.Println(sigma) + //get the serverIDsigner pubK + serverPubK := getServerPubK("http://" + config.ServerIDSigner.IP + ":" + config.ServerIDSigner.Port) + //unblind the response - //TODO - //després de la blindsign response, demanar al serverIDsigner la pubK - //unblinded := ownrsa.Unblind(sigma, rVal, ) + mSigned := ownrsa.Unblind(sigma, rVal, serverPubK) + fmt.Print("mSigned: ") + fmt.Println(mSigned) + + verified := ownrsa.Verify(m, mSigned, serverPubK) + fmt.Println(verified) + + var iKey int + for i, k := range keys { + if k.PubK == packPubK { + iKey = i + //save to k the key updated + k.PubKSigned = ownrsa.ArrayIntToString(mSigned, "_") + k.Verified = verified + } + fmt.Println(k) + } + keys[iKey].PubKSigned = ownrsa.ArrayIntToString(mSigned, "_") + keys[iKey].Verified = verified + fmt.Println(keys) + saveKeys(keys, "keys.json") + + jResp, err := json.Marshal(keys) + check(err) + fmt.Fprintln(w, string(jResp)) +} + +func Verify(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + packPubK := vars["pubK"] + color.Green(packPubK) + + //read the keys stored in /keys directory + keys := readKeys("keys.json") + + var key ownrsa.PackRSA + //search for complete key + for _, k := range keys { + if k.PubK == packPubK { + key = k + } + } + + //get the serverIDsigner pubK + serverPubK := getServerPubK("http://" + config.ServerIDSigner.IP + ":" + config.ServerIDSigner.Port) + m := ownrsa.StringToArrayInt(key.PubK, "_") + mSigned := ownrsa.StringToArrayInt(key.PubKSigned, "_") + + verified := ownrsa.Verify(m, mSigned, serverPubK) + fmt.Println(verified) + + for _, k := range keys { + if k.PubK == packPubK { + //save to k the key updated + k.PubKSigned = ownrsa.ArrayIntToString(mSigned, "_") + k.Verified = verified + } + } + saveKeys(keys, "keys.json") jResp, err := json.Marshal(keys) check(err) diff --git a/clientApp/keys.go b/clientApp/keys.go index a5483ff..5d6b1f4 100644 --- a/clientApp/keys.go +++ b/clientApp/keys.go @@ -2,9 +2,12 @@ package main import ( "encoding/json" + "fmt" "io/ioutil" + "net/http" ownrsa "./ownrsa" + "github.com/fatih/color" ) func readKeys(path string) []ownrsa.PackRSA { @@ -24,3 +27,21 @@ func saveKeys(keys []ownrsa.PackRSA, path string) { err = ioutil.WriteFile(path, jsonKeys, 0644) check(err) } + +func getServerPubK(url string) ownrsa.RSAPublicKey { + r, err := http.Get(url + "/") + check(err) + fmt.Println(r) + + decoder := json.NewDecoder(r.Body) + //var sigmaString string + var pubK ownrsa.RSAPublicKey + err = decoder.Decode(&pubK) + if err != nil { + panic(err) + } + defer r.Body.Close() + color.Blue("received server pubK:") + fmt.Println(pubK) + return pubK +} diff --git a/clientApp/ownrsa/rsa.go b/clientApp/ownrsa/rsa.go index 86c28e5..1e18627 100644 --- a/clientApp/ownrsa/rsa.go +++ b/clientApp/ownrsa/rsa.go @@ -33,6 +33,7 @@ type PackRSA struct { PrivK string `json:"privK"` Date time.Time `json:"date"` PubKSigned string `json:"pubKSigned"` + Verified bool `json:"verified"` } const maxPrime = 500 diff --git a/clientApp/restRoutes.go b/clientApp/restRoutes.go index 6cff6c7..9be9448 100755 --- a/clientApp/restRoutes.go +++ b/clientApp/restRoutes.go @@ -22,9 +22,15 @@ var routes = Routes{ NewID, }, Route{ - "BlindAndVerify", + "BlindAndSendToSign", "GET", - "/blindandverify/{pubK}", - BlindAndVerify, + "/blindandsendtosign/{pubK}", + BlindAndSendToSign, + }, + Route{ + "Verify", + "GET", + "/verify/{pubK}", + Verify, }, } diff --git a/documentation/screenshot01.png b/documentation/screenshot01.png new file mode 100644 index 0000000..1ed6847 Binary files /dev/null and b/documentation/screenshot01.png differ diff --git a/documentation/screenshot02.png b/documentation/screenshot02.png new file mode 100644 index 0000000..e81b4b3 Binary files /dev/null and b/documentation/screenshot02.png differ diff --git a/serverIDsigner/userRESTFunctions.go b/serverIDsigner/userRESTFunctions.go index cacb803..29fea4c 100644 --- a/serverIDsigner/userRESTFunctions.go +++ b/serverIDsigner/userRESTFunctions.go @@ -22,7 +22,12 @@ type User struct { func Index(w http.ResponseWriter, r *http.Request) { //TODO return the public key, to allow others verifign signed strings by this server - fmt.Fprintln(w, "serverIDsigner") + + jResp, err := json.Marshal(serverRSA.PubK) + if err != nil { + panic(err) + } + fmt.Fprintln(w, string(jResp)) } func Signup(w http.ResponseWriter, r *http.Request) {