mirror of
https://github.com/arnaucube/blockchainIDsystem.git
synced 2026-02-07 02:56:43 +01:00
sendtoserveridsigner
This commit is contained in:
@@ -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`)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,9 +22,15 @@ var routes = Routes{
|
||||
NewID,
|
||||
},
|
||||
Route{
|
||||
"BlindAndVerify",
|
||||
"BlindAndSendToSign",
|
||||
"GET",
|
||||
"/blindandverify/{pubK}",
|
||||
BlindAndVerify,
|
||||
"/blindandsendtosign/{pubK}",
|
||||
BlindAndSendToSign,
|
||||
},
|
||||
Route{
|
||||
"Verify",
|
||||
"GET",
|
||||
"/verify/{pubK}",
|
||||
Verify,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user