logo资料库

PBC库用户手册(英文).pdf

第1页 / 共51页
第2页 / 共51页
第3页 / 共51页
第4页 / 共51页
第5页 / 共51页
第6页 / 共51页
第7页 / 共51页
第8页 / 共51页
资料共51页,剩余部分请下载后查看
PBC Library Manual 0.5.11
Table of Contents
Preface
Chapter 1. Installing PBC
1.1. GNU Build System (autotools)
1.2. Simple Makefile
1.3. Quick start
1.4. Basics
Chapter 2. Tutorial
2.1. BLS signatures
2.2. Import/export
Chapter 3. Pairing functions
3.1. Initializing pairings
3.2. Applying pairings
3.3. Other pairing functions
Chapter 4. Element functions
4.1. Initializing elements
4.2. Assigning elements
4.3. Converting elements
4.4. Element arithmetic
4.5. Exponentiating elements
4.6. Comparing elements
4.7. Element I/O
4.8. Random elements
4.9. Element import/export
Chapter 5. Param functions
5.1. Param generation
Chapter 6. Other functions
6.1. Random bits
6.2. Custom allocation
6.3. Logging
Chapter 7. Bundled programs
7.1. Pairingbased calculator
7.2. Parameter generation
7.3. Example cryptosystems
7.4. Benchmarks
Chapter 8. PBC internals
8.1. Groups, rings, fields
8.2. Internal randomness
8.3. Type A internals
8.4. Type B internals
8.5. Type C internals
8.6. Type D internals
8.7. Type E Internals
8.8. Type F internals
8.9. Type G Internals
8.10. Testing functions
8.11. Dynamic arrays
8.12. Symbol tables
8.13. Religious stances
Chapter 9. Security issues
Appendix A. Contributors
PBC Library Manual 0.5.11 Ben Lynn
PBC Library Manual 0.5.11 by Ben Lynn Revision History 2006 Revised by: BL
Table of Contents Preface ........................................................................................................................................................v 1. Installing PBC ........................................................................................................................................1 1.1. GNU Build System (autotools) ...................................................................................................1 1.2. Simple Makefile ..........................................................................................................................1 1.3. Quick start ...................................................................................................................................1 1.4. Basics ..........................................................................................................................................2 2. Tutorial ...................................................................................................................................................4 2.1. BLS signatures ............................................................................................................................4 2.2. Import/export...............................................................................................................................5 3. Pairing functions....................................................................................................................................8 3.1. Initializing pairings .....................................................................................................................8 3.2. Applying pairings........................................................................................................................9 3.3. Other pairing functions .............................................................................................................10 4. Element functions ................................................................................................................................12 4.1. Initializing elements..................................................................................................................12 4.2. Assigning elements ...................................................................................................................13 4.3. Converting elements..................................................................................................................14 4.4. Element arithmetic ....................................................................................................................14 4.5. Exponentiating elements ...........................................................................................................16 4.6. Comparing elements .................................................................................................................18 4.7. Element I/O ...............................................................................................................................19 4.8. Random elements......................................................................................................................20 4.9. Element import/export ..............................................................................................................21 5. Param functions...................................................................................................................................24 5.1. Param generation.......................................................................................................................24 6. Other functions ....................................................................................................................................28 6.1. Random bits ..............................................................................................................................28 6.2. Custom allocation .....................................................................................................................29 6.3. Logging .....................................................................................................................................29 7. Bundled programs ...............................................................................................................................31 7.1. Pairing-based calculator ............................................................................................................31 7.2. Parameter generation.................................................................................................................32 7.3. Example cryptosystems.............................................................................................................32 7.4. Benchmarks...............................................................................................................................33 8. PBC internals .......................................................................................................................................34 8.1. Groups, rings, fields ..................................................................................................................34 8.2. Internal randomness ..................................................................................................................36 8.3. Type A internals ........................................................................................................................37 8.4. Type B internals ........................................................................................................................37 8.5. Type C internals ........................................................................................................................38 8.6. Type D internals ........................................................................................................................38 8.7. Type E Internals ........................................................................................................................38 8.8. Type F internals.........................................................................................................................39 iii
8.9. Type G Internals........................................................................................................................40 8.10. Testing functions .....................................................................................................................40 8.11. Dynamic arrays .......................................................................................................................41 8.12. Symbol tables..........................................................................................................................42 8.13. Religious stances.....................................................................................................................43 9. Security issues ......................................................................................................................................45 A. Contributors ........................................................................................................................................46 iv
Preface The PBC library is a free portable C library allowing the rapid prototyping of pairing-based cryptosystems. It provides an abstract interface to a cyclic group with a bilinear pairing, insulating the programmer from mathematical details. Knowledge of elliptic curves is optional. The PBC library is built on top of the GMP library, and the PBC API is strongly influenced by the GMP API. Accordingly, this manual tries to imitate the look and feel of the GMP manual. The PBC library homepage: http://crypto.stanford.edu/pbc/ The GMP library homepage: http://www.swox.com/gmp/ v
Chapter 1. Installing PBC The PBC library needs the GMP library (http://www.swox.com/gmp/). Multiple ways to install PBC are provided. 1.1. GNU Build System (autotools) This build system has been tested and works on Linux and Mac OS X with a fink installation. $ ./configure $ make $ make install On Windows, the configure command requires a couple of options: $ ./configure -disable-static -enable-shared By default the library is installed in /usr/local/lib. On some systems, this may not be in the library path. One way to fix this is to edit /etc/ld.so.conf and run ldconfig. 1.2. Simple Makefile For speed and simplicity, I use simple.make during development. Naturally it is less portable. $ make -f simple.make PBC uses some GNU C extensions such as nested functions. 1.3. Quick start We shall use the following notation. For our purposes, the pairing is a bilinear map from two cyclic groups, G1 and G2 to a third group GT, where each group has prime order r. Run pbc/pbc and type: g := rnd(G1); g; 1
The first line generates a random element g of the group G1, while the second prints out the value of g. (The syntax was influenced by bc, an arbitrary precision calculator.) Next, enter: Chapter 1. Installing PBC h := rnd(G2); h; This assigns h to a random element of the group G2. Actually, the default pairing pbc uses is symmetric so G1 and G2 are in fact the same group, but in general they are distinct. To compute the pairing applied to g and h, type: pairing(g,h); The order of both g and h is r. Let’s generate two random numbers between 1 and r: a := rnd(Zr); b := rnd(Zr); By bilinearity, the resulting output of both of these lines should be identical: pairing(g^a,h^b); pairing(g,h)^(a*b); This program has other features but the commands shown here should be enough to quickly and interactively experiment with many pairing-based cryptosystems using real numbers. 1.4. Basics Programs using the PBC library should include the file pbc.h: #include and linked against the PBC library and the GMP library, e.g. $ gcc program.c -L. -lpbc -lgmp The file pbc.h already includes gmp.h. PBC follows GMP in several respects: • Output arguments generally precede input arguments. • The same variable can be used as input and output in one call. • Before a variable may be used it must be initialized exactly once. When no longer needed it must be cleared. For efficiency, unnecessary initializating and clearing should be avoided. 2
Chapter 1. Installing PBC • PBC variables ending with _t behave the same as GMP variables in function calls: effectively as call-by references. In other words, as in GMP, if a function that modifies an input variable, that variable remains modified when control return is returned to the caller. • Like GMP, variables automatically allocate memory when needed. By default, malloc() and friends are called but this can be changed. • PBC functions are mostly reentrant. Since the PBC library is built on top of GMP, the GMP types are available. PBC types are similar to GMP types. The following example is paraphrased from an example in the GMP manual, and shows how to declare the PBC data type element_t. element_t sum; struct foo { element_t x, y; }; element_t vec[20]; GMP has the mpz_t type for integers, mpq_t for rationals and so on. In contrast, PBC uses the element_t data type for elements of different algebraic structures, such as elliptic curve groups, polynomial rings and finite fields. Functions assume their inputs come from appropriate algebraic structures. PBC data types and functions can be categorized as follows. The first two alone suffice for a range of applications. • element_t: elements of an algebraic structure. • pairing_t: pairings where elements belong; can initialize from sample pairing parameters bundled with PBC in the param subdirectory. • pbc_param_t: used to generate pairing parameters. • pbc_cm_t: parameters for constructing curves via the CM method; sometimes required by pbc_param_t. • field_t: algebraic structures: groups, rings and fields; used internally by pairing_t. • a few miscellaneous functions, such as ones controlling how random bits are generated. Functions operating on a given data type usually have the same prefix, e.g. those involving element_t objects begin with element_. 3
分享到:
收藏