Built-In Operations
Overview of the primitive and the array Nada operations.
Primitive Operations
Name | Syntax | Supported Types ( P: Public , S: Secret ) |
---|---|---|
Addition | x + y | P ← P + P ,S ← P + S ,S ← S + P ,S ← S + S |
Subtraction | x - y | P ← P - P ,S ← P - S ,S ← S - P ,S ← S - S |
Multiplication | x * y | P ← P * P ,S ← P * S ,S ← S * P ,S ← S * S |
Power | x ** y | P ← P ** P |
Division | x / y | P ← P / P ,S ← P / S ,S ← S / P ,S ← S / S |
Modulo | x % y | P ← P % P ,S ← P % S ,S ← S % P ,S ← S % S |
Shifts | x << y ,x >> y | P ← P << P ,S ← S << P |
Probabilistic truncation | x.trunc_pr(y) | S ← S.trunc_pr(P) |
Comparisons | x < y ,x <= y ,x > y ,x >= y | P ← P < P ,S ← P < S ,S ← S < P ,S ← S < S |
Ternary "if else" (public condition) | cond.if_else(x, y) | P ← P.if_else(P, P) ,S ← P.if_else(P, S) ,S ← P.if_else(S, P) ,S ← P.if_else(S, S) |
Ternary "if else" (secret condition) | cond.if_else(x, y) | S ← S.if_else(P, P) ,S ← S.if_else(P, S) ,S ← S.if_else(S, P) ,S ← S.if_else(S, S) |
Reveal (convert a private value into a public value) | x.reveal() | P ← S.reveal() |
Equality | x == y | S ← S == S ,S ← S == P ,S ← P == S ,P ← P == P |
Public Output Equality (publicly output if two secrets are equal) | x.public_equals(y) | P ← S.public_equals(S) |