https://github.com/ConsenSys/gnark-crypto
github.com/consensys/gnark
cloudflare
func finalExponentiation(in *gfP12, pool *bnPool) *gfP12 {
d := newGFp12(pool)
// This is the p^6-Frobenius
d.x.Negative(in.x)
d.y.Set(in.y)
inv := newGFp12(pool)
inv.Invert(in, pool)
d.Mul(d, inv, pool)
t2 := newGFp12(pool).FrobeniusP2(d, pool)
d.Mul(d, t2, pool)
p2 := new(big.Int).Mul(p, p)
p3 := new(big.Int).Mul(p2, p)
p4 := new(big.Int).Mul(p3, p)
p6 := new(big.Int).Mul(p3, p3)
p12 := new(big.Int).Mul(p6, p6)
p7 := new(big.Int).Mul(p6, p)
t := new(big.Int).Sub(p4, p2)
one := big.NewInt(1)
t.Add(t, one)
//t.Mod(t, Order)
t.Div(t, Order)
t.Mul(t, p12)
fmt.Println(t)
u2 := new(big.Int).Mul(u, u)
u3 := new(big.Int).Mul(u2, u)
y2 := new(big.Int).Mul(u2, p2)
y3 := new(big.Int).Mul(u, p7)
y0 := new(big.Int).Add(p, p2)
y0.Add(y0, p3)
y1 := p6
y5 := new(big.Int).Mul(u2, p6)
u2p := new(big.Int).Mul(u2, p)
y4 := new(big.Int).Add(u, u2p)
y4.Mul(y4, p6)
y6 := new(big.Int).Add(p, one)
y6.Mul(y6, u3)
y6.Mul(y6, p6)
t0 := new(big.Int).Add(y6, y6)
t0.Add(t0, y4)
t0.Add(t0, y5)
t1 := new(big.Int).Add(y3, y5)
t1.Add(t1, t0)
t0.Add(t0, y2)
t1.Add(t1, t1)
t1.Add(t1, t0)
t1.Add(t1, t1)
t0.Add(t1, y1)
t1.Add(t1, y0)
t0.Add(t0, t0)
t0.Add(t0, t1)
fmt.Println(t0)
r1 := newGFp12(pool).Exp(d, t0, pool)
r2 := newGFp12(pool).Exp(d, t, pool)
if !bytes.Equal((>{r2}).Marshal(), (>{r1}).Marshal()){
panic("e")
}
//panic("a")
return r1
}