rgsw

package
v4.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package rgsw implements an RLWE-based RGSW encryption scheme. In RSGW, ciphertexts are tuples of two gadget ciphertexts where the first gadget ciphertext encrypts the message and the second gadget ciphertext encrypts the message times the secret. This package only implements a subset of the RGSW scheme that is necessary for bridging between RLWE and LWE-based schemes and for supporting look-up table evaluation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNoModLvl

func AddNoModLvl(levelQ, levelP int, op interface{}, ringQP ringqp.Ring, ctOut *Ciphertext)

AddNoModLvl adds op to ctOut, without modular reduction.

func MulByXPowAlphaMinusOneAndAddNoModLvl

func MulByXPowAlphaMinusOneAndAddNoModLvl(levelQ, levelP int, ctIn *Ciphertext, powXMinusOne ringqp.Poly, ringQP ringqp.Ring, ctOut *Ciphertext)

MulByXPowAlphaMinusOneAndAddNoModLvl multiplies ctOut by (X^alpha - 1) and adds the result on ctOut.

func MulByXPowAlphaMinusOneConstantLvl

func MulByXPowAlphaMinusOneConstantLvl(levelQ, levelP int, ctIn *Ciphertext, powXMinusOne ringqp.Poly, ringQP ringqp.Ring, ctOut *Ciphertext)

MulByXPowAlphaMinusOneConstantLvl multiplies ctOut by (X^alpha - 1) and returns the result on ctOut.

func ReduceLvl

func ReduceLvl(levelQ, levelP int, ctIn *Ciphertext, ringQP ringqp.Ring, ctOut *Ciphertext)

ReduceLvl applies the modular reduction on ctIn and returns the result on ctOut.

Types

type Ciphertext

type Ciphertext struct {
	Value [2]rlwe.GadgetCiphertext
}

Ciphertext is a generic type for RGSW ciphertext.

func NewCiphertext

func NewCiphertext(levelQ, levelP, decompRNS, decompBit int, ringQP ringqp.Ring) (ct *Ciphertext)

NewCiphertext allocates a new RGSW ciphertext in the NTT domain.

func (*Ciphertext) LevelP

func (ct *Ciphertext) LevelP() int

LevelP returns the level of the modulus P of the target.

func (*Ciphertext) LevelQ

func (ct *Ciphertext) LevelQ() int

LevelQ returns the level of the modulus Q of the target.

type Encryptor

type Encryptor struct {
	rlwe.Encryptor
	// contains filtered or unexported fields
}

Encryptor is a type for encrypting RGSW ciphertexts. It implements the rlwe.Encryptor interface overriding the `Encrypt` and `EncryptZero` methods to accept rgsw.Ciphertext types in addition to ciphertexts types in the rlwe package.

func NewEncryptor

func NewEncryptor(params rlwe.Parameters, sk *rlwe.SecretKey) *Encryptor

NewEncryptor creates a new Encryptor type. Note that only secret-key encryption is supported at the moment.

func (*Encryptor) Encrypt

func (enc *Encryptor) Encrypt(pt *rlwe.Plaintext, ct interface{})

Encrypt encrypts a plaintext pt into a ciphertext ct, which can be a rgsw.Ciphertext or any of the `rlwe` cipheretxt types.

func (*Encryptor) EncryptZero

func (enc *Encryptor) EncryptZero(ct interface{})

EncryptZero generates an encryption of zero into a ciphertext ct, which can be a rgsw.Ciphertext or any of the `rlwe` cipheretxt types.

func (*Encryptor) ShallowCopy

func (enc *Encryptor) ShallowCopy() *Encryptor

ShallowCopy creates a shallow copy of this Encryptor in which all the read-only data-structures are shared with the receiver and the temporary buffers are reallocated. The receiver and the returned Encryptors can be used concurrently.

type Evaluator

type Evaluator struct {
	rlwe.Evaluator
	// contains filtered or unexported fields
}

Evaluator is a type for evaluating homomorphic operations involving RGSW ciphertexts. It currently supports the external product between a RLWE and a RGSW ciphertext (see Evaluator.ExternalProduct).

func NewEvaluator

func NewEvaluator(params rlwe.Parameters, evk *rlwe.EvaluationKey) *Evaluator

NewEvaluator creates a new Evaluator type supporting RGSW operations in addition to rlwe.Evaluator operations.

func (*Evaluator) ExternalProduct

func (eval *Evaluator) ExternalProduct(op0 *rlwe.Ciphertext, op1 *Ciphertext, op2 *rlwe.Ciphertext)

ExternalProduct computes RLWE x RGSW -> RLWE

RLWE : (-as + m + e, a)
x
RGSW : [(-as + P*w*m1 + e, a), (-bs + e, b + P*w*m1)]
=
RLWE : (<RLWE, RGSW[0]>, <RLWE, RGSW[1]>)

func (*Evaluator) ShallowCopy

func (eval *Evaluator) ShallowCopy() *Evaluator

ShallowCopy creates a shallow copy of this Evaluator in which all the read-only data-structures are shared with the receiver and the temporary buffers are reallocated. The receiver and the returned Evaluators can be used concurrently.

func (*Evaluator) WithKey

func (eval *Evaluator) WithKey(evaluationKey *rlwe.EvaluationKey) *Evaluator

WithKey creates a shallow copy of the receiver Evaluator for which the new EvaluationKey is evaluationKey and where the temporary buffers are shared. The receiver and the returned Evaluators cannot be used concurrently.

type Plaintext

type Plaintext rlwe.GadgetPlaintext

Plaintext stores an RGSW plaintext value.

func NewPlaintext

func NewPlaintext(value interface{}, levelQ, levelP, logBase2, decompBIT int, ringQP ringqp.Ring) (pt *Plaintext)

NewPlaintext creates a new RGSW plaintext from value, which can be either uint64, int64 or *ring.Poly. Plaintext is returned in the NTT and Mongtomery domain.

Directories

Path Synopsis
Package lut implements look-up tables evaluation for R-LWE schemes.
Package lut implements look-up tables evaluation for R-LWE schemes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL