源代码如下:
#include "/usr/local/include/pbc/pbc.h"
#include "/usr/local/include/pbc/pbc_test.h"
#include <stdio.h>
#include<string.h>
#include<time.h>
int main(int argc, char **argv) {
pairing_t pairing;
pbc_demo_pairing_init(pairing, argc, argv);
double th1, th2, th_1, th_2, ta1, ta2, tm1, tm2, tm_1, tm_2, tp1, tp2, te1, te2;
element_t x, x2, h;
element_t P, H, P1, P2;
element_t Q;
element_init_Zr(x, pairing);
element_init_Zr(x2, pairing);
element_init_Zr(h, pairing);
element_init_G1(P, pairing);
element_init_G1(P1, pairing);
element_init_G1(P2, pairing);
element_init_G1(H, pairing);
element_init_GT(Q, pairing);
//hash到数
th1 = pbc_get_time();
element_from_hash(h, "message", 7);
th2 = pbc_get_time();
//hash到点
th_1 = pbc_get_time();
element_from_hash(P, "message", 7);
th_2 = pbc_get_time();
element_random(x);
element_random(x2);
element_random(P);
element_random(P1);
element_random(P2);
element_random(H);
//点加
ta1 = pbc_get_time();
element_add(P, P, H);
ta2 = pbc_get_time();
//数和点的乘法
tm1 = pbc_get_time();
element_mul_zn(P, P, x);
tm2 = pbc_get_time();
//点和点的乘法
tm_1 = pbc_get_time();
element_mul_zn(P, P1, P2);
tm_2 = pbc_get_time();
//对运算weil pairing
tp1 = pbc_get_time();
pairing_apply(Q, P1, P1, pairing);
tp2 = pbc_get_time();
//模幂运算modular expone
te1 = pbc_get_time();
element_pow_zn(H, P2, x2);
te2 = pbc_get_time();
printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\n", th2-th1, th_2-th_1, ta2-ta1, tm2-tm1, tm_2-tm_1, tp2-tp1, te2-te1);
//FILE *fp;
//fp=fopen("data.txt", "a");
//fclose(fp);
element_clear(x);
element_clear(P);
element_clear(H);
pairing_clear(pairing);
return 0;
}
先编译运行gcc -Wall -o main main.c -L. -lpbc -lgmp是没有问题的,接下来编译运行./main < /home/gaokai/下载/pbc-0.5.14/param/a.param的时候,便有了以下报错:
./main: error while loading shared libraries: libpbc.so.1: cannot open shared object file: No such file or directory
本人新手,对这一块懂得很少,还请大神详细给我说一下是哪里出了问题,该怎么解决。万分感谢!!!