mirror of
https://github.com/arnaucube/blockchainIDsystem.git
synced 2026-02-07 02:56:43 +01:00
started to implement clientApp (Go + Electron(with Angularjs))
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
var userCollection *mgo.Collection
|
||||
|
||||
var serverRsa ownrsa.RSA
|
||||
var serverRSA ownrsa.RSA
|
||||
|
||||
func main() {
|
||||
color.Blue("Starting serverIDsigner")
|
||||
@@ -26,11 +26,11 @@ func main() {
|
||||
initializeToken()
|
||||
|
||||
//initialize RSA
|
||||
serverRsa = ownrsa.GenerateKeyPair()
|
||||
serverRSA = ownrsa.GenerateKeyPair()
|
||||
color.Blue("Public Key:")
|
||||
fmt.Println(serverRsa.PubK)
|
||||
fmt.Println(serverRSA.PubK)
|
||||
color.Green("Private Key:")
|
||||
fmt.Println(serverRsa.PrivK)
|
||||
fmt.Println(serverRSA.PrivK)
|
||||
|
||||
//mongodb
|
||||
session, err := getSession()
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -181,3 +182,28 @@ func PubKStringToBigInt(kS RSAPublicKeyString) (RSAPublicKey, error) {
|
||||
}
|
||||
return k, nil
|
||||
}
|
||||
|
||||
type PackRSA struct {
|
||||
PubK string `json:"pubK"`
|
||||
PrivK string `json:"privK"`
|
||||
}
|
||||
|
||||
func PackKey(k RSA) PackRSA {
|
||||
var p PackRSA
|
||||
p.PubK = k.PubK.E.String() + "," + k.PubK.N.String()
|
||||
p.PrivK = k.PrivK.D.String() + "," + k.PrivK.N.String()
|
||||
return p
|
||||
}
|
||||
|
||||
func UnpackKey(p PackRSA) RSA {
|
||||
var k RSA
|
||||
var ok bool
|
||||
k.PubK.E, ok = new(big.Int).SetString(strings.Split(p.PubK, ",")[0], 10)
|
||||
k.PubK.N, ok = new(big.Int).SetString(strings.Split(p.PubK, ",")[1], 10)
|
||||
k.PrivK.D, ok = new(big.Int).SetString(strings.Split(p.PrivK, ",")[0], 10)
|
||||
k.PrivK.N, ok = new(big.Int).SetString(strings.Split(p.PrivK, ",")[1], 10)
|
||||
if !ok {
|
||||
fmt.Println("error on Unpacking Keys")
|
||||
}
|
||||
return k
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func BlindSign(w http.ResponseWriter, r *http.Request) {
|
||||
m = append(m, int(byte))
|
||||
}
|
||||
|
||||
sigma := ownrsa.BlindSign(m, askBlindSign.PubK, serverRsa.PrivK) //here the privK will be the CA privK, not the m emmiter's one. The pubK is the user's one
|
||||
sigma := ownrsa.BlindSign(m, askBlindSign.PubK, serverRSA.PrivK) //here the privK will be the CA privK, not the m emmiter's one. The pubK is the user's one
|
||||
fmt.Print("Sigma': ")
|
||||
fmt.Println(sigma)
|
||||
|
||||
@@ -164,7 +164,7 @@ func VerifySign(w http.ResponseWriter, r *http.Request) {
|
||||
mSignedInts = append(mSignedInts, i)
|
||||
}
|
||||
|
||||
verified := ownrsa.Verify(mOriginal, mSignedInts, serverRsa.PubK)
|
||||
verified := ownrsa.Verify(mOriginal, mSignedInts, serverRSA.PubK)
|
||||
|
||||
fmt.Fprintln(w, verified)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user