mirror of
https://github.com/tuneinsight/lattigo.git
synced 2025-09-13 03:27:14 +00:00
[rlwe]: fixed nil interface bug in evaluator
This commit is contained in:
@@ -48,7 +48,7 @@ func (evk *EvaluationKeySet) GetGaloisKey(galEl uint64) (gk *GaloisKey, err erro
|
||||
// for which a Galois key exists in the object.
|
||||
func (evk *EvaluationKeySet) GetGaloisKeysList() (galEls []uint64) {
|
||||
|
||||
if evk.GaloisKeys == nil {
|
||||
if evk == nil || evk.GaloisKeys == nil {
|
||||
return []uint64{}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ func NewEvaluator(params Parameters, evk EvaluationKeySetInterface) (eval *Evalu
|
||||
|
||||
var AutomorphismIndex map[uint64][]uint64
|
||||
|
||||
if evk != nil {
|
||||
if !utils.IsNil(evk) {
|
||||
if galEls := evk.GetGaloisKeysList(); len(galEls) != 0 {
|
||||
AutomorphismIndex = make(map[uint64][]uint64)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package utils
|
||||
|
||||
import (
|
||||
"math/bits"
|
||||
"reflect"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
@@ -23,6 +24,12 @@ func Max[V constraints.Ordered](a, b V) (r V) {
|
||||
return b
|
||||
}
|
||||
|
||||
// IsNil returns true either type or value are nil.
|
||||
// Only interfaces or pointers to objects should be passed as argument.
|
||||
func IsNil(i interface{}) bool {
|
||||
return i == nil || reflect.ValueOf(i).IsNil()
|
||||
}
|
||||
|
||||
// BitReverse64 returns the bit-reverse value of the input value, within a context of 2^bitLen.
|
||||
func BitReverse64[V uint64 | uint32 | int | int64](index V, bitLen int) uint64 {
|
||||
return bits.Reverse64(uint64(index)) >> (64 - bitLen)
|
||||
|
||||
Reference in New Issue
Block a user