码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Goldilocks域


    1. 引言

    Goldilocks域 p = 2 64 − 2 32 + 1 p= 2^{64} - 2^{32} + 1 p=264−232+1,目前用于Polygon生态的多个项目中:

    • Polygon Miden VM:在https://github.com/maticnetwork/miden 中使用了winterfell项目的winter-math库:https://github.com/novifinancial/winterfell/blob/main/math/src/field/f64/mod.rs(Rust语言)
    • Polygon Zero Plonky2:https://github.com/mir-protocol/plonky2/blob/main/field/src/goldilocks_field.rs(Rust语言)
    • Polygon Hermez 2.0:https://github.com/0xPolygonHermez/goldilocks(C++语言)

    以Goldilocks域 p = 2 64 − 2 32 + 1 p= 2^{64} - 2^{32} + 1 p=264−232+1 为base prime field的椭圆曲线有:

    • 1)Cheetah curve:
      • 2022年论文 Security Analysis of Elliptic Curves over Sextic Extension of Small Prime Fields
      • https://github.com/ToposWare/cheetah (Cheetah curve实现,Rust语言)
      • https://github.com/ToposWare/cheetah_evidence (Cheetah curve安全性论证,Python和SageMath)
    • 2)ecGFp5 curve:
      • 2022年论文 EcGFp5: a Specialized Elliptic Curve
      • https://github.com/pornin/ecgfp5(ecGFp5 curve实现,Rust和Python)

    p = 2 64 − 2 32 + 1 p= 2^{64} - 2^{32} + 1 p=264−232+1, F p ∗ \mathbb{F}_p^* Fp∗​的order为 p − 1 p-1 p−1,即:
    2 64 − 2 32 = 2 32 ⋅ 3 ⋅ 5 ⋅ 17 ⋅ 257 ⋅ 65537 2^{64}-2^{32}=2^{32}\cdot 3\cdot 5\cdot 17\cdot 257\cdot 65537 264−232=232⋅3⋅5⋅17⋅257⋅65537
    即意味着该域具有 2 32 2^{32} 232-th root of unity。
    相应的generator为:
    g = 7 g=7 g=7
    2 32 2^{32} 232-th root of unity 为 g ( p − 1 ) / 2 32 = 0 x 185629 d c d a 58878 c = 1753635133440165772 g^{(p-1)/2^{32}}=0x185629dcda58878c=1753635133440165772 g(p−1)/232=0x185629dcda58878c=1753635133440165772。
    相应的sage脚本为:
    在这里插入图片描述

    1.1 乘法运算之Goldilocks域 vs. BN254域

    根据Ariel Gabizon twitter有:

    • 1)采用A100 GPU,Goldilocks域乘法运算比BN254域快15.5倍:
      • BN254: ~34*10^9 muls/s
      • Goldilocks: ~527*10^9 muls/s
    • 2)大多数CPU上,单个Goldilocks乘法运算需约2~3 cycles,256-bit乘法运算约需要80~100 cycles。
    • 3)根据polygon zkEVM repo,在AMD EPYC 7773Xc处理器上,Goldilocks域乘法运算比BN254域快约9倍。在该及其上采用的是Karatsuba算法来对n-digital long integers进行乘法运算。
    • 4)根据UIvetanna——ZKP加速(获得Bain Capital Crypto、Paradigm以及Jump Crytpo联合的1500万美金种子轮投资)的FPGA开发,Goldilocks域乘法运算的延迟要比BN254快约8倍,资源利用率要比BN254好10~15倍。

    2. Why Goldilocks?

    STARKs/SNARKs处理常规整数运算的难点在于:

    • 所有的值都是以有限域元素表示。
    • 将有限域运算 映射为 32-bit或64-bit整数运算 是昂贵的。(注意:EVM使用256-bit整数)

    Miden VM原生支持所有32-bit unsigned integers(u32)运算,从而使得相应的运算效率很高:

    • 每个u32运算仅需要一个VM cycle。

    Goldilocks域 p = 2 64 − 2 32 + 1 p= 2^{64} - 2^{32} + 1 p=264−232+1,具有一些很好的特性:【详细见:u32 operations in Miden VM 】

    • 1)值适于64-bit整数,从而使得基于该域的运算在现代CPU上运行很快。
    • 2)2个32-bit整数乘法不存在域模溢出问题。
    • 3)检查4个16-bit values是否构成了一个有效filed element 的效率可以很高。

    Miden VM中的大多数u32运算(包括bit shifts、bit rotations、value comparison)仅需要少量的16-bit range checks。对于一些复杂的运算(如bitwise AND/OR/XOR),需要使用辅助lookup tables,但是这些复杂运算也是efficient的。

    参考资料

    [1] twitter u32 operations in Miden VM
    [2] u32 operations in Miden VM
    [3] cronokirby 2022年9月1日博客 The Goldilocks Field
    [4] twitter Goldilocks Field

  • 相关阅读:
    leetcode每天5题-Day34
    案例丨一座小镇,如何推动“零售娱乐化”的风潮?合适的数字化工具如何为品牌带来助力?
    nginx相关使用
    常见的网络协议
    Prototype属性与Object.defineproperty方法:
    React之diff原理
    压缩与解压 .tar .tar.gz .tar.bz2 解压 tar.xz
    DC-9靶机
    相机One Shot标定
    第14章总结:lambda表达式与处理
  • 原文地址:https://blog.csdn.net/mutourend/article/details/126407028
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号