• 大小: 3.87MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-05-17
  • 语言: Java
  • 标签: jpbc  基于java  

资源简介

实用java配对加密库,亲测用来运行cp-abe

资源截图

代码片段和文件信息

package it.unisa.dia.gas.jpbc.android.benchmark;

import android.util.Log;
import it.unisa.dia.gas.jpbc.*;
import it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory;

import java.math.BigInteger;


/**
 * @author Angelo De Caro (jpbclib@gmail.com)
 */
public class AndroidBenchmark {
    private static final String TAG = “AndroidBenchmark“;

    protected int iterations;
    protected boolean running = false;


    public AndroidBenchmark(int iterations) {
        this.iterations = iterations;
    }


    public Benchmark benchmark(String[] curves) {
        Log.i(TAG “Benchmarking...%n“);

        this.running = true;
        Benchmark benchmark = new Benchmark(curves);

        double[][] pairingBenchmarks = benchmark.getPairingBenchmarks();

        for (int col = 0; col < curves.length && running; col++) {
            Log.i(TAG “Curve = “ + curves[col]);

            Pairing pairing = getPairing(curves[col]);

            int t1 = 0 t2 = 0 t3 = 0;
            for (int i = 0; i < iterations && running; i++) {
                Element g = pairing.getG1().newElement().setToRandom();
                Element h = pairing.getG2().newElement().setToRandom();

                long start = System.currentTimeMillis();
                pairing.pairing(g h);
                long end = System.currentTimeMillis();
                t1 += Math.abs((end - start));

                start = System.currentTimeMillis();
                PairingPreProcessing ppp = pairing.getPairingPreProcessingFromElement(g);
                end = System.currentTimeMillis();
                t2 += Math.abs((end - start));

                start = System.currentTimeMillis();
                ppp.pairing(h);
                end = System.currentTimeMillis();
                t3 += Math.abs((end - start));
            }

            if (!running)
                return benchmark;

            pairingBenchmarks[0][col] = (double) t1 / iterations;
            pairingBenchmarks[1][col] = (double) t2 / iterations;
            pairingBenchmarks[2][col] = (double) t3 / iterations;
            Log.i(TAG “Finished.%n“);
        }

        // Element Pow Benchmarks
        Log.i(TAG “Element Pow Benchmark...“);

        double[][][] elementBenchmarks = benchmark.getElementBenchmarks();

        for (int col = 0; col < curves.length && running; col++) {
            Log.i(TAG “Curve = “ + curves[col]);

            Pairing pairing = getPairing(curves[col]);
            Field[] fields = new Field[]{
                    pairing.getG1()
                    pairing.getG2()
                    pairing.getGT()
                    pairing.getZr()
            };

            for (int fieldIndex = 0; fieldIndex < fields.length && running; fieldIndex++) {
                Log.i(TAG “Field “ + Benchmark.fieldNames[fieldIndex]);

                long t1 = 0 t2 = 0 t3 = 0 t4 = 0 t5 = 0 t6 = 0 t7 = 0;
                for (int i = 0; i < iterations && running; i++) {
                    Element e1 = fi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1876535  2013-01-31 13:44  jpbc-2.0.0\jars\bcprov-jdk16-1.46.jar

     文件     946973  2013-01-31 13:44  jpbc-2.0.0\jars\jna-3.2.5.jar

     文件       7678  2013-11-27 14:34  jpbc-2.0.0\jars\jpbc-api-2.0.0.jar

     文件       9897  2013-11-27 14:50  jpbc-2.0.0\jars\jpbc-benchmark-2.0.0.jar

     文件     181635  2013-11-27 14:39  jpbc-2.0.0\jars\jpbc-crypto-2.0.0.jar

     文件      51697  2013-11-27 14:36  jpbc-2.0.0\jars\jpbc-mm-2.0.0.jar

     文件      39192  2013-11-27 14:36  jpbc-2.0.0\jars\jpbc-pbc-2.0.0.jar

     文件     252654  2013-11-27 14:34  jpbc-2.0.0\jars\jpbc-plaf-2.0.0.jar

     文件      34598  2013-11-27 14:50  jpbc-2.0.0\jars\test\jpbc-test-2.0.0-tests.jar

     文件        559  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\AndroidManifest.xml

     文件        359  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\assets\a.properties

     文件        979  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\assets\d159.properties

     文件       1222  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\assets\d201.properties

     文件       1347  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\assets\d224.properties

     文件      13965  2013-11-27 12:03  jpbc-2.0.0\jpbc-android\jpbc-android.iml

     文件       2360  2013-11-27 14:34  jpbc-2.0.0\jpbc-android\pom.xml

     文件       6094  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\res\drawable\icon.png

     文件       1847  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\res\layout\main.xml

     文件        154  2013-06-17 12:57  jpbc-2.0.0\jpbc-android\res\values\strings.xml

     文件       5944  2013-10-30 16:41  jpbc-2.0.0\jpbc-android\src\it\unisa\dia\gas\jpbc\android\benchmark\AndroidBenchmark.java

     文件       5346  2013-10-31 09:41  jpbc-2.0.0\jpbc-android\src\it\unisa\dia\gas\jpbc\android\benchmark\Benchmark.java

     文件       6672  2013-11-27 10:57  jpbc-2.0.0\jpbc-android\src\it\unisa\dia\gas\jpbc\android\benchmark\JPBCBenchmarkActivity.java

     文件       5270  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\AndroidBenchmark.class

     文件       3736  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\Benchmark.class

     文件        387  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\BuildConfig.class

     文件       1546  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\JPBCBenchmarkActivity$1.class

     文件       1592  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\JPBCBenchmarkActivity$2.class

     文件       3054  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\JPBCBenchmarkActivity$3.class

     文件       4052  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\JPBCBenchmarkActivity.class

     文件        403  2013-11-27 14:50  jpbc-2.0.0\jpbc-android\target\classes\it\unisa\dia\gas\jpbc\android\benchmark\R$attr.class

............此处省略835个文件信息

评论

共有 条评论