Removed unused ThresholdKey.divide function

This commit is contained in:
Piotr Dyraga committed 2018-05-30 14:48:50 +02:00
1 parent 1dc8db4cb2
commit 915950cb35
2 files changed
+4 -34

No files matched your search

+4 -17
View File
@@ -86,24 +86,12 @@ func (this *ThresholdKey) updateCprime(cprime, lambda *big.Int, share *PartialDe
return new(big.Int).Mod(ret, this.GetNSquare())
}
// TODO: unused? kill?
func (this *ThresholdKey) divide(a, b *big.Int) *big.Int {
if a.Cmp(ZERO) == -1 {
if b.Cmp(ZERO) == -1 {
return new(big.Int).Div(new(big.Int).Neg(a), new(big.Int).Neg(b))
}
return new(big.Int).Neg(new(big.Int).Div(new(big.Int).Neg(a), b))
}
return new(big.Int).Div(a, b)
}
func (this *ThresholdKey) exp(a, b, c *big.Int) *big.Int {
if b.Cmp(ZERO) == -1 {
ret := new(big.Int).Exp(a, new(big.Int).Neg(b), c)
return new(big.Int).ModInverse(ret, c)
}
return new(big.Int).Exp(a, b, c)
}
// Executes the last step of message decryption. Takes `cprime` value computed
@@ -146,11 +134,10 @@ func (this *ThresholdKey) CombinePartialDecryptionsZKP(shares []*PartialDecrypti
return this.CombinePartialDecryptions(ret)
}
// Verify if the decryption of `encryptedMessage` has well been done.
// It verifies all the zero-knoledge proofs, the value of the decrypted
// and decrypted message.
// The method returns `nil` if everything is good. Otherwise it returns an
// explicative message
// Verifies if the decryption of `encryptedMessage` has been done properly.
// It verifies all the zero-knoledge proofs, the value of the decrypted
// and decrypted message. The method returns `nil` if everything is fine.
// Otherwise, it returns an explicative message.
func (this *ThresholdKey) VerifyDecryption(encryptedMessage, decryptedMessage *big.Int, shares []*PartialDecryptionZKP) error {
for _, share := range shares {
if share.C.Cmp(encryptedMessage) != 0 {
-17
View File
@@ -230,23 +230,6 @@ func TestDecryption(t *testing.T) {
} else if n(msg) != 100 {
t.Error("decrypted message was not 100 but ", msg)
}
}
func TestDivide(t *testing.T) {
tk := new(ThresholdKey)
if r := tk.divide(b(77), b(4)); n(r) != 19 {
t.Error("77 / 4 != 19 ( ", r, " )")
}
if r := tk.divide(b(-77), b(-4)); n(r) != 19 {
t.Error("-77 / -4 != 19 ( ", r, " )")
}
if r := tk.divide(b(-77), b(4)); n(r) != -19 {
t.Error("-77 / 4 != -19 ( ", r, " )")
}
if r := tk.divide(b(77), b(-4)); n(r) != -19 {
t.Error("77 / -4 != -19 ( ", r, " )")
}
}
func TestValidate(t *testing.T) {