From 06fc09bbf842345f8456fbd1a667d531173dcaba Mon Sep 17 00:00:00 2001 From: Hwang In Tak Date: Mon, 22 Jul 2024 16:46:15 +0900 Subject: [PATCH] feat: Remove NewEvaluatorWithoutKey --- README.md | 2 +- mktfhe/evaluator.go | 8 +------- tfhe/evaluator.go | 6 ------ tfhe/tfhe_test.go | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f4b460c..f2249df 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ ctFlag := enc.EncryptFourierGGSW([]int{1}, gadgetParams) // Set up Evaluator. // Note that we don't need evaluation key for CMUX. -eval := tfhe.NewEvaluatorWithoutKey(params) +eval := tfhe.NewEvaluator(params, tfhe.EvaluationKey[uint64]{}) ctOut := eval.CMux(ctFlag, ct0, ct1) fmt.Println(enc.DecryptGLWE(ctOut)[0]) // 5 diff --git a/mktfhe/evaluator.go b/mktfhe/evaluator.go index 6c2395d..cc33037 100644 --- a/mktfhe/evaluator.go +++ b/mktfhe/evaluator.go @@ -96,7 +96,7 @@ func NewEvaluator[T tfhe.TorusInt](params Parameters[T], evk map[int]EvaluationK return &Evaluator[T]{ Encoder: tfhe.NewEncoder(params.Parameters), GLWETransformer: tfhe.NewGLWETransformer(params.Parameters), - BaseSingleKeyEvaluator: tfhe.NewEvaluatorWithoutKey(params.Parameters), + BaseSingleKeyEvaluator: tfhe.NewEvaluator(params.Parameters, tfhe.EvaluationKey[T]{}), SingleKeyEvaluators: singleEvals, Parameters: params, @@ -108,12 +108,6 @@ func NewEvaluator[T tfhe.TorusInt](params Parameters[T], evk map[int]EvaluationK } } -// NewEvaluatorWithoutKey allocates an empty Evaluator based on parameters, but without evaluation keys. -// This will panic if any operation that requires evaluation key is called. -func NewEvaluatorWithoutKey[T tfhe.TorusInt](params Parameters[T]) *Evaluator[T] { - return NewEvaluator(params, map[int]EvaluationKey[T]{}) -} - // newEvaluationBuffer allocates an empty evaluationBuffer. func newEvaluationBuffer[T tfhe.TorusInt](params Parameters[T]) evaluationBuffer[T] { polyFourierDecomposed := make([]poly.FourierPoly, params.relinKeyParameters.Level()) diff --git a/tfhe/evaluator.go b/tfhe/evaluator.go index 401441c..a95b21f 100644 --- a/tfhe/evaluator.go +++ b/tfhe/evaluator.go @@ -104,12 +104,6 @@ func NewEvaluator[T TorusInt](params Parameters[T], evk EvaluationKey[T]) *Evalu } } -// NewEvaluatorWithoutKey allocates an empty Evaluator based on parameters, but without evaluation keys. -// This will panic if any operation that requires evaluation key is called. -func NewEvaluatorWithoutKey[T TorusInt](params Parameters[T]) *Evaluator[T] { - return NewEvaluator(params, EvaluationKey[T]{}) -} - // newEvaluationBuffer allocates an empty evaluationBuffer. func newEvaluationBuffer[T TorusInt](params Parameters[T]) evaluationBuffer[T] { polyDecomposed := make([]poly.Poly[T], params.bootstrapParameters.level) diff --git a/tfhe/tfhe_test.go b/tfhe/tfhe_test.go index 9b3af29..4ae8970 100644 --- a/tfhe/tfhe_test.go +++ b/tfhe/tfhe_test.go @@ -435,7 +435,7 @@ func ExampleEvaluator_CMux() { ctFlag := enc.EncryptFourierGGSW([]int{1}, gadgetParams) // We don't need evaluation key for CMUX. - eval := tfhe.NewEvaluatorWithoutKey(params) + eval := tfhe.NewEvaluator(params, tfhe.EvaluationKey[uint64]{}) ctOut := eval.CMux(ctFlag, ct0, ct1) fmt.Println(enc.DecryptGLWE(ctOut)[0]) // 5