Lattigo

Lattigo attributes

BGVParametersLiteralAttr

Literal parameters for Lattigo BGV

Syntax:

#lattigo.bgv.parameters_literal<
  int,   # logN
  DenseI64ArrayAttr,   # Q
  DenseI64ArrayAttr,   # P
  DenseI32ArrayAttr,   # logQ
  DenseI32ArrayAttr,   # logP
  int64_t   # plaintextModulus
>

This attribute represents the literal parameters for Lattigo BGV.

This is in accordance with https://pkg.go.dev/github.com/tuneinsight/lattigo/v6@v6.1.0/schemes/bgv#ParametersLiteral where some field are not present in the current implementation.

Users must set the polynomial degree (LogN) and the coefficient modulus, by either setting the Q and P fields to the desired moduli chain, or by setting the LogQ and LogP fields to the desired moduli sizes.

Note that for Lattigo, Q/P requires []uint64, where this attribute only provides int64. We assume user should not select moduli so large to consider the signedness issue.

Users must also specify the coefficient modulus in plaintext-space (T). This modulus must be an NTT-friendly prime in the plaintext space: it must be equal to 1 modulo 2n where n is the plaintext ring degree (i.e., the plaintext space has n slots).

Parameters:

ParameterC++ typeDescription
logNint
QDenseI64ArrayAttr
PDenseI64ArrayAttr
logQDenseI32ArrayAttr
logPDenseI32ArrayAttr
plaintextModulusint64_t

Lattigo types

BGVEncoderType

Syntax: !lattigo.bgv.encoder

This type represents the encoder for the BGV encryption scheme.

BGVEvaluatorType

Syntax: !lattigo.bgv.evaluator

This type represents the evaluator for the BGV encryption scheme.

BGVParameterType

Syntax: !lattigo.bgv.parameter

This type represents the parameters for the BGV encryption scheme.

RLWECiphertextType

Syntax: !lattigo.rlwe.ciphertext

This type represents the ciphertext for the RLWE encryption scheme.

RLWEDecryptorType

Syntax: !lattigo.rlwe.decryptor

This type represents the decryptor for the RLWE encryption scheme.

RLWEEncryptorType

Syntax: !lattigo.rlwe.encryptor

This type represents the encryptor for the RLWE encryption scheme.

RLWEEvaluationKeySetType

Syntax: !lattigo.rlwe.evaluation_key_set

This type represents the evaluation key set for the RLWE encryption scheme.

RLWEGaloisKeyType

Syntax:

!lattigo.rlwe.galois_key<
  ::mlir::IntegerAttr   # galoisElement
>

This type represents the Galois key for the RLWE encryption scheme.

galoisElement: Enabling the automorphism X -> X^{galoisElement}.

Parameters:

ParameterC++ typeDescription
galoisElement::mlir::IntegerAttrAn Attribute containing a integer value

RLWEKeyGeneratorType

Syntax: !lattigo.rlwe.key_generator

This type represents the key generator for the RLWE encryption scheme.

RLWEPlaintextType

Syntax: !lattigo.rlwe.plaintext

This type represents the plaintext for the RLWE encryption scheme.

RLWEPublicKeyType

Syntax: !lattigo.rlwe.public_key

This type represents the public key for the RLWE encryption scheme.

RLWERelinearizationKeyType

Syntax: !lattigo.rlwe.relinearization_key

This type represents the relinearization key for the RLWE encryption scheme.

RLWESecretKeyType

Syntax: !lattigo.rlwe.secret_key

This type represents the secret key for the RLWE encryption scheme.

Lattigo ops

lattigo.bgv.add (heir::lattigo::BGVAddOp)

Add two ciphertexts in the Lattigo BGV dialect

Syntax:

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

This operation adds two ciphertext values in the Lattigo BGV dialect.

Operands:

OperandDescription
evaluator
lhs
rhs

Results:

ResultDescription
output

lattigo.bgv.decode (heir::lattigo::BGVDecodeOp)

Decode a plaintext value in the Lattigo BGV dialect

Syntax:

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

This operation decodes a plaintext value using the specified encoder in the Lattigo BGV dialect.

Operands:

OperandDescription
encoder
plaintext
valueany type

Results:

ResultDescription
decodedany type

lattigo.bgv.encode (heir::lattigo::BGVEncodeOp)

Encode a plaintext value in the Lattigo BGV dialect

Syntax:

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

This operation encodes a plaintext value using the specified encoder in the Lattigo BGV dialect.

Operands:

OperandDescription
encoder
valueany type
plaintext

Results:

ResultDescription
encoded

lattigo.bgv.mul (heir::lattigo::BGVMulOp)

Multiply two ciphertexts in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.mul` operands attr-dict `:` functional-type(operands, results)

This operation multiplies two ciphertext values in the Lattigo BGV dialect.

Operands:

OperandDescription
evaluator
lhs
rhs

Results:

ResultDescription
output

lattigo.bgv.new_encoder (heir::lattigo::BGVNewEncoderOp)

Create a new encoder in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.new_encoder` operands attr-dict `:` functional-type(operands, results)

This operation creates a new encoder for encoding plaintext values in the Lattigo BGV dialect.

Operands:

OperandDescription
params

Results:

ResultDescription
encoder

lattigo.bgv.new_evaluator (heir::lattigo::BGVNewEvaluatorOp)

Create a new evaluator in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.new_evaluator` operands attr-dict `:` functional-type(operands, results)

This operation creates a new evaluator for performing operations on ciphertexts in the Lattigo BGV dialect.

By default, the evaluator is created with the provided parameters and could execute operations which does not relying on evaluation keys.

To support operations that require evaluation keys, the optional evaluation key set should be provided.

Operands:

OperandDescription
params
evaluationKeySet

Results:

ResultDescription
evaluator

lattigo.bgv.new_parameters_from_literal (heir::lattigo::BGVNewParametersFromLiteralOp)

Create new BGV parameters from a literal in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.new_parameters_from_literal` operands attr-dict `:` functional-type(operands, results)

This operation creates new BGV parameters from a given literal value in the Lattigo BGV dialect.

Attributes:

AttributeMLIR TypeDescription
paramsLiteral::mlir::heir::lattigo::BGVParametersLiteralAttrLiteral parameters for Lattigo BGV

Results:

ResultDescription
params

lattigo.bgv.new_plaintext (heir::lattigo::BGVNewPlaintextOp)

Create a new plaintext in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.new_plaintext` operands attr-dict `:` functional-type(operands, results)

This operation creates a new plaintext value in the Lattigo BGV dialect.

Operands:

OperandDescription
params

Results:

ResultDescription
plaintext

lattigo.bgv.relinearize (heir::lattigo::BGVRelinearizeOp)

Relinearize a ciphertext in the Lattigo BGV dialect

Syntax:

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

This operation relinearizes a ciphertext value in the Lattigo BGV dialect.

Operands:

OperandDescription
evaluator
input

Results:

ResultDescription
output

lattigo.bgv.rescale (heir::lattigo::BGVRescaleOp)

Rescale a ciphertext in the Lattigo BGV dialect

Syntax:

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

This operation rescales a ciphertext value in the Lattigo BGV dialect.

Operands:

OperandDescription
evaluator
input

Results:

ResultDescription
output

lattigo.bgv.rotate_columns (heir::lattigo::BGVRotateColumnsOp)

Rotate columns of a ciphertext in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.rotate_columns` operands attr-dict `:` functional-type(operands, results)

This operation rotates the columns of a ciphertext value in the Lattigo BGV dialect.

Lattigo exposes the SIMD slot of BGV as a N/2 x 2 matrix, where N/2 is the column.

offset is valid in (-N/2, N/2).

Attributes:

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

Operands:

OperandDescription
evaluator
input

Results:

ResultDescription
output

lattigo.bgv.rotate_rows (heir::lattigo::BGVRotateRowsOp)

Rotate rows of a ciphertext in the Lattigo BGV dialect

Syntax:

operation ::= `lattigo.bgv.rotate_rows` operands attr-dict `:` functional-type(operands, results)

This operation swap the rows of a ciphertext value in the Lattigo BGV dialect.

Lattigo exposes the SIMD slot of BGV as a N/2 x 2 matrix, where 2 is the row.

Operands:

OperandDescription
evaluator
input

Results:

ResultDescription
output

lattigo.bgv.sub (heir::lattigo::BGVSubOp)

Subtract two ciphertexts in the Lattigo BGV dialect

Syntax:

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

This operation subtracts one ciphertext value from another in the Lattigo BGV dialect.

Operands:

OperandDescription
evaluator
lhs
rhs

Results:

ResultDescription
output

lattigo.rlwe.decrypt (heir::lattigo::RLWEDecryptOp)

Decrypts a ciphertext using RLWE

Syntax:

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

This operation decrypts a ciphertext using RLWE

Operands:

OperandDescription
decryptor
ciphertext

Results:

ResultDescription
plaintext

lattigo.rlwe.encrypt (heir::lattigo::RLWEEncryptOp)

Encrypts a plaintext using RLWE

Syntax:

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

This operation encrypts a plaintext using RLWE

Operands:

OperandDescription
encryptor
plaintext

Results:

ResultDescription
ciphertext

lattigo.rlwe.gen_galois_key (heir::lattigo::RLWEGenGaloisKeyOp)

Generates a new RLWE Galois key

Syntax:

operation ::= `lattigo.rlwe.gen_galois_key` operands attr-dict `:` functional-type(operands, results)

This operation generates a new RLWE Galois key

galoisElement: Enabling the automorphism X -> X^{galoisElement}.

Attributes:

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

Operands:

OperandDescription
keyGenerator
secretKey

Results:

ResultDescription
galoisKey

lattigo.rlwe.gen_key_pair (heir::lattigo::RLWEGenKeyPairOp)

Generates a new RLWE key pair

Syntax:

operation ::= `lattigo.rlwe.gen_key_pair` operands attr-dict `:` functional-type(operands, results)

This operation generates a new RLWE key pair

Operands:

OperandDescription
keyGenerator

Results:

ResultDescription
secretKey
publicKey

lattigo.rlwe.gen_relinearization_key (heir::lattigo::RLWEGenRelinearizationKeyOp)

Generates a new RLWE relinearization key

Syntax:

operation ::= `lattigo.rlwe.gen_relinearization_key` operands attr-dict `:` functional-type(operands, results)

This operation generates a new RLWE relinearization key

Operands:

OperandDescription
keyGenerator
secretKey

Results:

ResultDescription
relinearizationKey

lattigo.rlwe.new_decryptor (heir::lattigo::RLWENewDecryptorOp)

Creates a new RLWE decryptor

Syntax:

operation ::= `lattigo.rlwe.new_decryptor` operands attr-dict `:` functional-type(operands, results)

This operation creates a new RLWE decryptor

Operands:

OperandDescription
params
secretKey

Results:

ResultDescription
decryptor

lattigo.rlwe.new_encryptor (heir::lattigo::RLWENewEncryptorOp)

Creates a new RLWE encryptor

Syntax:

operation ::= `lattigo.rlwe.new_encryptor` operands attr-dict `:` functional-type(operands, results)

This operation creates a new RLWE encryptor

Operands:

OperandDescription
params
publicKey

Results:

ResultDescription
encryptor

lattigo.rlwe.new_evaluation_key_set (heir::lattigo::RLWENewEvaluationKeySetOp)

Generates a new RLWE evaluation key set

Syntax:

operation ::= `lattigo.rlwe.new_evaluation_key_set` operands attr-dict `:` functional-type(operands, results)

This operation generates a new RLWE evaluation key set

Operands:

OperandDescription
relinearizationKey
galoisKeysvariadic of

Results:

ResultDescription
evaluationKeySet

lattigo.rlwe.new_key_generator (heir::lattigo::RLWENewKeyGeneratorOp)

Generates a new RLWE key generator

Syntax:

operation ::= `lattigo.rlwe.new_key_generator` operands attr-dict `:` functional-type(operands, results)

This operation generates a new RLWE key generator

Operands:

OperandDescription
params

Results:

ResultDescription
keyGenerator