ported key formats code over to libwallet.