change genkey function, add a return of public key