I am having problems in doing pairing in cryptography. I have tried the PBC library but seems like it doesn't work and I do not understand the documentation because it uses C++ language.

Is there a library for pairing in cryptography using PHP language?

or is there anyone who can explain how pairing works in cryptography with an input and output? For example: Weil Pairing or Tate Pairing which uses Miller Algorithm.

Thank You

  • $\begingroup$ In my opinion, learning C (the actual language of the PBC library) is worth the moderate effort. The coding of number-theoretical cryptographic algorithms in PHP is unusual. That language seems more suitable to use such algorithms that are externally implemented in other languages. $\endgroup$ – fgrieu Dec 18 '17 at 8:05

As @fgrieu said [here], cryptography is usually not implemented in PHP. The best you can hope for is a binding/wrapper:

Search "php crypto binding" on Google

Unfortunately because pairings are not widely used in practice it is unlikely that you find them in major bindings, and although there are many bindings/wrappers listed on PBC website I don't see any for PHP.

Again agreeing with @fgrieu, this can be the opportunity to learn C++. Libraries like PBC (but also the RELIC toolkit) provide a rather "high-level" abstraction of pairings so you can use pairings with a few simple lines of C++.

Did you follow the PBC manual? It really takes you by the hand, if you need a basic use of pairings this should really suffice.

The RELIC toolkit does not have such a "beginner-friendly" tutorial but it is maintained (unlike PBC) and I find it nicer overall. To learn how to use RELIC you will have to read the test suite:


If you decide to learn the use of PBC or RELIC (or MIRACL) and have questions about their use I think (community, correct me?) you might want to post question stackoverflow instead.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.