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[ring]: ´ring.UniformSampler´ bad sampling #468

Open
Pro7ech opened this issue May 12, 2024 · 0 comments
Open

Bug[ring]: ´ring.UniformSampler´ bad sampling #468

Pro7ech opened this issue May 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Pro7ech
Copy link
Contributor

Pro7ech commented May 12, 2024

The following code should produce polynomials with independent and identically distributed coefficients but ends up producing polynomials with overlapping coefficients:

package main


import(
	"fmt"
	"github.com/tuneinsight/lattigo/v5/core/rlwe"
	"github.com/tuneinsight/lattigo/v5/utils/sampling"
	"github.com/tuneinsight/lattigo/v5/ring"
)

func main(){
	params, err := rlwe.NewParametersFromLiteral(rlwe.ParametersLiteral{
		LogN: 10,
		LogQ: []int{50},
	})

	if err != nil{
		panic(err)
	}

	prng, _ := sampling.NewKeyedPRNG([]byte{0x02})
	uniform := ring.NewUniformSampler(prng, params.RingQ())
	_ = uniform.ReadNew()

	a0 := uniform.AtLevel(0).ReadNew()
	a1 := uniform.AtLevel(0).ReadNew()

	m := map[uint64]int{}
	for i, v := range a0.Coeffs[0]{
		m[v] = i
	}

	for i, v := range a1.Coeffs[0]{
		if j, ok := m[v]; ok{
			fmt.Println(a0.Coeffs[0][j:j+8])
			fmt.Println(a1.Coeffs[0][i:i+8])
			break
		}
	}
}
@Pro7ech Pro7ech added the bug Something isn't working label May 12, 2024
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

1 participant