mirror of
https://github.com/tuneinsight/lattigo.git
synced 2025-09-13 03:27:14 +00:00
typo
This commit is contained in:
@@ -278,7 +278,7 @@ func testRelinKeyGen(testCtx testContext, t *testing.T) {
|
||||
ringQP := params.RingQP()
|
||||
levelQ, levelP := params.QCount()-1, params.PCount()-1
|
||||
|
||||
decompPW2 := params.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := params.DecompPw2(levelQ, levelP)
|
||||
|
||||
t.Run(testString(params, "RelinKeyGen"), func(t *testing.T) {
|
||||
|
||||
@@ -352,7 +352,7 @@ func testRelinKeyGen(testCtx testContext, t *testing.T) {
|
||||
}
|
||||
|
||||
log2Bound := bits.Len64(uint64(params.N() * len(swk.Value) * len(swk.Value[0]) * (params.N()*3*int(math.Floor(rlwe.DefaultSigma*6)) + 2*3*int(math.Floor(rlwe.DefaultSigma*6)) + params.N()*3)))
|
||||
for i := 0; i < decompPW2; i++ {
|
||||
for i := 0; i < decompPw2; i++ {
|
||||
|
||||
// P*s^i + sum(e) - P*s^i = sum(e)
|
||||
ringQ.Sub(swk.Value[0][i].Value[0].Q, skIn.Value.Q, swk.Value[0][i].Value[0].Q)
|
||||
@@ -385,7 +385,7 @@ func testRotKeyGen(testCtx testContext, t *testing.T) {
|
||||
ringQP := params.RingQP()
|
||||
levelQ, levelP := params.QCount()-1, params.PCount()-1
|
||||
|
||||
decompPW2 := params.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := params.DecompPw2(levelQ, levelP)
|
||||
|
||||
t.Run(testString(params, "RotKeyGen"), func(t *testing.T) {
|
||||
|
||||
@@ -455,7 +455,7 @@ func testRotKeyGen(testCtx testContext, t *testing.T) {
|
||||
}
|
||||
|
||||
log2Bound := bits.Len64(uint64(params.N() * len(swk.Value) * len(swk.Value[0]) * (params.N()*3*int(math.Floor(rlwe.DefaultSigma*6)) + 2*3*int(math.Floor(rlwe.DefaultSigma*6)) + params.N()*3)))
|
||||
for i := 0; i < decompPW2; i++ {
|
||||
for i := 0; i < decompPw2; i++ {
|
||||
|
||||
// P*s^i + sum(e) - P*s^i = sum(e)
|
||||
ringQ.Sub(swk.Value[0][i].Value[0].Q, skIn.Value.Q, swk.Value[0][i].Value[0].Q)
|
||||
|
||||
@@ -83,15 +83,15 @@ func (ekg *RKGProtocol) AllocateShare() (ephSk *rlwe.SecretKey, r1 *RKGShare, r2
|
||||
r1, r2 = new(RKGShare), new(RKGShare)
|
||||
|
||||
decompRNS := params.DecompRNS(params.QCount()-1, params.PCount()-1)
|
||||
decompPW2 := params.DecompPW2(params.QCount()-1, params.PCount()-1)
|
||||
decompPw2 := params.DecompPw2(params.QCount()-1, params.PCount()-1)
|
||||
|
||||
r1.Value = make([][][2]ringqp.Poly, decompRNS)
|
||||
r2.Value = make([][][2]ringqp.Poly, decompRNS)
|
||||
|
||||
for i := 0; i < decompRNS; i++ {
|
||||
r1.Value[i] = make([][2]ringqp.Poly, decompPW2)
|
||||
r2.Value[i] = make([][2]ringqp.Poly, decompPW2)
|
||||
for j := 0; j < decompPW2; j++ {
|
||||
r1.Value[i] = make([][2]ringqp.Poly, decompPw2)
|
||||
r2.Value[i] = make([][2]ringqp.Poly, decompPw2)
|
||||
for j := 0; j < decompPw2; j++ {
|
||||
r1.Value[i][j][0] = ekg.params.RingQP().NewPoly()
|
||||
r1.Value[i][j][1] = ekg.params.RingQP().NewPoly()
|
||||
r2.Value[i][j][0] = ekg.params.RingQP().NewPoly()
|
||||
@@ -106,12 +106,12 @@ func (ekg *RKGProtocol) AllocateShare() (ephSk *rlwe.SecretKey, r1 *RKGShare, r2
|
||||
func (ekg *RKGProtocol) SampleCRP(crs CRS) RKGCRP {
|
||||
params := ekg.params
|
||||
decompRNS := params.DecompRNS(params.QCount()-1, params.PCount()-1)
|
||||
decompPW2 := params.DecompPW2(params.QCount()-1, params.PCount()-1)
|
||||
decompPw2 := params.DecompPw2(params.QCount()-1, params.PCount()-1)
|
||||
|
||||
crp := make([][]ringqp.Poly, decompRNS)
|
||||
us := ringqp.NewUniformSampler(crs, *params.RingQP())
|
||||
for i := range crp {
|
||||
crp[i] = make([]ringqp.Poly, decompPW2)
|
||||
crp[i] = make([]ringqp.Poly, decompPw2)
|
||||
for j := range crp[i] {
|
||||
crp[i][j] = params.RingQP().NewPoly()
|
||||
us.Read(crp[i][j])
|
||||
|
||||
@@ -70,13 +70,13 @@ func (rtg *RTGProtocol) AllocateShare() (rtgShare *RTGShare) {
|
||||
|
||||
params := rtg.params
|
||||
decompRNS := rtg.params.DecompRNS(params.QCount()-1, params.PCount()-1)
|
||||
decompPW2 := rtg.params.DecompPW2(params.QCount()-1, params.PCount()-1)
|
||||
decompPw2 := rtg.params.DecompPw2(params.QCount()-1, params.PCount()-1)
|
||||
|
||||
rtgShare.Value = make([][]ringqp.Poly, decompRNS)
|
||||
|
||||
for i := 0; i < decompRNS; i++ {
|
||||
rtgShare.Value[i] = make([]ringqp.Poly, decompPW2)
|
||||
for j := 0; j < decompPW2; j++ {
|
||||
rtgShare.Value[i] = make([]ringqp.Poly, decompPw2)
|
||||
for j := 0; j < decompPw2; j++ {
|
||||
rtgShare.Value[i][j] = rtg.params.RingQP().NewPoly()
|
||||
}
|
||||
}
|
||||
@@ -89,13 +89,13 @@ func (rtg *RTGProtocol) SampleCRP(crs CRS) RTGCRP {
|
||||
|
||||
params := rtg.params
|
||||
decompRNS := rtg.params.DecompRNS(params.QCount()-1, params.PCount()-1)
|
||||
decompPW2 := rtg.params.DecompPW2(params.QCount()-1, params.PCount()-1)
|
||||
decompPw2 := rtg.params.DecompPw2(params.QCount()-1, params.PCount()-1)
|
||||
|
||||
crp := make([][]ringqp.Poly, decompRNS)
|
||||
us := ringqp.NewUniformSampler(crs, *params.RingQP())
|
||||
for i := 0; i < decompRNS; i++ {
|
||||
crp[i] = make([]ringqp.Poly, decompPW2)
|
||||
for j := 0; j < decompPW2; j++ {
|
||||
crp[i] = make([]ringqp.Poly, decompPw2)
|
||||
for j := 0; j < decompPw2; j++ {
|
||||
crp[i][j] = rtg.params.RingQP().NewPoly()
|
||||
us.Read(crp[i][j])
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ func (enc *Encryptor) Encrypt(pt *rlwe.Plaintext, ct interface{}) {
|
||||
levelP := rgswCt.LevelP()
|
||||
|
||||
decompRNS := params.DecompRNS(levelQ, levelP)
|
||||
decompPW2 := params.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := params.DecompPw2(levelQ, levelP)
|
||||
|
||||
for j := 0; j < decompPW2; j++ {
|
||||
for j := 0; j < decompPw2; j++ {
|
||||
for i := 0; i < decompRNS; i++ {
|
||||
enc.EncryptZero(&rgswCt.Value[0].Value[i][j])
|
||||
enc.EncryptZero(&rgswCt.Value[1].Value[i][j])
|
||||
|
||||
@@ -115,7 +115,7 @@ func (eval *Evaluator) externalProductInPlaceSinglePAndBitDecomp(ct0 *rlwe.Ciphe
|
||||
}
|
||||
|
||||
decompRNS := eval.params.DecompRNS(levelQ, levelP)
|
||||
decompPW2 := eval.params.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := eval.params.DecompPw2(levelQ, levelP)
|
||||
|
||||
// (a, b) + (c0 * rgsw[k][0], c0 * rgsw[k][1])
|
||||
for k, el := range rgsw.Value {
|
||||
@@ -123,7 +123,7 @@ func (eval *Evaluator) externalProductInPlaceSinglePAndBitDecomp(ct0 *rlwe.Ciphe
|
||||
cw := eval.BuffQP[0].Q.Coeffs[0]
|
||||
cwNTT := eval.BuffBitDecomp
|
||||
for i := 0; i < decompRNS; i++ {
|
||||
for j := 0; j < decompPW2; j++ {
|
||||
for j := 0; j < decompPw2; j++ {
|
||||
ring.MaskVec(eval.BuffInvNTT.Coeffs[i], cw, j*pw2, mask)
|
||||
if k == 0 && i == 0 && j == 0 {
|
||||
|
||||
|
||||
@@ -120,11 +120,11 @@ func NewEvaluator(paramsLUT, paramsLWE rlwe.Parameters, rtks *rlwe.RotationKeySe
|
||||
levelQ := paramsLUT.QCount() - 1
|
||||
levelP := paramsLUT.PCount() - 1
|
||||
decompRNS := paramsLUT.DecompRNS(levelQ, levelP)
|
||||
decompPW2 := paramsLUT.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := paramsLUT.DecompPw2(levelQ, levelP)
|
||||
ringQP := paramsLUT.RingQP()
|
||||
eval.tmpRGSW = rgsw.NewCiphertext(levelQ, levelP, decompRNS, decompPW2, *ringQP)
|
||||
eval.tmpRGSW = rgsw.NewCiphertext(levelQ, levelP, decompRNS, decompPw2, *ringQP)
|
||||
|
||||
eval.one = rgsw.NewPlaintext(uint64(1), levelQ, levelP, paramsLUT.Pow2Base(), decompPW2, *ringQP)
|
||||
eval.one = rgsw.NewPlaintext(uint64(1), levelQ, levelP, paramsLUT.Pow2Base(), decompPw2, *ringQP)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -42,13 +42,13 @@ func GenEvaluationKey(paramsRLWE rlwe.Parameters, skRLWE *rlwe.SecretKey, params
|
||||
MinusOneMform := ring.MForm(Q-1, Q, ringQ.BredParams[0])
|
||||
|
||||
decompRNS := paramsRLWE.DecompRNS(levelQ, levelP)
|
||||
decompPW2 := paramsRLWE.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := paramsRLWE.DecompPw2(levelQ, levelP)
|
||||
ringQP := *paramsRLWE.RingQP()
|
||||
|
||||
for i, si := range skLWEInvNTT.Coeffs[0] {
|
||||
|
||||
skRGSWPos[i] = rgsw.NewCiphertext(levelQ, levelP, decompRNS, decompPW2, ringQP)
|
||||
skRGSWNeg[i] = rgsw.NewCiphertext(levelQ, levelP, decompRNS, decompPW2, ringQP)
|
||||
skRGSWPos[i] = rgsw.NewCiphertext(levelQ, levelP, decompRNS, decompPw2, ringQP)
|
||||
skRGSWNeg[i] = rgsw.NewCiphertext(levelQ, levelP, decompRNS, decompPw2, ringQP)
|
||||
|
||||
// sk_i = 1 -> [RGSW(1), RGSW(0)]
|
||||
if si == OneMForm {
|
||||
|
||||
@@ -134,7 +134,7 @@ func (eval *Evaluator) GadgetProductSinglePAndBitDecompNoModDown(levelQ int, cx
|
||||
levelP := gadgetCt.LevelP()
|
||||
|
||||
decompRNS := eval.params.DecompRNS(levelQ, levelP)
|
||||
decompPW2 := eval.params.DecompPW2(levelQ, levelP)
|
||||
decompPw2 := eval.params.DecompPw2(levelQ, levelP)
|
||||
|
||||
pw2 := eval.params.pow2Base
|
||||
|
||||
@@ -155,7 +155,7 @@ func (eval *Evaluator) GadgetProductSinglePAndBitDecompNoModDown(levelQ int, cx
|
||||
// Key switching with CRT decomposition for the Qi
|
||||
var reduce int
|
||||
for i := 0; i < decompRNS; i++ {
|
||||
for j := 0; j < decompPW2; j++ {
|
||||
for j := 0; j < decompPw2; j++ {
|
||||
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], cw, j*pw2, mask)
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ func NewSwitchingKey(params Parameters, levelQ, levelP int) *SwitchingKey {
|
||||
levelQ,
|
||||
levelP,
|
||||
params.DecompRNS(levelQ, levelP),
|
||||
params.DecompPW2(levelQ, levelP),
|
||||
params.DecompPw2(levelQ, levelP),
|
||||
*params.RingQP())}
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ func (p Parameters) MaxBit(levelQ, levelP int) (c int) {
|
||||
}
|
||||
|
||||
// DecompPW2 returns ceil(p.MaxBitQ(levelQ, levelP)/bitDecomp).
|
||||
func (p Parameters) DecompPW2(levelQ, levelP int) (c int) {
|
||||
func (p Parameters) DecompPw2(levelQ, levelP int) (c int) {
|
||||
if p.pow2Base == 0 {
|
||||
return 1
|
||||
}
|
||||
@@ -495,6 +495,7 @@ func (p Parameters) MarshalBinary() ([]byte, error) {
|
||||
// 1 byte : logN
|
||||
// 1 byte : #Q
|
||||
// 1 byte : #P
|
||||
// 1 byte : pow2Base
|
||||
// 8 byte : H
|
||||
// 8 byte : sigma
|
||||
// 1 byte : ringType
|
||||
|
||||
@@ -212,7 +212,7 @@ func testSwitchKeyGen(kgen KeyGenerator, t *testing.T) {
|
||||
skIn := kgen.GenSecretKey()
|
||||
skOut := kgen.GenSecretKey()
|
||||
levelQ, levelP := params.QCount()-1, params.PCount()-1
|
||||
decompPW2 := params.DecompPW2(levelQ, levelP)
|
||||
decompPW2 := params.DecompPw2(levelQ, levelP)
|
||||
|
||||
// Generates Decomp([-asIn + w*P*sOut + e, a])
|
||||
swk := NewSwitchingKey(params, params.QCount()-1, params.PCount()-1)
|
||||
|
||||
Reference in New Issue
Block a user