pbc的官方网站是在
https://crypto.stanford.edu/pbc/
pbc是做双线性映射密码学的库
下载了pbc的库,然后在/pbc-0.5.14/example 文件夹下输入:
./bls < ../param/a.param
pbc 简单编程
以下程序是用pbc的库来验证e(ab,cd) = e(ac,bd)
#include <pbc.h>
#include <pbc_test.h>
int main(int argc, char **argv) {
pairing_t pairing;
element_t a, b, c, d;
element_t A, B, C, D;
element_t temp1, temp2;
pbc_demo_pairing_init(pairing, argc, argv);
element_init_G1(a, pairing); //初始化群G1的a
element_init_G2(b, pairing); //初始化群G1的b
element_init_G1(c, pairing); //初始化群G1的c
element_init_G2(d, pairing); //初始化群G1的d
element_init_G1(A, pairing);
element_init_G2(B, pairing);
element_init_G1(C, pairing);
element_init_G2(D, pairing);
element_init_GT(temp1, pairing);
element_init_GT(temp2, pairing);
element_random(a);
element_random(b);
element_random(c);
element_random(d);
element_mul(A, a, b);// A = ab a乘以b
element_mul(B, c, d);// B = cd
element_mul(C, a, c);// C = ac
element_mul(D, d, b);// D = bd
element_pairing(temp1, A, B);
element_pairing(temp2, C, D);
if(element_cmp(temp1,temp2))
{
printf("hello\n");
}
return 0;
}
test.c
./test < ../param/a.param
hello
pbc的编译方式是gcc test.c -L. -lpbc -lgmp -o test
运行
./test < ../param/a.param
true