Added code to generate keys and to securely do a key transfer