mirror of
https://github.com/arnaucube/blockchainIDsystem.git
synced 2026-02-07 02:56:43 +01:00
fixed blindsign process. Repo outdated.
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
<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 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>
|
||||
|
||||
@@ -58,13 +58,19 @@ func BlindAndSendToSign(w http.ResponseWriter, r *http.Request) {
|
||||
//read the keys stored in /keys directory
|
||||
keys := readKeys("keys.json")
|
||||
|
||||
var key ownrsa.RSA
|
||||
//search for complete key
|
||||
for _, k := range keys {
|
||||
if k.PubK == packPubK {
|
||||
key = ownrsa.UnpackKey(k)
|
||||
/*
|
||||
var key ownrsa.RSA
|
||||
//search for complete key
|
||||
for _, k := range keys {
|
||||
if k.PubK == packPubK {
|
||||
key = ownrsa.UnpackKey(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//get the serverIDsigner pubK
|
||||
serverPubK := getServerPubK("http://" + config.ServerIDSigner.IP + ":" + config.ServerIDSigner.Port)
|
||||
|
||||
//blind the key.PubK
|
||||
var m []int
|
||||
//convert packPubK to []bytes
|
||||
@@ -73,7 +79,7 @@ func BlindAndSendToSign(w http.ResponseWriter, r *http.Request) {
|
||||
m = append(m, int(byte))
|
||||
}
|
||||
rVal := 101
|
||||
blinded := ownrsa.Blind(m, rVal, key.PubK, key.PrivK)
|
||||
blinded := ownrsa.Blind(m, rVal, serverPubK)
|
||||
fmt.Println(blinded)
|
||||
|
||||
//convert blinded to string
|
||||
@@ -101,9 +107,6 @@ func BlindAndSendToSign(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
|
||||
mSigned := ownrsa.Unblind(sigma, rVal, serverPubK)
|
||||
fmt.Print("mSigned: ")
|
||||
|
||||
@@ -109,14 +109,14 @@ func DecryptInt(val int, privK RSAPrivateKey) int {
|
||||
return int(m.Int64())
|
||||
}
|
||||
|
||||
func Blind(m []int, r int, pubK RSAPublicKey, privK RSAPrivateKey) []int {
|
||||
func Blind(m []int, r int, pubK RSAPublicKey) []int {
|
||||
var mBlinded []int
|
||||
rBigInt := big.NewInt(int64(r))
|
||||
for i := 0; i < len(m); i++ {
|
||||
mBigInt := big.NewInt(int64(m[i]))
|
||||
rE := new(big.Int).Exp(rBigInt, pubK.E, nil)
|
||||
mrE := new(big.Int).Mul(mBigInt, rE)
|
||||
mrEmodN := new(big.Int).Mod(mrE, privK.N)
|
||||
mrEmodN := new(big.Int).Mod(mrE, pubK.N)
|
||||
mBlinded = append(mBlinded, int(mrEmodN.Int64()))
|
||||
}
|
||||
return mBlinded
|
||||
|
||||
Reference in New Issue
Block a user