Skip to content

Commit

Permalink
precompute rotated ciphertexts in linear transform evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
qantik committed Jun 12, 2024
1 parent 7e7719c commit 18cde0c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions he/linear_transformation_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ func EvaluateLinearTransformationsMany(evalLT EvaluatorForLinearTransformation,

evalDiag.Decompose(level, ctIn, BuffDecompQP)

ctPreRot := map[int]*rlwe.Element[ringqp.Poly]{}
// precompute all rotated ciphertexts for each linear transform
ctPreRot := make([]map[int]*rlwe.Element[ringqp.Poly], len(linearTransformations))
for i, lt := range linearTransformations {
if lt.N1 == 0 {
continue
}
ctPreRot[i] = map[int]*rlwe.Element[ringqp.Poly]{}
_, _, rotN2 := lt.BSGSIndex()
if err = evalDiag.GetPreRotatedCiphertextForDiagonalMatrixMultiplication(level, ctIn, BuffDecompQP, rotN2, ctPreRot[i]); err != nil {
return
}
}

for i, lt := range linearTransformations {

Expand All @@ -64,14 +75,7 @@ func EvaluateLinearTransformationsMany(evalLT EvaluatorForLinearTransformation,
return
}
} else {

_, _, rotN2 := lt.BSGSIndex()

if err = evalDiag.GetPreRotatedCiphertextForDiagonalMatrixMultiplication(level, ctIn, BuffDecompQP, rotN2, ctPreRot); err != nil {
return
}

if err = evalDiag.MultiplyByDiagMatrixBSGS(ctIn, lt, ctPreRot, opOut[i]); err != nil {
if err = evalDiag.MultiplyByDiagMatrixBSGS(ctIn, lt, ctPreRot[i], opOut[i]); err != nil {
return
}
}
Expand Down

0 comments on commit 18cde0c

Please sign in to comment.