Create functions for Miller-Rabin Primality Test, Euclidean Algorithm, Extended Euclidean Algorithm, and the Square and multiply algorithm to write the code for RSA key generation, encryption and decryption.