Open brech1 opened 2 months ago
@brech1 I have a wip branch here but I've run into some questions/issues:
-x
(ExpressionPrefixOpcode::Sub
) be handled? Should a u32
underflow? Or perhaps emit a compilation error?pub enum ArithGateType {
/// Addition gate.
Add,
/// Subtraction gate.
Sub,
/// Multiplication gate.
Mul,
/// Constant multiplication gate.
Cmul,
/// Unary projection gate.
Proj,
}
So perhaps we should update the gates we're supporting. This is also related to this comment @namnc left in the overview. There is no defined format.
-x
I think it would be equal to 0 - x
so perhaps declaring a constant 0 as the other gate input for a subtraction gate. I think this and other cases should be handled individually in a new handle_prefix_op function, if it gets too long.For simplicity let's (for now) stick to binary gate and have x = 0 - x for negation.
Point 2 is another issue itself. Rigft now we consider only u32 (behind the scene we do wraparound so -p becomes M-P with M being the bound of the value) but we should also consider i32? This is related to typing.
For simplicity let's (for now) stick to binary gate and have x = 0 - x for negation.
And what should we do regarding the amount of gates we're supporting (more than the supported by the backend)? Should the backend handle this? Perhaps MP-SPDZ have a broader support?
Point 2 is another issue itself. Rigft now we consider only u32 (behind the scene we do wraparound so -p becomes M-P with M being the bound of the value) but we should also consider i32? This is related to typing.
Even if we add the i32 type we have to handle overflows and underflows on unsigned. We could add a configurable mod
integer so we can implement modular arithmetic with it, this would only be applied on integer operations.
Add support for the
PrefixOp
expression.