Skip to main content

Built-In Operations

Overview of the primitive and the array Nada operations.

Primitive Operations

NameSyntaxSupported Types
(P: Public, S: Secret)
Additionx + yP ← P + P,
S ← P + S,
S ← S + P,
S ← S + S
Subtractionx - yP ← P - P,
S ← P - S,
S ← S - P,
S ← S - S
Multiplicationx * yP ← P * P,
S ← P * S,
S ← S * P,
S ← S * S
Powerx ** yP ← P ** P
Divisionx / yP ← P / P,
S ← P / S,
S ← S / P,
S ← S / S
Modulox % yP ← P % P,
S ← P % S,
S ← S % P,
S ← S % S
Shiftsx << y,
x >> y
P ← P << P,
S ← S << P
Probabilistic truncationx.trunc_pr(y)S ← S.trunc_pr(P)
Comparisonsx < 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()
Equalityx == yS ← 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)