Skip to main content

HomOps Reference

HomMin

Element-wise minimum of two encrypted values via polynomial comparison.

MnComparison
RunsServer
Changes shapeYes - broadcast
Changes scaleYes - via nested ops
Levels spentTunable - poly depth + mul
RotatesNo
KeysSquare key

What it does

HomMin computes the element-wise minimum of two encrypted values using a soft comparison:
a_is_greater = Compare(a, b), then min(a, b) = a − (a − b) · a_is_greater.
It is a composite, not a registered leaf: the compiler expands it into nested HomCompare / HomSign poly stages plus multiply and add/sub (including HomSub). Inputs must lie in [0, 1]; the current calibration rejects any other domain.
For the matching maximum, see HomMax. Prefer HomMin / HomMax in graphs; the shared core is HomMinMax.

Signature

HomMin(
    x_accuracy=10,
    y_accuracy=10,
    left=0.0,
    right=1.0,
    tol=1e-8,
    rows_budget=None,
)
Two ciphertext inputs. No set_data. Internally builds Compare with sign accuracy derived from x_accuracy.

Parameters

ParameterTypeDefaultDescription
x_accuracyint10Horizontal accuracy α. Must be in {4, …, 14}. Converted to sign accuracy via the α→ζ table below.
y_accuracyfloat10Vertical accuracy passed to HomCompare / Sign.
left, rightfloat0.0, 1.0Input domain. Must be 0.0 and 1.0; any other pair raises ValueError.
tolfloat1e-8Poly eval tolerance, forwarded to nested stages.
rows_budgetsequenceNoneRestricts which levels the nested mod-switches may spend. See rows_budget.
Rules that depend on the value
SettingRuleIf you break it
left, rightMust be exactly 0.0 and 1.0 (α–ζ calibration).ValueError at construction.
x_accuracyMust be a key in the α→ζ table (414).ValueError at construction.
α→ζ mapping used to derive Sign accuracy:
α (x_accuracy)ζ
45
55
610
711
812
913
1013
1115
1215
1316
1417

Requirements

  • Domain [0, 1]. Both inputs must lie in [0, 1], and left/right must stay at those defaults.
  • Square key. Nested Sign / PolyEval / Mul stages need the square key (generated for you during key generation).
  • Two inputs. Broadcast-compatible encrypted tensors.
  • Not a leaf. HomMin expands into nested ops; it is not a registered backend leaf.

Shape effect - yes

Element-wise; the output shape follows the broadcast of a and b through the child arithmetic.

Scale effect - yes

Scale is set by nested Compare → Sign poly stages, plus one multiply and add/sub. Check the compile-time simulation for the output scale.
How scale moves through a pipeline is on Ciphertext state - Scale.

Level budget

Plan levels like a multi-stage PolyEval plus one Mul: depth follows nested Compare / Sign accuracy, then the correction multiply. Tunable via x_accuracy / y_accuracy.
How primes are organized in the chain is explained on Level budget - The chain.

Keys

Square key (relinearization key). Required through nested children. Generated for you during key generation. No rotation key unless a child introduces rotations.

Example

Element-wise min on values in [0, 1]:
pipeline.pyPYTHON
from lattica_build.operators import HomMin

h_min = HomMin(x_accuracy=7, y_accuracy=7, left=0.0, right=1.0)
# out = h_min(a, b)

See also

  • HomMax - the matching element-wise maximum
  • HomMinMax - shared min/max core; prefer HomMin in graphs
  • HomCompare - soft comparison underneath
  • HomSign - multi-stage Chebyshev sign
  • HomSub - ciphertext difference in the correction