Added test ensuring threshold Paillier is a partially homomorphic system

This commit is contained in:
Piotr Dyraga committed 2018-05-30 14:49:05 +02:00
1 parent 915950cb35
commit 76f8f63a47
2 files changed
+27 -1

No files matched your search

+3
View File
@@ -48,6 +48,9 @@ func (pub *PublicKey) Encrypt(m *big.Int, random io.Reader) (*Cypher, error) {
// Takes two cypher texts and returns a 3rd one that encode
// the sum of the two plain texts.
//
// It's possible because Paillier is a homomorphic encryption scheme, where
// E(m1) * E(m2) = E(m1 + m2)
func (this *PublicKey) Add(cypher1, cypher2 *Cypher) *Cypher {
m := new(big.Int).Mul(cypher1.C, cypher2.C)
return &Cypher{new(big.Int).Mod(m, this.GetNSquare())}