The pbc
subdirectory contains
the pairingbased calculator, pbc
,
which is loosely based on bc
, a
wellknown arbitrary precision calculator.
See pairing_test.pbc
for an
example script. Some differences: the assignment operator is
:=
, and newlines are ordinary
whitespace and not statement terminators.
If started with the y
option,
the syntax is compatible with bc
:
newlines are treated as statement terminators and =
is assignment. Additionally, pbc
displays a prompt. This mode may be easier
for beginners.
Initially, the variables G1, G2, GT and Zr are represent groups associated with a particular A pairing.
An element is represented with a tree of integers, such as
[[1,2], 3]
, or 4
.
Assignments such as variable :=
expression;
return the value of the variable.
The arithmetic operators +, , /, *,
^
have the standard precedence. The C comparison
operators and ternary operator are available.
Each statement should be terminated by a semicolon.
Comments are the same as in (original) C, or begin with "#" and end at a newline.
Some of the pbc functions:
init_pairing_A()

Set the variables G1, G2, GT and Zr to the groups in a particular A pairing:
init_pairing_A();
Other sample pairings can be used by replacing
A
with one ofD, E, F, G
. rnd(
G)

Returns a random element of an algebraic structure G, e.g:
g := rnd(Zr);
Synonym:
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));
 G
(
g)

Maps an element g to element of the field G, e.g:
Zr(123); GT([456, 789]);