Skip to content

Commit

Permalink
feat: Remove NewEvaluatorWithoutKey
Browse files Browse the repository at this point in the history
  • Loading branch information
sp301415 committed Jul 22, 2024
1 parent 1d940b7 commit 06fc09b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions mktfhe/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
Expand Down
6 changes: 0 additions & 6 deletions tfhe/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tfhe/tfhe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06fc09b

Please sign in to comment.