[lib] Generate key pair.