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

Wrong result with exponentiation/inverse? #16

Open
Isolus opened this issue Feb 5, 2020 · 0 comments
Open

Wrong result with exponentiation/inverse? #16

Isolus opened this issue Feb 5, 2020 · 0 comments

Comments

@Isolus
Copy link

Isolus commented Feb 5, 2020

I have written some tests to better understand the library. I came across a problem. In my opinion according to the laws of exponentiation ( (a^b)^c = a^(b*c) ), all tests should return true since a^(b * inv(b)) = a. But the second and fourth don't.

Is there a fault in my reasoning or is this a bug?

	key, err := bls.RandFQ12(rand.Reader)
	if err != nil {
		fmt.Println(err)
		return
	}
	k, err := bls.RandFQ(rand.Reader)
	if err != nil {
		fmt.Println(err)
		return
	}
	kInv, b := k.Inverse()
	if !b {
		fmt.Println("no inverse")
		return
	}
	r := k.Copy()
	r.MulAssign(kInv)

	tmp := key.Exp(k.ToRepr()).Exp(kInv.ToRepr())

	fmt.Println("Test 1: ", r.Equals(bls.FQOne))
	fmt.Println("Test 2: ", key.Equals(tmp))

	g := bls.G1AffineOne.Mul(k.ToRepr())
	h := bls.G2AffineOne.Mul(kInv.ToRepr())
	p := bls.Pairing(g, h)
	palt := bls.Pairing(bls.G1AffineOne.ToProjective(), bls.G2AffineOne.ToProjective())

	fmt.Println("Test 3: ", r.Equals(bls.FQOne))
	fmt.Println("Test 4: ", p.Equals(palt))
	fmt.Println("Test 5: ", p.Equals(palt.Exp(k.ToRepr()).Exp(kInv.ToRepr())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant