Browse Source

sendtoserveridsigner

master
arnaucode 6 years ago
parent
commit
f0aa841275
12 changed files with 157 additions and 34 deletions
  1. +11
    -0
      README.md
  2. +3
    -3
      clientApp/GUI/main.js
  3. +12
    -7
      clientApp/GUI/views/login/login.html
  4. +18
    -11
      clientApp/GUI/views/main/main.html
  5. +13
    -2
      clientApp/GUI/views/main/main.js
  6. +63
    -7
      clientApp/clientAppRESTFunctions.go
  7. +21
    -0
      clientApp/keys.go
  8. +1
    -0
      clientApp/ownrsa/rsa.go
  9. +9
    -3
      clientApp/restRoutes.go
  10. BIN
      documentation/screenshot01.png
  11. BIN
      documentation/screenshot02.png
  12. +6
    -1
      serverIDsigner/userRESTFunctions.go

+ 11
- 0
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?

+ 3
- 3
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`)

+ 12
- 7
clientApp/GUI/views/login/login.html

@ -1,9 +1,9 @@
<div class="container">
<div class="container" style="margin-top: -80px;">
<div class="row">
<div class="col-sm-4">
<div class="col-sm-3">
</div>
<div class="col-sm-4">
<div class="col-sm-6">
<div class="card">
<img src="img/blockchainIDsystem-logo01.png" class="img-responsive" />
<div class="card-body">
@ -12,15 +12,20 @@
</h4>
<input ng-model="user.email" class="form-control" placeholder="Email" type="text">
<input ng-model="user.password" class="form-control" placeholder="Password" type="password">
<div ng-click="login()" class="btn btn-raised btn-block c_o_cyan300 pull-right">Login</div>
<div class="row">
<div class="col-sm-6">
<div href="#!/signup" class="btn btn-raised btn-block c_o_pink300">Signup</div>
</div>
<div class="col-sm-6">
<div ng-click="login()" class="btn btn-raised btn-block c_o_cyan300 pull-right">Login</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="col-sm-3">
</div>
</div>

+ 18
- 11
clientApp/GUI/views/main/main.html

@ -6,26 +6,33 @@
<div class="col-sm-8">
<div class="card">
<div class="card-body">
<h4 class="card-title">
blockchainIDsystem
</h4>
<p>
Generate new ID
<div ng-click="newID()" class="btn btn-raised pull-right c_o_cyan300">Create new ID</div>
</p>
<div ng-click="newID()" class="btn btn-raised c_o_pink300">Create new ID</div>
</div>
<hr>
<div class="card-body">
<h4 class="card-title">
Current IDs
My IDs
</h4>
<div class="row" ng-repeat="id in ids">
<div class="row" style="height:200px;" ng-repeat="id in ids">
<div class="col-sm-6">
Public Key: {{id.pubK}}
<br> Private Key: {{id.privK}}
<!--<br> Private Key: {{id.privK}}-->
<br> Date of creation: {{id.date}}
<!--<br> {{id.pubKSigned}}-->
<br>
<br><br>
</div>
<div class="col-sm-6">
<div ng-click="blindAndVerify(id.pubK)" class="btn btn-raised c_o_indigo300">Blind & Send to serverIDsigner</div>
<div class="pull-right">
<span class="badge c_o_red300" ng-show="!id.verified">Not verified</span>
<span class="badge c_o_green300" ng-show="id.verified">Verified</span>
</div>
<div class="pull-right">
<span class="badge c_o_orange300" ng-show="!id.pubKSigned">Not signed</span>
<span class="badge c_o_green300" ng-show="id.pubKSigned">Signed</span>
</div>
<div ng-click="blindAndSendToSign(id.pubK)" ng-show="!id.pubKSigned" class="btn btn-sm btn-raised c_o_cyan300 pull-right">Send to serverIDsigner</div>
<div ng-click="verify(id.pubK)" ng-show="!id.verified"class="btn btn-sm btn-raised c_o_deepPurple300 pull-right">Verify</div>
</div>
</div>
</div>

+ 13
- 2
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);

+ 63
- 7
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)

+ 21
- 0
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
}

+ 1
- 0
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

+ 9
- 3
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,
},
}

BIN
documentation/screenshot01.png

Before After
Width: 856  |  Height: 631  |  Size: 77 KiB

BIN
documentation/screenshot02.png

Before After
Width: 852  |  Height: 629  |  Size: 52 KiB

+ 6
- 1
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) {

Loading…
Cancel
Save