// Add homomorphically adds a passed constant to the encrypted integer
// (our cipher text). We do this by multiplying the constant with our
// ciphertext. Upon decryption, the resulting plain text will be the sum of
// the plaintext integer and the constant.
Add homomorphically adds a passed constant to the encrypted integer
(our cipher text). We do this by multiplying the constant with our
ciphertext. Upon decryption, the resulting plain text will be the sum of
the plaintext integer and the constant.
// Add homomorphically adds a passed constant to the encrypted integer // ( our cipher text ) . We do this by multiplying the constant with our // ciphertext . Upon decryption the resulting plain text will be the sum of // the plaintext integer and the constant .
func Add(pubKey *PublicKey, cipher, constant []byte) []byte {
	c := new(big.Int).SetBytes(cipher)
	x := new(big.Int).SetBytes(constant)
	return new(big.Int).Mod(
		new(big.Int).Mul(c, new(big.Int).Exp(pubKey.G, x, pubKey.NSquared)),
		pubKey.NSquared,
	).Bytes()
}
func Add ( pubKey * PublicKey , cipher , constant [ ] byte ) [ ] byte { c := new ( big . Int ) . SetBytes ( cipher ) x := new ( big . Int ) . SetBytes ( constant ) return new ( big . Int ) . Mod ( new ( big . Int ) . Mul ( c , new ( big . Int ) . Exp ( pubKey . G , x , pubKey . NSquared ) ) , pubKey . NSquared , ) . Bytes ( ) }
Add homomorphically adds a passed constant to the encrypted integer
(our cipher text).
Add homomorphically adds a passed constant to the encrypted integer ( our cipher text ) .
// c * g ^ x mod n^2