CKKS
‘ckks’ Dialect
The CKKS dialect defines the types and operations of the CKKS cryptosystem.
CKKS ops
ckks.add
(heir::ckks::AddOp)
Addition operation between ciphertexts.
Syntax:
operation ::= `ckks.add` operands attr-dict `:` qualified(type($output))
Traits: AlwaysSpeculatableImplTrait
, Commutative
, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
lhs | A type for RLWE ciphertexts |
rhs | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.add_plain
(heir::ckks::AddPlainOp)
Addition operation between ciphertext-plaintext.
Syntax:
operation ::= `ckks.add_plain` operands attr-dict `:` functional-type(operands, results)
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
ciphertextInput | A type for RLWE ciphertexts |
plaintextInput | A type for RLWE plaintexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.extract
(heir::ckks::ExtractOp)
Extract the i-th element of a ciphertext.
Syntax:
operation ::= `ckks.extract` operands attr-dict `:` functional-type(operands, results)
While this operation is costly to compute in FHE, we represent it so we can implement efficient lowerings and folders.
This op can be implemented as a plaintext multiplication with a one-hot vector and a rotate into the zero-th index.
An extraction op’s input ciphertext type is asserted to have an underlying_type
corresponding to a ranked tensor type, and this op’s return type is
inferred to have the underlying_type
corresponding to the element type of
that tensor type.
Traits: SameOperandsAndResultRings
Operands:
Operand | Description |
---|---|
input | A type for RLWE ciphertexts |
offset | signless integer or index |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.mul
(heir::ckks::MulOp)
Multiplication operation between ciphertexts.
Syntax:
operation ::= `ckks.mul` operands attr-dict `:` functional-type(operands, results)
Traits: AlwaysSpeculatableImplTrait
, Commutative
, InferTypeOpAdaptor
, SameOperandsAndResultRings
, SameTypeOperands
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
lhs | A type for RLWE ciphertexts |
rhs | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.mul_plain
(heir::ckks::MulPlainOp)
Multiplication operation between ciphertext-plaintext.
Syntax:
operation ::= `ckks.mul_plain` operands attr-dict `:` functional-type(operands, results)
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
ciphertextInput | A type for RLWE ciphertexts |
plaintextInput | A type for RLWE plaintexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.negate
(heir::ckks::NegateOp)
Negate the coefficients of the ciphertext.
Syntax:
operation ::= `ckks.negate` operands attr-dict `:` qualified(type($output))
Traits: AlwaysSpeculatableImplTrait
, Involution
, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
input | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.relinearize
(heir::ckks::RelinearizeOp)
Relinearize the ciphertext.
Syntax:
operation ::= `ckks.relinearize` operands attr-dict `:` qualified(type($input)) `->` qualified(type($output))
This op takes integer array attributes from_basis
and to_basis
that are
used to indicate the key basis from which and to which the ciphertext is
encrypted against. A ciphertext is canonically encrypted against key basis
(1, s)
. After a multiplication, its size will increase and the basis will be
(1, s, s^2)
. The array that represents the key basis is constructed by
listing the powers of s
at each position of the array. For example, (1, s, s^2)
corresponds to [0, 1, 2]
, while (1, s^2)
corresponds to [0, 2]
.
Traits: AlwaysSpeculatableImplTrait
, InferTypeOpAdaptor
, SameOperandsAndResultRings
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
from_basis | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
to_basis | ::mlir::DenseI32ArrayAttr | i32 dense array attribute |
Operands:
Operand | Description |
---|---|
input | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.rescale
(heir::ckks::RescaleOp)
Rescales the ciphertext, which is the CKKS version of modulus switching in BGV/BFV.
Syntax:
operation ::= `ckks.rescale` operands attr-dict `:` qualified(type($input)) `->` qualified(type($output))
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
to_ring | ::mlir::polynomial::RingAttr | an attribute specifying a polynomial ring |
Operands:
Operand | Description |
---|---|
input | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.rotate
(heir::ckks::RotateOp)
Rotate the coefficients of the ciphertext using a Galois automorphism.
Syntax:
operation ::= `ckks.rotate` operands attr-dict `:` qualified(type($input))
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
Attribute | MLIR Type | Description |
---|---|---|
offset | ::mlir::IntegerAttr | An Attribute containing a integer value |
Operands:
Operand | Description |
---|---|
input | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.sub
(heir::ckks::SubOp)
Subtraction operation between ciphertexts.
Syntax:
operation ::= `ckks.sub` operands attr-dict `:` qualified(type($output))
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface
Operands:
Operand | Description |
---|---|
lhs | A type for RLWE ciphertexts |
rhs | A type for RLWE ciphertexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |
ckks.sub_plain
(heir::ckks::SubPlainOp)
Subtraction operation between ciphertext-plaintext.
Syntax:
operation ::= `ckks.sub_plain` operands attr-dict `:` functional-type(operands, results)
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, InferTypeOpInterface
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
Operand | Description |
---|---|
ciphertextInput | A type for RLWE ciphertexts |
plaintextInput | A type for RLWE plaintexts |
Results:
Result | Description |
---|---|
output | A type for RLWE ciphertexts |