FHERMA
L3 · FUNCTIONALMEASURED

Encrypted Softmax

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

Create implementationSpecification

DESCRIPTION

Evaluates

softmax(x)_i = exp(x_i) / Σ_j exp(x_j)

over an encrypted vector.

Two things separate this from an elementwise activation. First, the denominator is a sum over all elements, so a realization needs to move data between slots — rotations, or whatever the scheme offers — and that cost dominates. Second, the plaintext trick of subtracting the maximum for numerical stability is itself an encrypted maximum, so stability is not free.

The kernel requires a distribution as output: non-negative and summing to one within the declared precision.

INTERFACE

encrypted_softmax(
  in  ct     : Ciphertext  // an encrypted vector of scores
  out ct     : Ciphertext  // the encrypted distribution over those scores
  ...               // anything else the realization needs — keys, context, encoding — is its own concern
)

PARAMETER SCHEMA

NAMETYPERANGE
value_countinteger1 – 2^16
element_abs_maxnumber0.001 – 1000
target_precisionnumber0.5 – 1

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

CORRECTNESS

01The output is a distribution: every element non-negative, and the elements summing to one within the declared precision.
02Order is preserved — the largest score maps to the largest probability.
03Accuracy holds when scores are close together, which is the case that separates real approximations from ones tuned to a wide gap.

SECURITY PROPERTIES

No secrecy requirement beyond that of the scheme in use.

ASSUMPTIONS

The vector to normalize is packed contiguously, and the parameters leave enough depth for both the exponential and the normalization.

REFERENCES

Encrypted Softmax · FHERMA