Skip to content

Commit 3d89d0a

Browse files
committed
fix: removed incorrect test
1 parent b0c47b0 commit 3d89d0a

File tree

2 files changed

+0
-47
lines changed

2 files changed

+0
-47
lines changed

contracts/Paillier.sol

-16
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,6 @@ contract Paillier {
133133
return enc_result;
134134
}
135135

136-
function mul(
137-
Ciphertext calldata a,
138-
Ciphertext calldata b,
139-
PublicKey calldata publicKey
140-
) public view returns (BigNumber memory) {
141-
BigNumber memory enc_a = BigNumber(a.value, false, BigNum.bitLength(a.value));
142-
BigNumber memory enc_b = BigNumber(b.value, false, BigNum.bitLength(b.value));
143-
BigNumber memory pub_n = BigNumber(publicKey.n, false, BigNum.bitLength(publicKey.n));
144-
145-
// Calculate the encrypted result as enc_a^enc_b * enc_b^enc_a % pub_n^2
146-
BigNumber memory alpha = BigNum.modexp(enc_a, enc_b, BigNum.pow(pub_n, 2));
147-
BigNumber memory beta = BigNum.modexp(enc_b, enc_a, BigNum.pow(pub_n, 2));
148-
BigNumber memory enc_result = BigNum.mod(BigNum.mul(alpha, beta), BigNum.pow(pub_n, 2));
149-
return enc_result;
150-
}
151-
152136
/// @notice Divides an encrypted value by a plaintext constant
153137
/// @dev The function computes Enc(a)^(n-1) % n^2 to divide Enc(a) by b
154138
/// @param a The encrypted value as a Ciphertext

test/Paillier.ts

-31
Original file line numberDiff line numberDiff line change
@@ -65,37 +65,6 @@ describe('Paillier', function () {
6565
expect(dec_sum).to.equal(3);
6666
});
6767

68-
it('should multiply 2 ciphertexts', async function () {
69-
70-
const { Paillier, publicKey, privateKey } = await loadFixture(fixture);
71-
const a: bigint = BigInt(2);
72-
const b: bigint = BigInt(5);
73-
const enc_a: Ciphertext = {
74-
value: ethers.toBeHex(publicKey.encrypt(a)),
75-
};
76-
const enc_b: Ciphertext = {
77-
value: ethers.toBeHex(publicKey.encrypt(b)),
78-
};
79-
80-
// Public key
81-
const pubKey: PublicKey = {
82-
n: ethers.toBeHex(publicKey.n),
83-
g: ethers.toBeHex(publicKey.g),
84-
};
85-
86-
// bit length will differ to what has been stated in this script.
87-
// if using 256-bit key, bit_length will be 264 as "0x" prefix may have been factored in
88-
// Now lets deploy the contract and test the addition
89-
const enc_prod = await Paillier.mul(enc_a, enc_b, pubKey);
90-
const enc_prod_int = bigIntConversion.hexToBigint(enc_prod[0]);
91-
92-
// Conversion to int for convenience
93-
const dec_prod = Number(privateKey.decrypt(enc_prod_int));
94-
console.log(dec_prod);
95-
// We want dec_prod to equal 10
96-
expect(dec_prod).to.equal(10);
97-
});
98-
9968
it('should add a ciphertext and plaintext', async function () {
10069
const { Paillier, publicKey, privateKey } = await loadFixture(fixture);
10170
const a: bigint = BigInt(1);

0 commit comments

Comments
 (0)