diff --git a/keycard_context.go b/keycard_context.go index edef88f..3608412 100644 --- a/keycard_context.go +++ b/keycard_context.go @@ -273,19 +273,19 @@ func (kc *keycardContext) signWithPath(data []byte, path string) (*types.Signatu return sig, nil } -func (kc *keycardContext) exportKey(derive bool, makeCurrent bool, onlyPublic bool, path string) ([]byte, error) { +func (kc *keycardContext) exportKey(derive bool, makeCurrent bool, onlyPublic bool, path string) ([]byte, []byte, error) { <-kc.connected if kc.runErr != nil { - return nil, kc.runErr + return nil, nil, kc.runErr } - key, err := kc.cmdSet.ExportKey(derive, makeCurrent, onlyPublic, path) + privKey, pubKey, err := kc.cmdSet.ExportKey(derive, makeCurrent, onlyPublic, path) if err != nil { l("exportKey failed %+v", err) - return nil, err + return nil, nil, err } - return key, nil + return privKey, pubKey, nil } func (kc *keycardContext) loadSeed(seed []byte) ([]byte, error) { diff --git a/main.go b/main.go index e9776e7..172f33d 100644 --- a/main.go +++ b/main.go @@ -260,12 +260,12 @@ func ExportKey(jsonParams *C.char) *C.char { return retValue("error", err.Error()) } - key, err := kctx.exportKey(params.Derive, params.MakeCurrent, params.OnlyPublic, params.Path) + privKey, pubKey, err := kctx.exportKey(params.Derive, params.MakeCurrent, params.OnlyPublic, params.Path) if err != nil { return retValue("error", err.Error()) } - return retValue("ok", true, "key", hexString(key)) + return retValue("ok", true, "privateKey", hexString(privKey), "publicKey", hexString(pubKey)) } //export LoadSeed