lattigo
lattigo copied to clipboard
Bug[rgsw]: panic: runtime error when encrypting and `rgsw.Ciphertext` with an `rlwe.PublicKey`
What version of Lattigo are you using?
v5@latest
Does this issue persist with the latest release?
Yes
What were you trying to do?
Encrypt an rgsw.Ciphertext using the public key
What actually happened?
panic: runtime error: invalid memory address or nil pointer dereference
Reproducibility
package main
import (
"github.com/tuneinsight/lattigo/v5/core/rgsw"
"github.com/tuneinsight/lattigo/v5/core/rlwe"
)
func main() {
params, err := rlwe.NewParametersFromLiteral(rlwe.ParametersLiteral{
LogN: 11,
LogQ: []int{54},
NTTFlag: true,
})
if err != nil {
panic(err)
}
_, pk := rlwe.NewKeyGenerator(params).GenKeyPairNew()
enc := rgsw.NewEncryptor(params, pk)
ct := rgsw.NewCiphertext(params, params.MaxLevelQ(), params.MaxLevelP(), 7)
pt := rlwe.NewPlaintext(params, ct.LevelQ())
if err = enc.Encrypt(pt, ct); err != nil {
panic(err)
}
}
Hey, to my knowledge RGSW uses the RingQP under the hood for the gadget products. Not specifying auxiliary primes P will result in an uninitialized RingP hence the nil pointer exception.
Maybe we could disallow parameters without P primes for RGSW?
RingQP should still work even without P, as before doing operations it checks if there is or not a RingP. In practice RGSW is mostly used in contexts where the parameters are too small to accommodate for an auxiliary modulus P, such as blind rotations.