Pairing-Based Calculator

The pbc subdirectory contains a program also named pbc which allows interactive testing of the PBC library.

Its syntax is loosely based on that of bc, a well-known arbitrary precision calculator language. I do not intend for pbc to be a fully-fledged scripting language. If this were the aim I would add a module to an extant popular language. Instead, pbc is meant to be a test program. (Nonetheless, it possesses enough functionality to be used to implement cryptosystems in shell scripts.)

Four pairings named A, D, E and F are initialized during startup, and furthermore, the variables G1, G2, GT and Zr are setup to represent groups associated with the A pairing. To use a different pairing, call the init_pairing funciton.

Assignments have a C-like syntax "variable = expression", and return the value of the variable. Function calls and expressions also resemble C. The arithmetic operators +, -, /, *, ^ have the standard precedence. Perhaps the only significant difference is that no terminating semicolon is required.

Comments begin with "#" and end at a newline. Double quotes are used to denote strings. On error, pbc prints the error code which I have yet to translate to English.

Some of the pbc functions:

init_pairing(pairing)

Set the variables G1, G2, GT and Zr to the groups in pairing, e.g:

init_pairing(D)
rnd(G)

Returns a random element of the group G, e.g:

g = rnd(Zr)

Has synonyms rand and random.

pairing(g, h)

Returns the pairing applied to g and h. The element g must be an element of G1 and h of G2, e.g:

pairing(rnd(G1), rnd(G2))
fromstr(string, G)

Returns string converted to an element of G, e.g.

x = fromstr("[123,456]", GT)