mirror of
https://github.com/zama-ai/fhevm-solidity.git
synced 2026-04-17 03:00:47 -04:00
chore: eq-neq bool support and bitwise scalar support chore: overloads for fheEq and fheNe fix: reverts onchain when rhs is 0 in fheDiv-fheRem feat: added support for scalar and,or,xor chore: cleanup codegen feat: adds euint128 and euint256 types chore: removes ebool fheRandBounded and adds manual tests feat: adds new types for fheRand feat: adds trivialEncrypt for ebytesXXX feat: adds fheEq fheNe ifThenElse for new types chore: rename asyncDecrypt() to initGateway()
4358 lines
178 KiB
TypeScript
4358 lines
178 KiB
TypeScript
import { expect } from 'chai';
|
|
import { ethers } from 'hardhat';
|
|
|
|
import type { TFHETestSuite1 } from '../../types/contracts/tests/TFHETestSuite1';
|
|
import type { TFHETestSuite2 } from '../../types/contracts/tests/TFHETestSuite2';
|
|
import type { TFHETestSuite3 } from '../../types/contracts/tests/TFHETestSuite3';
|
|
import type { TFHETestSuite4 } from '../../types/contracts/tests/TFHETestSuite4';
|
|
import type { TFHETestSuite5 } from '../../types/contracts/tests/TFHETestSuite5';
|
|
import type { TFHETestSuite6 } from '../../types/contracts/tests/TFHETestSuite6';
|
|
import type { TFHETestSuite7 } from '../../types/contracts/tests/TFHETestSuite7';
|
|
import type { TFHETestSuite8 } from '../../types/contracts/tests/TFHETestSuite8';
|
|
import type { TFHETestSuite9 } from '../../types/contracts/tests/TFHETestSuite9';
|
|
import type { TFHETestSuite10 } from '../../types/contracts/tests/TFHETestSuite10';
|
|
import type { TFHETestSuite11 } from '../../types/contracts/tests/TFHETestSuite11';
|
|
import {
|
|
createInstances,
|
|
decrypt4,
|
|
decrypt8,
|
|
decrypt16,
|
|
decrypt32,
|
|
decrypt64,
|
|
decrypt128,
|
|
decrypt256,
|
|
decryptBool,
|
|
} from '../instance';
|
|
import { getSigners, initSigners } from '../signers';
|
|
|
|
async function deployTfheTestFixture1(): Promise<TFHETestSuite1> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite1');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture2(): Promise<TFHETestSuite2> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite2');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture3(): Promise<TFHETestSuite3> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite3');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture4(): Promise<TFHETestSuite4> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite4');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture5(): Promise<TFHETestSuite5> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite5');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture6(): Promise<TFHETestSuite6> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite6');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture7(): Promise<TFHETestSuite7> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite7');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture8(): Promise<TFHETestSuite8> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite8');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture9(): Promise<TFHETestSuite9> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite9');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture10(): Promise<TFHETestSuite10> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite10');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
async function deployTfheTestFixture11(): Promise<TFHETestSuite11> {
|
|
const signers = await getSigners();
|
|
const admin = signers.alice;
|
|
|
|
const contractFactory = await ethers.getContractFactory('TFHETestSuite11');
|
|
const contract = await contractFactory.connect(admin).deploy();
|
|
await contract.waitForDeployment();
|
|
|
|
return contract;
|
|
}
|
|
|
|
describe('TFHE operations 2', function () {
|
|
before(async function () {
|
|
await initSigners(1);
|
|
this.signers = await getSigners();
|
|
|
|
const contract1 = await deployTfheTestFixture1();
|
|
this.contract1Address = await contract1.getAddress();
|
|
this.contract1 = contract1;
|
|
|
|
const contract2 = await deployTfheTestFixture2();
|
|
this.contract2Address = await contract2.getAddress();
|
|
this.contract2 = contract2;
|
|
|
|
const contract3 = await deployTfheTestFixture3();
|
|
this.contract3Address = await contract3.getAddress();
|
|
this.contract3 = contract3;
|
|
|
|
const contract4 = await deployTfheTestFixture4();
|
|
this.contract4Address = await contract4.getAddress();
|
|
this.contract4 = contract4;
|
|
|
|
const contract5 = await deployTfheTestFixture5();
|
|
this.contract5Address = await contract5.getAddress();
|
|
this.contract5 = contract5;
|
|
|
|
const contract6 = await deployTfheTestFixture6();
|
|
this.contract6Address = await contract6.getAddress();
|
|
this.contract6 = contract6;
|
|
|
|
const contract7 = await deployTfheTestFixture7();
|
|
this.contract7Address = await contract7.getAddress();
|
|
this.contract7 = contract7;
|
|
|
|
const contract8 = await deployTfheTestFixture8();
|
|
this.contract8Address = await contract8.getAddress();
|
|
this.contract8 = contract8;
|
|
|
|
const contract9 = await deployTfheTestFixture9();
|
|
this.contract9Address = await contract9.getAddress();
|
|
this.contract9 = contract9;
|
|
|
|
const contract10 = await deployTfheTestFixture10();
|
|
this.contract10Address = await contract10.getAddress();
|
|
this.contract10 = contract10;
|
|
|
|
const contract11 = await deployTfheTestFixture11();
|
|
this.contract11Address = await contract11.getAddress();
|
|
this.contract11 = contract11;
|
|
|
|
const instances = await createInstances(this.signers);
|
|
this.instances = instances;
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint128) => ebool test 1 (5, 340282366920938463463372463025889881069)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
input.add128(340282366920938463463372463025889881069n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.le_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint128) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add128(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.le_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint128) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.le_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint128) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.le_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint128) => ebool test 1 (8, 340282366920938463463367828600285579945)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(340282366920938463463367828600285579945n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.lt_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint128) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add128(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.lt_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint128) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.lt_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint128) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.lt_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract1.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint128) => euint128 test 1 (14, 340282366920938463463373484167219835469)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add128(340282366920938463463373484167219835469n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.min_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint128) => euint128 test 2 (10, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
input.add128(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.min_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint128) => euint128 test 3 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add128(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.min_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint128) => euint128 test 4 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add128(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.min_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint128) => euint128 test 1 (1, 340282366920938463463366284713062311837)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(1n);
|
|
input.add128(340282366920938463463366284713062311837n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.max_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(340282366920938463463366284713062311837n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint128) => euint128 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add128(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.max_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint128) => euint128 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.max_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint128) => euint128 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add128(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.max_euint4_euint128(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt128(await this.contract1.res128());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, euint256) => euint256 test 1 (2, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(2n);
|
|
input.add256(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.add_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(11n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, euint256) => euint256 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.add_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, euint256) => euint256 test 3 (5, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
input.add256(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.add_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, euint256) => euint256 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.add_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint4, euint256) => euint256 test 1 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.sub_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint4, euint256) => euint256 test 2 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.sub_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, euint256) => euint256 test 1 (2, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(2n);
|
|
input.add256(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.mul_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, euint256) => euint256 test 2 (3, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
input.add256(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.mul_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, euint256) => euint256 test 3 (3, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
input.add256(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.mul_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, euint256) => euint256 test 4 (5, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
input.add256(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.mul_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, euint256) => euint256 test 1 (3, 115792089237316195423570985008687907853269984665640564039457581650107790454269)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457581650107790454269n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.and_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(1n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, euint256) => euint256 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.and_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, euint256) => euint256 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.and_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, euint256) => euint256 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.and_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, euint256) => euint256 test 1 (8, 115792089237316195423570985008687907853269984665640564039457583166606888282231)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457583166606888282231n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.or_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(115792089237316195423570985008687907853269984665640564039457583166606888282239n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, euint256) => euint256 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.or_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, euint256) => euint256 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.or_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, euint256) => euint256 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.or_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, euint256) => euint256 test 1 (5, 115792089237316195423570985008687907853269984665640564039457578855535245251769)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457578855535245251769n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.xor_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(115792089237316195423570985008687907853269984665640564039457578855535245251772n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, euint256) => euint256 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.xor_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, euint256) => euint256 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.xor_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, euint256) => euint256 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract1Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract1.xor_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract1.res256());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, euint256) => ebool test 1 (14, 115792089237316195423570985008687907853269984665640564039457583778640701263885)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457583778640701263885n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, euint256) => ebool test 2 (10, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
input.add256(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, euint256) => ebool test 3 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, euint256) => ebool test 4 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, euint256) => ebool test 1 (14, 115792089237316195423570985008687907853269984665640564039457581114073806378677)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457581114073806378677n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, euint256) => ebool test 2 (10, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
input.add256(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, euint256) => ebool test 3 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, euint256) => ebool test 4 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
input.add256(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, euint256) => ebool test 1 (5, 115792089237316195423570985008687907853269984665640564039457582400238586978263)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457582400238586978263n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, euint256) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, euint256) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, euint256) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, euint256) => ebool test 1 (1, 115792089237316195423570985008687907853269984665640564039457576918680285784187)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(1n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457576918680285784187n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, euint256) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, euint256) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, euint256) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint256) => ebool test 1 (12, 115792089237316195423570985008687907853269984665640564039457582708981712427829)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(12n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457582708981712427829n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint256) => ebool test 2 (8, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(12n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint256) => ebool test 3 (12, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(12n);
|
|
input.add256(12n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, euint256) => ebool test 4 (12, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(12n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint256) => ebool test 1 (11, 115792089237316195423570985008687907853269984665640564039457582432165171824629)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(11n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457582432165171824629n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint256) => ebool test 2 (7, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(7n);
|
|
input.add256(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint256) => ebool test 3 (11, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(11n);
|
|
input.add256(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, euint256) => ebool test 4 (11, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(11n);
|
|
input.add256(7n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint256) => euint256 test 1 (1, 115792089237316195423570985008687907853269984665640564039457580584483222103041)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(1n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457580584483222103041n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(1n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint256) => euint256 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint256) => euint256 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, euint256) => euint256 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
input.add256(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint256) => euint256 test 1 (9, 115792089237316195423570985008687907853269984665640564039457577693528211281505)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(9n);
|
|
input.add256(115792089237316195423570985008687907853269984665640564039457577693528211281505n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(115792089237316195423570985008687907853269984665640564039457577693528211281505n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint256) => euint256 test 2 (5, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
input.add256(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint256) => euint256 test 3 (9, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(9n);
|
|
input.add256(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, euint256) => euint256 test 4 (9, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(9n);
|
|
input.add256(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_euint256(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt256(await this.contract2.res256());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, uint8) => euint4 test 1 (9, 2)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(9n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint4_uint8(encryptedAmount.handles[0], 2n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(11n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, uint8) => euint4 test 2 (5, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint4_uint8(encryptedAmount.handles[0], 9n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, uint8) => euint4 test 3 (5, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint4_uint8(encryptedAmount.handles[0], 5n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint4, uint8) => euint4 test 4 (9, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(9n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint4_uint8(encryptedAmount.handles[0], 5n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "add" overload (uint8, euint4) => euint4 test 1 (6, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_uint8_euint4(6n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "add" overload (uint8, euint4) => euint4 test 2 (5, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_uint8_euint4(5n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "add" overload (uint8, euint4) => euint4 test 3 (5, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_uint8_euint4(5n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "add" overload (uint8, euint4) => euint4 test 4 (9, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_uint8_euint4(9n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint4, uint8) => euint4 test 1 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint4, uint8) => euint4 test 2 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "sub" overload (uint8, euint4) => euint4 test 1 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_uint8_euint4(14n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "sub" overload (uint8, euint4) => euint4 test 2 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_uint8_euint4(14n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, uint8) => euint4 test 1 (3, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, uint8) => euint4 test 2 (3, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint4_uint8(encryptedAmount.handles[0], 5n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, uint8) => euint4 test 3 (3, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint4_uint8(encryptedAmount.handles[0], 3n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint4, uint8) => euint4 test 4 (5, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint4_uint8(encryptedAmount.handles[0], 3n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "mul" overload (uint8, euint4) => euint4 test 1 (2, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_uint8_euint4(2n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "mul" overload (uint8, euint4) => euint4 test 2 (3, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_uint8_euint4(3n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "mul" overload (uint8, euint4) => euint4 test 3 (3, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_uint8_euint4(3n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "mul" overload (uint8, euint4) => euint4 test 4 (5, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_uint8_euint4(5n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "div" overload (euint4, uint8) => euint4 test 1 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.div_euint4_uint8(encryptedAmount.handles[0], 14n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(1n);
|
|
});
|
|
|
|
it('test operator "div" overload (euint4, uint8) => euint4 test 2 (10, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.div_euint4_uint8(encryptedAmount.handles[0], 14n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "div" overload (euint4, uint8) => euint4 test 3 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.div_euint4_uint8(encryptedAmount.handles[0], 14n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(1n);
|
|
});
|
|
|
|
it('test operator "div" overload (euint4, uint8) => euint4 test 4 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.div_euint4_uint8(encryptedAmount.handles[0], 10n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(1n);
|
|
});
|
|
|
|
it('test operator "rem" overload (euint4, uint8) => euint4 test 1 (13, 2)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(13n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.rem_euint4_uint8(encryptedAmount.handles[0], 2n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(1n);
|
|
});
|
|
|
|
it('test operator "rem" overload (euint4, uint8) => euint4 test 2 (9, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(9n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.rem_euint4_uint8(encryptedAmount.handles[0], 13n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "rem" overload (euint4, uint8) => euint4 test 3 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(13n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.rem_euint4_uint8(encryptedAmount.handles[0], 13n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "rem" overload (euint4, uint8) => euint4 test 4 (13, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(13n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.rem_euint4_uint8(encryptedAmount.handles[0], 9n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, uint8) => euint4 test 1 (10, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, uint8) => euint4 test 2 (6, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(6n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint4_uint8(encryptedAmount.handles[0], 10n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(2n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, uint8) => euint4 test 3 (10, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint4_uint8(encryptedAmount.handles[0], 10n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint4, uint8) => euint4 test 4 (10, 6)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint4_uint8(encryptedAmount.handles[0], 6n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(2n);
|
|
});
|
|
|
|
it('test operator "and" overload (uint8, euint4) => euint4 test 1 (12, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_uint8_euint4(12n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "and" overload (uint8, euint4) => euint4 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_uint8_euint4(4n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "and" overload (uint8, euint4) => euint4 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "and" overload (uint8, euint4) => euint4 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, uint8) => euint4 test 1 (8, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint4_uint8(encryptedAmount.handles[0], 9n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, uint8) => euint4 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, uint8) => euint4 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint4, uint8) => euint4 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "or" overload (uint8, euint4) => euint4 test 1 (13, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_uint8_euint4(13n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "or" overload (uint8, euint4) => euint4 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_uint8_euint4(4n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "or" overload (uint8, euint4) => euint4 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "or" overload (uint8, euint4) => euint4 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, uint8) => euint4 test 1 (10, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint4_uint8(encryptedAmount.handles[0], 12n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(6n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, uint8) => euint4 test 2 (6, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(6n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint4_uint8(encryptedAmount.handles[0], 10n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, uint8) => euint4 test 3 (10, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint4_uint8(encryptedAmount.handles[0], 10n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint4, uint8) => euint4 test 4 (10, 6)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint4_uint8(encryptedAmount.handles[0], 6n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (uint8, euint4) => euint4 test 1 (1, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_uint8_euint4(1n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(5n);
|
|
});
|
|
|
|
it('test operator "xor" overload (uint8, euint4) => euint4 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_uint8_euint4(4n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (uint8, euint4) => euint4 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "xor" overload (uint8, euint4) => euint4 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, uint8) => ebool test 1 (14, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_uint8(encryptedAmount.handles[0], 7n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, uint8) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, uint8) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint4, uint8) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (uint8, euint4) => ebool test 1 (1, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_uint8_euint4(1n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (uint8, euint4) => ebool test 2 (5, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_uint8_euint4(5n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (uint8, euint4) => ebool test 3 (9, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_uint8_euint4(9n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "eq" overload (uint8, euint4) => ebool test 4 (9, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_uint8_euint4(9n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, uint8) => ebool test 1 (8, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_uint8(encryptedAmount.handles[0], 9n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, uint8) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, uint8) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint4, uint8) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (uint8, euint4) => ebool test 1 (9, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_uint8_euint4(9n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (uint8, euint4) => ebool test 2 (9, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_uint8_euint4(9n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (uint8, euint4) => ebool test 3 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_uint8_euint4(13n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (uint8, euint4) => ebool test 4 (13, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_uint8_euint4(13n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, uint8) => ebool test 1 (3, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(3n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_uint8(encryptedAmount.handles[0], 5n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, uint8) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, uint8) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint4, uint8) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (uint8, euint4) => ebool test 1 (14, 1)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(1n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_uint8_euint4(14n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (uint8, euint4) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_uint8_euint4(4n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (uint8, euint4) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (uint8, euint4) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, uint8) => ebool test 1 (1, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(1n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_uint8(encryptedAmount.handles[0], 3n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, uint8) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, uint8) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint4, uint8) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (uint8, euint4) => ebool test 1 (1, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_uint8_euint4(1n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (uint8, euint4) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_uint8_euint4(4n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (uint8, euint4) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (uint8, euint4) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_uint8_euint4(8n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, uint8) => ebool test 1 (1, 2)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(1n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_uint8(encryptedAmount.handles[0], 2n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, uint8) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, uint8) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint4, uint8) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "le" overload (uint8, euint4) => ebool test 1 (11, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_uint8_euint4(11n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "le" overload (uint8, euint4) => ebool test 2 (6, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_uint8_euint4(6n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (uint8, euint4) => ebool test 3 (10, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_uint8_euint4(10n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (uint8, euint4) => ebool test 4 (10, 6)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(6n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_uint8_euint4(10n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, uint8) => ebool test 1 (12, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(12n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_uint8(encryptedAmount.handles[0], 9n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, uint8) => ebool test 2 (8, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_uint8(encryptedAmount.handles[0], 12n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, uint8) => ebool test 3 (12, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(12n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_uint8(encryptedAmount.handles[0], 12n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint4, uint8) => ebool test 4 (12, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(12n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (uint8, euint4) => ebool test 1 (5, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_uint8_euint4(5n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (uint8, euint4) => ebool test 2 (7, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_uint8_euint4(7n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (uint8, euint4) => ebool test 3 (11, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_uint8_euint4(11n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (uint8, euint4) => ebool test 4 (11, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(7n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_uint8_euint4(11n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, uint8) => euint4 test 1 (5, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(5n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_uint8(encryptedAmount.handles[0], 5n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(5n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, uint8) => euint4 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(4n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, uint8) => euint4 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_uint8(encryptedAmount.handles[0], 8n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint4, uint8) => euint4 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(8n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint4_uint8(encryptedAmount.handles[0], 4n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "min" overload (uint8, euint4) => euint4 test 1 (5, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_uint8_euint4(5n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(5n);
|
|
});
|
|
|
|
it('test operator "min" overload (uint8, euint4) => euint4 test 2 (7, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_uint8_euint4(7n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(7n);
|
|
});
|
|
|
|
it('test operator "min" overload (uint8, euint4) => euint4 test 3 (11, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_uint8_euint4(11n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(11n);
|
|
});
|
|
|
|
it('test operator "min" overload (uint8, euint4) => euint4 test 4 (11, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(7n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_uint8_euint4(11n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(7n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, uint8) => euint4 test 1 (14, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_uint8(encryptedAmount.handles[0], 7n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, uint8) => euint4 test 2 (10, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(10n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_uint8(encryptedAmount.handles[0], 14n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, uint8) => euint4 test 3 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_uint8(encryptedAmount.handles[0], 14n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint4, uint8) => euint4 test 4 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add4(14n);
|
|
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint4_uint8(encryptedAmount.handles[0], 10n, encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "max" overload (uint8, euint4) => euint4 test 1 (14, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_uint8_euint4(14n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "max" overload (uint8, euint4) => euint4 test 2 (9, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_uint8_euint4(9n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(13n);
|
|
});
|
|
|
|
it('test operator "max" overload (uint8, euint4) => euint4 test 3 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_uint8_euint4(13n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(13n);
|
|
});
|
|
|
|
it('test operator "max" overload (uint8, euint4) => euint4 test 4 (13, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_uint8_euint4(13n, encryptedAmount.handles[0], encryptedAmount.inputProof);
|
|
await tx.wait();
|
|
const res = await decrypt4(await this.contract2.res4());
|
|
expect(res).to.equal(13n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint4) => euint8 test 1 (10, 2)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(10n);
|
|
input.add4(2n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint4) => euint8 test 2 (5, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(5n);
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint4) => euint8 test 3 (5, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(5n);
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(10n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint4) => euint8 test 4 (9, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(9n);
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint8, euint4) => euint8 test 1 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(14n);
|
|
input.add4(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint8, euint4) => euint8 test 2 (14, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(14n);
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint4) => euint8 test 1 (7, 2)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(7n);
|
|
input.add4(2n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(14n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint4) => euint8 test 2 (3, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(3n);
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint4) => euint8 test 3 (3, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(3n);
|
|
input.add4(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(9n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint4) => euint8 test 4 (5, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(5n);
|
|
input.add4(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(15n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint4) => euint8 test 1 (118, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(118n);
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint4) => euint8 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(4n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint4) => euint8 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint4) => euint8 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint4) => euint8 test 1 (189, 3)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(189n);
|
|
input.add4(3n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(191n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint4) => euint8 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(4n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint4) => euint8 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(8n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint4) => euint8 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint4) => euint8 test 1 (104, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(104n);
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(108n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint4) => euint8 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(4n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint4) => euint8 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint4) => euint8 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint4) => ebool test 1 (65, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(65n);
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint4) => ebool test 2 (5, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(5n);
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint4) => ebool test 3 (9, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(9n);
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint4) => ebool test 4 (9, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(9n);
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint4) => ebool test 1 (27, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(27n);
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint4) => ebool test 2 (9, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(9n);
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint4) => ebool test 3 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint4) => ebool test 4 (13, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint4) => ebool test 1 (53, 1)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(53n);
|
|
input.add4(1n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint4) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(4n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint4) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint4) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint4) => ebool test 1 (94, 5)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(94n);
|
|
input.add4(5n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint4) => ebool test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(4n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint4) => ebool test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint4) => ebool test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add4(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint4) => ebool test 1 (26, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(26n);
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint4) => ebool test 2 (6, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(6n);
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint4) => ebool test 3 (10, 10)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(10n);
|
|
input.add4(10n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint4) => ebool test 4 (10, 6)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(10n);
|
|
input.add4(6n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint4) => ebool test 1 (163, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(163n);
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint4) => ebool test 2 (7, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(7n);
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint4) => ebool test 3 (11, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(11n);
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint4) => ebool test 4 (11, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(11n);
|
|
input.add4(7n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint4) => euint8 test 1 (51, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(51n);
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(11n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint4) => euint8 test 2 (7, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(7n);
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(7n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint4) => euint8 test 3 (11, 11)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(11n);
|
|
input.add4(11n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(11n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint4) => euint8 test 4 (11, 7)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(11n);
|
|
input.add4(7n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(7n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint4) => euint8 test 1 (62, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(62n);
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(62n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint4) => euint8 test 2 (9, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(9n);
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(13n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint4) => euint8 test 3 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add4(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(13n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint4) => euint8 test 4 (13, 9)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add4(9n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint4(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(13n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint8) => euint8 test 1 (219, 18)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(219n);
|
|
input.add8(18n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(237n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint8) => euint8 test 2 (14, 18)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(14n);
|
|
input.add8(18n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(32n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint8) => euint8 test 3 (18, 18)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(18n);
|
|
input.add8(18n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(36n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint8) => euint8 test 4 (18, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(18n);
|
|
input.add8(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(32n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint8, euint8) => euint8 test 1 (152, 152)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(152n);
|
|
input.add8(152n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint8, euint8) => euint8 test 2 (152, 148)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(152n);
|
|
input.add8(148n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint8) => euint8 test 1 (8, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add8(12n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(96n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint8) => euint8 test 2 (12, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(12n);
|
|
input.add8(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(168n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint8) => euint8 test 3 (14, 14)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(14n);
|
|
input.add8(14n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(196n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint8) => euint8 test 4 (14, 12)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(14n);
|
|
input.add8(12n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(168n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint8) => euint8 test 1 (183, 135)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(183n);
|
|
input.add8(135n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(135n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint8) => euint8 test 2 (131, 135)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(131n);
|
|
input.add8(135n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(131n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint8) => euint8 test 3 (135, 135)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(135n);
|
|
input.add8(135n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(135n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint8) => euint8 test 4 (135, 131)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(135n);
|
|
input.add8(131n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(131n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint8) => euint8 test 1 (189, 251)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(189n);
|
|
input.add8(251n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(255n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint8) => euint8 test 2 (185, 189)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(185n);
|
|
input.add8(189n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(189n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint8) => euint8 test 3 (189, 189)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(189n);
|
|
input.add8(189n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(189n);
|
|
});
|
|
|
|
it('test operator "or" overload (euint8, euint8) => euint8 test 4 (189, 185)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(189n);
|
|
input.add8(185n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.or_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(189n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint8) => euint8 test 1 (234, 150)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(234n);
|
|
input.add8(150n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(124n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint8) => euint8 test 2 (146, 150)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(146n);
|
|
input.add8(150n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint8) => euint8 test 3 (150, 150)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(150n);
|
|
input.add8(150n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "xor" overload (euint8, euint8) => euint8 test 4 (150, 146)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(150n);
|
|
input.add8(146n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.xor_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint8) => ebool test 1 (175, 224)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(175n);
|
|
input.add8(224n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint8) => ebool test 2 (171, 175)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(171n);
|
|
input.add8(175n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint8) => ebool test 3 (175, 175)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(175n);
|
|
input.add8(175n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "eq" overload (euint8, euint8) => ebool test 4 (175, 171)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(175n);
|
|
input.add8(171n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.eq_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint8) => ebool test 1 (197, 245)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(197n);
|
|
input.add8(245n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint8) => ebool test 2 (193, 197)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(193n);
|
|
input.add8(197n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint8) => ebool test 3 (197, 197)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(197n);
|
|
input.add8(197n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ne" overload (euint8, euint8) => ebool test 4 (197, 193)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(197n);
|
|
input.add8(193n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ne_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint8) => ebool test 1 (63, 190)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(63n);
|
|
input.add8(190n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint8) => ebool test 2 (59, 63)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(59n);
|
|
input.add8(63n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint8) => ebool test 3 (63, 63)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(63n);
|
|
input.add8(63n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "ge" overload (euint8, euint8) => ebool test 4 (63, 59)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(63n);
|
|
input.add8(59n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.ge_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint8) => ebool test 1 (239, 212)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(239n);
|
|
input.add8(212n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint8) => ebool test 2 (208, 212)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(208n);
|
|
input.add8(212n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint8) => ebool test 3 (212, 212)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(212n);
|
|
input.add8(212n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "gt" overload (euint8, euint8) => ebool test 4 (212, 208)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(212n);
|
|
input.add8(208n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.gt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint8) => ebool test 1 (124, 71)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(124n);
|
|
input.add8(71n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint8) => ebool test 2 (67, 71)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(67n);
|
|
input.add8(71n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint8) => ebool test 3 (71, 71)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(71n);
|
|
input.add8(71n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "le" overload (euint8, euint8) => ebool test 4 (71, 67)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(71n);
|
|
input.add8(67n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.le_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint8) => ebool test 1 (221, 45)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(221n);
|
|
input.add8(45n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint8) => ebool test 2 (41, 45)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(41n);
|
|
input.add8(45n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(true);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint8) => ebool test 3 (45, 45)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(45n);
|
|
input.add8(45n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "lt" overload (euint8, euint8) => ebool test 4 (45, 41)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(45n);
|
|
input.add8(41n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.lt_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decryptBool(await this.contract2.resb());
|
|
expect(res).to.equal(false);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint8) => euint8 test 1 (183, 84)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(183n);
|
|
input.add8(84n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(84n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint8) => euint8 test 2 (80, 84)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(80n);
|
|
input.add8(84n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(80n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint8) => euint8 test 3 (84, 84)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(84n);
|
|
input.add8(84n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(84n);
|
|
});
|
|
|
|
it('test operator "min" overload (euint8, euint8) => euint8 test 4 (84, 80)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(84n);
|
|
input.add8(80n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.min_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(80n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint8) => euint8 test 1 (17, 182)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(17n);
|
|
input.add8(182n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(182n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint8) => euint8 test 2 (13, 17)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add8(17n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(17n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint8) => euint8 test 3 (17, 17)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(17n);
|
|
input.add8(17n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(17n);
|
|
});
|
|
|
|
it('test operator "max" overload (euint8, euint8) => euint8 test 4 (17, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(17n);
|
|
input.add8(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.max_euint8_euint8(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt8(await this.contract2.res8());
|
|
expect(res).to.equal(17n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint16) => euint16 test 1 (2, 132)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(2n);
|
|
input.add16(132n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(134n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint16) => euint16 test 2 (4, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(4n);
|
|
input.add16(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint16) => euint16 test 3 (8, 8)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add16(8n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(16n);
|
|
});
|
|
|
|
it('test operator "add" overload (euint8, euint16) => euint16 test 4 (8, 4)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(8n);
|
|
input.add16(4n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.add_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(12n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint8, euint16) => euint16 test 1 (32, 32)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(32n);
|
|
input.add16(32n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(0n);
|
|
});
|
|
|
|
it('test operator "sub" overload (euint8, euint16) => euint16 test 2 (32, 28)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(32n);
|
|
input.add16(28n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.sub_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(4n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint16) => euint16 test 1 (2, 60)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(2n);
|
|
input.add16(60n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(120n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint16) => euint16 test 2 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add16(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(169n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint16) => euint16 test 3 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add16(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(169n);
|
|
});
|
|
|
|
it('test operator "mul" overload (euint8, euint16) => euint16 test 4 (13, 13)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(13n);
|
|
input.add16(13n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.mul_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(169n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint16) => euint16 test 1 (225, 29113)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(225n);
|
|
input.add16(29113n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(161n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint16) => euint16 test 2 (221, 225)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(221n);
|
|
input.add16(225n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(193n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint16) => euint16 test 3 (225, 225)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(225n);
|
|
input.add16(225n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(225n);
|
|
});
|
|
|
|
it('test operator "and" overload (euint8, euint16) => euint16 test 4 (225, 221)', async function () {
|
|
const input = this.instances.alice.createEncryptedInput(this.contract2Address, this.signers.alice.address);
|
|
input.add8(225n);
|
|
input.add16(221n);
|
|
const encryptedAmount = await input.encrypt();
|
|
const tx = await this.contract2.and_euint8_euint16(
|
|
encryptedAmount.handles[0],
|
|
encryptedAmount.handles[1],
|
|
encryptedAmount.inputProof,
|
|
);
|
|
await tx.wait();
|
|
const res = await decrypt16(await this.contract2.res16());
|
|
expect(res).to.equal(193n);
|
|
});
|
|
});
|