Skip to content

Wrong result with exponentiation/inverse? #16

@Isolus

Description

@Isolus

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())))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions