Documentation ¶
Overview ¶
Package ringqp is implements a wrapper for both the ringQ and ringP.
Index ¶
- type Poly
- func (p *Poly) Copy(other Poly)
- func (p *Poly) CopyNew() Poly
- func (p *Poly) Decode64(data []byte) (pt int, err error)
- func (p *Poly) Encode64(data []byte) (pt int, err error)
- func (p *Poly) Equals(other Poly) (v bool)
- func (p *Poly) LevelP() int
- func (p *Poly) LevelQ() int
- func (p *Poly) MarshalBinary() ([]byte, error)
- func (p *Poly) MarshalBinarySize64() (dataLen int)
- func (p *Poly) UnmarshalBinary(b []byte) error
- type Ring
- func (r *Ring) AddLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) AddNoModLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) CopyLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) EvalPolyScalar(pol []Poly, pt uint64, p3 Poly)
- func (r *Ring) ExtendBasisSmallNormAndCenter(polyInQ *ring.Poly, levelP int, polyOutQ, polyOutP *ring.Poly)
- func (r *Ring) InvMFormLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) InvNTTLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) Inverse(scalar ring.RNSScalar)
- func (r *Ring) MFormLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) MulCoeffsMontgomeryAndAddLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) MulCoeffsMontgomeryAndSubLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) MulCoeffsMontgomeryConstantAndAddNoModLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) MulCoeffsMontgomeryConstantAndSubNoModLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) MulCoeffsMontgomeryConstantLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) MulCoeffsMontgomeryLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) MulRNSScalar(s1, s2, sout ring.RNSScalar)
- func (r *Ring) MulRNSScalarMontgomery(p Poly, scalar []uint64, pOut Poly)
- func (r *Ring) MulScalarLvl(levelQ, levelP int, p1 Poly, scalar uint64, p2 Poly)
- func (r *Ring) NTTLazyLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) NTTLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) NegLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) NewPoly() Poly
- func (r *Ring) NewPolyLvl(levelQ, levelP int) Poly
- func (r *Ring) NewRNSScalar() ring.RNSScalar
- func (r *Ring) NewRNSScalarFromUInt64(v uint64) ring.RNSScalar
- func (r *Ring) PermuteNTTWithIndexAndAddNoModLvl(levelQ, levelP int, p1 Poly, index []uint64, p2 Poly)
- func (r *Ring) PermuteNTTWithIndexLvl(levelQ, levelP int, p1 Poly, index []uint64, p2 Poly)
- func (r *Ring) ReduceLvl(levelQ, levelP int, p1, p2 Poly)
- func (r *Ring) SubLvl(levelQ, levelP int, p1, p2, p3 Poly)
- func (r *Ring) SubRNSScalar(s1, s2, sout ring.RNSScalar)
- type UniformSampler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Poly ¶
Poly represents a polynomial in the ring of polynomial modulo Q*P. This type is simply the union type between two ring.Poly, each one containing the modulus Q and P coefficients of that polynomial. The modulus Q represent the ciphertext modulus and the modulus P the special primes for the RNS decomposition during homomorphic operations involving keys.
func (*Poly) Copy ¶
Copy copies the coefficients of other on the target polynomial. This method simply calls the Copy method for each of its sub-polynomials.
func (*Poly) Decode64 ¶
Decode64 decodes the input bytes on the target Poly. Writes on pre-allocated coefficients. Assumes that each coefficient is encoded on 8 bytes.
func (*Poly) Encode64 ¶
Encode64 writes a Poly on the input data. Encodes each coefficient on 8 bytes.
func (*Poly) Equals ¶
Equals returns true if the receiver Poly is equal to the provided other Poly. This method checks for equality of its two sub-polynomials.
func (*Poly) LevelP ¶
LevelP returns the level of the polynomial modulo P. Returns -1 if the modulus P is absent.
func (*Poly) LevelQ ¶
LevelQ returns the level of the polynomial modulo Q. Returns -1 if the modulus Q is absent.
func (*Poly) MarshalBinary ¶
func (*Poly) MarshalBinarySize64 ¶
MarshalBinarySize64 returns the length in byte of the target Poly. Assumes that each coefficient uses 8 bytes.
func (*Poly) UnmarshalBinary ¶
type Ring ¶
Ring is a structure that implements the operation in the ring R_QP. This type is simply a union type between the two Ring types representing R_Q and R_P.
func (*Ring) AddLvl ¶
AddLvl adds p1 to p2 coefficient-wise and writes the result on p3. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) AddNoModLvl ¶
AddNoModLvl adds p1 to p2 coefficient-wise and writes the result on p3 without modular reduction. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) CopyLvl ¶
CopyLvl copies the values of p1 on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) EvalPolyScalar ¶
EvalPolyScalar evaluate the polynomial pol at pt and writes the result in p3
func (*Ring) ExtendBasisSmallNormAndCenter ¶
func (r *Ring) ExtendBasisSmallNormAndCenter(polyInQ *ring.Poly, levelP int, polyOutQ, polyOutP *ring.Poly)
ExtendBasisSmallNormAndCenter extends a small-norm polynomial polQ in R_Q to a polynomial polQP in R_QP.
func (*Ring) InvMFormLvl ¶
InvMFormLvl switches back p1 from the Montgomery domain to the conventional domain and writes the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) InvNTTLvl ¶
InvNTTLvl computes the inverse-NTT of p1 and returns the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) Inverse ¶
Inverse computes the modular inverse of a scalar a expressed in a CRT decomposition. The inversion is done in-place and assumes that a is in Montgomery form.
func (*Ring) MFormLvl ¶
MFormLvl switches p1 to the Montgomery domain and writes the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) MulCoeffsMontgomeryAndAddLvl ¶
MulCoeffsMontgomeryAndAddLvl multiplies p1 by p2 coefficient-wise with a Montgomery modular reduction and adds the result to p3. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) MulCoeffsMontgomeryAndSubLvl ¶
MulCoeffsMontgomeryAndSubLvl multiplies p1 by p2 coefficient-wise with a Montgomery modular reduction and subtracts the result from p3. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) MulCoeffsMontgomeryConstantAndAddNoModLvl ¶
MulCoeffsMontgomeryConstantAndAddNoModLvl multiplies p1 by p2 coefficient-wise with a constant-time Montgomery modular reduction and adds the result on p3. Result is within [0, 2q-1]
func (*Ring) MulCoeffsMontgomeryConstantAndSubNoModLvl ¶
MulCoeffsMontgomeryConstantAndSubNoModLvl multiplies p1 by p2 coefficient-wise with a Montgomery modular reduction and subtracts the result from p3. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) MulCoeffsMontgomeryConstantLvl ¶
MulCoeffsMontgomeryConstantLvl multiplies p1 by p2 coefficient-wise with a constant-time Montgomery modular reduction. The operation is performed at levelQ for the ringQ and levelP for the ringP. Result is within [0, 2q-1].
func (*Ring) MulCoeffsMontgomeryLvl ¶
MulCoeffsMontgomeryLvl multiplies p1 by p2 coefficient-wise with a Montgomery modular reduction. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) MulRNSScalar ¶
MulRNSScalar multiplies s1 and s2 and stores the result in sout.
func (*Ring) MulRNSScalarMontgomery ¶
MulRNSScalarMontgomery multiplies p with a scalar value expressed in the CRT decomposition. It assumes the scalar decomposition to be in Montgomery form.
func (*Ring) MulScalarLvl ¶
MulScalarLvl multiplies p1 by scalar and returns the result in p2.
func (*Ring) NTTLazyLvl ¶
NTTLazyLvl computes the NTT of p1 and returns the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP. Output values are in the range [0, 2q-1].
func (*Ring) NTTLvl ¶
NTTLvl computes the NTT of p1 and returns the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) NegLvl ¶
NegLvl negates p1 coefficient-wise and writes the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) NewPolyLvl ¶
NewPolyLvl creates a new polynomial with all coefficients set to 0.
func (*Ring) NewRNSScalar ¶
NewRNSScalar creates a new Scalar value (i.e., a degree-0 polynomial) in the RingQP.
func (*Ring) NewRNSScalarFromUInt64 ¶
NewRNSScalarFromUInt64 creates a new Scalar in the RingQP initialized with value v.
func (*Ring) PermuteNTTWithIndexAndAddNoModLvl ¶
func (r *Ring) PermuteNTTWithIndexAndAddNoModLvl(levelQ, levelP int, p1 Poly, index []uint64, p2 Poly)
PermuteNTTWithIndexAndAddNoModLvl applies the automorphism X^{5^j} on p1 and adds the result on p2. Index of automorphism must be provided. Method is not in place. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) PermuteNTTWithIndexLvl ¶
PermuteNTTWithIndexLvl applies the automorphism X^{5^j} on p1 and writes the result on p2. Index of automorphism must be provided. Method is not in place. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) ReduceLvl ¶
ReduceLvl applies the modular reduction on the coefficients of p1 and returns the result on p2. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) SubLvl ¶
SubLvl subtracts p2 to p1 coefficient-wise and writes the result on p3. The operation is performed at levelQ for the ringQ and levelP for the ringP.
func (*Ring) SubRNSScalar ¶
SubRNSScalar subtracts s2 to s1 and stores the result in sout.
type UniformSampler ¶
type UniformSampler struct {
// contains filtered or unexported fields
}
UniformSampler is a type for sampling polynomials in Ring.
func NewUniformSampler ¶
func NewUniformSampler(prng utils.PRNG, r Ring) (s UniformSampler)
NewUniformSampler instantiates a new UniformSampler from a given PRNG.
func (UniformSampler) Read ¶
func (s UniformSampler) Read(p Poly)
Read samples a new polynomial in Ring and stores it into p.
func (UniformSampler) ReadLvl ¶
func (s UniformSampler) ReadLvl(levelQ, levelP int, p Poly)
ReadLvl samples a new polynomial in Ring and stores it into p.
func (UniformSampler) WithPRNG ¶
func (s UniformSampler) WithPRNG(prng utils.PRNG) UniformSampler