Added test ensuring threshold Paillier is a partially homomorphic system
This commit is contained in:
2 files changed
+27
-1
No files matched your search
@@ -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())}
|
||||
|
||||
Reference in new issue
Block a user