Skip to main content

HomOps Reference

HomRotateSum

Rotate a ciphertext by fixed offsets, then optionally sum the copies.

RtSlots
RunsServer
Changes shapeUnchanged when summing; new leading axis when stacking
Changes scaleNo
Levels spent0
RotatesYes - listed offsets
KeysRotation key

What it does

HomRotateSum applies a set of Galois rotations to a ciphertext and, by default, sums the rotated copies with the original. It is the low-level rotate-and-add primitive behind expand trees, slot summation, matmul diagonals, and convolution.
With perform_sum=True (the default), every listed offset is rotated and added into one ciphertext of the same shape. With perform_sum=False, the rotated copies are stacked on a new leading axis instead of being reduced. You will mostly meet this operator inside higher-level ops such as HomSumSlots and HomExpand; write it yourself when you need an explicit set of offsets.

Signature

HomRotateSum(
    rotations,                          # offsets
    perform_sum=True,
    add_identity_rotation=False,
)
No set_data. Offsets are deduplicated and sorted internally.

Parameters

ParameterTypeDefaultDescription
rotationssequence | setrequiredRotation offsets to apply (deduplicated and sorted).
perform_sumboolTrueIf True, sum all rotated copies with the original. If False, stack the rotations on a new leading axis.
add_identity_rotationboolFalseWhen stacking (perform_sum=False), also keep an identity copy as an extra entry on the new axis. When summing, the identity is already included in the sum path.
Rules that depend on the value
SettingRuleIf you break it
rotationsAn empty set is allowed but typically useless - nothing rotates.Not an error; the op becomes a no-op sum/stack.

Requirements

  • Rotation key entries. Every offset in rotations must be present in the evaluation key. The compiler derives the exact set; you don't list them yourself.
  • No square key. Rotations and additions only.
These surface as compilation errors; see Compilation errors.

Shape effect

ModeOutput shape
perform_sum=TrueSame as input
perform_sum=FalseInsert axis 0 of size len(rotations) + int(add_identity_rotation)
Example: input (N,) through HomRotateSum(rotations=[2, 4, 8], perform_sum=True) stays (N,); each slot holds the sum of the identity plus the three rotations.

Scale effect - no

Rotations and additions only; the scale carries through unchanged.

Level budget

Zero. There is no mod-switch inside this operator. Rotation depth still costs evaluation time and needs keys, but it does not drop a modulus prime by itself.

Keys

Rotation key. Every listed offset needs an entry, derived at compile time and generated for you during key generation. No square key.

Example

Rotate-and-add over three power-of-two offsets:
pipeline.pyPYTHON
from lattica_build.operators import HomRotateSum
from lattica_build.base_classes.hom_pipeline import HomomorphicPipeline
from lattica_build.operators.composite.sequential import SequentialHomOp

pipeline = HomomorphicPipeline(
    hom=SequentialHomOp(
        HomRotateSum(rotations=[2, 4, 8], perform_sum=True),
    ),
    input_shape=(128,),
)

See also