FHERMA
L3 · FUNCTIONALMEASURED

Encrypted Sign Function

encrypted-sign · spec v0.1.0 · 0 implementations · 6 runners

Create implementationSpecification

DESCRIPTION

Evaluates sign(x) on an encrypted value — a single number or many at once — where

sign(x) =  1  if x > 0
sign(x) =  0  if x = 0
sign(x) = -1  if x < 0

The function is the foundation of encrypted comparison. Once sign(a - b) can be evaluated, the rest follows directly:

comp(a, b) = (sign(a - b) + 1) / 2
max (a, b) = ((a + b) + (a - b) · sign(a - b)) / 2

and from comparison and maximum come sorting, ranking and max-pooling. That makes it one of the most reused non-linear components in encrypted computation.

It is hard precisely because it is non-linear and discontinuous at zero, while encrypted arithmetic offers a restricted set of operations. The kernel therefore defines what the function is and how accurate the answer must be — nothing about how to get there.

The encryption scheme, the packing of elements into a ciphertext, the evaluation keys, the approximation strategy and the depth it consumes are all properties of an implementation, not of this kernel. A Chebyshev approximation under CKKS, a piecewise-linear one, a programmable bootstrap under TFHE and an exact arithmetic-circuit evaluation are all valid realizations, and comparing them is the entire point.

INTERFACE

encrypted_sign(
  in  ct     : Ciphertext  // an encrypted value — a single number or many
  out ct     : Ciphertext  // the encrypted result, one sign per input value
  ...               // anything else the realization needs — keys, context, encoding — is its own concern
)

PARAMETER SCHEMA

NAMETYPERANGE
value_countinteger1 – 2^20
element_abs_maxnumber0.001 – 1000000
target_precisionnumber0.5 – 1
zero_includedbooleantrue, false

The schema belongs to the kernel. Each implementation declares which part of it it supports.

CORRECTNESS

01Element i of the output encodes the sign of element i of the input.
02Comparison and maximum derived from it must hold: comp(a,b) = (sign(a−b)+1)/2 and max(a,b) = ((a+b)+(a−b)·sign(a−b))/2.
03Accuracy is measured per element as 1 - |expected - obtained|; an element below the required precision does not count as correct.
04Values at or near zero are part of the test set rather than excluded from it.
05The output is decryptable by the party that supplied the input, under the same keys.

Where the arithmetic is approximate, correctness is a precision threshold rather than bit-exactness. The threshold belongs to the benchmark case; the requirement to meet it belongs here.

SECURITY PROPERTIES

The kernel adds no secrecy requirement of its own — security is whatever the parameters of the chosen scheme provide, and is declared per implementation. What the kernel does require is that evaluation never depends on a decrypted value, since it never has one.

ASSUMPTIONS

Whatever material the evaluation needs is generated honestly and supplied with the input; producing it is outside the operation and outside the measurement.

REFERENCES

Encrypted Sign Function · FHERMA