PBC Library Manual 0.5.11 - Stanford Crypto Group
PBC Library Manual 0.5.11 - Stanford Crypto Group
PBC Library Manual 0.5.11 - Stanford Crypto Group
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 1. Installing <strong>PBC</strong><br />
The first line generates a random element g of the group G1, while the second prints out the value of g.<br />
(The syntax was influenced by bc, an arbitrary precision calculator.) Next, enter:<br />
h := rnd(G2);<br />
h;<br />
This assigns h to a random element of the group G2. Actually, the default pairing pbc uses is symmetric<br />
so G1 and G2 are in fact the same group, but in general they are distinct. To compute the pairing applied<br />
to g and h, type:<br />
pairing(g,h);<br />
The order of both g and h is r. Let’s generate two random numbers between 1 and r:<br />
a := rnd(Zr);<br />
b := rnd(Zr);<br />
1.4. Basics<br />
By bilinearity, the resulting output of both of these lines should be identical:<br />
pairing(g^a,h^b);<br />
pairing(g,h)^(a*b);<br />
This program has other features but the commands shown here should be enough to quickly and<br />
interactively experiment with many pairing-based cryptosystems using real numbers.<br />
Programs using the <strong>PBC</strong> library should include the file pbc.h:<br />
#include <br />
and linked against the <strong>PBC</strong> library and the GMP library, e.g.<br />
$ gcc program.c -L. -lpbc -lgmp<br />
The file pbc.h already includes gmp.h.<br />
<strong>PBC</strong> follows GMP in several respects:<br />
• Output arguments generally precede input arguments.<br />
• The same variable can be used as input and output in one call.<br />
• Before a variable may be used it must be initialized exactly once. When no longer needed it must be<br />
cleared. For efficiency, unnecessary initializating and clearing should be avoided.<br />
2