Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug[rgsw]: panic: runtime error when encrypting and rgsw.Ciphertext with an rlwe.PublicKey #481

Closed
Pro7ech opened this issue Jun 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Pro7ech
Copy link
Collaborator

Pro7ech commented Jun 3, 2024

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)
	}
}
@Pro7ech Pro7ech added the bug Something isn't working label Jun 3, 2024
@qantik
Copy link
Collaborator

qantik commented Jun 4, 2024

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?

@Pro7ech
Copy link
Collaborator Author

Pro7ech commented Jun 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants