sendtoserveridsigner

This commit is contained in:
arnaucode
2017-12-28 16:15:09 +01:00
parent 4898cae5c0
commit f0aa841275
12 changed files with 157 additions and 34 deletions

View File

@@ -1,9 +1,20 @@
# blockchainIDsystem # blockchainIDsystem
A blockchain based anonymous distributed login system 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 ### 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). 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? ## How it works?

View File

@@ -17,9 +17,9 @@ function createWindow () {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 850, width: 850,
height: 600, 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([ const contextMenu = Menu.buildFromTemplate([
{label: 'Obre la finestra', type: 'radio'}, {label: 'Obre la finestra', type: 'radio'},
{label: 'javascript madness', type: 'radio'}, {label: 'javascript madness', type: 'radio'},
@@ -29,7 +29,7 @@ function createWindow () {
tray.setToolTip('Panopticon, projectNSA') tray.setToolTip('Panopticon, projectNSA')
tray.setContextMenu(contextMenu) tray.setContextMenu(contextMenu)
//mainWindow.setMenu(null); mainWindow.setMenu(null);
// and load the index.html of the app. // and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`) mainWindow.loadURL(`file://${__dirname}/index.html`)

View File

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

View File

@@ -6,26 +6,33 @@
<div class="col-sm-8"> <div class="col-sm-8">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="card-title"> <div ng-click="newID()" class="btn btn-raised c_o_pink300">Create new ID</div>
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> </div>
<hr>
<div class="card-body"> <div class="card-body">
<h4 class="card-title"> <h4 class="card-title">
Current IDs My IDs
</h4> </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"> <div class="col-sm-6">
Public Key: {{id.pubK}} Public Key: {{id.pubK}}
<br> Private Key: {{id.privK}} <!--<br> Private Key: {{id.privK}}-->
<br> Date of creation: {{id.date}} <br> Date of creation: {{id.date}}
<!--<br> {{id.pubKSigned}}-->
<br>
<br><br>
</div> </div>
<div class="col-sm-6"> <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> </div>
</div> </div>

View File

@@ -33,8 +33,19 @@ angular.module('app.main', ['ngRoute'])
}); });
}; };
$scope.blindAndVerify = function(pubK) { $scope.blindAndSendToSign = function(pubK) {
$http.get(clientapi + 'blindandverify/' + 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) { .then(function(data) {
console.log('data success'); console.log('data success');
console.log(data); console.log(data);

View File

@@ -50,7 +50,7 @@ type AskBlindSign struct {
M string `json:"m"` M string `json:"m"`
} }
func BlindAndVerify(w http.ResponseWriter, r *http.Request) { func BlindAndSendToSign(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
packPubK := vars["pubK"] packPubK := vars["pubK"]
color.Green(packPubK) color.Green(packPubK)
@@ -61,9 +61,6 @@ func BlindAndVerify(w http.ResponseWriter, r *http.Request) {
var key ownrsa.RSA var key ownrsa.RSA
//search for complete key //search for complete key
for _, k := range keys { for _, k := range keys {
fmt.Println(k.PubK)
fmt.Println(packPubK)
fmt.Println("")
if k.PubK == packPubK { if k.PubK == packPubK {
key = ownrsa.UnpackKey(k) key = ownrsa.UnpackKey(k)
} }
@@ -104,10 +101,69 @@ func BlindAndVerify(w http.ResponseWriter, r *http.Request) {
sigma := ownrsa.StringToArrayInt(askBlindSign.M, "_") sigma := ownrsa.StringToArrayInt(askBlindSign.M, "_")
fmt.Println(sigma) fmt.Println(sigma)
//get the serverIDsigner pubK
serverPubK := getServerPubK("http://" + config.ServerIDSigner.IP + ":" + config.ServerIDSigner.Port)
//unblind the response //unblind the response
//TODO mSigned := ownrsa.Unblind(sigma, rVal, serverPubK)
//després de la blindsign response, demanar al serverIDsigner la pubK fmt.Print("mSigned: ")
//unblinded := ownrsa.Unblind(sigma, rVal, ) 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) jResp, err := json.Marshal(keys)
check(err) check(err)

View File

@@ -2,9 +2,12 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io/ioutil" "io/ioutil"
"net/http"
ownrsa "./ownrsa" ownrsa "./ownrsa"
"github.com/fatih/color"
) )
func readKeys(path string) []ownrsa.PackRSA { func readKeys(path string) []ownrsa.PackRSA {
@@ -24,3 +27,21 @@ func saveKeys(keys []ownrsa.PackRSA, path string) {
err = ioutil.WriteFile(path, jsonKeys, 0644) err = ioutil.WriteFile(path, jsonKeys, 0644)
check(err) 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
}

View File

@@ -33,6 +33,7 @@ type PackRSA struct {
PrivK string `json:"privK"` PrivK string `json:"privK"`
Date time.Time `json:"date"` Date time.Time `json:"date"`
PubKSigned string `json:"pubKSigned"` PubKSigned string `json:"pubKSigned"`
Verified bool `json:"verified"`
} }
const maxPrime = 500 const maxPrime = 500

View File

@@ -22,9 +22,15 @@ var routes = Routes{
NewID, NewID,
}, },
Route{ Route{
"BlindAndVerify", "BlindAndSendToSign",
"GET", "GET",
"/blindandverify/{pubK}", "/blindandsendtosign/{pubK}",
BlindAndVerify, BlindAndSendToSign,
},
Route{
"Verify",
"GET",
"/verify/{pubK}",
Verify,
}, },
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -22,7 +22,12 @@ type User struct {
func Index(w http.ResponseWriter, r *http.Request) { func Index(w http.ResponseWriter, r *http.Request) {
//TODO return the public key, to allow others verifign signed strings by this server //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) { func Signup(w http.ResponseWriter, r *http.Request) {