Removed unused ThresholdKey.divide function
This commit is contained in:
2 files changed
+4
-34
No files matched your search
+4
-17
@@ -86,24 +86,12 @@ func (this *ThresholdKey) updateCprime(cprime, lambda *big.Int, share *PartialDe
|
|||||||
return new(big.Int).Mod(ret, this.GetNSquare())
|
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 {
|
func (this *ThresholdKey) exp(a, b, c *big.Int) *big.Int {
|
||||||
if b.Cmp(ZERO) == -1 {
|
if b.Cmp(ZERO) == -1 {
|
||||||
ret := new(big.Int).Exp(a, new(big.Int).Neg(b), c)
|
ret := new(big.Int).Exp(a, new(big.Int).Neg(b), c)
|
||||||
return new(big.Int).ModInverse(ret, c)
|
return new(big.Int).ModInverse(ret, c)
|
||||||
}
|
}
|
||||||
return new(big.Int).Exp(a, b, c)
|
return new(big.Int).Exp(a, b, c)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executes the last step of message decryption. Takes `cprime` value computed
|
// 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)
|
return this.CombinePartialDecryptions(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify if the decryption of `encryptedMessage` has well been done.
|
// Verifies if the decryption of `encryptedMessage` has been done properly.
|
||||||
// It verifies all the zero-knoledge proofs, the value of the decrypted
|
// It verifies all the zero-knoledge proofs, the value of the decrypted
|
||||||
// and decrypted message.
|
// and decrypted message. The method returns `nil` if everything is fine.
|
||||||
// The method returns `nil` if everything is good. Otherwise it returns an
|
// Otherwise, it returns an explicative message.
|
||||||
// explicative message
|
|
||||||
func (this *ThresholdKey) VerifyDecryption(encryptedMessage, decryptedMessage *big.Int, shares []*PartialDecryptionZKP) error {
|
func (this *ThresholdKey) VerifyDecryption(encryptedMessage, decryptedMessage *big.Int, shares []*PartialDecryptionZKP) error {
|
||||||
for _, share := range shares {
|
for _, share := range shares {
|
||||||
if share.C.Cmp(encryptedMessage) != 0 {
|
if share.C.Cmp(encryptedMessage) != 0 {
|
||||||
|
|||||||
@@ -230,23 +230,6 @@ func TestDecryption(t *testing.T) {
|
|||||||
} else if n(msg) != 100 {
|
} else if n(msg) != 100 {
|
||||||
t.Error("decrypted message was not 100 but ", msg)
|
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) {
|
func TestValidate(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user