Updated private key generation and encryption

Also, some reformatting slipped into this commit