I am using the following function to generate a public and private key. The public key is send as a string to the user like this:
val public = Base64.getEncod