diff --git a/README.md b/README.md index 362ff60e..743fb86d 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ npm install Note: Solidity files are formatted with prettier. -### Generate TFHE lib +### Generate TFHE lib and tests ``` npm run codegen @@ -57,6 +57,22 @@ npm run codegen WARNING: Use this command to generate Solidity code and prettier result automatically! +Files that are generated now (can be seen inside `codegen/main.ts`) + +``` +lib/Common.sol +lib/Precompiles.sol +lib/Impl.sol +lib/TFHE.sol +contracts/tests/TFHETestSuiteX.sol +test/tfheOperations/tfheOperations.ts +``` + +### Adding new operators + +Operators can be defined as data inside `codegen/common.ts` file and code automatically generates solidity overloads. +Test for overloads must be added (or the build doesn't pass) inside `codegen/overloadsTests.ts` file. + ### Test ``` diff --git a/codegen/common.ts b/codegen/common.ts index 71885c5e..c1bedbd4 100644 --- a/codegen/common.ts +++ b/codegen/common.ts @@ -1,13 +1,18 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; export type Operator = { name: string; + // express left scalar operation as different operation with arguments swapped leftScalarInvertOp?: string; precompileName: string; hasScalar: boolean; hasEncrypted: boolean; arguments: OperatorArguments; returnType: ReturnType; + // if true do trivial encryption for left scalar operand, this is workaround until tfhe-rs supports left scalar operands + leftScalarEncrypt?: boolean; + // disable left scalar operator + leftScalarDisable?: boolean; }; export type Precompile = { @@ -73,6 +78,7 @@ export const ALL_OPERATORS: Operator[] = [ hasEncrypted: true, arguments: OperatorArguments.Binary, returnType: ReturnType.Uint, + leftScalarEncrypt: true, }, { name: 'mul', @@ -89,6 +95,7 @@ export const ALL_OPERATORS: Operator[] = [ hasEncrypted: false, arguments: OperatorArguments.Binary, returnType: ReturnType.Uint, + leftScalarDisable: true, }, { name: 'and', @@ -121,6 +128,7 @@ export const ALL_OPERATORS: Operator[] = [ hasEncrypted: true, arguments: OperatorArguments.Binary, returnType: ReturnType.Uint, + leftScalarEncrypt: true, }, { name: 'shr', @@ -129,6 +137,7 @@ export const ALL_OPERATORS: Operator[] = [ hasEncrypted: true, arguments: OperatorArguments.Binary, returnType: ReturnType.Uint, + leftScalarEncrypt: true, }, { name: 'eq', diff --git a/codegen/main.ts b/codegen/main.ts index b49aa35a..da3978dc 100644 --- a/codegen/main.ts +++ b/codegen/main.ts @@ -1,15 +1,23 @@ -import { writeFileSync } from 'fs'; +import { mkdirSync, writeFileSync } from 'fs'; import { ALL_OPERATORS, ALL_PRECOMPILES, SUPPORTED_BITS, checks } from './common'; import * as t from './templates'; +import * as testgen from './testgen'; function generateAllFiles() { const operators = checks(ALL_OPERATORS); - writeFileSync(`lib/Common.sol`, t.commonSolHeader()); - writeFileSync(`lib/Precompiles.sol`, t.precompiles(ALL_PRECOMPILES)); - writeFileSync(`lib/Impl.sol`, t.implSol(operators)); - writeFileSync(`lib/TFHE.sol`, t.tfheSol(operators, SUPPORTED_BITS)); + const [tfheSolSource, overloads] = t.tfheSol(operators, SUPPORTED_BITS); + const ovShards = testgen.splitOverloadsToShards(overloads); + writeFileSync('lib/Common.sol', t.commonSolHeader()); + writeFileSync('lib/Precompiles.sol', t.precompiles(ALL_PRECOMPILES)); + writeFileSync('lib/Impl.sol', t.implSol(operators)); + writeFileSync('lib/TFHE.sol', tfheSolSource); + mkdirSync('contracts/tests', { recursive: true }); + ovShards.forEach((os) => { + writeFileSync(`contracts/tests/TFHETestSuite${os.shardNumber}.sol`, testgen.generateSmartContract(os)); + }); + writeFileSync('test/tfheOperations/tfheOperations.ts', testgen.generateTestCode(ovShards)); } generateAllFiles(); diff --git a/codegen/overloadTests.ts b/codegen/overloadTests.ts new file mode 100644 index 00000000..44278c29 --- /dev/null +++ b/codegen/overloadTests.ts @@ -0,0 +1,820 @@ +import { OverloadSignature, signatureContractMethodName } from './testgen'; + +type OverloadTest = { + inputs: number[]; + output: boolean | number; +}; + +export const overloadTests: { [methodName: string]: OverloadTest[] } = { + add_euint8_euint8: [{ inputs: [3, 4], output: 7 }], + sub_euint8_euint8: [{ inputs: [4, 3], output: 1 }], + mul_euint8_euint8: [{ inputs: [3, 4], output: 12 }], + and_euint8_euint8: [{ inputs: [0xff, 0x0f], output: 0x0f }], + or_euint8_euint8: [{ inputs: [0x70, 0x0f], output: 0x7f }], + xor_euint8_euint8: [ + { inputs: [0x77, 0x77], output: 0x00 }, + { inputs: [12, 34], output: 46 }, + ], + shl_euint8_euint8: [ + { inputs: [2, 1], output: 4 }, + { inputs: [2, 4], output: 32 }, + ], + shr_euint8_euint8: [ + { inputs: [2, 1], output: 1 }, + { inputs: [32, 4], output: 2 }, + ], + eq_euint8_euint8: [ + { inputs: [12, 49], output: false }, + { inputs: [7, 7], output: true }, + ], + ne_euint8_euint8: [ + { inputs: [1, 2], output: true }, + { inputs: [2, 2], output: false }, + ], + ge_euint8_euint8: [ + { inputs: [10, 10], output: true }, + { inputs: [10, 9], output: true }, + { inputs: [10, 11], output: false }, + ], + gt_euint8_euint8: [ + { inputs: [10, 10], output: false }, + { inputs: [10, 9], output: true }, + { inputs: [10, 11], output: false }, + ], + le_euint8_euint8: [ + { inputs: [10, 10], output: true }, + { inputs: [10, 9], output: false }, + { inputs: [10, 11], output: true }, + ], + lt_euint8_euint8: [ + { inputs: [10, 10], output: false }, + { inputs: [10, 9], output: false }, + { inputs: [10, 11], output: true }, + ], + min_euint8_euint8: [ + { inputs: [10, 10], output: 10 }, + { inputs: [12, 10], output: 10 }, + { inputs: [9, 12], output: 9 }, + ], + max_euint8_euint8: [ + { inputs: [10, 10], output: 10 }, + { inputs: [12, 10], output: 12 }, + { inputs: [9, 12], output: 12 }, + ], + add_euint8_euint16: [{ inputs: [0x03, 0xff00], output: 0xff03 }], + sub_euint8_euint16: [{ inputs: [0x03, 0x1000], output: 0xf003 }], + mul_euint8_euint16: [{ inputs: [0x03, 0x1000], output: 0x3000 }], + and_euint8_euint16: [ + { inputs: [0x03, 0x1000], output: 0x0000 }, + { inputs: [0x03, 0x1001], output: 0x0001 }, + ], + or_euint8_euint16: [ + { inputs: [0x03, 0x1000], output: 0x1003 }, + { inputs: [0x03, 0x1001], output: 0x1003 }, + ], + xor_euint8_euint16: [ + { inputs: [0xff, 0xffff], output: 0xff00 }, + { inputs: [0xff, 0xff00], output: 0xffff }, + ], + shl_euint8_euint16: [ + // TODO: should shl output 8bit with 16bit be like that? + { inputs: [0xff, 0x0100], output: 0xff }, + { inputs: [0x02, 0x0001], output: 0x04 }, + ], + shr_euint8_euint16: [ + // TODO: should shr output 8bit with 16bit be like that? + { inputs: [0xff, 0x0100], output: 0xff }, + { inputs: [0xff, 0x0001], output: 0x7f }, + ], + eq_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: true }, + { inputs: [0xff, 0x01ff], output: false }, + ], + ne_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: false }, + { inputs: [0xff, 0x01ff], output: true }, + ], + ge_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: true }, + { inputs: [0xff, 0x01ff], output: false }, + { inputs: [0xff, 0x007f], output: true }, + ], + gt_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: false }, + { inputs: [0xff, 0x01ff], output: false }, + { inputs: [0xff, 0x007f], output: true }, + ], + le_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: true }, + { inputs: [0xff, 0x01ff], output: true }, + { inputs: [0xff, 0x007f], output: false }, + ], + lt_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: false }, + { inputs: [0xff, 0x01ff], output: true }, + { inputs: [0xff, 0x007f], output: false }, + ], + min_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: 0xff }, + { inputs: [0xff, 0x01ff], output: 0xff }, + { inputs: [0xff, 0x007f], output: 0x7f }, + ], + max_euint8_euint16: [ + { inputs: [0xff, 0x00ff], output: 0xff }, + { inputs: [0xff, 0x01ff], output: 0x1ff }, + { inputs: [0xff, 0x007f], output: 0xff }, + ], + add_euint8_euint32: [{ inputs: [0xff, 0xffff00ff], output: 0xffff01fe }], + sub_euint8_euint32: [ + { inputs: [0xff, 0xffff00ff], output: 0x10000 }, + { inputs: [0xff, 0x00000010], output: 0x000ef }, + ], + mul_euint8_euint32: [{ inputs: [0x10, 0x00010000], output: 0x00100000 }], + and_euint8_euint32: [ + { inputs: [0x10, 0x00010000], output: 0x00000000 }, + { inputs: [0x11, 0x00010010], output: 0x00000010 }, + ], + or_euint8_euint32: [ + { inputs: [0x10, 0x00010000], output: 0x00010010 }, + { inputs: [0x11, 0x00010010], output: 0x00010011 }, + ], + xor_euint8_euint32: [ + { inputs: [0x10, 0x00010000], output: 0x00010010 }, + { inputs: [0x11, 0x00010010], output: 0x00010001 }, + ], + shl_euint8_euint32: [ + // C compiler emits the same + { inputs: [0x10, 0x00010000], output: 0x10 }, + { inputs: [0x1f, 0x00010000], output: 0x1f }, + ], + shr_euint8_euint32: [ + // C compiler emits the same + { inputs: [0x10, 0x00010000], output: 0x10 }, + { inputs: [0x1f, 0x00010000], output: 0x1f }, + { inputs: [0x10, 0x00000001], output: 0x8 }, + { inputs: [0x1f, 0x00000001], output: 0xf }, + ], + eq_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: true }, + { inputs: [0x01, 0x00010001], output: false }, + ], + ne_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: false }, + { inputs: [0x01, 0x00010001], output: true }, + ], + ge_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: true }, + { inputs: [0x01, 0x00010001], output: false }, + { inputs: [0x10, 0x00000001], output: true }, + ], + gt_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: false }, + { inputs: [0x01, 0x00010001], output: false }, + { inputs: [0x10, 0x00000001], output: true }, + ], + le_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: true }, + { inputs: [0x01, 0x00010001], output: true }, + { inputs: [0x10, 0x00000001], output: false }, + ], + lt_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: false }, + { inputs: [0x01, 0x00010001], output: true }, + { inputs: [0x10, 0x00000001], output: false }, + ], + min_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: 0x1 }, + { inputs: [0x01, 0x00010001], output: 0x1 }, + { inputs: [0x10, 0x00000004], output: 0x4 }, + ], + max_euint8_euint32: [ + { inputs: [0x01, 0x00000001], output: 0x1 }, + { inputs: [0x01, 0x00010001], output: 0x10001 }, + { inputs: [0x10, 0x00000004], output: 0x10 }, + ], + add_euint8_uint8: [{ inputs: [0x04, 0x03], output: 0x07 }], + add_uint8_euint8: [{ inputs: [0x04, 0x03], output: 0x07 }], + sub_euint8_uint8: [ + // bug found + { inputs: [0x04, 0x03], output: 0x01 }, + { inputs: [0x03, 0x04], output: 0xff }, + ], + sub_uint8_euint8: [ + // bug found + { inputs: [0x04, 0x03], output: 0x01 }, + { inputs: [0x03, 0x04], output: 0xff }, + ], + mul_euint8_uint8: [ + { inputs: [0x04, 0x03], output: 0x0c }, + { inputs: [0x03, 0x04], output: 0x0c }, + { inputs: [0x08, 0x02], output: 0x10 }, + ], + mul_uint8_euint8: [ + { inputs: [0x04, 0x03], output: 0x0c }, + { inputs: [0x03, 0x04], output: 0x0c }, + { inputs: [0x08, 0x02], output: 0x10 }, + ], + div_euint8_uint8: [{ inputs: [0x10, 0x02], output: 0x08 }], + shl_euint8_uint8: [ + { inputs: [0x10, 0x01], output: 0x20 }, + { inputs: [0x10, 0x02], output: 0x40 }, + ], + shl_uint8_euint8: [ + { inputs: [0x10, 0x01], output: 0x20 }, + { inputs: [0x10, 0x02], output: 0x40 }, + ], + shr_euint8_uint8: [ + { inputs: [0x10, 0x01], output: 0x08 }, + { inputs: [0x10, 0x02], output: 0x04 }, + ], + shr_uint8_euint8: [ + { inputs: [0x10, 0x01], output: 0x08 }, + { inputs: [0x10, 0x02], output: 0x04 }, + ], + eq_euint8_uint8: [ + { inputs: [0x10, 0x10], output: true }, + { inputs: [0x10, 0x02], output: false }, + ], + eq_uint8_euint8: [ + { inputs: [0x10, 0x10], output: true }, + { inputs: [0x10, 0x02], output: false }, + ], + ne_euint8_uint8: [ + { inputs: [0x10, 0x10], output: false }, + { inputs: [0x10, 0x02], output: true }, + ], + ne_uint8_euint8: [ + { inputs: [0x10, 0x10], output: false }, + { inputs: [0x10, 0x02], output: true }, + ], + ge_euint8_uint8: [ + { inputs: [0x10, 0x10], output: true }, + { inputs: [0x10, 0x02], output: true }, + { inputs: [0x10, 0x11], output: false }, + ], + ge_uint8_euint8: [ + { inputs: [0x10, 0x10], output: true }, + { inputs: [0x10, 0x02], output: true }, + { inputs: [0x10, 0x11], output: false }, + ], + gt_euint8_uint8: [ + { inputs: [0x10, 0x10], output: false }, + { inputs: [0x10, 0x02], output: true }, + { inputs: [0x10, 0x11], output: false }, + ], + gt_uint8_euint8: [ + { inputs: [0x10, 0x10], output: false }, + { inputs: [0x10, 0x02], output: true }, + { inputs: [0x10, 0x11], output: false }, + ], + le_euint8_uint8: [ + { inputs: [0x10, 0x10], output: true }, + { inputs: [0x10, 0x02], output: false }, + { inputs: [0x10, 0x11], output: true }, + ], + le_uint8_euint8: [ + { inputs: [0x10, 0x10], output: true }, + { inputs: [0x10, 0x02], output: false }, + { inputs: [0x10, 0x11], output: true }, + ], + lt_euint8_uint8: [ + { inputs: [0x10, 0x10], output: false }, + { inputs: [0x10, 0x02], output: false }, + { inputs: [0x10, 0x11], output: true }, + ], + lt_uint8_euint8: [ + { inputs: [0x10, 0x10], output: false }, + { inputs: [0x10, 0x02], output: false }, + { inputs: [0x10, 0x11], output: true }, + ], + min_euint8_uint8: [ + { inputs: [0x10, 0x10], output: 0x10 }, + { inputs: [0x10, 0x02], output: 0x02 }, + { inputs: [0x10, 0x11], output: 0x10 }, + ], + min_uint8_euint8: [ + { inputs: [0x10, 0x10], output: 0x10 }, + { inputs: [0x10, 0x02], output: 0x02 }, + { inputs: [0x10, 0x11], output: 0x10 }, + ], + max_euint8_uint8: [ + { inputs: [0x10, 0x10], output: 0x10 }, + { inputs: [0x10, 0x02], output: 0x10 }, + { inputs: [0x10, 0x11], output: 0x11 }, + ], + max_uint8_euint8: [ + { inputs: [0x10, 0x10], output: 0x10 }, + { inputs: [0x10, 0x02], output: 0x10 }, + { inputs: [0x10, 0x11], output: 0x11 }, + ], + add_euint16_euint8: [ + { inputs: [0x1000, 0x10], output: 0x1010 }, + { inputs: [0x1010, 0x10], output: 0x1020 }, + ], + sub_euint16_euint8: [ + { inputs: [0x1000, 0x10], output: 0x0ff0 }, + { inputs: [0x1010, 0x10], output: 0x1000 }, + ], + mul_euint16_euint8: [{ inputs: [0x1000, 0x04], output: 0x4000 }], + and_euint16_euint8: [ + { inputs: [0x1000, 0x04], output: 0x0000 }, + { inputs: [0x10f0, 0xf0], output: 0x00f0 }, + ], + or_euint16_euint8: [ + { inputs: [0x1000, 0x04], output: 0x1004 }, + { inputs: [0x10f0, 0xf0], output: 0x10f0 }, + ], + xor_euint16_euint8: [ + { inputs: [0x1000, 0x04], output: 0x1004 }, + { inputs: [0x10f0, 0xf2], output: 0x1002 }, + ], + shl_euint16_euint8: [{ inputs: [0x1010, 0x02], output: 0x4040 }], + shr_euint16_euint8: [{ inputs: [0x1010, 0x02], output: 0x0404 }], + eq_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: true }, + { inputs: [0x0110, 0x10], output: false }, + ], + ne_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: false }, + { inputs: [0x0110, 0x10], output: true }, + ], + ge_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: true }, + { inputs: [0x0110, 0x10], output: true }, + { inputs: [0x000f, 0x10], output: false }, + ], + gt_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: false }, + { inputs: [0x0110, 0x10], output: true }, + { inputs: [0x000f, 0x10], output: false }, + ], + le_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: true }, + { inputs: [0x0110, 0x10], output: false }, + { inputs: [0x000f, 0x10], output: true }, + ], + lt_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: false }, + { inputs: [0x0110, 0x10], output: false }, + { inputs: [0x000f, 0x10], output: true }, + ], + min_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: 0x10 }, + { inputs: [0x0110, 0x10], output: 0x10 }, + { inputs: [0x000f, 0x10], output: 0x0f }, + ], + max_euint16_euint8: [ + { inputs: [0x0010, 0x10], output: 0x10 }, + { inputs: [0x0110, 0x10], output: 0x0110 }, + { inputs: [0x000f, 0x10], output: 0x10 }, + ], + add_euint16_euint16: [{ inputs: [0x0102, 0x0201], output: 0x0303 }], + sub_euint16_euint16: [{ inputs: [0x0403, 0x0102], output: 0x0301 }], + mul_euint16_euint16: [{ inputs: [0x0200, 0x0002], output: 0x0400 }], + and_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: 0x0000 }, + { inputs: [0x0210, 0x0012], output: 0x0010 }, + ], + or_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: 0x0202 }, + { inputs: [0x0210, 0x0012], output: 0x0212 }, + ], + xor_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: 0x0202 }, + { inputs: [0x0210, 0x0012], output: 0x0202 }, + ], + shl_euint16_euint16: [{ inputs: [0x0200, 0x0002], output: 0x0800 }], + shr_euint16_euint16: [{ inputs: [0x0200, 0x0002], output: 0x0080 }], + eq_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: false }, + { inputs: [0x0200, 0x0200], output: true }, + ], + ne_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: true }, + { inputs: [0x0200, 0x0200], output: false }, + ], + ge_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: true }, + { inputs: [0x0200, 0x0200], output: true }, + { inputs: [0x0200, 0x0201], output: false }, + ], + gt_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: true }, + { inputs: [0x0200, 0x0200], output: false }, + { inputs: [0x0200, 0x0201], output: false }, + ], + le_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: false }, + { inputs: [0x0200, 0x0200], output: true }, + { inputs: [0x0200, 0x0201], output: true }, + ], + lt_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: false }, + { inputs: [0x0200, 0x0200], output: false }, + { inputs: [0x0200, 0x0201], output: true }, + ], + min_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: 0x02 }, + { inputs: [0x0200, 0x0200], output: 0x0200 }, + { inputs: [0x0200, 0x0201], output: 0x0200 }, + ], + max_euint16_euint16: [ + { inputs: [0x0200, 0x0002], output: 0x0200 }, + { inputs: [0x0200, 0x0200], output: 0x0200 }, + { inputs: [0x0200, 0x0201], output: 0x0201 }, + ], + add_euint16_euint32: [{ inputs: [0x0202, 0x00020002], output: 0x00020204 }], + sub_euint16_euint32: [ + { inputs: [0x0202, 0x00000002], output: 0x00000200 }, + { inputs: [0x0202, 0x00010000], output: 0xffff0202 }, + ], + mul_euint16_euint32: [{ inputs: [0x0200, 0x00010000], output: 0x02000000 }], + and_euint16_euint32: [ + { inputs: [0x0202, 0x00010000], output: 0x00000000 }, + { inputs: [0x0202, 0x00010002], output: 0x00000002 }, + ], + or_euint16_euint32: [ + { inputs: [0x0202, 0x00010000], output: 0x00010202 }, + { inputs: [0x0202, 0x00010002], output: 0x00010202 }, + ], + xor_euint16_euint32: [ + { inputs: [0x0202, 0x00010000], output: 0x00010202 }, + { inputs: [0x0202, 0x00010002], output: 0x00010200 }, + ], + shl_euint16_euint32: [{ inputs: [0x0202, 0x00000002], output: 0x00000808 }], + shr_euint16_euint32: [{ inputs: [0x0202, 0x00000002], output: 0x00000080 }], + eq_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: false }, + { inputs: [0x0202, 0x00000202], output: true }, + ], + ne_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: true }, + { inputs: [0x0202, 0x00000202], output: false }, + ], + ge_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: false }, + { inputs: [0x0202, 0x00000202], output: true }, + { inputs: [0x0202, 0x00000201], output: true }, + ], + gt_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: false }, + { inputs: [0x0202, 0x00000202], output: false }, + { inputs: [0x0202, 0x00000201], output: true }, + ], + le_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: true }, + { inputs: [0x0202, 0x00000202], output: true }, + { inputs: [0x0202, 0x00000201], output: false }, + ], + lt_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: true }, + { inputs: [0x0202, 0x00000202], output: false }, + { inputs: [0x0202, 0x00000201], output: false }, + ], + min_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: 0x202 }, + { inputs: [0x0202, 0x00000202], output: 0x202 }, + { inputs: [0x0202, 0x00000201], output: 0x201 }, + ], + max_euint16_euint32: [ + { inputs: [0x0202, 0x00010202], output: 0x00010202 }, + { inputs: [0x0202, 0x00000202], output: 0x202 }, + { inputs: [0x0202, 0x00000201], output: 0x202 }, + ], + add_euint16_uint16: [{ inputs: [0x0202, 0x0222], output: 0x0424 }], + add_uint16_euint16: [{ inputs: [0x0202, 0x0222], output: 0x0424 }], + sub_euint16_uint16: [{ inputs: [0x0202, 0x0201], output: 0x0001 }], + sub_uint16_euint16: [{ inputs: [0x0202, 0x0201], output: 0x0001 }], + mul_euint16_uint16: [{ inputs: [0x0202, 0x0003], output: 0x0606 }], + mul_uint16_euint16: [{ inputs: [0x0202, 0x0003], output: 0x0606 }], + div_euint16_uint16: [{ inputs: [0x0606, 0x0003], output: 0x0202 }], + shl_euint16_uint16: [{ inputs: [0x0606, 0x0003], output: 0x3030 }], + shl_uint16_euint16: [{ inputs: [0x0606, 0x0003], output: 0x3030 }], + shr_euint16_uint16: [{ inputs: [0x0606, 0x0003], output: 0x00c0 }], + shr_uint16_euint16: [{ inputs: [0x0606, 0x0003], output: 0x00c0 }], + eq_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: true }, + { inputs: [0x0606, 0x0605], output: false }, + ], + eq_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: true }, + { inputs: [0x0606, 0x0605], output: false }, + ], + ne_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: false }, + { inputs: [0x0606, 0x0605], output: true }, + ], + ne_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: false }, + { inputs: [0x0606, 0x0605], output: true }, + ], + ge_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: true }, + { inputs: [0x0606, 0x0605], output: true }, + { inputs: [0x0606, 0x0607], output: false }, + ], + ge_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: true }, + { inputs: [0x0606, 0x0605], output: true }, + { inputs: [0x0606, 0x0607], output: false }, + ], + gt_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: false }, + { inputs: [0x0606, 0x0605], output: true }, + { inputs: [0x0606, 0x0607], output: false }, + ], + gt_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: false }, + { inputs: [0x0606, 0x0605], output: true }, + { inputs: [0x0606, 0x0607], output: false }, + ], + le_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: true }, + { inputs: [0x0606, 0x0605], output: false }, + { inputs: [0x0606, 0x0607], output: true }, + ], + le_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: true }, + { inputs: [0x0606, 0x0605], output: false }, + { inputs: [0x0606, 0x0607], output: true }, + ], + lt_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: false }, + { inputs: [0x0606, 0x0605], output: false }, + { inputs: [0x0606, 0x0607], output: true }, + ], + lt_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: false }, + { inputs: [0x0606, 0x0605], output: false }, + { inputs: [0x0606, 0x0607], output: true }, + ], + min_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: 0x0606 }, + { inputs: [0x0606, 0x0605], output: 0x0605 }, + { inputs: [0x0606, 0x0607], output: 0x0606 }, + ], + min_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: 0x0606 }, + { inputs: [0x0606, 0x0605], output: 0x0605 }, + { inputs: [0x0606, 0x0607], output: 0x0606 }, + ], + max_euint16_uint16: [ + { inputs: [0x0606, 0x0606], output: 0x0606 }, + { inputs: [0x0606, 0x0605], output: 0x0606 }, + { inputs: [0x0606, 0x0607], output: 0x0607 }, + ], + max_uint16_euint16: [ + { inputs: [0x0606, 0x0606], output: 0x0606 }, + { inputs: [0x0606, 0x0605], output: 0x0606 }, + { inputs: [0x0606, 0x0607], output: 0x0607 }, + ], + add_euint32_euint8: [{ inputs: [0x03000000, 0x03], output: 0x03000003 }], + sub_euint32_euint8: [{ inputs: [0x03000000, 0x03], output: 0x2fffffd }], + mul_euint32_euint8: [{ inputs: [0x03000000, 0x03], output: 0x09000000 }], + and_euint32_euint8: [ + { inputs: [0x03010000, 0x03], output: 0x00000000 }, + { inputs: [0x03010003, 0x03], output: 0x00000003 }, + ], + or_euint32_euint8: [ + { inputs: [0x03010000, 0x03], output: 0x03010003 }, + { inputs: [0x03010003, 0x03], output: 0x03010003 }, + ], + xor_euint32_euint8: [ + { inputs: [0x03010000, 0x03], output: 0x03010003 }, + { inputs: [0x03010003, 0x03], output: 0x03010000 }, + ], + shl_euint32_euint8: [{ inputs: [0x03010000, 0x03], output: 0x18080000 }], + shr_euint32_euint8: [{ inputs: [0x03010000, 0x03], output: 0x00602000 }], + eq_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: true }, + { inputs: [0x03000003, 0x03], output: false }, + ], + ne_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: false }, + { inputs: [0x03000003, 0x03], output: true }, + ], + ge_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: true }, + { inputs: [0x03000003, 0x03], output: true }, + { inputs: [0x00000003, 0x04], output: false }, + ], + gt_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: false }, + { inputs: [0x03000003, 0x03], output: true }, + { inputs: [0x00000003, 0x04], output: false }, + ], + le_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: true }, + { inputs: [0x03000003, 0x03], output: false }, + { inputs: [0x00000003, 0x04], output: true }, + ], + lt_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: false }, + { inputs: [0x03000003, 0x03], output: false }, + { inputs: [0x00000003, 0x04], output: true }, + ], + min_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: 0x03 }, + { inputs: [0x03000003, 0x03], output: 0x03 }, + { inputs: [0x00000003, 0x04], output: 0x03 }, + ], + max_euint32_euint8: [ + { inputs: [0x00000003, 0x03], output: 0x03 }, + { inputs: [0x03000003, 0x03], output: 0x03000003 }, + { inputs: [0x00000003, 0x04], output: 0x04 }, + ], + add_euint32_euint16: [{ inputs: [0x03001023, 0x1003], output: 0x03002026 }], + sub_euint32_euint16: [{ inputs: [0x03001023, 0x1003], output: 0x03000020 }], + mul_euint32_euint16: [{ inputs: [0x03001023, 0x0003], output: 0x09003069 }], + and_euint32_euint16: [ + { inputs: [0x03001020, 0x0003], output: 0x00000000 }, + { inputs: [0x03001023, 0x1003], output: 0x00001003 }, + ], + or_euint32_euint16: [ + { inputs: [0x03000020, 0x1003], output: 0x03001023 }, + { inputs: [0x03000023, 0x1003], output: 0x03001023 }, + ], + xor_euint32_euint16: [{ inputs: [0x03000023, 0x1003], output: 0x03001020 }], + shl_euint32_euint16: [{ inputs: [0x03000000, 0x0002], output: 0x0c000000 }], + shr_euint32_euint16: [{ inputs: [0x03000000, 0x0002], output: 0x00c00000 }], + eq_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: true }, + { inputs: [0x01001000, 0x1000], output: false }, + ], + ne_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: false }, + { inputs: [0x01001000, 0x1000], output: true }, + ], + ge_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: true }, + { inputs: [0x01001000, 0x1000], output: true }, + { inputs: [0x00001000, 0x1001], output: false }, + ], + gt_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: false }, + { inputs: [0x01001000, 0x1000], output: true }, + { inputs: [0x00001000, 0x1001], output: false }, + ], + le_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: true }, + { inputs: [0x01001000, 0x1000], output: false }, + { inputs: [0x00001000, 0x1001], output: true }, + ], + lt_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: false }, + { inputs: [0x01001000, 0x1000], output: false }, + { inputs: [0x00001000, 0x1001], output: true }, + ], + min_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: 0x1000 }, + { inputs: [0x01001000, 0x1000], output: 0x1000 }, + { inputs: [0x00001000, 0x1001], output: 0x1000 }, + ], + max_euint32_euint16: [ + { inputs: [0x00001000, 0x1000], output: 0x1000 }, + { inputs: [0x01001000, 0x1000], output: 0x01001000 }, + { inputs: [0x00001000, 0x1001], output: 0x1001 }, + ], + add_euint32_euint32: [{ inputs: [0x00321000, 0x00111000], output: 0x00432000 }], + sub_euint32_euint32: [{ inputs: [0x00321000, 0x00111000], output: 0x00210000 }], + mul_euint32_euint32: [{ inputs: [0x00321000, 0x00000020], output: 0x06420000 }], + and_euint32_euint32: [ + { inputs: [0x00321000, 0x54000000], output: 0x00000000 }, + { inputs: [0x00321000, 0x54030000], output: 0x00020000 }, + ], + or_euint32_euint32: [ + { inputs: [0x00321000, 0x54000000], output: 0x54321000 }, + { inputs: [0x00321000, 0x54030000], output: 0x54331000 }, + ], + xor_euint32_euint32: [ + { inputs: [0x00321000, 0x54000000], output: 0x54321000 }, + { inputs: [0x00321000, 0x54030000], output: 0x54311000 }, + ], + shl_euint32_euint32: [{ inputs: [0x00321000, 0x00000002], output: 0x00c84000 }], + shr_euint32_euint32: [{ inputs: [0x00321000, 0x00000002], output: 0x000c8400 }], + eq_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: true }, + { inputs: [0x00321000, 0x00321001], output: false }, + ], + ne_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: false }, + { inputs: [0x00321000, 0x00321001], output: true }, + ], + ge_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: true }, + { inputs: [0x00321000, 0x00321001], output: false }, + { inputs: [0x00321000, 0x00320fff], output: true }, + ], + gt_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: false }, + { inputs: [0x00321000, 0x00321001], output: false }, + { inputs: [0x00321000, 0x00320fff], output: true }, + ], + le_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: true }, + { inputs: [0x00321000, 0x00321001], output: true }, + { inputs: [0x00321000, 0x00320fff], output: false }, + ], + lt_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: false }, + { inputs: [0x00321000, 0x00321001], output: true }, + { inputs: [0x00321000, 0x00320fff], output: false }, + ], + min_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: 0x00321000 }, + { inputs: [0x00321000, 0x00321001], output: 0x00321000 }, + { inputs: [0x00321000, 0x00320fff], output: 0x00320fff }, + ], + max_euint32_euint32: [ + { inputs: [0x00321000, 0x00321000], output: 0x00321000 }, + { inputs: [0x00321000, 0x00321001], output: 0x00321001 }, + { inputs: [0x00321000, 0x00320fff], output: 0x00321000 }, + ], + add_euint32_uint32: [{ inputs: [0x00342000, 0x00321000], output: 0x00663000 }], + add_uint32_euint32: [{ inputs: [0x00342000, 0x00321000], output: 0x00663000 }], + sub_euint32_uint32: [{ inputs: [0x00342000, 0x00321000], output: 0x00021000 }], + sub_uint32_euint32: [{ inputs: [0x00342000, 0x00321000], output: 0x00021000 }], + mul_euint32_uint32: [{ inputs: [0x00342000, 0x00000100], output: 0x34200000 }], + mul_uint32_euint32: [{ inputs: [0x00342000, 0x00000100], output: 0x34200000 }], + div_euint32_uint32: [{ inputs: [0x00342000, 0x00000100], output: 0x00003420 }], + shl_euint32_uint32: [{ inputs: [0x00342000, 0x00000001], output: 0x00684000 }], + shl_uint32_euint32: [{ inputs: [0x00342000, 0x00000001], output: 0x00684000 }], + shr_euint32_uint32: [{ inputs: [0x00342000, 0x00000001], output: 0x001a1000 }], + shr_uint32_euint32: [{ inputs: [0x00342000, 0x00000001], output: 0x001a1000 }], + eq_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: true }, + { inputs: [0x00342000, 0x00342001], output: false }, + ], + eq_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: true }, + { inputs: [0x00342000, 0x00342001], output: false }, + ], + ne_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: false }, + { inputs: [0x00342000, 0x00342001], output: true }, + ], + ne_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: false }, + { inputs: [0x00342000, 0x00342001], output: true }, + ], + ge_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: true }, + { inputs: [0x00342000, 0x00342001], output: false }, + { inputs: [0x00342000, 0x00341fff], output: true }, + ], + ge_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: true }, + { inputs: [0x00342000, 0x00342001], output: false }, + { inputs: [0x00342000, 0x00341fff], output: true }, + ], + gt_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: false }, + { inputs: [0x00342000, 0x00342001], output: false }, + { inputs: [0x00342000, 0x00341fff], output: true }, + ], + gt_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: false }, + { inputs: [0x00342000, 0x00342001], output: false }, + { inputs: [0x00342000, 0x00341fff], output: true }, + ], + le_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: true }, + { inputs: [0x00342000, 0x00342001], output: true }, + { inputs: [0x00342000, 0x00341fff], output: false }, + ], + le_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: true }, + { inputs: [0x00342000, 0x00342001], output: true }, + { inputs: [0x00342000, 0x00341fff], output: false }, + ], + lt_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: false }, + { inputs: [0x00342000, 0x00342001], output: true }, + { inputs: [0x00342000, 0x00341fff], output: false }, + ], + lt_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: false }, + { inputs: [0x00342000, 0x00342001], output: true }, + { inputs: [0x00342000, 0x00341fff], output: false }, + ], + min_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: 0x00342000 }, + { inputs: [0x00342000, 0x00342001], output: 0x00342000 }, + { inputs: [0x00342000, 0x00341fff], output: 0x00341fff }, + ], + min_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: 0x00342000 }, + { inputs: [0x00342000, 0x00342001], output: 0x00342000 }, + { inputs: [0x00342000, 0x00341fff], output: 0x00341fff }, + ], + max_euint32_uint32: [ + { inputs: [0x00342000, 0x00342000], output: 0x00342000 }, + { inputs: [0x00342000, 0x00342001], output: 0x00342001 }, + { inputs: [0x00342000, 0x00341fff], output: 0x00342000 }, + ], + max_uint32_euint32: [ + { inputs: [0x00342000, 0x00342000], output: 0x00342000 }, + { inputs: [0x00342000, 0x00342001], output: 0x00342001 }, + { inputs: [0x00342000, 0x00341fff], output: 0x00342000 }, + ], +}; diff --git a/codegen/templates.ts b/codegen/templates.ts index 0826b08f..a2905384 100644 --- a/codegen/templates.ts +++ b/codegen/templates.ts @@ -1,6 +1,7 @@ import { assert } from 'console'; import { Operator, OperatorArguments, Precompile, ReturnType } from './common'; +import { ArgumentType, OverloadSignature } from './testgen'; export function commonSolHeader(): string { return ` @@ -97,7 +98,8 @@ library Impl { return res.join(''); } -export function tfheSol(operators: Operator[], supportedBits: number[]): string { +export function tfheSol(operators: Operator[], supportedBits: number[]): [string, OverloadSignature[]] { + const signatures: OverloadSignature[] = []; const res: string[] = []; res.push(`// SPDX-License-Identifier: BSD-3-Clause-Clear @@ -125,9 +127,9 @@ library TFHE { supportedBits.forEach((lhsBits) => { supportedBits.forEach((rhsBits) => { - operators.forEach((operator) => res.push(tfheEncryptedOperator(lhsBits, rhsBits, operator))); + operators.forEach((operator) => res.push(tfheEncryptedOperator(lhsBits, rhsBits, operator, signatures))); }); - operators.forEach((operator) => res.push(tfheScalarOperator(lhsBits, lhsBits, operator))); + operators.forEach((operator) => res.push(tfheScalarOperator(lhsBits, lhsBits, operator, signatures))); }); // TODO: Decide whether we want to have mixed-inputs for CMUX @@ -144,10 +146,15 @@ library TFHE { res.push('}\n'); - return res.join(''); + return [res.join(''), signatures]; } -function tfheEncryptedOperator(lhsBits: number, rhsBits: number, operator: Operator): string { +function tfheEncryptedOperator( + lhsBits: number, + rhsBits: number, + operator: Operator, + signatures: OverloadSignature[], +): string { if (!operator.hasEncrypted || operator.arguments != OperatorArguments.Binary) { return ''; } @@ -164,6 +171,8 @@ function tfheEncryptedOperator(lhsBits: number, rhsBits: number, operator: Opera : operator.returnType == ReturnType.Ebool ? `ebool` : assert(false, 'Unknown return type'); + const returnTypeOverload: ArgumentType = + operator.returnType == ReturnType.Uint ? ArgumentType.EUint : ArgumentType.Ebool; const scalarFlag = operator.hasEncrypted && operator.hasScalar ? ', false' : ''; const leftExpr = castLeftToRight ? `asEuint${outputBits}(a)` : 'a'; @@ -172,6 +181,14 @@ function tfheEncryptedOperator(lhsBits: number, rhsBits: number, operator: Opera if (boolCastNeeded) { implExpression = `Impl.cast(${implExpression}, Common.ebool_t)`; } + signatures.push({ + name: operator.name, + arguments: [ + { type: ArgumentType.EUint, bits: lhsBits }, + { type: ArgumentType.EUint, bits: rhsBits }, + ], + returnType: { type: returnTypeOverload, bits: outputBits }, + }); res.push(` // Evaluate ${operator.name}(a, b) and return the result. function ${operator.name}(euint${lhsBits} a, euint${rhsBits} b) internal view returns (${returnType}) { @@ -188,7 +205,12 @@ function tfheEncryptedOperator(lhsBits: number, rhsBits: number, operator: Opera return res.join(''); } -function tfheScalarOperator(lhsBits: number, rhsBits: number, operator: Operator): string { +function tfheScalarOperator( + lhsBits: number, + rhsBits: number, + operator: Operator, + signatures: OverloadSignature[], +): string { if (operator.arguments != OperatorArguments.Binary) { return ''; } @@ -207,17 +229,34 @@ function tfheScalarOperator(lhsBits: number, rhsBits: number, operator: Operator : operator.returnType == ReturnType.Ebool ? `ebool` : assert(false, 'Unknown return type'); - const scalarFlag = operator.hasEncrypted && operator.hasScalar ? ', true' : ''; + const returnTypeOverload = operator.returnType == ReturnType.Uint ? ArgumentType.EUint : ArgumentType.Ebool; + var scalarFlag = operator.hasEncrypted && operator.hasScalar ? ', true' : ''; + const leftOpName = operator.leftScalarInvertOp ?? operator.name; var implExpressionA = `Impl.${operator.name}(euint${outputBits}.unwrap(a), uint256(b)${scalarFlag})`; - var implExpressionB = `Impl.${operator.name}(euint${outputBits}.unwrap(b), uint256(a)${scalarFlag})`; - if (operator.leftScalarInvertOp) { - implExpressionB = `Impl.${operator.leftScalarInvertOp}(euint${outputBits}.unwrap(b), uint256(a)${scalarFlag})`; + var implExpressionB = `Impl.${leftOpName}(euint${outputBits}.unwrap(b), uint256(a)${scalarFlag})`; + var maybeEncryptLeft = ''; + if (operator.leftScalarEncrypt) { + // workaround until tfhe-rs left scalar support: + // do the trivial encryption and preserve order of operations + scalarFlag = ', false'; + maybeEncryptLeft = `euint${outputBits} aEnc = asEuint${outputBits}(a);`; + implExpressionB = `Impl.${leftOpName}(euint${outputBits}.unwrap(aEnc), euint${outputBits}.unwrap(b)${scalarFlag})`; } if (boolCastNeeded) { implExpressionA = `Impl.cast(${implExpressionA}, Common.ebool_t)`; implExpressionB = `Impl.cast(${implExpressionB}, Common.ebool_t)`; } + signatures.push({ + name: operator.name, + arguments: [ + { type: ArgumentType.EUint, bits: lhsBits }, + { type: ArgumentType.Uint, bits: rhsBits }, + ], + returnType: { type: returnTypeOverload, bits: outputBits }, + }); + + // rhs scalar res.push(` // Evaluate ${operator.name}(a, b) and return the result. function ${operator.name}(euint${lhsBits} a, uint${rhsBits} b) internal view returns (${returnType}) { @@ -226,15 +265,31 @@ function tfheScalarOperator(lhsBits: number, rhsBits: number, operator: Operator } return ${returnType}.wrap(${implExpressionA}); } +`); + + // lhs scalar + if (!operator.leftScalarDisable) { + signatures.push({ + name: operator.name, + arguments: [ + { type: ArgumentType.Uint, bits: rhsBits }, + { type: ArgumentType.EUint, bits: lhsBits }, + ], + returnType: { type: returnTypeOverload, bits: outputBits }, + }); + + res.push(` // Evaluate ${operator.name}(a, b) and return the result. function ${operator.name}(uint${lhsBits} a, euint${rhsBits} b) internal view returns (${returnType}) { + ${maybeEncryptLeft} if (!isInitialized(b)) { b = asEuint${rhsBits}(0); } return ${returnType}.wrap(${implExpressionB}); } -`); + `); + } return res.join(''); } diff --git a/codegen/testgen.ts b/codegen/testgen.ts new file mode 100644 index 00000000..034bdf75 --- /dev/null +++ b/codegen/testgen.ts @@ -0,0 +1,295 @@ +import { strict as assert } from 'node:assert'; + +import { Operator } from './common'; +import { overloadTests } from './overloadTests'; + +export enum ArgumentType { + Ebool, + EUint, + Uint, +} + +export type FunctionType = { + type: ArgumentType; + bits: number; +}; + +export type OverloadSignature = { + name: string; + arguments: FunctionType[]; + returnType: FunctionType; +}; + +export type OverloadShard = { + shardNumber: number; + overloads: OverloadSignature[]; +}; + +/** + * This is done because there's a limit on how big + * of a smart contract you can deploy + */ +export function splitOverloadsToShards(overloads: OverloadSignature[]): OverloadShard[] { + const MAX_SHARD_SIZE = 150; + const res: OverloadShard[] = []; + + var shardNo = 1; + var accumulator: OverloadSignature[] = []; + overloads.forEach((o) => { + accumulator.push(o); + if (accumulator.length >= MAX_SHARD_SIZE) { + res.push({ + shardNumber: shardNo, + overloads: Object.assign([], accumulator), + }); + shardNo++; + accumulator = []; + } + }); + + if (accumulator.length > 0) { + res.push({ + shardNumber: shardNo, + overloads: Object.assign([], accumulator), + }); + } + + return res; +} + +export function generateTestCode(shards: OverloadShard[]): string { + const res: string[] = []; + + res.push(` + import { expect } from 'chai'; + import { ethers } from 'hardhat'; + import { createInstances } from '../instance'; + import { getSigners } from '../signers'; + + `); + + shards.forEach((os) => { + res.push(` + import type { TFHETestSuite${os.shardNumber} } from '../../types/contracts/tests/TFHETestSuite${os.shardNumber}'; + `); + }); + + shards.forEach((os) => { + res.push(` +async function deployTfheTestFixture${os.shardNumber}(): Promise { + const signers = await ethers.getSigners(); + const admin = signers[0]; + + const contractFactory = await ethers.getContractFactory('TFHETestSuite${os.shardNumber}'); + const contract = await contractFactory.connect(admin).deploy(); + await contract.waitForDeployment(); + + return contract; +} + `); + }); + + res.push(` + describe('TFHE operations', function () { + before(async function () { + this.signers = await getSigners(); + + `); + + shards.forEach((os) => { + res.push(` + const contract${os.shardNumber} = await deployTfheTestFixture${os.shardNumber}(); + this.contract${os.shardNumber}Address = await contract${os.shardNumber}.getAddress(); + this.contract${os.shardNumber} = contract${os.shardNumber}; + const instances${os.shardNumber} = await createInstances(this.contract${os.shardNumber}Address, ethers, this.signers); + this.instances${os.shardNumber} = instances${os.shardNumber}; + `); + }); + + res.push(` + }); + `); + + // don't allow user to add test for method that doesn't exist + const overloadUsages: { [methodName: string]: boolean } = {}; + shards.forEach((os) => { + os.overloads.forEach((o) => { + const testName = `test operator "${o.name}" overload ${signatureContractEncryptedSignature(o)}`; + const methodName = signatureContractMethodName(o); + overloadUsages[methodName] = true; + const tests = overloadTests[methodName] || []; + assert(tests.length > 0, `Overload ${methodName} has no tests, please add them.`); + var testIndex = 1; + tests.forEach((t) => { + assert( + t.inputs.length == o.arguments.length, + `Test argument count is different to operator arguments, arguments: ${t.inputs}, expected count: ${o.arguments.length}`, + ); + t.inputs.forEach((input, index) => ensureNumberAcceptableInBitRange(o.arguments[index].bits, input)); + if (typeof t.output === 'number') { + ensureNumberAcceptableInBitRange(o.returnType.bits, t.output); + } + const testArgs = t.inputs.join(', '); + res.push(` + it('${testName} test ${testIndex} (${testArgs})', async function () { + const res = await this.contract${os.shardNumber}.${methodName}(${testArgs}); + expect(res).to.equal(${t.output}); + }); + `); + testIndex++; + }); + }); + }); + + for (let key in overloadTests) { + assert(overloadUsages[key], `No such overload '${key}' exists for which test data is defined`); + } + + res.push(` + }); + `); + + return res.join(''); +} + +function ensureNumberAcceptableInBitRange(bits: number, input: number) { + switch (bits) { + case 8: + ensureNumberInRange(bits, input, 0x00, 0xff); + break; + case 16: + ensureNumberInRange(bits, input, 0x00, 0xffff); + break; + case 32: + ensureNumberInRange(bits, input, 0x00, 0xffffffff); + break; + default: + assert(false, `TODO: add support for ${bits} numbers`); + } +} + +function ensureNumberInRange(bits: number, input: number, min: number, max: number) { + assert(input >= min && input <= max, `${bits} bit number ${input} doesn't fall into expected [${min}; ${max}] range`); +} + +export function generateSmartContract(os: OverloadShard): string { + const res: string[] = []; + + res.push(` + // SPDX-License-Identifier: BSD-3-Clause-Clear + pragma solidity >=0.8.13 <0.8.20; + + import "../../lib/TFHE.sol"; + contract TFHETestSuite${os.shardNumber} { + `); + + os.overloads.forEach((o) => { + const methodName = signatureContractMethodName(o); + const args = signatureContractArguments(o); + const retType = functionTypeToDecryptedType(o.returnType); + res.push(`function ${methodName}(${args}) public view returns (${retType}) {`); + res.push('\n'); + + const procArgs: string[] = []; + var argName = 97; // letter 'a' in ascii + o.arguments.forEach((a) => { + const arg = String.fromCharCode(argName); + const argProc = `${arg}Proc`; + procArgs.push(argProc); + res.push(`${functionTypeToString(a)} ${argProc} = ${castExpressionToType(arg, a)};`); + res.push('\n'); + argName++; + }); + + const tfheArgs = procArgs.join(', '); + + res.push(`${functionTypeToEncryptedType(o.returnType)} result = TFHE.${o.name}(${tfheArgs});`); + res.push('\n'); + + res.push(`return TFHE.decrypt(result); + } + `); + }); + + res.push(` + } + `); + + return res.join(''); +} + +export function signatureContractMethodName(s: OverloadSignature): string { + const res: string[] = []; + + res.push(s.name); + s.arguments.forEach((a) => res.push(functionTypeToString(a))); + + return res.join('_'); +} + +function signatureContractArguments(s: OverloadSignature): string { + const res: string[] = []; + + var argName = 97; // letter 'a' in ascii + s.arguments.forEach((a) => { + res.push(`${functionTypeToDecryptedType(a)} ${String.fromCharCode(argName)}`); + argName++; + }); + + return res.join(', '); +} + +function signatureContractEncryptedSignature(s: OverloadSignature): string { + const res: string[] = []; + + var argName = 97; // letter 'a' in ascii + s.arguments.forEach((a) => { + res.push(`${functionTypeToString(a)}`); + argName++; + }); + + const joined = res.join(', '); + return `(${joined}) => ${functionTypeToEncryptedType(s.returnType)}`; +} + +function castExpressionToType(argExpr: string, outputType: FunctionType): string { + switch (outputType.type) { + case ArgumentType.EUint: + return `TFHE.asEuint${outputType.bits}(${argExpr})`; + case ArgumentType.Uint: + return argExpr; + case ArgumentType.Ebool: + return `TFHE.asEbool(${argExpr})`; + } +} + +function functionTypeToDecryptedType(t: FunctionType): string { + switch (t.type) { + case ArgumentType.EUint: + case ArgumentType.Uint: + return `uint${t.bits}`; + case ArgumentType.Ebool: + return `bool`; + } +} + +function functionTypeToEncryptedType(t: FunctionType): string { + switch (t.type) { + case ArgumentType.EUint: + case ArgumentType.Uint: + return `euint${t.bits}`; + case ArgumentType.Ebool: + return `ebool`; + } +} + +function functionTypeToString(t: FunctionType): string { + switch (t.type) { + case ArgumentType.EUint: + return `euint${t.bits}`; + case ArgumentType.Uint: + return `uint${t.bits}`; + case ArgumentType.Ebool: + return `ebool`; + } +} diff --git a/contracts/TFHETestSuite.sol b/contracts/TFHETestSuite.sol deleted file mode 100644 index 55c5502d..00000000 --- a/contracts/TFHETestSuite.sol +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause-Clear - -pragma solidity >=0.8.13 <0.8.20; - -import "../lib/TFHE.sol"; - -contract TFHETestSuite { - function addUint8(uint8 a, uint8 b) public view returns (uint8) { - return TFHE.decrypt(TFHE.add(TFHE.asEuint8(a), TFHE.asEuint8(b))); - } - - function mulUint8(uint8 a, uint8 b) public view returns (uint8) { - return TFHE.decrypt(TFHE.mul(TFHE.asEuint8(a), TFHE.asEuint8(b))); - } -} diff --git a/contracts/tests/TFHETestSuite1.sol b/contracts/tests/TFHETestSuite1.sol new file mode 100644 index 00000000..a2aecd26 --- /dev/null +++ b/contracts/tests/TFHETestSuite1.sol @@ -0,0 +1,1056 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity >=0.8.13 <0.8.20; + +import "../../lib/TFHE.sol"; + +contract TFHETestSuite1 { + function add_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint8_euint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint8_euint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint8_euint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint8_euint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint8_euint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint8_euint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint8_euint16(uint8 a, uint16 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint8_euint16(uint8 a, uint16 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint8_euint16(uint8 a, uint16 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint8_euint16(uint8 a, uint16 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint8_euint16(uint8 a, uint16 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint8_euint16(uint8 a, uint16 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint8_euint16(uint8 a, uint16 b) public view returns (uint16) { + euint8 aProc = TFHE.asEuint8(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint8_euint32(uint8 a, uint32 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint8_euint32(uint8 a, uint32 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint8_euint32(uint8 a, uint32 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint8_euint32(uint8 a, uint32 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint8_euint32(uint8 a, uint32 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint8_euint32(uint8 a, uint32 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint8_euint32(uint8 a, uint32 b) public view returns (uint32) { + euint8 aProc = TFHE.asEuint8(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function div_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.div(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint8_uint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_uint8_euint8(uint8 a, uint8 b) public view returns (bool) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint8_uint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_uint8_euint8(uint8 a, uint8 b) public view returns (bool) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint8_uint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_uint8_euint8(uint8 a, uint8 b) public view returns (bool) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint8_uint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_uint8_euint8(uint8 a, uint8 b) public view returns (bool) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint8_uint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_uint8_euint8(uint8 a, uint8 b) public view returns (bool) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint8_uint8(uint8 a, uint8 b) public view returns (bool) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_uint8_euint8(uint8 a, uint8 b) public view returns (bool) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint8_uint8(uint8 a, uint8 b) public view returns (uint8) { + euint8 aProc = TFHE.asEuint8(a); + uint8 bProc = b; + euint8 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_uint8_euint8(uint8 a, uint8 b) public view returns (uint8) { + uint8 aProc = a; + euint8 bProc = TFHE.asEuint8(b); + euint8 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint16_euint8(uint16 a, uint8 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint16_euint8(uint16 a, uint8 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint16_euint8(uint16 a, uint8 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint16_euint8(uint16 a, uint8 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint16_euint8(uint16 a, uint8 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint16_euint8(uint16 a, uint8 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint16_euint8(uint16 a, uint8 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint8 bProc = TFHE.asEuint8(b); + euint16 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint16_euint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint16_euint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint16_euint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint16_euint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint16_euint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint16_euint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint16_euint32(uint16 a, uint32 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint16_euint32(uint16 a, uint32 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint16_euint32(uint16 a, uint32 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint16_euint32(uint16 a, uint32 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint16_euint32(uint16 a, uint32 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint16_euint32(uint16 a, uint32 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint16_euint32(uint16 a, uint32 b) public view returns (uint32) { + euint16 aProc = TFHE.asEuint16(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function div_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.div(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint16_uint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_uint16_euint16(uint16 a, uint16 b) public view returns (bool) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint16_uint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_uint16_euint16(uint16 a, uint16 b) public view returns (bool) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint16_uint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_uint16_euint16(uint16 a, uint16 b) public view returns (bool) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint16_uint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_uint16_euint16(uint16 a, uint16 b) public view returns (bool) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint16_uint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_uint16_euint16(uint16 a, uint16 b) public view returns (bool) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint16_uint16(uint16 a, uint16 b) public view returns (bool) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_uint16_euint16(uint16 a, uint16 b) public view returns (bool) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint16_uint16(uint16 a, uint16 b) public view returns (uint16) { + euint16 aProc = TFHE.asEuint16(a); + uint16 bProc = b; + euint16 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_uint16_euint16(uint16 a, uint16 b) public view returns (uint16) { + uint16 aProc = a; + euint16 bProc = TFHE.asEuint16(b); + euint16 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } +} diff --git a/contracts/tests/TFHETestSuite2.sol b/contracts/tests/TFHETestSuite2.sol new file mode 100644 index 00000000..2bddb14f --- /dev/null +++ b/contracts/tests/TFHETestSuite2.sol @@ -0,0 +1,531 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear +pragma solidity >=0.8.13 <0.8.20; + +import "../../lib/TFHE.sol"; + +contract TFHETestSuite2 { + function add_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint32_euint8(uint32 a, uint8 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint32_euint8(uint32 a, uint8 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint32_euint8(uint32 a, uint8 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint32_euint8(uint32 a, uint8 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint32_euint8(uint32 a, uint8 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint32_euint8(uint32 a, uint8 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint32_euint8(uint32 a, uint8 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint8 bProc = TFHE.asEuint8(b); + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint32_euint16(uint32 a, uint16 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint32_euint16(uint32 a, uint16 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint32_euint16(uint32 a, uint16 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint32_euint16(uint32 a, uint16 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint32_euint16(uint32 a, uint16 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint32_euint16(uint32 a, uint16 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint32_euint16(uint32 a, uint16 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint16 bProc = TFHE.asEuint16(b); + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function and_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.and(aProc, bProc); + return TFHE.decrypt(result); + } + + function or_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.or(aProc, bProc); + return TFHE.decrypt(result); + } + + function xor_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.xor(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint32_euint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint32_euint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint32_euint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint32_euint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint32_euint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint32_euint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function add_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.add(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function sub_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.sub(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function mul_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.mul(aProc, bProc); + return TFHE.decrypt(result); + } + + function div_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.div(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shl_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shl(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function shr_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.shr(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_euint32_uint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function eq_uint32_euint32(uint32 a, uint32 b) public view returns (bool) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.eq(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_euint32_uint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ne_uint32_euint32(uint32 a, uint32 b) public view returns (bool) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ne(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_euint32_uint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function ge_uint32_euint32(uint32 a, uint32 b) public view returns (bool) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.ge(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_euint32_uint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function gt_uint32_euint32(uint32 a, uint32 b) public view returns (bool) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.gt(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_euint32_uint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function le_uint32_euint32(uint32 a, uint32 b) public view returns (bool) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.le(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_euint32_uint32(uint32 a, uint32 b) public view returns (bool) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function lt_uint32_euint32(uint32 a, uint32 b) public view returns (bool) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + ebool result = TFHE.lt(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function min_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.min(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_euint32_uint32(uint32 a, uint32 b) public view returns (uint32) { + euint32 aProc = TFHE.asEuint32(a); + uint32 bProc = b; + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } + + function max_uint32_euint32(uint32 a, uint32 b) public view returns (uint32) { + uint32 aProc = a; + euint32 bProc = TFHE.asEuint32(b); + euint32 result = TFHE.max(aProc, bProc); + return TFHE.decrypt(result); + } +} diff --git a/lib/TFHE.sol b/lib/TFHE.sol index e8c14d48..eb3dd0b4 100644 --- a/lib/TFHE.sol +++ b/lib/TFHE.sol @@ -579,10 +579,11 @@ library TFHE { // Evaluate sub(a, b) and return the result. function sub(uint8 a, euint8 b) internal view returns (euint8) { + euint8 aEnc = asEuint8(a); if (!isInitialized(b)) { b = asEuint8(0); } - return euint8.wrap(Impl.sub(euint8.unwrap(b), uint256(a), true)); + return euint8.wrap(Impl.sub(euint8.unwrap(aEnc), euint8.unwrap(b), false)); } // Evaluate mul(a, b) and return the result. @@ -609,14 +610,6 @@ library TFHE { return euint8.wrap(Impl.div(euint8.unwrap(a), uint256(b))); } - // Evaluate div(a, b) and return the result. - function div(uint8 a, euint8 b) internal view returns (euint8) { - if (!isInitialized(b)) { - b = asEuint8(0); - } - return euint8.wrap(Impl.div(euint8.unwrap(b), uint256(a))); - } - // Evaluate shl(a, b) and return the result. function shl(euint8 a, uint8 b) internal view returns (euint8) { if (!isInitialized(a)) { @@ -627,10 +620,11 @@ library TFHE { // Evaluate shl(a, b) and return the result. function shl(uint8 a, euint8 b) internal view returns (euint8) { + euint8 aEnc = asEuint8(a); if (!isInitialized(b)) { b = asEuint8(0); } - return euint8.wrap(Impl.shl(euint8.unwrap(b), uint256(a), true)); + return euint8.wrap(Impl.shl(euint8.unwrap(aEnc), euint8.unwrap(b), false)); } // Evaluate shr(a, b) and return the result. @@ -643,10 +637,11 @@ library TFHE { // Evaluate shr(a, b) and return the result. function shr(uint8 a, euint8 b) internal view returns (euint8) { + euint8 aEnc = asEuint8(a); if (!isInitialized(b)) { b = asEuint8(0); } - return euint8.wrap(Impl.shr(euint8.unwrap(b), uint256(a), true)); + return euint8.wrap(Impl.shr(euint8.unwrap(aEnc), euint8.unwrap(b), false)); } // Evaluate eq(a, b) and return the result. @@ -1331,10 +1326,11 @@ library TFHE { // Evaluate sub(a, b) and return the result. function sub(uint16 a, euint16 b) internal view returns (euint16) { + euint16 aEnc = asEuint16(a); if (!isInitialized(b)) { b = asEuint16(0); } - return euint16.wrap(Impl.sub(euint16.unwrap(b), uint256(a), true)); + return euint16.wrap(Impl.sub(euint16.unwrap(aEnc), euint16.unwrap(b), false)); } // Evaluate mul(a, b) and return the result. @@ -1361,14 +1357,6 @@ library TFHE { return euint16.wrap(Impl.div(euint16.unwrap(a), uint256(b))); } - // Evaluate div(a, b) and return the result. - function div(uint16 a, euint16 b) internal view returns (euint16) { - if (!isInitialized(b)) { - b = asEuint16(0); - } - return euint16.wrap(Impl.div(euint16.unwrap(b), uint256(a))); - } - // Evaluate shl(a, b) and return the result. function shl(euint16 a, uint16 b) internal view returns (euint16) { if (!isInitialized(a)) { @@ -1379,10 +1367,11 @@ library TFHE { // Evaluate shl(a, b) and return the result. function shl(uint16 a, euint16 b) internal view returns (euint16) { + euint16 aEnc = asEuint16(a); if (!isInitialized(b)) { b = asEuint16(0); } - return euint16.wrap(Impl.shl(euint16.unwrap(b), uint256(a), true)); + return euint16.wrap(Impl.shl(euint16.unwrap(aEnc), euint16.unwrap(b), false)); } // Evaluate shr(a, b) and return the result. @@ -1395,10 +1384,11 @@ library TFHE { // Evaluate shr(a, b) and return the result. function shr(uint16 a, euint16 b) internal view returns (euint16) { + euint16 aEnc = asEuint16(a); if (!isInitialized(b)) { b = asEuint16(0); } - return euint16.wrap(Impl.shr(euint16.unwrap(b), uint256(a), true)); + return euint16.wrap(Impl.shr(euint16.unwrap(aEnc), euint16.unwrap(b), false)); } // Evaluate eq(a, b) and return the result. @@ -2083,10 +2073,11 @@ library TFHE { // Evaluate sub(a, b) and return the result. function sub(uint32 a, euint32 b) internal view returns (euint32) { + euint32 aEnc = asEuint32(a); if (!isInitialized(b)) { b = asEuint32(0); } - return euint32.wrap(Impl.sub(euint32.unwrap(b), uint256(a), true)); + return euint32.wrap(Impl.sub(euint32.unwrap(aEnc), euint32.unwrap(b), false)); } // Evaluate mul(a, b) and return the result. @@ -2113,14 +2104,6 @@ library TFHE { return euint32.wrap(Impl.div(euint32.unwrap(a), uint256(b))); } - // Evaluate div(a, b) and return the result. - function div(uint32 a, euint32 b) internal view returns (euint32) { - if (!isInitialized(b)) { - b = asEuint32(0); - } - return euint32.wrap(Impl.div(euint32.unwrap(b), uint256(a))); - } - // Evaluate shl(a, b) and return the result. function shl(euint32 a, uint32 b) internal view returns (euint32) { if (!isInitialized(a)) { @@ -2131,10 +2114,11 @@ library TFHE { // Evaluate shl(a, b) and return the result. function shl(uint32 a, euint32 b) internal view returns (euint32) { + euint32 aEnc = asEuint32(a); if (!isInitialized(b)) { b = asEuint32(0); } - return euint32.wrap(Impl.shl(euint32.unwrap(b), uint256(a), true)); + return euint32.wrap(Impl.shl(euint32.unwrap(aEnc), euint32.unwrap(b), false)); } // Evaluate shr(a, b) and return the result. @@ -2147,10 +2131,11 @@ library TFHE { // Evaluate shr(a, b) and return the result. function shr(uint32 a, euint32 b) internal view returns (euint32) { + euint32 aEnc = asEuint32(a); if (!isInitialized(b)) { b = asEuint32(0); } - return euint32.wrap(Impl.shr(euint32.unwrap(b), uint256(a), true)); + return euint32.wrap(Impl.shr(euint32.unwrap(aEnc), euint32.unwrap(b), false)); } // Evaluate eq(a, b) and return the result. diff --git a/package.json b/package.json index 4d57de90..a5facfef 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain", "codegen": "cd ./lib && npx ts-node codegen/main.ts && npm run prettier && cd ..", "task:getEthereumAddress": "hardhat task:getEthereumAddress", - "fhevm:start": "docker run -i -p 8545:8545 --rm --name fhevm ghcr.io/zama-ai/evmos-dev-node:v0.1.7", + "fhevm:start": "docker run -i -p 8545:8545 --rm --name fhevm ghcr.io/zama-ai/evmos-dev-node:v0.1.8", "fhevm:stop": "docker rm -f fhevm", "fhevm:restart": "fhevm:stop && fhevm:start", "fhevm:faucet": "docker exec -i fhevm faucet $(npx hardhat task:getEthereumAddress)" diff --git a/test/tfheOperations/tfheOperations.fixture.ts b/test/tfheOperations/tfheOperations.fixture.ts deleted file mode 100644 index fcd4ec81..00000000 --- a/test/tfheOperations/tfheOperations.fixture.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ethers } from 'hardhat'; - -import type { TFHETestSuite } from '../../types'; - -export async function deployTfheTestFixture(): Promise { - const signers = await ethers.getSigners(); - const admin = signers[0]; - - const contractFactory = await ethers.getContractFactory('TFHETestSuite'); - const contract = await contractFactory.connect(admin).deploy(); - await contract.waitForDeployment(); - - return contract; -} diff --git a/test/tfheOperations/tfheOperations.ts b/test/tfheOperations/tfheOperations.ts index 0d0ee00b..67aba1eb 100644 --- a/test/tfheOperations/tfheOperations.ts +++ b/test/tfheOperations/tfheOperations.ts @@ -1,28 +1,2452 @@ 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 { createInstances } from '../instance'; import { getSigners } from '../signers'; -import { deployTfheTestFixture } from './tfheOperations.fixture'; + +async function deployTfheTestFixture1(): Promise { + const signers = await ethers.getSigners(); + const admin = signers[0]; + + const contractFactory = await ethers.getContractFactory('TFHETestSuite1'); + const contract = await contractFactory.connect(admin).deploy(); + await contract.waitForDeployment(); + + return contract; +} + +async function deployTfheTestFixture2(): Promise { + const signers = await ethers.getSigners(); + const admin = signers[0]; + + const contractFactory = await ethers.getContractFactory('TFHETestSuite2'); + const contract = await contractFactory.connect(admin).deploy(); + await contract.waitForDeployment(); + + return contract; +} describe('TFHE operations', function () { before(async function () { this.signers = await getSigners(); - const contract = await deployTfheTestFixture(); - this.contractAddress = await contract.getAddress(); - this.contract = contract; - const instances = await createInstances(this.contractAddress, ethers, this.signers); - this.instances = instances; + const contract1 = await deployTfheTestFixture1(); + this.contract1Address = await contract1.getAddress(); + this.contract1 = contract1; + const instances1 = await createInstances(this.contract1Address, ethers, this.signers); + this.instances1 = instances1; + + const contract2 = await deployTfheTestFixture2(); + this.contract2Address = await contract2.getAddress(); + this.contract2 = contract2; + const instances2 = await createInstances(this.contract2Address, ethers, this.signers); + this.instances2 = instances2; + }); + + it('test operator "add" overload (euint8, euint8) => euint8 test 1 (3, 4)', async function () { + const res = await this.contract1.add_euint8_euint8(3, 4); + expect(res).to.equal(7); + }); + + it('test operator "sub" overload (euint8, euint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.sub_euint8_euint8(4, 3); + expect(res).to.equal(1); + }); + + it('test operator "mul" overload (euint8, euint8) => euint8 test 1 (3, 4)', async function () { + const res = await this.contract1.mul_euint8_euint8(3, 4); + expect(res).to.equal(12); + }); + + it('test operator "and" overload (euint8, euint8) => euint8 test 1 (255, 15)', async function () { + const res = await this.contract1.and_euint8_euint8(255, 15); + expect(res).to.equal(15); + }); + + it('test operator "or" overload (euint8, euint8) => euint8 test 1 (112, 15)', async function () { + const res = await this.contract1.or_euint8_euint8(112, 15); + expect(res).to.equal(127); + }); + + it('test operator "xor" overload (euint8, euint8) => euint8 test 1 (119, 119)', async function () { + const res = await this.contract1.xor_euint8_euint8(119, 119); + expect(res).to.equal(0); + }); + + it('test operator "xor" overload (euint8, euint8) => euint8 test 2 (12, 34)', async function () { + const res = await this.contract1.xor_euint8_euint8(12, 34); + expect(res).to.equal(46); + }); + + it('test operator "shl" overload (euint8, euint8) => euint8 test 1 (2, 1)', async function () { + const res = await this.contract1.shl_euint8_euint8(2, 1); + expect(res).to.equal(4); + }); + + it('test operator "shl" overload (euint8, euint8) => euint8 test 2 (2, 4)', async function () { + const res = await this.contract1.shl_euint8_euint8(2, 4); + expect(res).to.equal(32); + }); + + it('test operator "shr" overload (euint8, euint8) => euint8 test 1 (2, 1)', async function () { + const res = await this.contract1.shr_euint8_euint8(2, 1); + expect(res).to.equal(1); + }); + + it('test operator "shr" overload (euint8, euint8) => euint8 test 2 (32, 4)', async function () { + const res = await this.contract1.shr_euint8_euint8(32, 4); + expect(res).to.equal(2); + }); + + it('test operator "eq" overload (euint8, euint8) => ebool test 1 (12, 49)', async function () { + const res = await this.contract1.eq_euint8_euint8(12, 49); + expect(res).to.equal(false); + }); + + it('test operator "eq" overload (euint8, euint8) => ebool test 2 (7, 7)', async function () { + const res = await this.contract1.eq_euint8_euint8(7, 7); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (euint8, euint8) => ebool test 1 (1, 2)', async function () { + const res = await this.contract1.ne_euint8_euint8(1, 2); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (euint8, euint8) => ebool test 2 (2, 2)', async function () { + const res = await this.contract1.ne_euint8_euint8(2, 2); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint8, euint8) => ebool test 1 (10, 10)', async function () { + const res = await this.contract1.ge_euint8_euint8(10, 10); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, euint8) => ebool test 2 (10, 9)', async function () { + const res = await this.contract1.ge_euint8_euint8(10, 9); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, euint8) => ebool test 3 (10, 11)', async function () { + const res = await this.contract1.ge_euint8_euint8(10, 11); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, euint8) => ebool test 1 (10, 10)', async function () { + const res = await this.contract1.gt_euint8_euint8(10, 10); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, euint8) => ebool test 2 (10, 9)', async function () { + const res = await this.contract1.gt_euint8_euint8(10, 9); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint8, euint8) => ebool test 3 (10, 11)', async function () { + const res = await this.contract1.gt_euint8_euint8(10, 11); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint8, euint8) => ebool test 1 (10, 10)', async function () { + const res = await this.contract1.le_euint8_euint8(10, 10); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint8) => ebool test 2 (10, 9)', async function () { + const res = await this.contract1.le_euint8_euint8(10, 9); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint8, euint8) => ebool test 3 (10, 11)', async function () { + const res = await this.contract1.le_euint8_euint8(10, 11); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint8, euint8) => ebool test 1 (10, 10)', async function () { + const res = await this.contract1.lt_euint8_euint8(10, 10); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, euint8) => ebool test 2 (10, 9)', async function () { + const res = await this.contract1.lt_euint8_euint8(10, 9); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, euint8) => ebool test 3 (10, 11)', async function () { + const res = await this.contract1.lt_euint8_euint8(10, 11); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint8, euint8) => euint8 test 1 (10, 10)', async function () { + const res = await this.contract1.min_euint8_euint8(10, 10); + expect(res).to.equal(10); + }); + + it('test operator "min" overload (euint8, euint8) => euint8 test 2 (12, 10)', async function () { + const res = await this.contract1.min_euint8_euint8(12, 10); + expect(res).to.equal(10); + }); + + it('test operator "min" overload (euint8, euint8) => euint8 test 3 (9, 12)', async function () { + const res = await this.contract1.min_euint8_euint8(9, 12); + expect(res).to.equal(9); + }); + + it('test operator "max" overload (euint8, euint8) => euint8 test 1 (10, 10)', async function () { + const res = await this.contract1.max_euint8_euint8(10, 10); + expect(res).to.equal(10); + }); + + it('test operator "max" overload (euint8, euint8) => euint8 test 2 (12, 10)', async function () { + const res = await this.contract1.max_euint8_euint8(12, 10); + expect(res).to.equal(12); + }); + + it('test operator "max" overload (euint8, euint8) => euint8 test 3 (9, 12)', async function () { + const res = await this.contract1.max_euint8_euint8(9, 12); + expect(res).to.equal(12); + }); + + it('test operator "add" overload (euint8, euint16) => euint16 test 1 (3, 65280)', async function () { + const res = await this.contract1.add_euint8_euint16(3, 65280); + expect(res).to.equal(65283); + }); + + it('test operator "sub" overload (euint8, euint16) => euint16 test 1 (3, 4096)', async function () { + const res = await this.contract1.sub_euint8_euint16(3, 4096); + expect(res).to.equal(61443); + }); + + it('test operator "mul" overload (euint8, euint16) => euint16 test 1 (3, 4096)', async function () { + const res = await this.contract1.mul_euint8_euint16(3, 4096); + expect(res).to.equal(12288); + }); + + it('test operator "and" overload (euint8, euint16) => euint16 test 1 (3, 4096)', async function () { + const res = await this.contract1.and_euint8_euint16(3, 4096); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint8, euint16) => euint16 test 2 (3, 4097)', async function () { + const res = await this.contract1.and_euint8_euint16(3, 4097); + expect(res).to.equal(1); + }); + + it('test operator "or" overload (euint8, euint16) => euint16 test 1 (3, 4096)', async function () { + const res = await this.contract1.or_euint8_euint16(3, 4096); + expect(res).to.equal(4099); + }); + + it('test operator "or" overload (euint8, euint16) => euint16 test 2 (3, 4097)', async function () { + const res = await this.contract1.or_euint8_euint16(3, 4097); + expect(res).to.equal(4099); + }); + + it('test operator "xor" overload (euint8, euint16) => euint16 test 1 (255, 65535)', async function () { + const res = await this.contract1.xor_euint8_euint16(255, 65535); + expect(res).to.equal(65280); + }); + + it('test operator "xor" overload (euint8, euint16) => euint16 test 2 (255, 65280)', async function () { + const res = await this.contract1.xor_euint8_euint16(255, 65280); + expect(res).to.equal(65535); + }); + + it('test operator "shl" overload (euint8, euint16) => euint16 test 1 (255, 256)', async function () { + const res = await this.contract1.shl_euint8_euint16(255, 256); + expect(res).to.equal(255); + }); + + it('test operator "shl" overload (euint8, euint16) => euint16 test 2 (2, 1)', async function () { + const res = await this.contract1.shl_euint8_euint16(2, 1); + expect(res).to.equal(4); + }); + + it('test operator "shr" overload (euint8, euint16) => euint16 test 1 (255, 256)', async function () { + const res = await this.contract1.shr_euint8_euint16(255, 256); + expect(res).to.equal(255); + }); + + it('test operator "shr" overload (euint8, euint16) => euint16 test 2 (255, 1)', async function () { + const res = await this.contract1.shr_euint8_euint16(255, 1); + expect(res).to.equal(127); + }); + + it('test operator "eq" overload (euint8, euint16) => ebool test 1 (255, 255)', async function () { + const res = await this.contract1.eq_euint8_euint16(255, 255); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint8, euint16) => ebool test 2 (255, 511)', async function () { + const res = await this.contract1.eq_euint8_euint16(255, 511); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint8, euint16) => ebool test 1 (255, 255)', async function () { + const res = await this.contract1.ne_euint8_euint16(255, 255); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint8, euint16) => ebool test 2 (255, 511)', async function () { + const res = await this.contract1.ne_euint8_euint16(255, 511); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, euint16) => ebool test 1 (255, 255)', async function () { + const res = await this.contract1.ge_euint8_euint16(255, 255); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, euint16) => ebool test 2 (255, 511)', async function () { + const res = await this.contract1.ge_euint8_euint16(255, 511); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint8, euint16) => ebool test 3 (255, 127)', async function () { + const res = await this.contract1.ge_euint8_euint16(255, 127); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint8, euint16) => ebool test 1 (255, 255)', async function () { + const res = await this.contract1.gt_euint8_euint16(255, 255); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, euint16) => ebool test 2 (255, 511)', async function () { + const res = await this.contract1.gt_euint8_euint16(255, 511); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, euint16) => ebool test 3 (255, 127)', async function () { + const res = await this.contract1.gt_euint8_euint16(255, 127); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint16) => ebool test 1 (255, 255)', async function () { + const res = await this.contract1.le_euint8_euint16(255, 255); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint16) => ebool test 2 (255, 511)', async function () { + const res = await this.contract1.le_euint8_euint16(255, 511); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint16) => ebool test 3 (255, 127)', async function () { + const res = await this.contract1.le_euint8_euint16(255, 127); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, euint16) => ebool test 1 (255, 255)', async function () { + const res = await this.contract1.lt_euint8_euint16(255, 255); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, euint16) => ebool test 2 (255, 511)', async function () { + const res = await this.contract1.lt_euint8_euint16(255, 511); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint8, euint16) => ebool test 3 (255, 127)', async function () { + const res = await this.contract1.lt_euint8_euint16(255, 127); + expect(res).to.equal(false); + }); + + it('test operator "min" overload (euint8, euint16) => euint16 test 1 (255, 255)', async function () { + const res = await this.contract1.min_euint8_euint16(255, 255); + expect(res).to.equal(255); + }); + + it('test operator "min" overload (euint8, euint16) => euint16 test 2 (255, 511)', async function () { + const res = await this.contract1.min_euint8_euint16(255, 511); + expect(res).to.equal(255); + }); + + it('test operator "min" overload (euint8, euint16) => euint16 test 3 (255, 127)', async function () { + const res = await this.contract1.min_euint8_euint16(255, 127); + expect(res).to.equal(127); + }); + + it('test operator "max" overload (euint8, euint16) => euint16 test 1 (255, 255)', async function () { + const res = await this.contract1.max_euint8_euint16(255, 255); + expect(res).to.equal(255); + }); + + it('test operator "max" overload (euint8, euint16) => euint16 test 2 (255, 511)', async function () { + const res = await this.contract1.max_euint8_euint16(255, 511); + expect(res).to.equal(511); + }); + + it('test operator "max" overload (euint8, euint16) => euint16 test 3 (255, 127)', async function () { + const res = await this.contract1.max_euint8_euint16(255, 127); + expect(res).to.equal(255); + }); + + it('test operator "add" overload (euint8, euint32) => euint32 test 1 (255, 4294902015)', async function () { + const res = await this.contract1.add_euint8_euint32(255, 4294902015); + expect(res).to.equal(4294902270); + }); + + it('test operator "sub" overload (euint8, euint32) => euint32 test 1 (255, 4294902015)', async function () { + const res = await this.contract1.sub_euint8_euint32(255, 4294902015); + expect(res).to.equal(65536); + }); + + it('test operator "sub" overload (euint8, euint32) => euint32 test 2 (255, 16)', async function () { + const res = await this.contract1.sub_euint8_euint32(255, 16); + expect(res).to.equal(239); + }); + + it('test operator "mul" overload (euint8, euint32) => euint32 test 1 (16, 65536)', async function () { + const res = await this.contract1.mul_euint8_euint32(16, 65536); + expect(res).to.equal(1048576); + }); + + it('test operator "and" overload (euint8, euint32) => euint32 test 1 (16, 65536)', async function () { + const res = await this.contract1.and_euint8_euint32(16, 65536); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint8, euint32) => euint32 test 2 (17, 65552)', async function () { + const res = await this.contract1.and_euint8_euint32(17, 65552); + expect(res).to.equal(16); + }); + + it('test operator "or" overload (euint8, euint32) => euint32 test 1 (16, 65536)', async function () { + const res = await this.contract1.or_euint8_euint32(16, 65536); + expect(res).to.equal(65552); + }); + + it('test operator "or" overload (euint8, euint32) => euint32 test 2 (17, 65552)', async function () { + const res = await this.contract1.or_euint8_euint32(17, 65552); + expect(res).to.equal(65553); + }); + + it('test operator "xor" overload (euint8, euint32) => euint32 test 1 (16, 65536)', async function () { + const res = await this.contract1.xor_euint8_euint32(16, 65536); + expect(res).to.equal(65552); + }); + + it('test operator "xor" overload (euint8, euint32) => euint32 test 2 (17, 65552)', async function () { + const res = await this.contract1.xor_euint8_euint32(17, 65552); + expect(res).to.equal(65537); + }); + + it('test operator "shl" overload (euint8, euint32) => euint32 test 1 (16, 65536)', async function () { + const res = await this.contract1.shl_euint8_euint32(16, 65536); + expect(res).to.equal(16); + }); + + it('test operator "shl" overload (euint8, euint32) => euint32 test 2 (31, 65536)', async function () { + const res = await this.contract1.shl_euint8_euint32(31, 65536); + expect(res).to.equal(31); + }); + + it('test operator "shr" overload (euint8, euint32) => euint32 test 1 (16, 65536)', async function () { + const res = await this.contract1.shr_euint8_euint32(16, 65536); + expect(res).to.equal(16); + }); + + it('test operator "shr" overload (euint8, euint32) => euint32 test 2 (31, 65536)', async function () { + const res = await this.contract1.shr_euint8_euint32(31, 65536); + expect(res).to.equal(31); + }); + + it('test operator "shr" overload (euint8, euint32) => euint32 test 3 (16, 1)', async function () { + const res = await this.contract1.shr_euint8_euint32(16, 1); + expect(res).to.equal(8); + }); + + it('test operator "shr" overload (euint8, euint32) => euint32 test 4 (31, 1)', async function () { + const res = await this.contract1.shr_euint8_euint32(31, 1); + expect(res).to.equal(15); + }); + + it('test operator "eq" overload (euint8, euint32) => ebool test 1 (1, 1)', async function () { + const res = await this.contract1.eq_euint8_euint32(1, 1); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint8, euint32) => ebool test 2 (1, 65537)', async function () { + const res = await this.contract1.eq_euint8_euint32(1, 65537); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint8, euint32) => ebool test 1 (1, 1)', async function () { + const res = await this.contract1.ne_euint8_euint32(1, 1); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint8, euint32) => ebool test 2 (1, 65537)', async function () { + const res = await this.contract1.ne_euint8_euint32(1, 65537); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, euint32) => ebool test 1 (1, 1)', async function () { + const res = await this.contract1.ge_euint8_euint32(1, 1); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, euint32) => ebool test 2 (1, 65537)', async function () { + const res = await this.contract1.ge_euint8_euint32(1, 65537); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint8, euint32) => ebool test 3 (16, 1)', async function () { + const res = await this.contract1.ge_euint8_euint32(16, 1); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint8, euint32) => ebool test 1 (1, 1)', async function () { + const res = await this.contract1.gt_euint8_euint32(1, 1); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, euint32) => ebool test 2 (1, 65537)', async function () { + const res = await this.contract1.gt_euint8_euint32(1, 65537); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, euint32) => ebool test 3 (16, 1)', async function () { + const res = await this.contract1.gt_euint8_euint32(16, 1); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint32) => ebool test 1 (1, 1)', async function () { + const res = await this.contract1.le_euint8_euint32(1, 1); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint32) => ebool test 2 (1, 65537)', async function () { + const res = await this.contract1.le_euint8_euint32(1, 65537); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, euint32) => ebool test 3 (16, 1)', async function () { + const res = await this.contract1.le_euint8_euint32(16, 1); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, euint32) => ebool test 1 (1, 1)', async function () { + const res = await this.contract1.lt_euint8_euint32(1, 1); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, euint32) => ebool test 2 (1, 65537)', async function () { + const res = await this.contract1.lt_euint8_euint32(1, 65537); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint8, euint32) => ebool test 3 (16, 1)', async function () { + const res = await this.contract1.lt_euint8_euint32(16, 1); + expect(res).to.equal(false); + }); + + it('test operator "min" overload (euint8, euint32) => euint32 test 1 (1, 1)', async function () { + const res = await this.contract1.min_euint8_euint32(1, 1); + expect(res).to.equal(1); + }); + + it('test operator "min" overload (euint8, euint32) => euint32 test 2 (1, 65537)', async function () { + const res = await this.contract1.min_euint8_euint32(1, 65537); + expect(res).to.equal(1); + }); + + it('test operator "min" overload (euint8, euint32) => euint32 test 3 (16, 4)', async function () { + const res = await this.contract1.min_euint8_euint32(16, 4); + expect(res).to.equal(4); + }); + + it('test operator "max" overload (euint8, euint32) => euint32 test 1 (1, 1)', async function () { + const res = await this.contract1.max_euint8_euint32(1, 1); + expect(res).to.equal(1); + }); + + it('test operator "max" overload (euint8, euint32) => euint32 test 2 (1, 65537)', async function () { + const res = await this.contract1.max_euint8_euint32(1, 65537); + expect(res).to.equal(65537); + }); + + it('test operator "max" overload (euint8, euint32) => euint32 test 3 (16, 4)', async function () { + const res = await this.contract1.max_euint8_euint32(16, 4); + expect(res).to.equal(16); + }); + + it('test operator "add" overload (euint8, uint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.add_euint8_uint8(4, 3); + expect(res).to.equal(7); }); - it('should work for addition', async function () { - const res = await this.contract.addUint8(3, 4); + it('test operator "add" overload (uint8, euint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.add_uint8_euint8(4, 3); expect(res).to.equal(7); }); - it('should work for multiplication', async function () { - const res = await this.contract.mulUint8(3, 4); + it('test operator "sub" overload (euint8, uint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.sub_euint8_uint8(4, 3); + expect(res).to.equal(1); + }); + + it('test operator "sub" overload (euint8, uint8) => euint8 test 2 (3, 4)', async function () { + const res = await this.contract1.sub_euint8_uint8(3, 4); + expect(res).to.equal(255); + }); + + it('test operator "sub" overload (uint8, euint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.sub_uint8_euint8(4, 3); + expect(res).to.equal(1); + }); + + it('test operator "sub" overload (uint8, euint8) => euint8 test 2 (3, 4)', async function () { + const res = await this.contract1.sub_uint8_euint8(3, 4); + expect(res).to.equal(255); + }); + + it('test operator "mul" overload (euint8, uint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.mul_euint8_uint8(4, 3); + expect(res).to.equal(12); + }); + + it('test operator "mul" overload (euint8, uint8) => euint8 test 2 (3, 4)', async function () { + const res = await this.contract1.mul_euint8_uint8(3, 4); + expect(res).to.equal(12); + }); + + it('test operator "mul" overload (euint8, uint8) => euint8 test 3 (8, 2)', async function () { + const res = await this.contract1.mul_euint8_uint8(8, 2); + expect(res).to.equal(16); + }); + + it('test operator "mul" overload (uint8, euint8) => euint8 test 1 (4, 3)', async function () { + const res = await this.contract1.mul_uint8_euint8(4, 3); + expect(res).to.equal(12); + }); + + it('test operator "mul" overload (uint8, euint8) => euint8 test 2 (3, 4)', async function () { + const res = await this.contract1.mul_uint8_euint8(3, 4); expect(res).to.equal(12); }); + + it('test operator "mul" overload (uint8, euint8) => euint8 test 3 (8, 2)', async function () { + const res = await this.contract1.mul_uint8_euint8(8, 2); + expect(res).to.equal(16); + }); + + it('test operator "div" overload (euint8, uint8) => euint8 test 1 (16, 2)', async function () { + const res = await this.contract1.div_euint8_uint8(16, 2); + expect(res).to.equal(8); + }); + + it('test operator "shl" overload (euint8, uint8) => euint8 test 1 (16, 1)', async function () { + const res = await this.contract1.shl_euint8_uint8(16, 1); + expect(res).to.equal(32); + }); + + it('test operator "shl" overload (euint8, uint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.shl_euint8_uint8(16, 2); + expect(res).to.equal(64); + }); + + it('test operator "shl" overload (uint8, euint8) => euint8 test 1 (16, 1)', async function () { + const res = await this.contract1.shl_uint8_euint8(16, 1); + expect(res).to.equal(32); + }); + + it('test operator "shl" overload (uint8, euint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.shl_uint8_euint8(16, 2); + expect(res).to.equal(64); + }); + + it('test operator "shr" overload (euint8, uint8) => euint8 test 1 (16, 1)', async function () { + const res = await this.contract1.shr_euint8_uint8(16, 1); + expect(res).to.equal(8); + }); + + it('test operator "shr" overload (euint8, uint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.shr_euint8_uint8(16, 2); + expect(res).to.equal(4); + }); + + it('test operator "shr" overload (uint8, euint8) => euint8 test 1 (16, 1)', async function () { + const res = await this.contract1.shr_uint8_euint8(16, 1); + expect(res).to.equal(8); + }); + + it('test operator "shr" overload (uint8, euint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.shr_uint8_euint8(16, 2); + expect(res).to.equal(4); + }); + + it('test operator "eq" overload (euint8, uint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.eq_euint8_uint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint8, uint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.eq_euint8_uint8(16, 2); + expect(res).to.equal(false); + }); + + it('test operator "eq" overload (uint8, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.eq_uint8_euint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (uint8, euint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.eq_uint8_euint8(16, 2); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint8, uint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.ne_euint8_uint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint8, uint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.ne_euint8_uint8(16, 2); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (uint8, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.ne_uint8_euint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (uint8, euint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.ne_uint8_euint8(16, 2); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, uint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.ge_euint8_uint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, uint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.ge_euint8_uint8(16, 2); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint8, uint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.ge_euint8_uint8(16, 17); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (uint8, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.ge_uint8_euint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (uint8, euint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.ge_uint8_euint8(16, 2); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (uint8, euint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.ge_uint8_euint8(16, 17); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, uint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.gt_euint8_uint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint8, uint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.gt_euint8_uint8(16, 2); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint8, uint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.gt_euint8_uint8(16, 17); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (uint8, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.gt_uint8_euint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (uint8, euint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.gt_uint8_euint8(16, 2); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (uint8, euint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.gt_uint8_euint8(16, 17); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint8, uint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.le_euint8_uint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint8, uint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.le_euint8_uint8(16, 2); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint8, uint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.le_euint8_uint8(16, 17); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (uint8, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.le_uint8_euint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (uint8, euint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.le_uint8_euint8(16, 2); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (uint8, euint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.le_uint8_euint8(16, 17); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint8, uint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.lt_euint8_uint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, uint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.lt_euint8_uint8(16, 2); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint8, uint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.lt_euint8_uint8(16, 17); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (uint8, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.lt_uint8_euint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (uint8, euint8) => ebool test 2 (16, 2)', async function () { + const res = await this.contract1.lt_uint8_euint8(16, 2); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (uint8, euint8) => ebool test 3 (16, 17)', async function () { + const res = await this.contract1.lt_uint8_euint8(16, 17); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint8, uint8) => euint8 test 1 (16, 16)', async function () { + const res = await this.contract1.min_euint8_uint8(16, 16); + expect(res).to.equal(16); + }); + + it('test operator "min" overload (euint8, uint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.min_euint8_uint8(16, 2); + expect(res).to.equal(2); + }); + + it('test operator "min" overload (euint8, uint8) => euint8 test 3 (16, 17)', async function () { + const res = await this.contract1.min_euint8_uint8(16, 17); + expect(res).to.equal(16); + }); + + it('test operator "min" overload (uint8, euint8) => euint8 test 1 (16, 16)', async function () { + const res = await this.contract1.min_uint8_euint8(16, 16); + expect(res).to.equal(16); + }); + + it('test operator "min" overload (uint8, euint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.min_uint8_euint8(16, 2); + expect(res).to.equal(2); + }); + + it('test operator "min" overload (uint8, euint8) => euint8 test 3 (16, 17)', async function () { + const res = await this.contract1.min_uint8_euint8(16, 17); + expect(res).to.equal(16); + }); + + it('test operator "max" overload (euint8, uint8) => euint8 test 1 (16, 16)', async function () { + const res = await this.contract1.max_euint8_uint8(16, 16); + expect(res).to.equal(16); + }); + + it('test operator "max" overload (euint8, uint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.max_euint8_uint8(16, 2); + expect(res).to.equal(16); + }); + + it('test operator "max" overload (euint8, uint8) => euint8 test 3 (16, 17)', async function () { + const res = await this.contract1.max_euint8_uint8(16, 17); + expect(res).to.equal(17); + }); + + it('test operator "max" overload (uint8, euint8) => euint8 test 1 (16, 16)', async function () { + const res = await this.contract1.max_uint8_euint8(16, 16); + expect(res).to.equal(16); + }); + + it('test operator "max" overload (uint8, euint8) => euint8 test 2 (16, 2)', async function () { + const res = await this.contract1.max_uint8_euint8(16, 2); + expect(res).to.equal(16); + }); + + it('test operator "max" overload (uint8, euint8) => euint8 test 3 (16, 17)', async function () { + const res = await this.contract1.max_uint8_euint8(16, 17); + expect(res).to.equal(17); + }); + + it('test operator "add" overload (euint16, euint8) => euint16 test 1 (4096, 16)', async function () { + const res = await this.contract1.add_euint16_euint8(4096, 16); + expect(res).to.equal(4112); + }); + + it('test operator "add" overload (euint16, euint8) => euint16 test 2 (4112, 16)', async function () { + const res = await this.contract1.add_euint16_euint8(4112, 16); + expect(res).to.equal(4128); + }); + + it('test operator "sub" overload (euint16, euint8) => euint16 test 1 (4096, 16)', async function () { + const res = await this.contract1.sub_euint16_euint8(4096, 16); + expect(res).to.equal(4080); + }); + + it('test operator "sub" overload (euint16, euint8) => euint16 test 2 (4112, 16)', async function () { + const res = await this.contract1.sub_euint16_euint8(4112, 16); + expect(res).to.equal(4096); + }); + + it('test operator "mul" overload (euint16, euint8) => euint16 test 1 (4096, 4)', async function () { + const res = await this.contract1.mul_euint16_euint8(4096, 4); + expect(res).to.equal(16384); + }); + + it('test operator "and" overload (euint16, euint8) => euint16 test 1 (4096, 4)', async function () { + const res = await this.contract1.and_euint16_euint8(4096, 4); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint16, euint8) => euint16 test 2 (4336, 240)', async function () { + const res = await this.contract1.and_euint16_euint8(4336, 240); + expect(res).to.equal(240); + }); + + it('test operator "or" overload (euint16, euint8) => euint16 test 1 (4096, 4)', async function () { + const res = await this.contract1.or_euint16_euint8(4096, 4); + expect(res).to.equal(4100); + }); + + it('test operator "or" overload (euint16, euint8) => euint16 test 2 (4336, 240)', async function () { + const res = await this.contract1.or_euint16_euint8(4336, 240); + expect(res).to.equal(4336); + }); + + it('test operator "xor" overload (euint16, euint8) => euint16 test 1 (4096, 4)', async function () { + const res = await this.contract1.xor_euint16_euint8(4096, 4); + expect(res).to.equal(4100); + }); + + it('test operator "xor" overload (euint16, euint8) => euint16 test 2 (4336, 242)', async function () { + const res = await this.contract1.xor_euint16_euint8(4336, 242); + expect(res).to.equal(4098); + }); + + it('test operator "shl" overload (euint16, euint8) => euint16 test 1 (4112, 2)', async function () { + const res = await this.contract1.shl_euint16_euint8(4112, 2); + expect(res).to.equal(16448); + }); + + it('test operator "shr" overload (euint16, euint8) => euint16 test 1 (4112, 2)', async function () { + const res = await this.contract1.shr_euint16_euint8(4112, 2); + expect(res).to.equal(1028); + }); + + it('test operator "eq" overload (euint16, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.eq_euint16_euint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint16, euint8) => ebool test 2 (272, 16)', async function () { + const res = await this.contract1.eq_euint16_euint8(272, 16); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint16, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.ne_euint16_euint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint16, euint8) => ebool test 2 (272, 16)', async function () { + const res = await this.contract1.ne_euint16_euint8(272, 16); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.ge_euint16_euint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, euint8) => ebool test 2 (272, 16)', async function () { + const res = await this.contract1.ge_euint16_euint8(272, 16); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, euint8) => ebool test 3 (15, 16)', async function () { + const res = await this.contract1.ge_euint16_euint8(15, 16); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.gt_euint16_euint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, euint8) => ebool test 2 (272, 16)', async function () { + const res = await this.contract1.gt_euint16_euint8(272, 16); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint16, euint8) => ebool test 3 (15, 16)', async function () { + const res = await this.contract1.gt_euint16_euint8(15, 16); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint16, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.le_euint16_euint8(16, 16); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint16, euint8) => ebool test 2 (272, 16)', async function () { + const res = await this.contract1.le_euint16_euint8(272, 16); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint16, euint8) => ebool test 3 (15, 16)', async function () { + const res = await this.contract1.le_euint16_euint8(15, 16); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint16, euint8) => ebool test 1 (16, 16)', async function () { + const res = await this.contract1.lt_euint16_euint8(16, 16); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, euint8) => ebool test 2 (272, 16)', async function () { + const res = await this.contract1.lt_euint16_euint8(272, 16); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, euint8) => ebool test 3 (15, 16)', async function () { + const res = await this.contract1.lt_euint16_euint8(15, 16); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint16, euint8) => euint16 test 1 (16, 16)', async function () { + const res = await this.contract1.min_euint16_euint8(16, 16); + expect(res).to.equal(16); + }); + + it('test operator "min" overload (euint16, euint8) => euint16 test 2 (272, 16)', async function () { + const res = await this.contract1.min_euint16_euint8(272, 16); + expect(res).to.equal(16); + }); + + it('test operator "min" overload (euint16, euint8) => euint16 test 3 (15, 16)', async function () { + const res = await this.contract1.min_euint16_euint8(15, 16); + expect(res).to.equal(15); + }); + + it('test operator "max" overload (euint16, euint8) => euint16 test 1 (16, 16)', async function () { + const res = await this.contract1.max_euint16_euint8(16, 16); + expect(res).to.equal(16); + }); + + it('test operator "max" overload (euint16, euint8) => euint16 test 2 (272, 16)', async function () { + const res = await this.contract1.max_euint16_euint8(272, 16); + expect(res).to.equal(272); + }); + + it('test operator "max" overload (euint16, euint8) => euint16 test 3 (15, 16)', async function () { + const res = await this.contract1.max_euint16_euint8(15, 16); + expect(res).to.equal(16); + }); + + it('test operator "add" overload (euint16, euint16) => euint16 test 1 (258, 513)', async function () { + const res = await this.contract1.add_euint16_euint16(258, 513); + expect(res).to.equal(771); + }); + + it('test operator "sub" overload (euint16, euint16) => euint16 test 1 (1027, 258)', async function () { + const res = await this.contract1.sub_euint16_euint16(1027, 258); + expect(res).to.equal(769); + }); + + it('test operator "mul" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.mul_euint16_euint16(512, 2); + expect(res).to.equal(1024); + }); + + it('test operator "and" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.and_euint16_euint16(512, 2); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint16, euint16) => euint16 test 2 (528, 18)', async function () { + const res = await this.contract1.and_euint16_euint16(528, 18); + expect(res).to.equal(16); + }); + + it('test operator "or" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.or_euint16_euint16(512, 2); + expect(res).to.equal(514); + }); + + it('test operator "or" overload (euint16, euint16) => euint16 test 2 (528, 18)', async function () { + const res = await this.contract1.or_euint16_euint16(528, 18); + expect(res).to.equal(530); + }); + + it('test operator "xor" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.xor_euint16_euint16(512, 2); + expect(res).to.equal(514); + }); + + it('test operator "xor" overload (euint16, euint16) => euint16 test 2 (528, 18)', async function () { + const res = await this.contract1.xor_euint16_euint16(528, 18); + expect(res).to.equal(514); + }); + + it('test operator "shl" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.shl_euint16_euint16(512, 2); + expect(res).to.equal(2048); + }); + + it('test operator "shr" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.shr_euint16_euint16(512, 2); + expect(res).to.equal(128); + }); + + it('test operator "eq" overload (euint16, euint16) => ebool test 1 (512, 2)', async function () { + const res = await this.contract1.eq_euint16_euint16(512, 2); + expect(res).to.equal(false); + }); + + it('test operator "eq" overload (euint16, euint16) => ebool test 2 (512, 512)', async function () { + const res = await this.contract1.eq_euint16_euint16(512, 512); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (euint16, euint16) => ebool test 1 (512, 2)', async function () { + const res = await this.contract1.ne_euint16_euint16(512, 2); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (euint16, euint16) => ebool test 2 (512, 512)', async function () { + const res = await this.contract1.ne_euint16_euint16(512, 512); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint16, euint16) => ebool test 1 (512, 2)', async function () { + const res = await this.contract1.ge_euint16_euint16(512, 2); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, euint16) => ebool test 2 (512, 512)', async function () { + const res = await this.contract1.ge_euint16_euint16(512, 512); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, euint16) => ebool test 3 (512, 513)', async function () { + const res = await this.contract1.ge_euint16_euint16(512, 513); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, euint16) => ebool test 1 (512, 2)', async function () { + const res = await this.contract1.gt_euint16_euint16(512, 2); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint16, euint16) => ebool test 2 (512, 512)', async function () { + const res = await this.contract1.gt_euint16_euint16(512, 512); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, euint16) => ebool test 3 (512, 513)', async function () { + const res = await this.contract1.gt_euint16_euint16(512, 513); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint16, euint16) => ebool test 1 (512, 2)', async function () { + const res = await this.contract1.le_euint16_euint16(512, 2); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint16, euint16) => ebool test 2 (512, 512)', async function () { + const res = await this.contract1.le_euint16_euint16(512, 512); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint16, euint16) => ebool test 3 (512, 513)', async function () { + const res = await this.contract1.le_euint16_euint16(512, 513); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint16, euint16) => ebool test 1 (512, 2)', async function () { + const res = await this.contract1.lt_euint16_euint16(512, 2); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, euint16) => ebool test 2 (512, 512)', async function () { + const res = await this.contract1.lt_euint16_euint16(512, 512); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, euint16) => ebool test 3 (512, 513)', async function () { + const res = await this.contract1.lt_euint16_euint16(512, 513); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.min_euint16_euint16(512, 2); + expect(res).to.equal(2); + }); + + it('test operator "min" overload (euint16, euint16) => euint16 test 2 (512, 512)', async function () { + const res = await this.contract1.min_euint16_euint16(512, 512); + expect(res).to.equal(512); + }); + + it('test operator "min" overload (euint16, euint16) => euint16 test 3 (512, 513)', async function () { + const res = await this.contract1.min_euint16_euint16(512, 513); + expect(res).to.equal(512); + }); + + it('test operator "max" overload (euint16, euint16) => euint16 test 1 (512, 2)', async function () { + const res = await this.contract1.max_euint16_euint16(512, 2); + expect(res).to.equal(512); + }); + + it('test operator "max" overload (euint16, euint16) => euint16 test 2 (512, 512)', async function () { + const res = await this.contract1.max_euint16_euint16(512, 512); + expect(res).to.equal(512); + }); + + it('test operator "max" overload (euint16, euint16) => euint16 test 3 (512, 513)', async function () { + const res = await this.contract1.max_euint16_euint16(512, 513); + expect(res).to.equal(513); + }); + + it('test operator "add" overload (euint16, euint32) => euint32 test 1 (514, 131074)', async function () { + const res = await this.contract1.add_euint16_euint32(514, 131074); + expect(res).to.equal(131588); + }); + + it('test operator "sub" overload (euint16, euint32) => euint32 test 1 (514, 2)', async function () { + const res = await this.contract1.sub_euint16_euint32(514, 2); + expect(res).to.equal(512); + }); + + it('test operator "sub" overload (euint16, euint32) => euint32 test 2 (514, 65536)', async function () { + const res = await this.contract1.sub_euint16_euint32(514, 65536); + expect(res).to.equal(4294902274); + }); + + it('test operator "mul" overload (euint16, euint32) => euint32 test 1 (512, 65536)', async function () { + const res = await this.contract1.mul_euint16_euint32(512, 65536); + expect(res).to.equal(33554432); + }); + + it('test operator "and" overload (euint16, euint32) => euint32 test 1 (514, 65536)', async function () { + const res = await this.contract1.and_euint16_euint32(514, 65536); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint16, euint32) => euint32 test 2 (514, 65538)', async function () { + const res = await this.contract1.and_euint16_euint32(514, 65538); + expect(res).to.equal(2); + }); + + it('test operator "or" overload (euint16, euint32) => euint32 test 1 (514, 65536)', async function () { + const res = await this.contract1.or_euint16_euint32(514, 65536); + expect(res).to.equal(66050); + }); + + it('test operator "or" overload (euint16, euint32) => euint32 test 2 (514, 65538)', async function () { + const res = await this.contract1.or_euint16_euint32(514, 65538); + expect(res).to.equal(66050); + }); + + it('test operator "xor" overload (euint16, euint32) => euint32 test 1 (514, 65536)', async function () { + const res = await this.contract1.xor_euint16_euint32(514, 65536); + expect(res).to.equal(66050); + }); + + it('test operator "xor" overload (euint16, euint32) => euint32 test 2 (514, 65538)', async function () { + const res = await this.contract1.xor_euint16_euint32(514, 65538); + expect(res).to.equal(66048); + }); + + it('test operator "shl" overload (euint16, euint32) => euint32 test 1 (514, 2)', async function () { + const res = await this.contract1.shl_euint16_euint32(514, 2); + expect(res).to.equal(2056); + }); + + it('test operator "shr" overload (euint16, euint32) => euint32 test 1 (514, 2)', async function () { + const res = await this.contract1.shr_euint16_euint32(514, 2); + expect(res).to.equal(128); + }); + + it('test operator "eq" overload (euint16, euint32) => ebool test 1 (514, 66050)', async function () { + const res = await this.contract1.eq_euint16_euint32(514, 66050); + expect(res).to.equal(false); + }); + + it('test operator "eq" overload (euint16, euint32) => ebool test 2 (514, 514)', async function () { + const res = await this.contract1.eq_euint16_euint32(514, 514); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (euint16, euint32) => ebool test 1 (514, 66050)', async function () { + const res = await this.contract1.ne_euint16_euint32(514, 66050); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (euint16, euint32) => ebool test 2 (514, 514)', async function () { + const res = await this.contract1.ne_euint16_euint32(514, 514); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint16, euint32) => ebool test 1 (514, 66050)', async function () { + const res = await this.contract1.ge_euint16_euint32(514, 66050); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint16, euint32) => ebool test 2 (514, 514)', async function () { + const res = await this.contract1.ge_euint16_euint32(514, 514); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, euint32) => ebool test 3 (514, 513)', async function () { + const res = await this.contract1.ge_euint16_euint32(514, 513); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint16, euint32) => ebool test 1 (514, 66050)', async function () { + const res = await this.contract1.gt_euint16_euint32(514, 66050); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, euint32) => ebool test 2 (514, 514)', async function () { + const res = await this.contract1.gt_euint16_euint32(514, 514); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, euint32) => ebool test 3 (514, 513)', async function () { + const res = await this.contract1.gt_euint16_euint32(514, 513); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint16, euint32) => ebool test 1 (514, 66050)', async function () { + const res = await this.contract1.le_euint16_euint32(514, 66050); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint16, euint32) => ebool test 2 (514, 514)', async function () { + const res = await this.contract1.le_euint16_euint32(514, 514); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint16, euint32) => ebool test 3 (514, 513)', async function () { + const res = await this.contract1.le_euint16_euint32(514, 513); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, euint32) => ebool test 1 (514, 66050)', async function () { + const res = await this.contract1.lt_euint16_euint32(514, 66050); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint16, euint32) => ebool test 2 (514, 514)', async function () { + const res = await this.contract1.lt_euint16_euint32(514, 514); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, euint32) => ebool test 3 (514, 513)', async function () { + const res = await this.contract1.lt_euint16_euint32(514, 513); + expect(res).to.equal(false); + }); + + it('test operator "min" overload (euint16, euint32) => euint32 test 1 (514, 66050)', async function () { + const res = await this.contract1.min_euint16_euint32(514, 66050); + expect(res).to.equal(514); + }); + + it('test operator "min" overload (euint16, euint32) => euint32 test 2 (514, 514)', async function () { + const res = await this.contract1.min_euint16_euint32(514, 514); + expect(res).to.equal(514); + }); + + it('test operator "min" overload (euint16, euint32) => euint32 test 3 (514, 513)', async function () { + const res = await this.contract1.min_euint16_euint32(514, 513); + expect(res).to.equal(513); + }); + + it('test operator "max" overload (euint16, euint32) => euint32 test 1 (514, 66050)', async function () { + const res = await this.contract1.max_euint16_euint32(514, 66050); + expect(res).to.equal(66050); + }); + + it('test operator "max" overload (euint16, euint32) => euint32 test 2 (514, 514)', async function () { + const res = await this.contract1.max_euint16_euint32(514, 514); + expect(res).to.equal(514); + }); + + it('test operator "max" overload (euint16, euint32) => euint32 test 3 (514, 513)', async function () { + const res = await this.contract1.max_euint16_euint32(514, 513); + expect(res).to.equal(514); + }); + + it('test operator "add" overload (euint16, uint16) => euint16 test 1 (514, 546)', async function () { + const res = await this.contract1.add_euint16_uint16(514, 546); + expect(res).to.equal(1060); + }); + + it('test operator "add" overload (uint16, euint16) => euint16 test 1 (514, 546)', async function () { + const res = await this.contract1.add_uint16_euint16(514, 546); + expect(res).to.equal(1060); + }); + + it('test operator "sub" overload (euint16, uint16) => euint16 test 1 (514, 513)', async function () { + const res = await this.contract1.sub_euint16_uint16(514, 513); + expect(res).to.equal(1); + }); + + it('test operator "sub" overload (uint16, euint16) => euint16 test 1 (514, 513)', async function () { + const res = await this.contract1.sub_uint16_euint16(514, 513); + expect(res).to.equal(1); + }); + + it('test operator "mul" overload (euint16, uint16) => euint16 test 1 (514, 3)', async function () { + const res = await this.contract1.mul_euint16_uint16(514, 3); + expect(res).to.equal(1542); + }); + + it('test operator "mul" overload (uint16, euint16) => euint16 test 1 (514, 3)', async function () { + const res = await this.contract1.mul_uint16_euint16(514, 3); + expect(res).to.equal(1542); + }); + + it('test operator "div" overload (euint16, uint16) => euint16 test 1 (1542, 3)', async function () { + const res = await this.contract1.div_euint16_uint16(1542, 3); + expect(res).to.equal(514); + }); + + it('test operator "shl" overload (euint16, uint16) => euint16 test 1 (1542, 3)', async function () { + const res = await this.contract1.shl_euint16_uint16(1542, 3); + expect(res).to.equal(12336); + }); + + it('test operator "shl" overload (uint16, euint16) => euint16 test 1 (1542, 3)', async function () { + const res = await this.contract1.shl_uint16_euint16(1542, 3); + expect(res).to.equal(12336); + }); + + it('test operator "shr" overload (euint16, uint16) => euint16 test 1 (1542, 3)', async function () { + const res = await this.contract1.shr_euint16_uint16(1542, 3); + expect(res).to.equal(192); + }); + + it('test operator "shr" overload (uint16, euint16) => euint16 test 1 (1542, 3)', async function () { + const res = await this.contract1.shr_uint16_euint16(1542, 3); + expect(res).to.equal(192); + }); + + it('test operator "eq" overload (euint16, uint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.eq_euint16_uint16(1542, 1542); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint16, uint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.eq_euint16_uint16(1542, 1541); + expect(res).to.equal(false); + }); + + it('test operator "eq" overload (uint16, euint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.eq_uint16_euint16(1542, 1542); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (uint16, euint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.eq_uint16_euint16(1542, 1541); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint16, uint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.ne_euint16_uint16(1542, 1542); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint16, uint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.ne_euint16_uint16(1542, 1541); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (uint16, euint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.ne_uint16_euint16(1542, 1542); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (uint16, euint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.ne_uint16_euint16(1542, 1541); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, uint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.ge_euint16_uint16(1542, 1542); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, uint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.ge_euint16_uint16(1542, 1541); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint16, uint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.ge_euint16_uint16(1542, 1543); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (uint16, euint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.ge_uint16_euint16(1542, 1542); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (uint16, euint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.ge_uint16_euint16(1542, 1541); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (uint16, euint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.ge_uint16_euint16(1542, 1543); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, uint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.gt_euint16_uint16(1542, 1542); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint16, uint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.gt_euint16_uint16(1542, 1541); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint16, uint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.gt_euint16_uint16(1542, 1543); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (uint16, euint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.gt_uint16_euint16(1542, 1542); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (uint16, euint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.gt_uint16_euint16(1542, 1541); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (uint16, euint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.gt_uint16_euint16(1542, 1543); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint16, uint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.le_euint16_uint16(1542, 1542); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint16, uint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.le_euint16_uint16(1542, 1541); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint16, uint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.le_euint16_uint16(1542, 1543); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (uint16, euint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.le_uint16_euint16(1542, 1542); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (uint16, euint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.le_uint16_euint16(1542, 1541); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (uint16, euint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.le_uint16_euint16(1542, 1543); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint16, uint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.lt_euint16_uint16(1542, 1542); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, uint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.lt_euint16_uint16(1542, 1541); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint16, uint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.lt_euint16_uint16(1542, 1543); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (uint16, euint16) => ebool test 1 (1542, 1542)', async function () { + const res = await this.contract1.lt_uint16_euint16(1542, 1542); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (uint16, euint16) => ebool test 2 (1542, 1541)', async function () { + const res = await this.contract1.lt_uint16_euint16(1542, 1541); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (uint16, euint16) => ebool test 3 (1542, 1543)', async function () { + const res = await this.contract1.lt_uint16_euint16(1542, 1543); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint16, uint16) => euint16 test 1 (1542, 1542)', async function () { + const res = await this.contract1.min_euint16_uint16(1542, 1542); + expect(res).to.equal(1542); + }); + + it('test operator "min" overload (euint16, uint16) => euint16 test 2 (1542, 1541)', async function () { + const res = await this.contract1.min_euint16_uint16(1542, 1541); + expect(res).to.equal(1541); + }); + + it('test operator "min" overload (euint16, uint16) => euint16 test 3 (1542, 1543)', async function () { + const res = await this.contract1.min_euint16_uint16(1542, 1543); + expect(res).to.equal(1542); + }); + + it('test operator "min" overload (uint16, euint16) => euint16 test 1 (1542, 1542)', async function () { + const res = await this.contract1.min_uint16_euint16(1542, 1542); + expect(res).to.equal(1542); + }); + + it('test operator "min" overload (uint16, euint16) => euint16 test 2 (1542, 1541)', async function () { + const res = await this.contract1.min_uint16_euint16(1542, 1541); + expect(res).to.equal(1541); + }); + + it('test operator "min" overload (uint16, euint16) => euint16 test 3 (1542, 1543)', async function () { + const res = await this.contract1.min_uint16_euint16(1542, 1543); + expect(res).to.equal(1542); + }); + + it('test operator "max" overload (euint16, uint16) => euint16 test 1 (1542, 1542)', async function () { + const res = await this.contract1.max_euint16_uint16(1542, 1542); + expect(res).to.equal(1542); + }); + + it('test operator "max" overload (euint16, uint16) => euint16 test 2 (1542, 1541)', async function () { + const res = await this.contract1.max_euint16_uint16(1542, 1541); + expect(res).to.equal(1542); + }); + + it('test operator "max" overload (euint16, uint16) => euint16 test 3 (1542, 1543)', async function () { + const res = await this.contract1.max_euint16_uint16(1542, 1543); + expect(res).to.equal(1543); + }); + + it('test operator "max" overload (uint16, euint16) => euint16 test 1 (1542, 1542)', async function () { + const res = await this.contract1.max_uint16_euint16(1542, 1542); + expect(res).to.equal(1542); + }); + + it('test operator "max" overload (uint16, euint16) => euint16 test 2 (1542, 1541)', async function () { + const res = await this.contract1.max_uint16_euint16(1542, 1541); + expect(res).to.equal(1542); + }); + + it('test operator "max" overload (uint16, euint16) => euint16 test 3 (1542, 1543)', async function () { + const res = await this.contract1.max_uint16_euint16(1542, 1543); + expect(res).to.equal(1543); + }); + + it('test operator "add" overload (euint32, euint8) => euint32 test 1 (50331648, 3)', async function () { + const res = await this.contract2.add_euint32_euint8(50331648, 3); + expect(res).to.equal(50331651); + }); + + it('test operator "sub" overload (euint32, euint8) => euint32 test 1 (50331648, 3)', async function () { + const res = await this.contract2.sub_euint32_euint8(50331648, 3); + expect(res).to.equal(50331645); + }); + + it('test operator "mul" overload (euint32, euint8) => euint32 test 1 (50331648, 3)', async function () { + const res = await this.contract2.mul_euint32_euint8(50331648, 3); + expect(res).to.equal(150994944); + }); + + it('test operator "and" overload (euint32, euint8) => euint32 test 1 (50397184, 3)', async function () { + const res = await this.contract2.and_euint32_euint8(50397184, 3); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint32, euint8) => euint32 test 2 (50397187, 3)', async function () { + const res = await this.contract2.and_euint32_euint8(50397187, 3); + expect(res).to.equal(3); + }); + + it('test operator "or" overload (euint32, euint8) => euint32 test 1 (50397184, 3)', async function () { + const res = await this.contract2.or_euint32_euint8(50397184, 3); + expect(res).to.equal(50397187); + }); + + it('test operator "or" overload (euint32, euint8) => euint32 test 2 (50397187, 3)', async function () { + const res = await this.contract2.or_euint32_euint8(50397187, 3); + expect(res).to.equal(50397187); + }); + + it('test operator "xor" overload (euint32, euint8) => euint32 test 1 (50397184, 3)', async function () { + const res = await this.contract2.xor_euint32_euint8(50397184, 3); + expect(res).to.equal(50397187); + }); + + it('test operator "xor" overload (euint32, euint8) => euint32 test 2 (50397187, 3)', async function () { + const res = await this.contract2.xor_euint32_euint8(50397187, 3); + expect(res).to.equal(50397184); + }); + + it('test operator "shl" overload (euint32, euint8) => euint32 test 1 (50397184, 3)', async function () { + const res = await this.contract2.shl_euint32_euint8(50397184, 3); + expect(res).to.equal(403177472); + }); + + it('test operator "shr" overload (euint32, euint8) => euint32 test 1 (50397184, 3)', async function () { + const res = await this.contract2.shr_euint32_euint8(50397184, 3); + expect(res).to.equal(6299648); + }); + + it('test operator "eq" overload (euint32, euint8) => ebool test 1 (3, 3)', async function () { + const res = await this.contract2.eq_euint32_euint8(3, 3); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint32, euint8) => ebool test 2 (50331651, 3)', async function () { + const res = await this.contract2.eq_euint32_euint8(50331651, 3); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, euint8) => ebool test 1 (3, 3)', async function () { + const res = await this.contract2.ne_euint32_euint8(3, 3); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, euint8) => ebool test 2 (50331651, 3)', async function () { + const res = await this.contract2.ne_euint32_euint8(50331651, 3); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint8) => ebool test 1 (3, 3)', async function () { + const res = await this.contract2.ge_euint32_euint8(3, 3); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint8) => ebool test 2 (50331651, 3)', async function () { + const res = await this.contract2.ge_euint32_euint8(50331651, 3); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint8) => ebool test 3 (3, 4)', async function () { + const res = await this.contract2.ge_euint32_euint8(3, 4); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, euint8) => ebool test 1 (3, 3)', async function () { + const res = await this.contract2.gt_euint32_euint8(3, 3); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, euint8) => ebool test 2 (50331651, 3)', async function () { + const res = await this.contract2.gt_euint32_euint8(50331651, 3); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint32, euint8) => ebool test 3 (3, 4)', async function () { + const res = await this.contract2.gt_euint32_euint8(3, 4); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint32, euint8) => ebool test 1 (3, 3)', async function () { + const res = await this.contract2.le_euint32_euint8(3, 3); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, euint8) => ebool test 2 (50331651, 3)', async function () { + const res = await this.contract2.le_euint32_euint8(50331651, 3); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint32, euint8) => ebool test 3 (3, 4)', async function () { + const res = await this.contract2.le_euint32_euint8(3, 4); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint32, euint8) => ebool test 1 (3, 3)', async function () { + const res = await this.contract2.lt_euint32_euint8(3, 3); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, euint8) => ebool test 2 (50331651, 3)', async function () { + const res = await this.contract2.lt_euint32_euint8(50331651, 3); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, euint8) => ebool test 3 (3, 4)', async function () { + const res = await this.contract2.lt_euint32_euint8(3, 4); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint32, euint8) => euint32 test 1 (3, 3)', async function () { + const res = await this.contract2.min_euint32_euint8(3, 3); + expect(res).to.equal(3); + }); + + it('test operator "min" overload (euint32, euint8) => euint32 test 2 (50331651, 3)', async function () { + const res = await this.contract2.min_euint32_euint8(50331651, 3); + expect(res).to.equal(3); + }); + + it('test operator "min" overload (euint32, euint8) => euint32 test 3 (3, 4)', async function () { + const res = await this.contract2.min_euint32_euint8(3, 4); + expect(res).to.equal(3); + }); + + it('test operator "max" overload (euint32, euint8) => euint32 test 1 (3, 3)', async function () { + const res = await this.contract2.max_euint32_euint8(3, 3); + expect(res).to.equal(3); + }); + + it('test operator "max" overload (euint32, euint8) => euint32 test 2 (50331651, 3)', async function () { + const res = await this.contract2.max_euint32_euint8(50331651, 3); + expect(res).to.equal(50331651); + }); + + it('test operator "max" overload (euint32, euint8) => euint32 test 3 (3, 4)', async function () { + const res = await this.contract2.max_euint32_euint8(3, 4); + expect(res).to.equal(4); + }); + + it('test operator "add" overload (euint32, euint16) => euint32 test 1 (50335779, 4099)', async function () { + const res = await this.contract2.add_euint32_euint16(50335779, 4099); + expect(res).to.equal(50339878); + }); + + it('test operator "sub" overload (euint32, euint16) => euint32 test 1 (50335779, 4099)', async function () { + const res = await this.contract2.sub_euint32_euint16(50335779, 4099); + expect(res).to.equal(50331680); + }); + + it('test operator "mul" overload (euint32, euint16) => euint32 test 1 (50335779, 3)', async function () { + const res = await this.contract2.mul_euint32_euint16(50335779, 3); + expect(res).to.equal(151007337); + }); + + it('test operator "and" overload (euint32, euint16) => euint32 test 1 (50335776, 3)', async function () { + const res = await this.contract2.and_euint32_euint16(50335776, 3); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint32, euint16) => euint32 test 2 (50335779, 4099)', async function () { + const res = await this.contract2.and_euint32_euint16(50335779, 4099); + expect(res).to.equal(4099); + }); + + it('test operator "or" overload (euint32, euint16) => euint32 test 1 (50331680, 4099)', async function () { + const res = await this.contract2.or_euint32_euint16(50331680, 4099); + expect(res).to.equal(50335779); + }); + + it('test operator "or" overload (euint32, euint16) => euint32 test 2 (50331683, 4099)', async function () { + const res = await this.contract2.or_euint32_euint16(50331683, 4099); + expect(res).to.equal(50335779); + }); + + it('test operator "xor" overload (euint32, euint16) => euint32 test 1 (50331683, 4099)', async function () { + const res = await this.contract2.xor_euint32_euint16(50331683, 4099); + expect(res).to.equal(50335776); + }); + + it('test operator "shl" overload (euint32, euint16) => euint32 test 1 (50331648, 2)', async function () { + const res = await this.contract2.shl_euint32_euint16(50331648, 2); + expect(res).to.equal(201326592); + }); + + it('test operator "shr" overload (euint32, euint16) => euint32 test 1 (50331648, 2)', async function () { + const res = await this.contract2.shr_euint32_euint16(50331648, 2); + expect(res).to.equal(12582912); + }); + + it('test operator "eq" overload (euint32, euint16) => ebool test 1 (4096, 4096)', async function () { + const res = await this.contract2.eq_euint32_euint16(4096, 4096); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint32, euint16) => ebool test 2 (16781312, 4096)', async function () { + const res = await this.contract2.eq_euint32_euint16(16781312, 4096); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, euint16) => ebool test 1 (4096, 4096)', async function () { + const res = await this.contract2.ne_euint32_euint16(4096, 4096); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, euint16) => ebool test 2 (16781312, 4096)', async function () { + const res = await this.contract2.ne_euint32_euint16(16781312, 4096); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint16) => ebool test 1 (4096, 4096)', async function () { + const res = await this.contract2.ge_euint32_euint16(4096, 4096); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint16) => ebool test 2 (16781312, 4096)', async function () { + const res = await this.contract2.ge_euint32_euint16(16781312, 4096); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint16) => ebool test 3 (4096, 4097)', async function () { + const res = await this.contract2.ge_euint32_euint16(4096, 4097); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, euint16) => ebool test 1 (4096, 4096)', async function () { + const res = await this.contract2.gt_euint32_euint16(4096, 4096); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, euint16) => ebool test 2 (16781312, 4096)', async function () { + const res = await this.contract2.gt_euint32_euint16(16781312, 4096); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint32, euint16) => ebool test 3 (4096, 4097)', async function () { + const res = await this.contract2.gt_euint32_euint16(4096, 4097); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint32, euint16) => ebool test 1 (4096, 4096)', async function () { + const res = await this.contract2.le_euint32_euint16(4096, 4096); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, euint16) => ebool test 2 (16781312, 4096)', async function () { + const res = await this.contract2.le_euint32_euint16(16781312, 4096); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (euint32, euint16) => ebool test 3 (4096, 4097)', async function () { + const res = await this.contract2.le_euint32_euint16(4096, 4097); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint32, euint16) => ebool test 1 (4096, 4096)', async function () { + const res = await this.contract2.lt_euint32_euint16(4096, 4096); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, euint16) => ebool test 2 (16781312, 4096)', async function () { + const res = await this.contract2.lt_euint32_euint16(16781312, 4096); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, euint16) => ebool test 3 (4096, 4097)', async function () { + const res = await this.contract2.lt_euint32_euint16(4096, 4097); + expect(res).to.equal(true); + }); + + it('test operator "min" overload (euint32, euint16) => euint32 test 1 (4096, 4096)', async function () { + const res = await this.contract2.min_euint32_euint16(4096, 4096); + expect(res).to.equal(4096); + }); + + it('test operator "min" overload (euint32, euint16) => euint32 test 2 (16781312, 4096)', async function () { + const res = await this.contract2.min_euint32_euint16(16781312, 4096); + expect(res).to.equal(4096); + }); + + it('test operator "min" overload (euint32, euint16) => euint32 test 3 (4096, 4097)', async function () { + const res = await this.contract2.min_euint32_euint16(4096, 4097); + expect(res).to.equal(4096); + }); + + it('test operator "max" overload (euint32, euint16) => euint32 test 1 (4096, 4096)', async function () { + const res = await this.contract2.max_euint32_euint16(4096, 4096); + expect(res).to.equal(4096); + }); + + it('test operator "max" overload (euint32, euint16) => euint32 test 2 (16781312, 4096)', async function () { + const res = await this.contract2.max_euint32_euint16(16781312, 4096); + expect(res).to.equal(16781312); + }); + + it('test operator "max" overload (euint32, euint16) => euint32 test 3 (4096, 4097)', async function () { + const res = await this.contract2.max_euint32_euint16(4096, 4097); + expect(res).to.equal(4097); + }); + + it('test operator "add" overload (euint32, euint32) => euint32 test 1 (3280896, 1118208)', async function () { + const res = await this.contract2.add_euint32_euint32(3280896, 1118208); + expect(res).to.equal(4399104); + }); + + it('test operator "sub" overload (euint32, euint32) => euint32 test 1 (3280896, 1118208)', async function () { + const res = await this.contract2.sub_euint32_euint32(3280896, 1118208); + expect(res).to.equal(2162688); + }); + + it('test operator "mul" overload (euint32, euint32) => euint32 test 1 (3280896, 32)', async function () { + const res = await this.contract2.mul_euint32_euint32(3280896, 32); + expect(res).to.equal(104988672); + }); + + it('test operator "and" overload (euint32, euint32) => euint32 test 1 (3280896, 1409286144)', async function () { + const res = await this.contract2.and_euint32_euint32(3280896, 1409286144); + expect(res).to.equal(0); + }); + + it('test operator "and" overload (euint32, euint32) => euint32 test 2 (3280896, 1409482752)', async function () { + const res = await this.contract2.and_euint32_euint32(3280896, 1409482752); + expect(res).to.equal(131072); + }); + + it('test operator "or" overload (euint32, euint32) => euint32 test 1 (3280896, 1409286144)', async function () { + const res = await this.contract2.or_euint32_euint32(3280896, 1409286144); + expect(res).to.equal(1412567040); + }); + + it('test operator "or" overload (euint32, euint32) => euint32 test 2 (3280896, 1409482752)', async function () { + const res = await this.contract2.or_euint32_euint32(3280896, 1409482752); + expect(res).to.equal(1412632576); + }); + + it('test operator "xor" overload (euint32, euint32) => euint32 test 1 (3280896, 1409286144)', async function () { + const res = await this.contract2.xor_euint32_euint32(3280896, 1409286144); + expect(res).to.equal(1412567040); + }); + + it('test operator "xor" overload (euint32, euint32) => euint32 test 2 (3280896, 1409482752)', async function () { + const res = await this.contract2.xor_euint32_euint32(3280896, 1409482752); + expect(res).to.equal(1412501504); + }); + + it('test operator "shl" overload (euint32, euint32) => euint32 test 1 (3280896, 2)', async function () { + const res = await this.contract2.shl_euint32_euint32(3280896, 2); + expect(res).to.equal(13123584); + }); + + it('test operator "shr" overload (euint32, euint32) => euint32 test 1 (3280896, 2)', async function () { + const res = await this.contract2.shr_euint32_euint32(3280896, 2); + expect(res).to.equal(820224); + }); + + it('test operator "eq" overload (euint32, euint32) => ebool test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.eq_euint32_euint32(3280896, 3280896); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint32, euint32) => ebool test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.eq_euint32_euint32(3280896, 3280897); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, euint32) => ebool test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.ne_euint32_euint32(3280896, 3280896); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, euint32) => ebool test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.ne_euint32_euint32(3280896, 3280897); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint32) => ebool test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.ge_euint32_euint32(3280896, 3280896); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, euint32) => ebool test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.ge_euint32_euint32(3280896, 3280897); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint32, euint32) => ebool test 3 (3280896, 3280895)', async function () { + const res = await this.contract2.ge_euint32_euint32(3280896, 3280895); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint32, euint32) => ebool test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.gt_euint32_euint32(3280896, 3280896); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, euint32) => ebool test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.gt_euint32_euint32(3280896, 3280897); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, euint32) => ebool test 3 (3280896, 3280895)', async function () { + const res = await this.contract2.gt_euint32_euint32(3280896, 3280895); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, euint32) => ebool test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.le_euint32_euint32(3280896, 3280896); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, euint32) => ebool test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.le_euint32_euint32(3280896, 3280897); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, euint32) => ebool test 3 (3280896, 3280895)', async function () { + const res = await this.contract2.le_euint32_euint32(3280896, 3280895); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, euint32) => ebool test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.lt_euint32_euint32(3280896, 3280896); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, euint32) => ebool test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.lt_euint32_euint32(3280896, 3280897); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint32, euint32) => ebool test 3 (3280896, 3280895)', async function () { + const res = await this.contract2.lt_euint32_euint32(3280896, 3280895); + expect(res).to.equal(false); + }); + + it('test operator "min" overload (euint32, euint32) => euint32 test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.min_euint32_euint32(3280896, 3280896); + expect(res).to.equal(3280896); + }); + + it('test operator "min" overload (euint32, euint32) => euint32 test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.min_euint32_euint32(3280896, 3280897); + expect(res).to.equal(3280896); + }); + + it('test operator "min" overload (euint32, euint32) => euint32 test 3 (3280896, 3280895)', async function () { + const res = await this.contract2.min_euint32_euint32(3280896, 3280895); + expect(res).to.equal(3280895); + }); + + it('test operator "max" overload (euint32, euint32) => euint32 test 1 (3280896, 3280896)', async function () { + const res = await this.contract2.max_euint32_euint32(3280896, 3280896); + expect(res).to.equal(3280896); + }); + + it('test operator "max" overload (euint32, euint32) => euint32 test 2 (3280896, 3280897)', async function () { + const res = await this.contract2.max_euint32_euint32(3280896, 3280897); + expect(res).to.equal(3280897); + }); + + it('test operator "max" overload (euint32, euint32) => euint32 test 3 (3280896, 3280895)', async function () { + const res = await this.contract2.max_euint32_euint32(3280896, 3280895); + expect(res).to.equal(3280896); + }); + + it('test operator "add" overload (euint32, uint32) => euint32 test 1 (3416064, 3280896)', async function () { + const res = await this.contract2.add_euint32_uint32(3416064, 3280896); + expect(res).to.equal(6696960); + }); + + it('test operator "add" overload (uint32, euint32) => euint32 test 1 (3416064, 3280896)', async function () { + const res = await this.contract2.add_uint32_euint32(3416064, 3280896); + expect(res).to.equal(6696960); + }); + + it('test operator "sub" overload (euint32, uint32) => euint32 test 1 (3416064, 3280896)', async function () { + const res = await this.contract2.sub_euint32_uint32(3416064, 3280896); + expect(res).to.equal(135168); + }); + + it('test operator "sub" overload (uint32, euint32) => euint32 test 1 (3416064, 3280896)', async function () { + const res = await this.contract2.sub_uint32_euint32(3416064, 3280896); + expect(res).to.equal(135168); + }); + + it('test operator "mul" overload (euint32, uint32) => euint32 test 1 (3416064, 256)', async function () { + const res = await this.contract2.mul_euint32_uint32(3416064, 256); + expect(res).to.equal(874512384); + }); + + it('test operator "mul" overload (uint32, euint32) => euint32 test 1 (3416064, 256)', async function () { + const res = await this.contract2.mul_uint32_euint32(3416064, 256); + expect(res).to.equal(874512384); + }); + + it('test operator "div" overload (euint32, uint32) => euint32 test 1 (3416064, 256)', async function () { + const res = await this.contract2.div_euint32_uint32(3416064, 256); + expect(res).to.equal(13344); + }); + + it('test operator "shl" overload (euint32, uint32) => euint32 test 1 (3416064, 1)', async function () { + const res = await this.contract2.shl_euint32_uint32(3416064, 1); + expect(res).to.equal(6832128); + }); + + it('test operator "shl" overload (uint32, euint32) => euint32 test 1 (3416064, 1)', async function () { + const res = await this.contract2.shl_uint32_euint32(3416064, 1); + expect(res).to.equal(6832128); + }); + + it('test operator "shr" overload (euint32, uint32) => euint32 test 1 (3416064, 1)', async function () { + const res = await this.contract2.shr_euint32_uint32(3416064, 1); + expect(res).to.equal(1708032); + }); + + it('test operator "shr" overload (uint32, euint32) => euint32 test 1 (3416064, 1)', async function () { + const res = await this.contract2.shr_uint32_euint32(3416064, 1); + expect(res).to.equal(1708032); + }); + + it('test operator "eq" overload (euint32, uint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.eq_euint32_uint32(3416064, 3416064); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (euint32, uint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.eq_euint32_uint32(3416064, 3416065); + expect(res).to.equal(false); + }); + + it('test operator "eq" overload (uint32, euint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.eq_uint32_euint32(3416064, 3416064); + expect(res).to.equal(true); + }); + + it('test operator "eq" overload (uint32, euint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.eq_uint32_euint32(3416064, 3416065); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, uint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.ne_euint32_uint32(3416064, 3416064); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (euint32, uint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.ne_euint32_uint32(3416064, 3416065); + expect(res).to.equal(true); + }); + + it('test operator "ne" overload (uint32, euint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.ne_uint32_euint32(3416064, 3416064); + expect(res).to.equal(false); + }); + + it('test operator "ne" overload (uint32, euint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.ne_uint32_euint32(3416064, 3416065); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, uint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.ge_euint32_uint32(3416064, 3416064); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (euint32, uint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.ge_euint32_uint32(3416064, 3416065); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (euint32, uint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.ge_euint32_uint32(3416064, 3416063); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (uint32, euint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.ge_uint32_euint32(3416064, 3416064); + expect(res).to.equal(true); + }); + + it('test operator "ge" overload (uint32, euint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.ge_uint32_euint32(3416064, 3416065); + expect(res).to.equal(false); + }); + + it('test operator "ge" overload (uint32, euint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.ge_uint32_euint32(3416064, 3416063); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (euint32, uint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.gt_euint32_uint32(3416064, 3416064); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, uint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.gt_euint32_uint32(3416064, 3416065); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (euint32, uint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.gt_euint32_uint32(3416064, 3416063); + expect(res).to.equal(true); + }); + + it('test operator "gt" overload (uint32, euint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.gt_uint32_euint32(3416064, 3416064); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (uint32, euint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.gt_uint32_euint32(3416064, 3416065); + expect(res).to.equal(false); + }); + + it('test operator "gt" overload (uint32, euint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.gt_uint32_euint32(3416064, 3416063); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, uint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.le_euint32_uint32(3416064, 3416064); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, uint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.le_euint32_uint32(3416064, 3416065); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (euint32, uint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.le_euint32_uint32(3416064, 3416063); + expect(res).to.equal(false); + }); + + it('test operator "le" overload (uint32, euint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.le_uint32_euint32(3416064, 3416064); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (uint32, euint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.le_uint32_euint32(3416064, 3416065); + expect(res).to.equal(true); + }); + + it('test operator "le" overload (uint32, euint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.le_uint32_euint32(3416064, 3416063); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, uint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.lt_euint32_uint32(3416064, 3416064); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (euint32, uint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.lt_euint32_uint32(3416064, 3416065); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (euint32, uint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.lt_euint32_uint32(3416064, 3416063); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (uint32, euint32) => ebool test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.lt_uint32_euint32(3416064, 3416064); + expect(res).to.equal(false); + }); + + it('test operator "lt" overload (uint32, euint32) => ebool test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.lt_uint32_euint32(3416064, 3416065); + expect(res).to.equal(true); + }); + + it('test operator "lt" overload (uint32, euint32) => ebool test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.lt_uint32_euint32(3416064, 3416063); + expect(res).to.equal(false); + }); + + it('test operator "min" overload (euint32, uint32) => euint32 test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.min_euint32_uint32(3416064, 3416064); + expect(res).to.equal(3416064); + }); + + it('test operator "min" overload (euint32, uint32) => euint32 test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.min_euint32_uint32(3416064, 3416065); + expect(res).to.equal(3416064); + }); + + it('test operator "min" overload (euint32, uint32) => euint32 test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.min_euint32_uint32(3416064, 3416063); + expect(res).to.equal(3416063); + }); + + it('test operator "min" overload (uint32, euint32) => euint32 test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.min_uint32_euint32(3416064, 3416064); + expect(res).to.equal(3416064); + }); + + it('test operator "min" overload (uint32, euint32) => euint32 test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.min_uint32_euint32(3416064, 3416065); + expect(res).to.equal(3416064); + }); + + it('test operator "min" overload (uint32, euint32) => euint32 test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.min_uint32_euint32(3416064, 3416063); + expect(res).to.equal(3416063); + }); + + it('test operator "max" overload (euint32, uint32) => euint32 test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.max_euint32_uint32(3416064, 3416064); + expect(res).to.equal(3416064); + }); + + it('test operator "max" overload (euint32, uint32) => euint32 test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.max_euint32_uint32(3416064, 3416065); + expect(res).to.equal(3416065); + }); + + it('test operator "max" overload (euint32, uint32) => euint32 test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.max_euint32_uint32(3416064, 3416063); + expect(res).to.equal(3416064); + }); + + it('test operator "max" overload (uint32, euint32) => euint32 test 1 (3416064, 3416064)', async function () { + const res = await this.contract2.max_uint32_euint32(3416064, 3416064); + expect(res).to.equal(3416064); + }); + + it('test operator "max" overload (uint32, euint32) => euint32 test 2 (3416064, 3416065)', async function () { + const res = await this.contract2.max_uint32_euint32(3416064, 3416065); + expect(res).to.equal(3416065); + }); + + it('test operator "max" overload (uint32, euint32) => euint32 test 3 (3416064, 3416063)', async function () { + const res = await this.contract2.max_uint32_euint32(3416064, 3416063); + expect(res).to.equal(3416064); + }); });