cloudflare_finalExp

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((&GT{r2}).Marshal(), (&GT{r1}).Marshal()){
panic("e")
}
//panic("a")
return r1
}
posted @   zJanly  阅读(34)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示