Cheddar

‘cheddar’ Dialect

The cheddar dialect is an exit dialect for generating C++ code against the CHEDDAR GPU FHE library API.

CHEDDAR is a CKKS-only GPU-accelerated FHE library. It supports both 32-bit and 64-bit word types, with 32-bit being the primary fast path on GPUs.

See the Cheddar GitHub repository

Cheddar types

BootContextType

Syntax: !cheddar.boot_context

This type represents a CHEDDAR BootContext: a Context extended with bootstrapping support, created via BootContext::Create(param, boot_param). A BootContext is-a Context in CHEDDAR, so it is accepted anywhere a Context is via the Cheddar_AnyContext constraint; only cheddar.boot requires it specifically (so the emitter can call BootContext::Boot with no downcast).

CiphertextType

Syntax: !cheddar.ciphertext

This type represents a CHEDDAR Ciphertext. Move-only, lives on GPU.

ConstantType

Syntax: !cheddar.constant

This type represents a CHEDDAR Constant. A scalar in RNS form, used for efficient ciphertext-scalar operations.

ContextType

Syntax: !cheddar.context

This type represents a CHEDDAR Context, the main server-side computation engine. Created via Context::Create(param).

EncoderType

Syntax: !cheddar.encoder

This type represents the CHEDDAR Encoder, accessed via context->encoder_. Used for encoding/decoding plaintext values.

EvalKeyType

Syntax: !cheddar.eval_key

This type represents a single CHEDDAR EvaluationKey.

EvkMapType

Syntax: !cheddar.evk_map

This type represents a CHEDDAR EvkMap, which bundles all evaluation keys (multiplication, rotation, conjugation, etc.) into a single map.

ParameterType

Syntax: !cheddar.parameter

This type represents a CHEDDAR Parameter object, constructed from a JSON file or programmatically.

PlaintextType

Syntax: !cheddar.plaintext

This type represents a CHEDDAR Plaintext. Contains an NTT-applied encoded message.

UserInterfaceType

Syntax: !cheddar.user_interface

This type represents the CHEDDAR UserInterface, used for key generation, encryption, and decryption. Note: this is for test purposes only and is not security-hardened.

Cheddar ops

cheddar.add (heir::cheddar::AddOp)

Add two ciphertexts

Syntax:

operation ::= `cheddar.add` operands attr-dict `:` functional-type(operands, results)

Calls context->Add(res, a, b).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
lhsTensor or MemRef of values
rhsTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.add_const (heir::cheddar::AddConstOp)

Add a constant to a ciphertext

Syntax:

operation ::= `cheddar.add_const` operands attr-dict `:` functional-type(operands, results)

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ciphertextTensor or MemRef of values
constantTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.add_plain (heir::cheddar::AddPlainOp)

Add a plaintext to a ciphertext

Syntax:

operation ::= `cheddar.add_plain` operands attr-dict `:` functional-type(operands, results)

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ciphertextTensor or MemRef of values
plaintextTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.boot (heir::cheddar::BootOp)

Bootstrap a ciphertext

Syntax:

operation ::= `cheddar.boot` operands attr-dict `:` functional-type(operands, results)

Calls boot_ctx->Boot(res, input, evk_map). Refreshes the ciphertext noise budget.

Requires a !cheddar.boot_context (not a plain !cheddar.context): Boot is a BootContext method, so this op statically guarantees the context it runs on is a BootContext and the emitter needs no downcast.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface, ResetsMulDepthOpInterface

Operands:

OperandDescription
ctx
inputTensor or MemRef of values
evkMap
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.create_boot_context (heir::cheddar::CreateBootContextOp)

Create a CHEDDAR bootstrapping context from parameters

Syntax:

operation ::= `cheddar.create_boot_context` operands attr-dict `:` functional-type(operands, results)

Creates a BootContext<word> from a Parameter object (DPS), for programs that bootstrap. Bootstrapping is parameterized by the CoeffToSlot (CtS) and SlotToCoeff (StC) level budgets – a depth/rotation trade-off that mirrors OpenFHE’s levelBudgetEncode/levelBudgetDecode – carried here as the numCtsLevels/numStcLevels attributes. $output is the destination buffer hint; after bufferization the result becomes a memref<!cheddar.boot_context> re-typed to std::shared_ptr<BootContext<word>>& at the emitc boundary: ctx_out = BootContext<word>::Create(params, BootParameter(params.max_level_, numCtsLevels, numStcLevels, logMessageRatio)).

logMessageRatio ~ log2(q0 / scale): the headroom between the bottom modulus and the message scale that CHEDDAR’s EvalMod assumes. It governs bootstrap precision – too small and large messages hit the sine-approximation domain edge, too large and the absolute noise floor (~ q0/scale) dominates small messages. When omitted, the emitter falls back to CHEDDAR’s default.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
numCtsLevels::mlir::IntegerAttrAn Attribute containing a integer value
numStcLevels::mlir::IntegerAttrAn Attribute containing a integer value
logMessageRatio::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
params
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.create_context (heir::cheddar::CreateContextOp)

Create a CHEDDAR context from parameters

Syntax:

operation ::= `cheddar.create_context` operands attr-dict `:` functional-type(operands, results)

Creates a CHEDDAR Context from a Parameter object (DPS). The result is the owning context (the main server-side computation engine); $output is the destination buffer hint. After bufferization the destination is a memref<!cheddar.context> re-typed to std::shared_ptr<Context<word>>& at the emitc boundary, so a generated __configure hands the context back through an out-param: ctx_out = Context<word>::Create(params).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
params
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.create_user_interface (heir::cheddar::CreateUserInterfaceOp)

Create a CHEDDAR UserInterface for key gen and encrypt/decrypt

Syntax:

operation ::= `cheddar.create_user_interface` operands attr-dict `:` functional-type(operands, results)

Creates a UserInterface from an owning context (DPS). The result is the owning user_interface; $output is the destination buffer hint (becomes a std::unique_ptr<UserInterface<word>>& out-param at the boundary): ui_out = std::make_unique<UserInterface<word>>(ctx).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxTensor or MemRef of or values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.decode (heir::cheddar::DecodeOp)

Decode a CHEDDAR plaintext back to a message vector

Syntax:

operation ::= `cheddar.decode` operands attr-dict `:` functional-type(operands, results)

Calls encoder.Decode(message, pt). value is the destination buffer the decoded message is written into (the DPS init); the DPS interface verifier ties it 1:1 to the decoded result (same type).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
encoder
plaintextTensor or MemRef of values
valueTensor or MemRef of floating-point or complex-type values

Results:

ResultDescription
decodedvariadic of ranked tensor of any non-token type values

cheddar.decrypt (heir::cheddar::DecryptOp)

Decrypt a ciphertext into a plaintext

Syntax:

operation ::= `cheddar.decrypt` operands attr-dict `:` functional-type(operands, results)

Calls ui.Decrypt(pt, ct). Test-only operation. $output is the destination plaintext.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ui
ciphertextTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.encode (heir::cheddar::EncodeOp)

Encode a message vector into a CHEDDAR plaintext

Syntax:

operation ::= `cheddar.encode` operands attr-dict `:` functional-type(operands, results)

Calls encoder.Encode(pt, level, scale, message). The message is a vector of complex numbers (or reals). scale is the C++ double value used by CHEDDAR’s Encoder. $output is the destination plaintext.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface, PlaintextEncodeOpInterface

Attributes:

AttributeMLIR TypeDescription
level::mlir::IntegerAttrAn Attribute containing a integer value
scale::mlir::FloatAttr64-bit float attribute

Operands:

OperandDescription
encoder
messageTensor or MemRef of floating-point or complex-type values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.encode_constant (heir::cheddar::EncodeConstantOp)

Encode a scalar double into a CHEDDAR constant

Syntax:

operation ::= `cheddar.encode_constant` operands attr-dict `:` functional-type(operands, results)

Calls encoder.EncodeConstant(constant, level, scale, number). The result is in RNS form for efficient ciphertext-scalar ops. scale is the C++ double value used by CHEDDAR’s Encoder. $output is the destination constant.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
level::mlir::IntegerAttrAn Attribute containing a integer value
scale::mlir::FloatAttr64-bit float attribute

Operands:

OperandDescription
encoder
valuefloating-point
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.encrypt (heir::cheddar::EncryptOp)

Encrypt a plaintext into a ciphertext

Syntax:

operation ::= `cheddar.encrypt` operands attr-dict `:` functional-type(operands, results)

Calls ui.Encrypt(ct, pt). Test-only operation. $output is the destination ciphertext.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ui
plaintextTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.eval_poly (heir::cheddar::EvalPolyOp)

Evaluate a polynomial on a ciphertext

Syntax:

operation ::= `cheddar.eval_poly` operands attr-dict `:` functional-type(operands, results)

Evaluates a polynomial (e.g., Chebyshev approximation) on an encrypted input using CHEDDAR’s EvalPoly extension. level is the level the input ciphertext enters at; outputLevel is the level the result lands at after the polynomial’s multiplicative depth.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
coefficients::mlir::ArrayAttr64-bit float array attribute
level::mlir::IntegerAttrAn Attribute containing a integer value
outputLevel::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
evkMap
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.get_encoder (heir::cheddar::GetEncoderOp)

Get the encoder from a CHEDDAR context

Syntax:

operation ::= `cheddar.get_encoder` operands attr-dict `:` functional-type(operands, results)

Returns a reference to the context’s encoder (context->encoder_).

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

OperandDescription
ctxor

Results:

ResultDescription
encoder

cheddar.get_evk_map (heir::cheddar::GetEvkMapOp)

Get the evaluation key map from a UserInterface

Syntax:

operation ::= `cheddar.get_evk_map` operands attr-dict `:` functional-type(operands, results)

Returns the EvkMap from the UserInterface (ui.GetEvkMap()).

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

OperandDescription
ui

Results:

ResultDescription
evkMap

cheddar.get_mult_key (heir::cheddar::GetMultKeyOp)

Get the multiplication evaluation key

Syntax:

operation ::= `cheddar.get_mult_key` operands attr-dict `:` functional-type(operands, results)

Returns the multiplication key from the UserInterface (ui.GetMultiplicationKey()).

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands:

OperandDescription
ui

Results:

ResultDescription
key

cheddar.hconj (heir::cheddar::HConjOp)

Fused key-switch + conjugation

Syntax:

operation ::= `cheddar.hconj` operands attr-dict `:` functional-type(operands, results)

Calls context->HConj(res, a, conj_key). The conjugation key is looked up from the $ui UserInterface operand.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ui
inputTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.hconj_add (heir::cheddar::HConjAddOp)

Fused conjugation + addition

Syntax:

operation ::= `cheddar.hconj_add` operands attr-dict `:` functional-type(operands, results)

Computes res = conj(a) + b in a single fused GPU kernel. Calls context->HConjAdd(res, a, b, conj_key). The conjugation key is looked up from the $ui UserInterface operand.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ui
inputTensor or MemRef of values
addendTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.hmult (heir::cheddar::HMultOp)

Fused multiply + relinearize (+ optional rescale)

Syntax:

operation ::= `cheddar.hmult` operands attr-dict `:` functional-type(operands, results)

Calls context->HMult(res, a, b, mult_key, rescale). Single fused GPU kernel launch. The rescale attribute controls whether rescaling is included (default: true).

Interfaces: DestinationStyleOpInterface, IncreasesMulDepthOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
rescale::mlir::BoolAttrbool attribute

Operands:

OperandDescription
ctxor
lhsTensor or MemRef of values
rhsTensor or MemRef of values
multKey
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.hrot (heir::cheddar::HRotOp)

Fused key-switch + rotation

Syntax:

operation ::= `cheddar.hrot` operands attr-dict `:` functional-type(operands, results)

Calls context->HRot(res, a, rot_key, distance). The rotation key is looked up from the $ui UserInterface operand using distance. Single fused GPU kernel. Supports both static and dynamic distances.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface, RotationOpInterface

Attributes:

AttributeMLIR TypeDescription
static_distance::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
ctxor
ui
inputTensor or MemRef of values
outputTensor or MemRef of values
dynamic_distancesignless integer or index

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.hrot_add (heir::cheddar::HRotAddOp)

Fused rotation + addition

Syntax:

operation ::= `cheddar.hrot_add` operands attr-dict `:` functional-type(operands, results)

Computes res = rotate(a, distance) + b in a single fused GPU kernel. Calls context->HRotAdd(res, a, b, rot_key, distance). The rotation key is looked up from the $ui UserInterface operand using distance.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface, RotationOpInterface

Attributes:

AttributeMLIR TypeDescription
distance::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
ctxor
ui
inputTensor or MemRef of values
addendTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.level_down (heir::cheddar::LevelDownOp)

Reduce ciphertext to a target level

Syntax:

operation ::= `cheddar.level_down` operands attr-dict `:` functional-type(operands, results)

Calls context->LevelDown(res, a, target_level).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
targetLevel::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.linear_transform (heir::cheddar::LinearTransformOp)

Apply a linear transform on a ciphertext

Syntax:

operation ::= `cheddar.linear_transform` operands attr-dict `:` functional-type(operands, results)

Applies a matrix-vector product using CHEDDAR’s LinearTransform extension with BSGS optimization and hoisting.

The diagonals input is a 2D tensor where each row is a non-zero diagonal. The diagonal_indices attribute specifies which diagonal each row represents. The level attribute specifies the modulus level for the operation.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface, RotationOpInterface

Attributes:

AttributeMLIR TypeDescription
diagonal_indices::mlir::DenseI32ArrayAttri32 dense array attribute
level::mlir::IntegerAttrAn Attribute containing a integer value
bs::mlir::IntegerAttrAn Attribute containing a integer value
gs::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
evkMap
diagonalsTensor or MemRef of floating-point values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.mad_unsafe (heir::cheddar::MadUnsafeOp)

Fused multiply-accumulate with constant (no rescale)

Syntax:

operation ::= `cheddar.mad_unsafe` operands attr-dict `:` functional-type(operands, results)

Computes res += a * constant (in-place accumulation). Calls context->MadUnsafe(res, a, constant). The $accumulator operand is the in-place destination (the DPS init); the result is tied to it.

Note: this op would typically be called mac, the current name reflects the spelling in Cheddar (MadUnsafe).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
accumulatorTensor or MemRef of values
inputTensor or MemRef of values
constantTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.make_parameter (heir::cheddar::MakeParameterOp)

Construct a CHEDDAR Parameter from CKKS scheme parameters

Syntax:

operation ::= `cheddar.make_parameter` attr-dict `:` type($params)

Builds a cheddar::Parameter<word> from the CKKS modulus chain. The main primes are the CKKS Q limbs and the aux primes are the P limbs; the canonical level config is one-main-prime-per-level ({{1, 0}, {2, 0}, ...}) and the default encryption level is #mainPrimes - 1, both derived from mainPrimes by the emitter. logScale is the log2 of the default CKKS scale. This is the single setup op that produces the !cheddar.parameter consumed by cheddar.create_context, so a generated __configure is self-contained.

Bootstrapping programs override the defaults: defaultEncryptionLevel pins the encryption level below the chain top (the boot-circuit primes sit above it), and denseHammingWeight/sparseHammingWeight set the secret-key hamming weights CHEDDAR’s BootContext requires. Each is omitted (and the emitter falls back to #mainPrimes - 1 / not emitting a SetHammingWeight call) for non-bootstrapping programs.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes:

AttributeMLIR TypeDescription
logN::mlir::IntegerAttrAn Attribute containing a integer value
logScale::mlir::IntegerAttrAn Attribute containing a integer value
mainPrimes::mlir::DenseI64ArrayAttri64 dense array attribute
auxPrimes::mlir::DenseI64ArrayAttri64 dense array attribute
defaultEncryptionLevel::mlir::IntegerAttrAn Attribute containing a integer value
denseHammingWeight::mlir::IntegerAttrAn Attribute containing a integer value
sparseHammingWeight::mlir::IntegerAttrAn Attribute containing a integer value

Results:

ResultDescription
params

cheddar.mult (heir::cheddar::MultOp)

Multiply two ciphertexts (tensor product, no relin/rescale)

Syntax:

operation ::= `cheddar.mult` operands attr-dict `:` functional-type(operands, results)

Calls context->Mult(res, a, b). Produces a degree-3 ciphertext. Does NOT include relinearization or rescaling.

Interfaces: DestinationStyleOpInterface, IncreasesMulDepthOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
lhsTensor or MemRef of values
rhsTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.mult_const (heir::cheddar::MultConstOp)

Multiply a ciphertext by a constant (no rescale)

Syntax:

operation ::= `cheddar.mult_const` operands attr-dict `:` functional-type(operands, results)

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ciphertextTensor or MemRef of values
constantTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.mult_plain (heir::cheddar::MultPlainOp)

Multiply a ciphertext by a plaintext (no rescale)

Syntax:

operation ::= `cheddar.mult_plain` operands attr-dict `:` functional-type(operands, results)

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ciphertextTensor or MemRef of values
plaintextTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.neg (heir::cheddar::NegOp)

Negate a ciphertext

Syntax:

operation ::= `cheddar.neg` operands attr-dict `:` functional-type(operands, results)

Calls context->Neg(res, a).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.prepare_bootstrap (heir::cheddar::PrepareBootstrapOp)

Run the one-time bootstrap precompute and rotation-key setup

Syntax:

operation ::= `cheddar.prepare_bootstrap` operands attr-dict `:` functional-type(operands, results)

Performs the one-time bootstrapping preparation on a !cheddar.boot_context and threads the resulting rotation keys into the UserInterface (DPS on $ui). Emits the canonical CHEDDAR sequence: ctx->PrepareEvalMod(); ctx->PrepareEvalSpecialFFT(numSlots); EvkRequest req; ctx->AddRequiredRotations(req, numSlots); ui->PrepareRotationKey(req); numSlots is the number of slots the bootstrap refreshes (full-slot boot uses the context’s slot count). Must run after the boot context + user interface are created and (for programs that also rotate outside boot) after the program’s own prepare_rot_keys, so all keys land in one EvkMap.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
numSlots::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
ctxTensor or MemRef of values
uiTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.prepare_rot_key (heir::cheddar::PrepareRotKeyOp)

Generate a rotation key for a given distance

Syntax:

operation ::= `cheddar.prepare_rot_key` operands attr-dict `:` functional-type(operands, results)

Calls ui->PrepareRotationKey(distance, maxLevel) to generate a rotation key, mutating the UserInterface in place. DPS: $ui is the in-place destination and the result is the updated UserInterface (threaded to the next setup op / the configure return). Must be called before using rotation with that distance; maxLevel is the maximum ciphertext level at which the key will be used.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Attributes:

AttributeMLIR TypeDescription
distance::mlir::IntegerAttrAn Attribute containing a integer value
maxLevel::mlir::IntegerAttrAn Attribute containing a integer value

Operands:

OperandDescription
uiTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.relinearize (heir::cheddar::RelinearizeOp)

Relinearize a ciphertext (without rescale)

Syntax:

operation ::= `cheddar.relinearize` operands attr-dict `:` functional-type(operands, results)

Calls context->Relinearize(res, a, mult_key).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
multKey
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.relinearize_rescale (heir::cheddar::RelinearizeRescaleOp)

Fused relinearize + rescale

Syntax:

operation ::= `cheddar.relinearize_rescale` operands attr-dict `:` functional-type(operands, results)

Calls context->RelinearizeRescale(res, a, mult_key). Faster than separate Relinearize + Rescale.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
multKey
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.rescale (heir::cheddar::RescaleOp)

Rescale a ciphertext (drop one level)

Syntax:

operation ::= `cheddar.rescale` operands attr-dict `:` functional-type(operands, results)

Calls context->Rescale(res, a). Reduces the ciphertext level by 1.

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
inputTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.sub (heir::cheddar::SubOp)

Subtract two ciphertexts

Syntax:

operation ::= `cheddar.sub` operands attr-dict `:` functional-type(operands, results)

Calls context->Sub(res, a, b).

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
lhsTensor or MemRef of values
rhsTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values

cheddar.sub_plain (heir::cheddar::SubPlainOp)

Subtract a plaintext from a ciphertext

Syntax:

operation ::= `cheddar.sub_plain` operands attr-dict `:` functional-type(operands, results)

Interfaces: DestinationStyleOpInterface, MemoryEffectOpInterface

Operands:

OperandDescription
ctxor
ciphertextTensor or MemRef of values
plaintextTensor or MemRef of values
outputTensor or MemRef of values

Results:

ResultDescription
resultvariadic of ranked tensor of values