FFT rust代码实现

目前的实现主要有:
1)Halo中(https://github.com/ebfull/halo/blob/master/src/util.rs)在utils.rs中对两条新的曲线做了实现;
2)Zexe中,设计了单独的ff-fft模块,对pairing曲线(如Jubjub/mnt6等)做了实现;
3)Openzkp中(https://github.com/0xProject/OpenZKP/blob/master/algebra/primefield/src/fft.rs)在fft.rs 中对251-bit prime field 做了fft实现。

注意,其实在做polynomial commitment时,factor(p-1) = 2^s*t,其中的2^s值代表允许的多项式的最高阶数。generator=primitive_root(p)【generator为 ( p − 1 ) (p-1) (p1)-th root of unity,有限域内任意 x x x,其 x ( p − 1 ) = 1 x^{(p-1)}=1 x(p1)=1恒成立】, 2 s 2^s 2s-th root of unity的计算方式为power_mod(generator, t, p)
对于curve25519来说,其Fr域内的s值仅为2且generator无返回(无论是基于magma还是sagemath)。所以在polynomial commitment时,其并不适用。
另外,考虑到vector commitment(如系数的commitment,需要用到scalar值乘以point)的结合,一般polynomial commitment都采用的是scalar field的值。
Zexe中的ff-fft模块中,会由 2 s 2^s 2s-th root of unity获得多项式阶数(提升到最近的2^k值, 如下代码中的size值)对应的root of unity(对应如下代码中的group_gen值):

		// Compute the size of our evaluation domain
        let size = num_coeffs.next_power_of_two() as u64;
        let log_size_of_group = size.trailing_zeros();

        if log_size_of_group >= F::Params::TWO_ADICITY {
            return None;
        }

        // Compute the generator for the multiplicative subgroup.
        // It should be 2^(log_size_of_group) root of unity.
        let mut group_gen = F::root_of_unity();
        for _ in log_size_of_group..F::Params::TWO_ADICITY {
            group_gen.square_in_place();
        }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值