简体   繁体   English

使用jpbc的程序需要很长时间

[英]Program that uses jpbc takes a long time

This is a very simple program I have written that uses jpbc library. 这是我编写的使用jpbc库的非常简单的程序。 It compiles without any errors, but takes an unusually long time to show the output, or in fact it doesn't show the output at all. 它可以编译,没有任何错误,但是要花费很长时间才能显示输出,或者实际上根本不显示输出。 (Who in this era will have the patience to wait for nearly half an hour for such a tiny program?) I am using a system with i7 processor but still this is the case. (在这个时代,谁会耐心等待将近半个小时的时间来处理如此小的程序?)我正在使用带有i7处理器的系统,但事实仍然如此。

Could anyone tell what might be wrong with this code? 谁能告诉我这段代码有什么问题吗?

import it.unisa.dia.gas.jpbc.*;
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory;
import it.unisa.dia.gas.plaf.jpbc.pairing.parameters.*;
import it.unisa.dia.gas.jpbc.PairingParametersGenerator;
import it.unisa.dia.gas.jpbc.PairingParameters;
import it.unisa.dia.gas.plaf.jpbc.pairing.a1.TypeA1CurveGenerator;
public class PairingDemo {

    public static void main(String [] args){
        try{
            int rBits = 160;
            int qBits = 512;
            PairingParametersGenerator pg = new TypeA1CurveGenerator(rBits, qBits);
            PairingParameters params = pg.generate();
            Pairing pair = PairingFactory.getPairing("D:\\JPBCLib\\params\\curves\\a1.Properties");
            Field Zr = pair.getZr();
            int degree = pair.getDegree();
            System.out.println("Degree of the pairing : " + degree);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

There are three issues that you're dealing with here 您正在处理三个问题

  • Generating the pairing parameters takes some time, but this only has to be done once for a system that you're building. 生成配对参数需要花费一些时间,但是对于要构建的系统,只需执行一次即可。 You should store the generated pairing parameter for later use. 您应该存储生成的配对参数,以备后用。

  • Since you're not using pg or params , you can remove that code. 由于您没有使用pgparams ,因此可以删除该代码。 Instead you're reading precomputed parameters from a file. 相反,您是从文件中读取预先计算的参数。

  • jPBC is a complete and pure Java implementation of PBC. jPBC是PBC的完整和纯Java实现。 It is fully portable and therefore quite slow. 它是完全可移植的,因此速度很慢。 jPBC has an option of using a PBCWrapper library which is a wrapper around libpbc which would enable you to get the performance of the native library. jPBC可以选择使用PBCWrapper库,它是libpbc的包装器,可以使您获得本机库的性能。 I wasn't able to make it work on Windows, but Linux should not be an issue (make sure to check the JNI version or load your own). 我无法使其在Windows上运行,但是Linux不应成为问题(请确保检查JNI版本或加载您自己的版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM