Documentation improvements, code cleaned up #2

Merged
pdyraga merged 31 commits from master-with-bson into master 2018-06-05 19:08:37 -04:00
Showing only changes of commit f05e5219c2 - Show all commits
+15 -2
View File
@@ -79,6 +79,16 @@ func (this *ThresholdKey) computeLambda(share *PartialDecryption, shares []*Part
return lambda return lambda
} }
// Used to evaluate c' parameter which combines individual share decryptions.
//
// Modulo division is performed on the computed exponent to avoid creating
// large numbers. This is possible because of the following property of modulo:
// A^B mod C = (A mod C)^B mod C
//
// Modulo division is performed on the computed coefficient because of the
// following property of modulo:
// (AB) mod C = (A mod C * B mod C) mod C
// Note, we need to combine coefficients into single c'.
func (this *ThresholdKey) updateCprime(cprime, lambda *big.Int, share *PartialDecryption) *big.Int { func (this *ThresholdKey) updateCprime(cprime, lambda *big.Int, share *PartialDecryption) *big.Int {
twoLambda := new(big.Int).Mul(TWO, lambda) twoLambda := new(big.Int).Mul(TWO, lambda)
ret := this.exp(share.Decryption, twoLambda, this.GetNSquare()) ret := this.exp(share.Decryption, twoLambda, this.GetNSquare())
@@ -154,13 +164,17 @@ func (this *ThresholdKey) VerifyDecryption(encryptedMessage, decryptedMessage *b
return nil return nil
} }
// Private key for a threshold Paillier scheme. Holds private information
// for the given decryption server.
// `Id` is the unique identifier of a decryption server and `Share` is a secret
// share generated from hiding polynomial and is used for a partial share decryption.
type ThresholdPrivateKey struct { type ThresholdPrivateKey struct {
ThresholdKey ThresholdKey
Id int Id int
Share *big.Int Share *big.Int
} }
// Decrypt the cypher text and returns the partial decryption // Decrypts the cypher text and returns the partial decryption
func (this *ThresholdPrivateKey) Decrypt(c *big.Int) *PartialDecryption { func (this *ThresholdPrivateKey) Decrypt(c *big.Int) *PartialDecryption {
ret := new(PartialDecryption) ret := new(PartialDecryption)
ret.Id = this.Id ret.Id = this.Id
@@ -264,7 +278,6 @@ type PartialDecryptionZKP struct {
E *big.Int // the challenge E *big.Int // the challenge
Z *big.Int // the value needed to check to verify the decryption Z *big.Int // the value needed to check to verify the decryption
C *big.Int // the input cypher text C *big.Int // the input cypher text
} }
func (this *PartialDecryptionZKP) verifyPart1() *big.Int { func (this *PartialDecryptionZKP) verifyPart1() *big.Int {