diff --git a/clientApp/GUI/img/darkID-logo01_transparent.png b/clientApp/GUI/img/darkID-logo01_transparent.png
new file mode 100644
index 0000000..50cb8eb
Binary files /dev/null and b/clientApp/GUI/img/darkID-logo01_transparent.png differ
diff --git a/clientApp/GUI/views/id/id.html b/clientApp/GUI/views/id/id.html
index 339eb36..7a305f2 100644
--- a/clientApp/GUI/views/id/id.html
+++ b/clientApp/GUI/views/id/id.html
@@ -21,29 +21,30 @@
placeholder="Enter here the proof-of-decrypt..."
>
+
PoD:
{{decryptData.m}}
Proof of decrypt
-
-
-
-
-
-
Testing only:
-
-
-
-
-
- Encrypt
+
+
+
Testing only:
+
+
+
+
+
+
+
+ Encrypt
+
diff --git a/clientApp/GUI/views/login/login.js b/clientApp/GUI/views/login/login.js
index c5e7bdb..929b348 100755
--- a/clientApp/GUI/views/login/login.js
+++ b/clientApp/GUI/views/login/login.js
@@ -49,7 +49,7 @@ angular.module('app.login', ['ngRoute'])
window.location.reload();
} else {
console.log("login failed");
- toastr.error('Login failed');
+ toastr.error('Login failed, ' + data.data);
}
diff --git a/clientApp/GUI/views/signup/signup.js b/clientApp/GUI/views/signup/signup.js
index bfab98d..399f3eb 100755
--- a/clientApp/GUI/views/signup/signup.js
+++ b/clientApp/GUI/views/signup/signup.js
@@ -9,11 +9,27 @@ angular.module('app.signup', ['ngRoute'])
});
}])
-.controller('SignupCtrl', function($scope, $http, $routeParams) {
+.controller('SignupCtrl', function($scope, $http, $routeParams, $rootScope) {
$scope.user = {};
- $scope.doSignup = function() {
+ $scope.signup = function() {
console.log('Doing signup', $scope.user);
+ $http({
+ url: $rootScope.server + 'signup',
+ method: "POST",
+ headers: {
+ "Content-Type": undefined
+ },
+ data: $scope.user
+ })
+ .then(function(data) {
+ console.log("data: ");
+ console.log(data.data);
+ window.location="/";
+ },
+ function(data) {
+ console.log(data);
+ });
};
});
diff --git a/clientApp/main.go b/clientApp/main.go
index bf32d9f..b73d0e9 100644
--- a/clientApp/main.go
+++ b/clientApp/main.go
@@ -38,5 +38,8 @@ func main() {
}
func GUI() {
- //here, run electron app
+ //here, run webserver
+ log.Println("webserver in port " + "8080")
+ http.Handle("/", http.FileServer(http.Dir("./web")))
+ http.ListenAndServe(":"+"8080", nil)
}
diff --git a/darkID-library-login-example/.gitignore b/darkID-library-login-example/.gitignore
new file mode 100644
index 0000000..8afb6b9
--- /dev/null
+++ b/darkID-library-login-example/.gitignore
@@ -0,0 +1,3 @@
+keys.json
+keys
+web
diff --git a/darkID-library-login-example/README.md b/darkID-library-login-example/README.md
new file mode 100644
index 0000000..3634e94
--- /dev/null
+++ b/darkID-library-login-example/README.md
@@ -0,0 +1 @@
+# darkID-login-library-example
diff --git a/darkID-library-login-example/RESTfunctions.go b/darkID-library-login-example/RESTfunctions.go
new file mode 100644
index 0000000..340d8c0
--- /dev/null
+++ b/darkID-library-login-example/RESTfunctions.go
@@ -0,0 +1,75 @@
+package main
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+
+ "github.com/cryptoballot/rsablind"
+ "github.com/fatih/color"
+
+ "gopkg.in/mgo.v2/bson"
+)
+
+type User struct {
+ Id bson.ObjectId `json:"id" bson:"_id,omitempty"`
+ Email string `json:"email"`
+ Password string `json:"password"`
+ Token string `json:"token"`
+}
+
+func Index(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintln(w, "clientApp")
+}
+
+func Signup(w http.ResponseWriter, r *http.Request) {
+
+ decoder := json.NewDecoder(r.Body)
+ var user User
+ err := decoder.Decode(&user)
+ if err != nil {
+ panic(err)
+ }
+ defer r.Body.Close()
+
+ fmt.Print("user signup: ")
+ fmt.Println(user)
+
+ jResp, err := json.Marshal(user)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Fprintln(w, string(jResp))
+}
+
+func Login(w http.ResponseWriter, r *http.Request) {
+
+ decoder := json.NewDecoder(r.Body)
+ var key Key
+ err := decoder.Decode(&key)
+ if err != nil {
+ panic(err)
+ }
+ defer r.Body.Close()
+ //TODO check if the user password exists in the database
+
+ fmt.Print("key login: ")
+ fmt.Println(key)
+ token, err := newToken()
+ check(err)
+
+ //validate if the pubK darkID is in the blockchain
+
+ //verify that the darkID is signed
+ if err := rsablind.VerifyBlindSignature(key.ServerVerifier, key.Hashed, key.UnblindedSig); err != nil {
+ fmt.Println(err)
+ } else {
+ color.Green("blind signature verified")
+ }
+
+ /*jResp, err := json.Marshal(token)
+ if err != nil {
+ panic(err)
+ }*/
+ fmt.Fprintln(w, string(token))
+}
diff --git a/darkID-library-login-example/config.json b/darkID-library-login-example/config.json
new file mode 100755
index 0000000..dfefadd
--- /dev/null
+++ b/darkID-library-login-example/config.json
@@ -0,0 +1,3 @@
+{
+ "port": "5000"
+}
diff --git a/darkID-library-login-example/errors.go b/darkID-library-login-example/errors.go
new file mode 100755
index 0000000..b3cf6b2
--- /dev/null
+++ b/darkID-library-login-example/errors.go
@@ -0,0 +1,15 @@
+package main
+
+import (
+ "log"
+ "runtime"
+)
+
+func check(err error) {
+ if err != nil {
+ _, fn, line, _ := runtime.Caller(1)
+ log.Println(line)
+ log.Println(fn)
+ log.Println(err)
+ }
+}
diff --git a/darkID-library-login-example/hash.go b/darkID-library-login-example/hash.go
new file mode 100644
index 0000000..87c2932
--- /dev/null
+++ b/darkID-library-login-example/hash.go
@@ -0,0 +1,12 @@
+package main
+
+import (
+ "crypto/sha256"
+ "encoding/base64"
+)
+
+func hash(s string) string {
+ h := sha256.New()
+ h.Write([]byte(s))
+ return base64.URLEncoding.EncodeToString(h.Sum(nil))
+}
diff --git a/darkID-library-login-example/keys.go b/darkID-library-login-example/keys.go
new file mode 100644
index 0000000..cb4624b
--- /dev/null
+++ b/darkID-library-login-example/keys.go
@@ -0,0 +1,183 @@
+package main
+
+import (
+ "crypto/rsa"
+ "crypto/x509"
+ "encoding/asn1"
+ "encoding/json"
+ "encoding/pem"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "time"
+
+ "github.com/fatih/color"
+)
+
+type Key struct {
+ ID string `json:"id"`
+ PrivK string `json:"privK"` //path of the PrivK file
+ PubK string `json:"pubK"` //path of the PubK file
+ Date time.Time `json:"date"`
+ Hashed []byte `json:"hashed"`
+ UnblindedSig []byte `json:"unblindedsig"`
+ Verified bool `json:"verified"`
+ ServerVerifier *rsa.PublicKey `json:"serververifier"`
+ SignerID string `json:"signerid"`
+ BlockchainRef string `json:"blockchainref"`
+}
+
+func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string {
+ privkey_bytes := x509.MarshalPKCS1PrivateKey(privkey)
+ privkey_pem := pem.EncodeToMemory(
+ &pem.Block{
+ Type: "RSA PRIVATE KEY",
+ Bytes: privkey_bytes,
+ },
+ )
+ return string(privkey_pem)
+}
+
+func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
+ block, _ := pem.Decode([]byte(privPEM))
+ if block == nil {
+ return nil, errors.New("failed to parse PEM block containing the key")
+ }
+ priv, err := x509.ParsePKCS1PrivateKey(block.Bytes)
+ if err != nil {
+ return nil, err
+ }
+ return priv, nil
+}
+
+func ExportRsaPublicKeyAsPemStr(pubkey rsa.PublicKey) (string, error) {
+ asn1Bytes, err := asn1.Marshal(pubkey)
+ check(err)
+ pubkey_pem := pem.EncodeToMemory(
+ &pem.Block{
+ Type: "PUBLIC KEY",
+ Bytes: asn1Bytes,
+ },
+ )
+ color.Red("pubkey_pem")
+ fmt.Println(pubkey_pem)
+ return string(pubkey_pem), nil
+}
+
+func ParseRsaPublicKeyFromPemStr(pubPEM string) (pub rsa.PublicKey, err error) {
+ pemBlock, _ := pem.Decode([]byte(pubPEM))
+ _, err = asn1.Unmarshal(pemBlock.Bytes, &pub)
+ return
+}
+
+func savePEMKey(fileName string, key *rsa.PrivateKey) {
+ outFile, err := os.Create(fileName)
+ check(err)
+ defer outFile.Close()
+
+ var privateKey = &pem.Block{
+ Type: "PRIVATE KEY",
+ Bytes: x509.MarshalPKCS1PrivateKey(key),
+ }
+
+ err = pem.Encode(outFile, privateKey)
+ check(err)
+}
+func savePublicPEMKey(fileName string, pubkey rsa.PublicKey) {
+ asn1Bytes, err := asn1.Marshal(pubkey)
+ check(err)
+
+ var pemkey = &pem.Block{
+ Type: "PUBLIC KEY",
+ Bytes: asn1Bytes,
+ }
+
+ pemfile, err := os.Create(fileName)
+ check(err)
+ defer pemfile.Close()
+
+ err = pem.Encode(pemfile, pemkey)
+ check(err)
+}
+func openPEMKey(path string) (key *rsa.PrivateKey, err error) {
+ b, err := ioutil.ReadFile(path)
+ if err != nil {
+ fmt.Print(err)
+ }
+ key, err = ParseRsaPrivateKeyFromPemStr(string(b))
+ return
+}
+func openPublicPEMKey(path string) (key rsa.PublicKey, err error) {
+ b, err := ioutil.ReadFile(path)
+ if err != nil {
+ fmt.Print(err)
+ }
+ key, err = ParseRsaPublicKeyFromPemStr(string(b))
+ return
+}
+func readKeys() []Key {
+ path := keysDir + "/keys.json"
+ var keys []Key
+
+ file, err := ioutil.ReadFile(path)
+ check(err)
+ content := string(file)
+ json.Unmarshal([]byte(content), &keys)
+
+ return keys
+}
+
+func saveKeys(keys []Key) {
+ jsonKeys, err := json.Marshal(keys)
+ check(err)
+ err = ioutil.WriteFile(keysDir+"/keys.json", jsonKeys, 0644)
+ check(err)
+}
+func saveKey(k Key) {
+ fmt.Println(k)
+ keys := readKeys()
+ for i, key := range keys {
+ if key.ID == k.ID {
+ keys[i] = k
+ }
+ }
+ saveKeys(keys)
+}
+func getKeyByKeyID(keyID string) (k Key) {
+ keys := readKeys()
+ for _, key := range keys {
+ if key.ID == keyID {
+ k = key
+ }
+ }
+ return k
+}
+func removeKey(keyID string, originalKeys []Key) (keys []Key) {
+ for _, key := range originalKeys {
+ if key.ID != keyID {
+ keys = append(keys, key)
+ }
+ }
+ return
+}
+
+/*
+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/darkID-library-login-example/log.go b/darkID-library-login-example/log.go
new file mode 100755
index 0000000..e8f391a
--- /dev/null
+++ b/darkID-library-login-example/log.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "io"
+ "log"
+ "os"
+ "strings"
+ "time"
+)
+
+func savelog() {
+ timeS := time.Now().String()
+ _ = os.Mkdir("logs", os.ModePerm)
+ //next 3 lines are to avoid windows filesystem errors
+ timeS = strings.Replace(timeS, " ", "_", -1)
+ timeS = strings.Replace(timeS, ".", "-", -1)
+ timeS = strings.Replace(timeS, ":", "-", -1)
+ logFile, err := os.OpenFile("logs/log-"+timeS+".log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666)
+ if err != nil {
+ panic(err)
+ }
+ mw := io.MultiWriter(os.Stdout, logFile)
+ log.SetOutput(mw)
+}
diff --git a/darkID-library-login-example/main.go b/darkID-library-login-example/main.go
new file mode 100644
index 0000000..eb43162
--- /dev/null
+++ b/darkID-library-login-example/main.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "net/http"
+
+ "github.com/fatih/color"
+ "github.com/gorilla/handlers"
+)
+
+const keysDir = "keys"
+const keysize = 2048
+const hashize = 1536
+
+func main() {
+ color.Blue("Starting darkID-libarary-login-example")
+
+ readConfig("config.json")
+ fmt.Println(config)
+
+ /*//create keys directory
+ _ = os.Mkdir(keysDir, os.ModePerm)*/
+
+ initializeToken()
+
+ //run thw webserver
+ go GUI()
+
+ //run API
+ log.Println("api server running")
+ log.Print("port: ")
+ log.Println(config.Port)
+ router := NewRouter()
+ headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"})
+ originsOk := handlers.AllowedOrigins([]string{"*"})
+ methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"})
+ log.Fatal(http.ListenAndServe(":"+config.Port, handlers.CORS(originsOk, headersOk, methodsOk)(router)))
+}
+
+func GUI() {
+ //here, run webserver
+ log.Println("webserver in port " + "8080")
+ http.Handle("/", http.FileServer(http.Dir("./web")))
+ http.ListenAndServe(":"+"8080", nil)
+}
diff --git a/darkID-library-login-example/readConfig.go b/darkID-library-login-example/readConfig.go
new file mode 100755
index 0000000..9b7e71d
--- /dev/null
+++ b/darkID-library-login-example/readConfig.go
@@ -0,0 +1,20 @@
+package main
+
+import (
+ "encoding/json"
+ "io/ioutil"
+)
+
+//Config reads the config
+type Config struct {
+ Port string `json:"port"`
+}
+
+var config Config
+
+func readConfig(path string) {
+ file, err := ioutil.ReadFile(path)
+ check(err)
+ content := string(file)
+ json.Unmarshal([]byte(content), &config)
+}
diff --git a/darkID-library-login-example/restConfig.go b/darkID-library-login-example/restConfig.go
new file mode 100755
index 0000000..36a332e
--- /dev/null
+++ b/darkID-library-login-example/restConfig.go
@@ -0,0 +1,47 @@
+package main
+
+import (
+ "log"
+ "net/http"
+ "time"
+
+ "github.com/gorilla/mux"
+)
+
+type Route struct {
+ Name string
+ Method string
+ Pattern string
+ HandlerFunc http.HandlerFunc
+}
+
+func Logger(inner http.Handler, name string) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ start := time.Now()
+
+ inner.ServeHTTP(w, r)
+
+ log.Printf(
+ "%s\t%s\t%s\t%s",
+ r.Method,
+ r.RequestURI,
+ name,
+ time.Since(start),
+ )
+ })
+}
+func NewRouter() *mux.Router {
+ router := mux.NewRouter().StrictSlash(true)
+ for _, route := range routes {
+ var handler http.Handler
+ handler = route.HandlerFunc
+ handler = Logger(handler, route.Name)
+
+ router.
+ Methods(route.Method).
+ Path(route.Pattern).
+ Name(route.Name).
+ Handler(handler)
+ }
+ return router
+}
diff --git a/darkID-library-login-example/restRoutes.go b/darkID-library-login-example/restRoutes.go
new file mode 100755
index 0000000..e053e94
--- /dev/null
+++ b/darkID-library-login-example/restRoutes.go
@@ -0,0 +1,24 @@
+package main
+
+type Routes []Route
+
+var routes = Routes{
+ Route{
+ "Index",
+ "GET",
+ "/",
+ Index,
+ },
+ Route{
+ "Signup",
+ "POST",
+ "/signup",
+ Signup,
+ },
+ Route{
+ "Login",
+ "POST",
+ "/login",
+ Login,
+ },
+}
diff --git a/darkID-library-login-example/testUser.sh b/darkID-library-login-example/testUser.sh
new file mode 100644
index 0000000..01b1ef7
--- /dev/null
+++ b/darkID-library-login-example/testUser.sh
@@ -0,0 +1,20 @@
+echo ""
+echo "sending the signup, response:"
+curl -X POST http://127.0.0.1:3130/signup -d '{"email": "user1@e.com", "password": "user1"}'
+
+echo ""
+echo "sending the login, response:"
+curl -X POST http://127.0.0.1:3130/login -d '{"email": "user1@e.com", "password": "user1"}'
+
+
+echo ""
+echo "send pubK and m to blind sign"
+echo "json to send to the serverIDsigner:"
+echo '{"pubKstring": {"e": "65537", "n": "139093"}, "m": "hola"}'
+echo "serverIDsigner response:"
+BLINDSIGNED=$(curl -X POST http://127.0.0.1:3130/blindsign -d '{"pubKstring": {"e": "65537", "n": "139093"}, "m": "hola"}')
+echo "$BLINDSIGNED"
+
+echo ""
+echo "send blindsigned to the serverIDsigner to verify"
+curl -X POST http://127.0.0.1:3130/verifysign -d '{"m": "hola", "mSigned": "131898 40373 107552 34687"}'
diff --git a/darkID-library-login-example/tokens.go b/darkID-library-login-example/tokens.go
new file mode 100644
index 0000000..94db69c
--- /dev/null
+++ b/darkID-library-login-example/tokens.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "fmt"
+ "time"
+
+ jwt "github.com/dgrijalva/jwt-go"
+)
+
+const (
+ signingKey = "this is the secret signing key"
+)
+
+var createdToken string
+
+func initializeToken() {
+ var err error
+ createdToken, err = newToken()
+ if err != nil {
+ fmt.Println("Creating token failed")
+ }
+}
+
+func newToken() (string, error) {
+ signingKeyB := []byte(signingKey)
+ // Create the token
+ token := jwt.New(jwt.SigningMethodHS256)
+ // Set some claims
+ claims := make(jwt.MapClaims)
+ claims["foo"] = "bar"
+ claims["exp"] = time.Now().Add(time.Hour * 72).Unix()
+ token.Claims = claims
+
+ // Sign and get the complete encoded token as a string
+ tokenString, err := token.SignedString(signingKeyB)
+ return tokenString, err
+}
+
+func parseToken(myToken string, myKey string) {
+ token, err := jwt.Parse(myToken, func(token *jwt.Token) (interface{}, error) {
+ return []byte(myKey), nil
+ })
+
+ if err == nil && token.Valid {
+ fmt.Println("Your token is valid. I like your style.")
+ } else {
+ fmt.Println("This token is terrible! I cannot accept this.")
+ }
+}
diff --git a/eth/darkID_contract.sol b/eth/darkID_contract.sol
index 4d7fb87..ddc4f9a 100644
--- a/eth/darkID_contract.sol
+++ b/eth/darkID_contract.sol
@@ -13,7 +13,7 @@ contract DarkID {
}
- IdStruct ID;
+ IdStruct public ID;
function DarkID(string _pubK, string _hashed, string _unblindedSig, string _serverVerifier, string _signerID) public {
diff --git a/eth/darkID_contract_sol_DarkID.abi b/eth/darkID_contract_sol_DarkID.abi
new file mode 100644
index 0000000..e3c0f1e
--- /dev/null
+++ b/eth/darkID_contract_sol_DarkID.abi
@@ -0,0 +1 @@
+[{"constant":true,"inputs":[],"name":"getDarkID","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ID","outputs":[{"name":"pubK","type":"string"},{"name":"date","type":"string"},{"name":"hashed","type":"string"},{"name":"unblindedSig","type":"string"},{"name":"serverVerifier","type":"string"},{"name":"signerID","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_pubK","type":"string"},{"name":"_hashed","type":"string"},{"name":"_unblindedSig","type":"string"},{"name":"_serverVerifier","type":"string"},{"name":"_signerID","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]
\ No newline at end of file
diff --git a/eth/darkID_contract_sol_DarkID.bin b/eth/darkID_contract_sol_DarkID.bin
new file mode 100644
index 0000000..e99470c
--- /dev/null
+++ b/eth/darkID_contract_sol_DarkID.bin
@@ -0,0 +1 @@
+606060405234156200001057600080fd5b60405162000cfd38038062000cfd8339810160405280805182019190602001805182019190602001805182019190602001805182019190602001805182019190505060c0604051908101604052808681526020016040805190810160405280601581526020017f746869732077696c6c2062652074686520646174650000000000000000000000815250815260200185815260200184815260200183815260200182815250600080820151816000019080519060200190620000d49291906200017e565b506020820151816001019080519060200190620000f39291906200017e565b506040820151816002019080519060200190620001129291906200017e565b506060820151816003019080519060200190620001319291906200017e565b506080820151816004019080519060200190620001509291906200017e565b5060a08201518160050190805190602001906200016f9291906200017e565b5090505050505050506200022d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001c157805160ff1916838001178555620001f2565b82800160010185558215620001f2579182015b82811115620001f1578251825591602001919060010190620001d4565b5b50905062000201919062000205565b5090565b6200022a91905b80821115620002265760008160009055506001016200020c565b5090565b90565b610ac0806200023d6000396000f30060606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636cd14a5714610051578063b3cea217146102fb575b600080fd5b341561005c57600080fd5b610064610653565b6040518080602001806020018060200180602001806020018060200187810387528d818151815260200191508051906020019080838360005b838110156100b857808201518184015260208101905061009d565b50505050905090810190601f1680156100e55780820380516001836020036101000a031916815260200191505b5087810386528c818151815260200191508051906020019080838360005b8381101561011e578082015181840152602081019050610103565b50505050905090810190601f16801561014b5780820380516001836020036101000a031916815260200191505b5087810385528b818151815260200191508051906020019080838360005b83811015610184578082015181840152602081019050610169565b50505050905090810190601f1680156101b15780820380516001836020036101000a031916815260200191505b5087810384528a818151815260200191508051906020019080838360005b838110156101ea5780820151818401526020810190506101cf565b50505050905090810190601f1680156102175780820380516001836020036101000a031916815260200191505b50878103835289818151815260200191508051906020019080838360005b83811015610250578082015181840152602081019050610235565b50505050905090810190601f16801561027d5780820380516001836020036101000a031916815260200191505b50878103825288818151815260200191508051906020019080838360005b838110156102b657808201518184015260208101905061029b565b50505050905090810190601f1680156102e35780820380516001836020036101000a031916815260200191505b509c5050505050505050505050505060405180910390f35b341561030657600080fd5b61030e610a5c565b6040518080602001806020018060200180602001806020018060200187810387528d8181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156103ab5780601f10610380576101008083540402835291602001916103ab565b820191906000526020600020905b81548152906001019060200180831161038e57829003601f168201915b505087810386528c81815460018160011615610100020316600290048152602001915080546001816001161561010002031660029004801561042e5780601f106104035761010080835404028352916020019161042e565b820191906000526020600020905b81548152906001019060200180831161041157829003601f168201915b505087810385528b8181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156104b15780601f10610486576101008083540402835291602001916104b1565b820191906000526020600020905b81548152906001019060200180831161049457829003601f168201915b505087810384528a8181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156105345780601f1061050957610100808354040283529160200191610534565b820191906000526020600020905b81548152906001019060200180831161051757829003601f168201915b50508781038352898181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156105b75780601f1061058c576101008083540402835291602001916105b7565b820191906000526020600020905b81548152906001019060200180831161059a57829003601f168201915b505087810382528881815460018160011615610100020316600290048152602001915080546001816001161561010002031660029004801561063a5780601f1061060f5761010080835404028352916020019161063a565b820191906000526020600020905b81548152906001019060200180831161061d57829003601f168201915b50509c5050505050505050505050505060405180910390f35b61065b610a80565b610663610a80565b61066b610a80565b610673610a80565b61067b610a80565b610683610a80565b6000800160006001016000600201600060030160006004016000600501858054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107355780601f1061070a57610100808354040283529160200191610735565b820191906000526020600020905b81548152906001019060200180831161071857829003601f168201915b50505050509550848054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107d15780601f106107a6576101008083540402835291602001916107d1565b820191906000526020600020905b8154815290600101906020018083116107b457829003601f168201915b50505050509450838054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561086d5780601f106108425761010080835404028352916020019161086d565b820191906000526020600020905b81548152906001019060200180831161085057829003601f168201915b50505050509350828054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109095780601f106108de57610100808354040283529160200191610909565b820191906000526020600020905b8154815290600101906020018083116108ec57829003601f168201915b50505050509250818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109a55780601f1061097a576101008083540402835291602001916109a5565b820191906000526020600020905b81548152906001019060200180831161098857829003601f168201915b50505050509150808054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a415780601f10610a1657610100808354040283529160200191610a41565b820191906000526020600020905b815481529060010190602001808311610a2457829003601f168201915b50505050509050955095509550955095509550909192939495565b60008060000190806001019080600201908060030190806004019080600501905086565b6020604051908101604052806000815250905600a165627a7a723058208b0a6ea6ff1ccb3d9a834e06c07d638ea32246f3cf891267bc251acb1baebeb20029
\ No newline at end of file
diff --git a/eth/instructions.md b/eth/instructions.md
new file mode 100644
index 0000000..67556f4
--- /dev/null
+++ b/eth/instructions.md
@@ -0,0 +1,52 @@
+- start node and blockchain syncing in testnet
+```
+geth --testnet --datadir ~/eth-testnet
+```
+
+- create first account (wallet)
+```
+geth --testnet --datadir ~/eth-testnet account new
+```
+
+- mine ethers in testnet
+```
+geth --testnet --datadir ~/eth-testnet --mine
+```
+
+- serve dapp running on localhost:8000 via RPC
+```
+geth --testnet --datadir ~/eth-testnet --rpc --rpccorsdomain "http://localhost:8000" --rpcapi eth,web3,personal
+```
+
+
+- generate ABI from contract.sol
+```
+solcjs --abi HelloWorldContract.sol
+```
+
+- generate the byte code
+```
+solcjs --bin HelloWorldContract.sol
+```
+
+
+- deploy contract via geth js console
+ - open geth console
+ ```
+ geth --testnet --datadir ~/eth-testnet console
+ ```
+
+ - in the console create the contract using ABI and BYTE CODE result from compilation
+ ```js
+ var abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}];
+ var code = '0x60606040527f48656c6c6f20576f726c64000000000000000000000000000000000000000000600090600019169055341561003957600080fd5b5b609d806100486000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314603d575b600080fd5b3415604757600080fd5b604d606b565b60405180826000191660001916815260200191505060405180910390f35b600054815600a165627a7a72305820f4c510e24a238337d5334b5b38a44e88ea53ef40f26aeb96eba4609cb72827cd0029';
+ web3.personal.unlockAccount(eth.accounts[0], 'PASSWORD');
+ var inputdata = ["pub", "h", "u", "sv", "signerid"];
+ var contract = web3.eth.contract(abi).new(inputdata,{ from: eth.accounts[0], data: code, gas: 1000000 });
+ web3.personal.lockAccount(eth.accounts[0]);
+ ```
+
+ - call the method in the contract
+ ```js
+ contract.name()
+ ```
diff --git a/serverIDsigner/userRESTFunctions.go b/serverIDsigner/RESTfunctions.go
similarity index 90%
rename from serverIDsigner/userRESTFunctions.go
rename to serverIDsigner/RESTfunctions.go
index 4f655d7..efadeeb 100644
--- a/serverIDsigner/userRESTFunctions.go
+++ b/serverIDsigner/RESTfunctions.go
@@ -82,11 +82,21 @@ func Login(w http.ResponseWriter, r *http.Request) {
rUser := User{}
err = userCollection.Find(bson.M{"email": user.Email}).One(&rUser)
if err != nil {
- } else {
- //user exists, update with the token
- err = userCollection.Update(bson.M{"_id": rUser.Id}, user)
+ jResp, err := json.Marshal("error login, email not found")
+ check(err)
+ fmt.Fprintln(w, string(jResp))
+ return
+ }
+ //user exists, check password
+ if user.Password != rUser.Password {
+ jResp, err := json.Marshal("error login, password not match")
check(err)
+ fmt.Fprintln(w, string(jResp))
+ return
}
+ //update with the token
+ err = userCollection.Update(bson.M{"_id": rUser.Id}, user)
+ check(err)
jResp, err := json.Marshal(user)
if err != nil {