I have Alice who should do some cryptographic operations off-chain. Then a smart contact has to verify equality by performing Modular exponentiation operation. 
I attached an image of the off-chain and on-chain operations. Is there any library that can verify the last equality in the image. I tried to write the math here, but writing math equations is not allowed. 

[![enter image description here](https://i.stack.imgur.com/ncaE5.png)](https://i.stack.imgur.com/ncaE5.png)