Efficient Algorithms for Pairing-Based Cryptosystems