|
| 1 | +import { Operator, OperatorArguments, ReturnType } from './common'; |
| 2 | + |
| 3 | +/** |
| 4 | + * A list of all supported operators with their respective properties. |
| 5 | + * |
| 6 | + * Each operator object contains the following properties: |
| 7 | + * - `name`: The name of the operator. |
| 8 | + * - `hasScalar`: A boolean indicating if the operator supports scalar values. |
| 9 | + * - `hasEncrypted`: A boolean indicating if the operator supports encrypted values. |
| 10 | + * - `arguments`: The type of arguments the operator accepts (binary or unary). |
| 11 | + * - `returnType`: The return type of the operator. |
| 12 | + * - `fheLibName`: The corresponding function name in the FHE library. |
| 13 | + * - `leftScalarEncrypt` (optional): A boolean indicating if the left scalar should be encrypted. |
| 14 | + * - `leftScalarDisable` (optional): A boolean indicating if the left scalar is disabled. |
| 15 | + * - `shiftOperator` (optional): A boolean indicating if the operator is a shift operator. |
| 16 | + * - `rotateOperator` (optional): A boolean indicating if the operator is a rotate operator. |
| 17 | + * - `leftScalarInvertOp` (optional): The name of the inverted operator for the left scalar. |
| 18 | + */ |
| 19 | +export const ALL_OPERATORS: Operator[] = [ |
| 20 | + { |
| 21 | + name: 'add', |
| 22 | + hasScalar: true, |
| 23 | + hasEncrypted: true, |
| 24 | + arguments: OperatorArguments.Binary, |
| 25 | + returnType: ReturnType.Uint, |
| 26 | + fheLibName: 'fheAdd', |
| 27 | + }, |
| 28 | + { |
| 29 | + name: 'sub', |
| 30 | + hasScalar: true, |
| 31 | + hasEncrypted: true, |
| 32 | + arguments: OperatorArguments.Binary, |
| 33 | + returnType: ReturnType.Uint, |
| 34 | + leftScalarEncrypt: true, |
| 35 | + fheLibName: 'fheSub', |
| 36 | + }, |
| 37 | + { |
| 38 | + name: 'mul', |
| 39 | + hasScalar: true, |
| 40 | + hasEncrypted: true, |
| 41 | + arguments: OperatorArguments.Binary, |
| 42 | + returnType: ReturnType.Uint, |
| 43 | + fheLibName: 'fheMul', |
| 44 | + }, |
| 45 | + { |
| 46 | + name: 'div', |
| 47 | + hasScalar: true, |
| 48 | + hasEncrypted: false, |
| 49 | + arguments: OperatorArguments.Binary, |
| 50 | + returnType: ReturnType.Uint, |
| 51 | + leftScalarDisable: true, |
| 52 | + fheLibName: 'fheDiv', |
| 53 | + }, |
| 54 | + { |
| 55 | + name: 'rem', |
| 56 | + hasScalar: true, |
| 57 | + hasEncrypted: false, |
| 58 | + arguments: OperatorArguments.Binary, |
| 59 | + returnType: ReturnType.Uint, |
| 60 | + leftScalarDisable: true, |
| 61 | + fheLibName: 'fheRem', |
| 62 | + }, |
| 63 | + { |
| 64 | + name: 'and', |
| 65 | + hasScalar: true, |
| 66 | + hasEncrypted: true, |
| 67 | + arguments: OperatorArguments.Binary, |
| 68 | + returnType: ReturnType.Uint, |
| 69 | + fheLibName: 'fheBitAnd', |
| 70 | + }, |
| 71 | + { |
| 72 | + name: 'or', |
| 73 | + hasScalar: true, |
| 74 | + hasEncrypted: true, |
| 75 | + arguments: OperatorArguments.Binary, |
| 76 | + returnType: ReturnType.Uint, |
| 77 | + fheLibName: 'fheBitOr', |
| 78 | + }, |
| 79 | + { |
| 80 | + name: 'xor', |
| 81 | + hasScalar: true, |
| 82 | + hasEncrypted: true, |
| 83 | + arguments: OperatorArguments.Binary, |
| 84 | + returnType: ReturnType.Uint, |
| 85 | + fheLibName: 'fheBitXor', |
| 86 | + }, |
| 87 | + { |
| 88 | + name: 'shl', |
| 89 | + hasScalar: true, |
| 90 | + hasEncrypted: true, |
| 91 | + arguments: OperatorArguments.Binary, |
| 92 | + returnType: ReturnType.Uint, |
| 93 | + leftScalarEncrypt: true, |
| 94 | + shiftOperator: true, |
| 95 | + fheLibName: 'fheShl', |
| 96 | + }, |
| 97 | + { |
| 98 | + name: 'shr', |
| 99 | + hasScalar: true, |
| 100 | + hasEncrypted: true, |
| 101 | + arguments: OperatorArguments.Binary, |
| 102 | + returnType: ReturnType.Uint, |
| 103 | + leftScalarEncrypt: true, |
| 104 | + shiftOperator: true, |
| 105 | + fheLibName: 'fheShr', |
| 106 | + }, |
| 107 | + { |
| 108 | + name: 'rotl', |
| 109 | + hasScalar: true, |
| 110 | + hasEncrypted: true, |
| 111 | + arguments: OperatorArguments.Binary, |
| 112 | + returnType: ReturnType.Uint, |
| 113 | + leftScalarEncrypt: true, |
| 114 | + rotateOperator: true, |
| 115 | + fheLibName: 'fheRotl', |
| 116 | + }, |
| 117 | + { |
| 118 | + name: 'rotr', |
| 119 | + hasScalar: true, |
| 120 | + hasEncrypted: true, |
| 121 | + arguments: OperatorArguments.Binary, |
| 122 | + returnType: ReturnType.Uint, |
| 123 | + leftScalarEncrypt: true, |
| 124 | + rotateOperator: true, |
| 125 | + fheLibName: 'fheRotr', |
| 126 | + }, |
| 127 | + { |
| 128 | + name: 'eq', |
| 129 | + hasScalar: true, |
| 130 | + hasEncrypted: true, |
| 131 | + arguments: OperatorArguments.Binary, |
| 132 | + returnType: ReturnType.Ebool, |
| 133 | + fheLibName: 'fheEq', |
| 134 | + }, |
| 135 | + { |
| 136 | + name: 'ne', |
| 137 | + hasScalar: true, |
| 138 | + hasEncrypted: true, |
| 139 | + arguments: OperatorArguments.Binary, |
| 140 | + returnType: ReturnType.Ebool, |
| 141 | + fheLibName: 'fheNe', |
| 142 | + }, |
| 143 | + { |
| 144 | + name: 'ge', |
| 145 | + leftScalarInvertOp: 'le', |
| 146 | + hasScalar: true, |
| 147 | + hasEncrypted: true, |
| 148 | + arguments: OperatorArguments.Binary, |
| 149 | + returnType: ReturnType.Ebool, |
| 150 | + fheLibName: 'fheGe', |
| 151 | + }, |
| 152 | + { |
| 153 | + name: 'gt', |
| 154 | + leftScalarInvertOp: 'lt', |
| 155 | + hasScalar: true, |
| 156 | + hasEncrypted: true, |
| 157 | + arguments: OperatorArguments.Binary, |
| 158 | + returnType: ReturnType.Ebool, |
| 159 | + fheLibName: 'fheGt', |
| 160 | + }, |
| 161 | + { |
| 162 | + name: 'le', |
| 163 | + leftScalarInvertOp: 'ge', |
| 164 | + hasScalar: true, |
| 165 | + hasEncrypted: true, |
| 166 | + arguments: OperatorArguments.Binary, |
| 167 | + returnType: ReturnType.Ebool, |
| 168 | + fheLibName: 'fheLe', |
| 169 | + }, |
| 170 | + { |
| 171 | + name: 'lt', |
| 172 | + leftScalarInvertOp: 'gt', |
| 173 | + hasScalar: true, |
| 174 | + hasEncrypted: true, |
| 175 | + arguments: OperatorArguments.Binary, |
| 176 | + returnType: ReturnType.Ebool, |
| 177 | + fheLibName: 'fheLt', |
| 178 | + }, |
| 179 | + { |
| 180 | + name: 'min', |
| 181 | + hasScalar: true, |
| 182 | + hasEncrypted: true, |
| 183 | + arguments: OperatorArguments.Binary, |
| 184 | + returnType: ReturnType.Uint, |
| 185 | + fheLibName: 'fheMin', |
| 186 | + }, |
| 187 | + { |
| 188 | + name: 'max', |
| 189 | + hasScalar: true, |
| 190 | + hasEncrypted: true, |
| 191 | + arguments: OperatorArguments.Binary, |
| 192 | + returnType: ReturnType.Uint, |
| 193 | + fheLibName: 'fheMax', |
| 194 | + }, |
| 195 | + { |
| 196 | + name: 'neg', |
| 197 | + hasScalar: true, |
| 198 | + hasEncrypted: true, |
| 199 | + arguments: OperatorArguments.Unary, |
| 200 | + returnType: ReturnType.Uint, |
| 201 | + fheLibName: 'fheNeg', |
| 202 | + }, |
| 203 | + { |
| 204 | + name: 'not', |
| 205 | + hasScalar: true, |
| 206 | + hasEncrypted: true, |
| 207 | + arguments: OperatorArguments.Unary, |
| 208 | + returnType: ReturnType.Uint, |
| 209 | + fheLibName: 'fheNot', |
| 210 | + }, |
| 211 | +]; |
0 commit comments