rgsw

package
v6.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rgsw implements an RLWE-based GSW encryption and external product RLWE x RGSW -> RLWE. RSGW ciphertexts are tuples of two rlwe.GadgetCiphertext encrypting (`m(X)`, s*m(X)).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLazy

func AddLazy(op interface{}, ringQP ringqp.Ring, opOut *Ciphertext)

AddLazy adds op to opOut, without modular reduction.

func MulByXPowAlphaMinusOneLazy

func MulByXPowAlphaMinusOneLazy(ctIn *Ciphertext, powXMinusOne ringqp.Poly, ringQP ringqp.Ring, opOut *Ciphertext)

MulByXPowAlphaMinusOneLazy multiplies opOut by (X^alpha - 1) and returns the result on opOut.

func MulByXPowAlphaMinusOneThenAddLazy

func MulByXPowAlphaMinusOneThenAddLazy(ctIn *Ciphertext, powXMinusOne ringqp.Poly, ringQP ringqp.Ring, opOut *Ciphertext)

MulByXPowAlphaMinusOneThenAddLazy multiplies opOut by (X^alpha - 1) and adds the result on opOut.

func NoiseRGSWCiphertext

func NoiseRGSWCiphertext(ct *Ciphertext, pt ring.Poly, sk *rlwe.SecretKey, params rlwe.Parameters) (float64, float64)

NoiseRGSWCiphertext returns the log2 of the standard deviation of the noise of each component of the RGSW ciphertext. pt must be in the NTT and Montgomery domain

func Reduce

func Reduce(ctIn *Ciphertext, ringQP ringqp.Ring, opOut *Ciphertext)

Reduce applies the modular reduction on ctIn and returns the result on opOut.

Types

type Ciphertext

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

Ciphertext is a generic type for RGSW ciphertext.

func NewCiphertext

func NewCiphertext(params rlwe.Parameters, levelQ, levelP, BaseTwoDecomposition int) (ct *Ciphertext)

NewCiphertext allocates a new RGSW Ciphertext in the NTT domain.

func (Ciphertext) BinarySize

func (ct Ciphertext) BinarySize() int

BinarySize returns the serialized size of the object in bytes.

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.

func (Ciphertext) MarshalBinary

func (ct Ciphertext) MarshalBinary() (p []byte, err error)

MarshalBinary encodes the object into a binary form on a newly allocated slice of bytes.

func (*Ciphertext) ReadFrom

func (ct *Ciphertext) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads on the object from an io.Writer. It implements the io.ReaderFrom interface.

Unless r implements the buffer.Reader interface (see see lattigo/utils/buffer/reader.go), it will be wrapped into a bufio.Reader. Since this requires allocation, it is preferable to pass a buffer.Reader directly:

  • When reading multiple values from a io.Reader, it is preferable to first first wrap io.Reader in a pre-allocated bufio.Reader.
  • When reading from a var b []byte, it is preferable to pass a buffer.NewBuffer(b) as w (see lattigo/utils/buffer/buffer.go).

func (*Ciphertext) UnmarshalBinary

func (ct *Ciphertext) UnmarshalBinary(p []byte) (err error)

UnmarshalBinary decodes a slice of bytes generated by Ciphertext.MarshalBinary or Ciphertext.WriteTo on the object.

func (Ciphertext) WriteTo

func (ct Ciphertext) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the object on an io.Writer. It implements the io.WriterTo interface, and will write exactly object.BinarySize() bytes on w.

Unless w implements the buffer.Writer interface (see lattigo/utils/buffer/writer.go), it will be wrapped into a bufio.Writer. Since this requires allocations, it is preferable to pass a buffer.Writer directly:

  • When writing multiple times to a io.Writer, it is preferable to first wrap the io.Writer in a pre-allocated bufio.Writer.
  • When writing to a pre-allocated var b []byte, it is preferable to pass buffer.NewBuffer(b) as w (see lattigo/utils/buffer/buffer.go).

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 rlwe.Encryptor.Encrypt and rlwe.Encryptor.EncryptZero methods to accept rgsw.Ciphertext types in addition to ciphertexts types in the rlwe package.

func NewEncryptor

func NewEncryptor(params rlwe.ParameterProvider, key rlwe.EncryptionKey) *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{}) (err error)

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{}) (err error)

EncryptZero generates an encryption of zero into a ciphertext ct, which can be a rgsw.Ciphertext or any of the `rlwe` ciphertext 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
}

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.ParameterProvider, evk rlwe.EvaluationKeySet) *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, opOut *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(evk rlwe.EvaluationKeySet) *Evaluator

WithKey creates a shallow copy of the receiver Evaluator for which the evaluation key is set to the provided rlwe.EvaluationKeySet 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(params rlwe.Parameters, value interface{}, levelQ, levelP, BaseTwoDecomposition int) (*Plaintext, error)

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

Directories

Path Synopsis
Package blindrot implements blind rotations evaluation for RLWE schemes.
Package blindrot implements blind rotations evaluation for RLWE schemes.

Jump to

Keyboard shortcuts

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