Key pair

These commits add support for key pair generation.

Please, review it.