Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
froelich committed Sep 24, 2018
1 parent 95f9782 commit bc81393
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 74 deletions.
70 changes: 0 additions & 70 deletions lib/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ func EncryptIntVector(pubkey kyber.Point, intArray []int64) *CipherVector {
cv[i] = *EncryptInt(pubkey, n)
}
}

return &cv
}

Expand Down Expand Up @@ -367,45 +366,6 @@ func discreteLog(P kyber.Point, checkNeg bool) int64 {

}

// OLD, TODO: remove when sure the other one works
// Brute-Forces the discrete log for integer decoding.
/*func discreteLog(P kyber.Point, checkNeg bool) int64 {
B := SuiTe.Point().Base()
var Bi kyber.Point
var m int64
object, ok := PointToInt.Get(P.String())
if ok == nil && object != nil {
return object.(int64)
}
mutex.Lock()
if currentGreatestInt == 0 {
currentGreatestM = SuiTe.Point().Null()
}
BiNeg := SuiTe.Point().Neg(B)
for Bi, m = currentGreatestM, currentGreatestInt; !Bi.Equal(P) && !SuiTe.Point().Neg(Bi).Equal(P) && m < MaxHomomorphicInt; Bi, m = SuiTe.Point().Add(Bi, B), m+1 {
if checkNeg {
BiNeg := SuiTe.Point().Neg(Bi)
PointToInt.Put(BiNeg.String(), -m)
}
PointToInt.Put(Bi.String(), m)
}
currentGreatestM = Bi
PointToInt.Put(BiNeg.String(), -m)
PointToInt.Put(Bi.String(), m)
currentGreatestInt = m
//no negative responses
if m == MaxHomomorphicInt {
log.LLvl1("No decryption")
mutex.Unlock()
return 0
}
mutex.Unlock()
if SuiTe.Point().Neg(Bi).Equal(P){
return -m
}
return m
}*/

// DeterministicTagging is a distributed deterministic Tagging switching, removes server contribution and multiplies
func (c *CipherText) DeterministicTagging(gc *CipherText, private, secretContrib kyber.Scalar) {
c.K = SuiTe.Point().Mul(secretContrib, gc.K)
Expand Down Expand Up @@ -495,36 +455,6 @@ func (cv *CipherVector) KeySwitching(cipher CipherVector, originalEphemeralKeys
return r
}

// NewKeySwitching implements the key switching operation as presented in Drynx (improved from UnLynx)
func (cv *CipherVector) NewKeySwitching(targetPubKey kyber.Point, rbs []kyber.Point, secretKey kyber.Scalar) ([]kyber.Point, []kyber.Point, []kyber.Scalar) {
length := len(rbs)

ks2s := make([]kyber.Point, length)
rBNegs := make([]kyber.Point, length)
vis := make([]kyber.Scalar, length)

wg := StartParallelize(length)
for i, v := range rbs {
go func(i int, v kyber.Point) {
defer wg.Done()
vi := SuiTe.Scalar().Pick(random.New())
(*cv)[i].K = SuiTe.Point().Mul(vi, SuiTe.Point().Base())
rbNeg := SuiTe.Point().Neg(rbs[i])
rbkNeg := SuiTe.Point().Mul(secretKey, rbNeg)
viNewK := SuiTe.Point().Mul(vi, targetPubKey)
(*cv)[i].C = SuiTe.Point().Add(rbkNeg, viNewK)

//proof
ks2s[i] = (*cv)[i].C
rBNegs[i] = rbNeg
vis[i] = vi
}(i, v)
}
EndParallelize(wg)

return ks2s, rBNegs, vis
}

// Homomorphic operations
//______________________________________________________________________________________________________________________

Expand Down
10 changes: 6 additions & 4 deletions lib/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ func (cv *FilteredResponse) FromBytes(data []byte, aabLength, pgaebLength int) {
(*cv).AggregatingAttributes = make(CipherVector, aabLength)
(*cv).GroupByEnc = make(CipherVector, pgaebLength)

aabByteLength := aabLength * 64 //CAREFUL: hardcoded 64 (size of el-gamal element C,K)
pgaebByteLength := pgaebLength * 64
lengthCipher := 2 * SuiTe.PointLen()
aabByteLength := aabLength * lengthCipher
pgaebByteLength := pgaebLength * lengthCipher

aab := data[:aabByteLength]
pgaeb := data[aabByteLength : aabByteLength+pgaebByteLength]
Expand All @@ -318,8 +319,9 @@ func (crd *FilteredResponseDet) FromBytes(data []byte, gacbLength, aabLength, dt
(*crd).Fr.AggregatingAttributes = make(CipherVector, aabLength)
(*crd).Fr.GroupByEnc = make(CipherVector, gacbLength)

aabByteLength := aabLength * 64 //CAREFUL: hardcoded 64 (size of el-gamal element C,K)
gacbByteLength := gacbLength * 64
lengthCipher := 2 * SuiTe.PointLen()
aabByteLength := aabLength * lengthCipher //CAREFUL: hardcoded 64 (size of el-gamal element C,K)
gacbByteLength := gacbLength * lengthCipher

aab := data[:aabByteLength]
gacb := data[aabByteLength : gacbByteLength+aabByteLength]
Expand Down

0 comments on commit bc81393

Please sign in to comment.