mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-26 07:15:53 +00:00
[#10409] Invalid mnemonic on keycard acc creation
Usage of `Keycard.generateMnemonic` is removed from the code as we always generate new multiaccounts on status-go side. Previously it was misused and was called with intention of generation of mnemonic for an existing keycard multiacc.
This commit is contained in:
parent
ed87e350ae
commit
c805333bcd
@ -171,26 +171,6 @@
|
|||||||
(re-frame/dispatch
|
(re-frame/dispatch
|
||||||
[:hardwallet.callback/on-pair-error (error-object->map response)]))})))
|
[:hardwallet.callback/on-pair-error (error-object->map response)]))})))
|
||||||
|
|
||||||
(defn generate-mnemonic [args]
|
|
||||||
(log/info "[keycard] generate-mnemonic" args)
|
|
||||||
(keycard/generate-mnemonic
|
|
||||||
card
|
|
||||||
(merge
|
|
||||||
args
|
|
||||||
{:on-success
|
|
||||||
(fn [response]
|
|
||||||
(log/info "[keycard response succ] generate-mnemonic"
|
|
||||||
(js->clj response :keywordize-keys true))
|
|
||||||
(re-frame/dispatch
|
|
||||||
[:hardwallet.callback/on-generate-mnemonic-success response]))
|
|
||||||
:on-failure
|
|
||||||
(fn [response]
|
|
||||||
(log/info "[keycard response fail] generate-mnemonic"
|
|
||||||
(error-object->map response))
|
|
||||||
(re-frame/dispatch
|
|
||||||
[:hardwallet.callback/on-generate-mnemonic-error
|
|
||||||
(error-object->map response)]))})))
|
|
||||||
|
|
||||||
(defn generate-and-load-key [args]
|
(defn generate-and-load-key [args]
|
||||||
(log/info "[keycard] generate-and-load-key" args)
|
(log/info "[keycard] generate-and-load-key" args)
|
||||||
(keycard/generate-and-load-key
|
(keycard/generate-and-load-key
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
{:db (update-in db [:hardwallet :secrets] merge pairing-data)}
|
{:db (update-in db [:hardwallet :secrets] merge pairing-data)}
|
||||||
(common/listen-to-hardware-back-button)
|
(common/listen-to-hardware-back-button)
|
||||||
(when (= flow :create)
|
(when (= flow :create)
|
||||||
(mnemonic/proceed-with-generating-mnemonic))
|
(mnemonic/set-mnemonic))
|
||||||
(when (= flow :recovery)
|
(when (= flow :recovery)
|
||||||
(onboarding/proceed-with-generating-key)))
|
(onboarding/proceed-with-generating-key)))
|
||||||
(recovery/load-pair-screen cofx)))))
|
(recovery/load-pair-screen cofx)))))
|
||||||
@ -181,7 +181,6 @@
|
|||||||
:hardwallet/generate-and-load-key
|
:hardwallet/generate-and-load-key
|
||||||
:hardwallet/remove-key-with-unpair
|
:hardwallet/remove-key-with-unpair
|
||||||
:hardwallet/unpair-and-delete
|
:hardwallet/unpair-and-delete
|
||||||
:hardwallet/generate-mnemonic
|
|
||||||
:wallet.accounts/generate-new-keycard-account} on-verified)
|
:wallet.accounts/generate-new-keycard-account} on-verified)
|
||||||
(common/get-application-info pairing nil))
|
(common/get-application-info pairing nil))
|
||||||
(when on-verified
|
(when on-verified
|
||||||
|
@ -42,10 +42,6 @@
|
|||||||
:hardwallet/pair
|
:hardwallet/pair
|
||||||
card/pair)
|
card/pair)
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:hardwallet/generate-mnemonic
|
|
||||||
card/generate-mnemonic)
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:hardwallet/generate-and-load-key
|
:hardwallet/generate-and-load-key
|
||||||
card/generate-and-load-key)
|
card/generate-and-load-key)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
(init-card [this args])
|
(init-card [this args])
|
||||||
(install-applet-and-init-card [this args])
|
(install-applet-and-init-card [this args])
|
||||||
(pair [this args])
|
(pair [this args])
|
||||||
(generate-mnemonic [this args])
|
|
||||||
(generate-and-load-key [this args])
|
(generate-and-load-key [this args])
|
||||||
(unblock-pin [this args])
|
(unblock-pin [this args])
|
||||||
(verify-pin [this args])
|
(verify-pin [this args])
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
(init-card [this args])
|
(init-card [this args])
|
||||||
(install-applet-and-init-card [this args])
|
(install-applet-and-init-card [this args])
|
||||||
(pair [this args])
|
(pair [this args])
|
||||||
(generate-mnemonic [this args])
|
|
||||||
(generate-and-load-key [this args])
|
(generate-and-load-key [this args])
|
||||||
(unblock-pin [this args])
|
(unblock-pin [this args])
|
||||||
(verify-pin [this args])
|
(verify-pin [this args])
|
||||||
|
@ -1,81 +1,27 @@
|
|||||||
(ns status-im.hardwallet.mnemonic
|
(ns status-im.hardwallet.mnemonic
|
||||||
(:require [clojure.string :as string]
|
(:require [status-im.ui.screens.navigation :as navigation]
|
||||||
[status-im.ethereum.mnemonic :as mnemonic]
|
|
||||||
[status-im.ui.screens.navigation :as navigation]
|
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.hardwallet.common :as common]
|
[status-im.hardwallet.common :as common]
|
||||||
status-im.hardwallet.fx))
|
status-im.hardwallet.fx))
|
||||||
|
|
||||||
(fx/defn on-generate-mnemonic-success
|
|
||||||
{:events [:hardwallet.callback/on-generate-mnemonic-success]}
|
|
||||||
[{:keys [db] :as cofx} mnemonic]
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (-> db
|
|
||||||
(assoc-in [:hardwallet :setup-step] :recovery-phrase)
|
|
||||||
(assoc-in [:hardwallet :secrets :mnemonic] mnemonic))}
|
|
||||||
(common/clear-on-card-connected)
|
|
||||||
(navigation/navigate-replace-cofx :keycard-onboarding-recovery-phrase nil)))
|
|
||||||
|
|
||||||
(fx/defn set-mnemonic
|
(fx/defn set-mnemonic
|
||||||
{:events [:test-mnemonic]}
|
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
|
(log/debug "[hardwallet] set-mnemonic")
|
||||||
(let [selected-id (get-in db [:intro-wizard :selected-id])
|
(let [selected-id (get-in db [:intro-wizard :selected-id])
|
||||||
accounts (get-in db [:intro-wizard :multiaccounts])
|
mnemonic (reduce
|
||||||
mnemonic (->> accounts
|
(fn [_ {:keys [id mnemonic]}]
|
||||||
(filter (fn [{:keys [id]}]
|
(when (= selected-id id)
|
||||||
(= id selected-id)))
|
(reduced mnemonic)))
|
||||||
first
|
nil
|
||||||
:mnemonic)]
|
(get-in db [:intro-wizard :multiaccounts]))]
|
||||||
(fx/merge cofx
|
(fx/merge
|
||||||
{:db (assoc-in db [:hardwallet :secrets :mnemonic] mnemonic)}
|
cofx
|
||||||
(on-generate-mnemonic-success mnemonic))))
|
{:db (-> db
|
||||||
|
(assoc-in [:hardwallet :setup-step] :recovery-phrase)
|
||||||
(fx/defn generate-mnemonic
|
(assoc-in [:hardwallet :secrets :mnemonic] mnemonic))}
|
||||||
{:events [:hardwallet/generate-mnemonic]}
|
(common/clear-on-card-connected)
|
||||||
[cofx]
|
(navigation/navigate-replace-cofx :keycard-onboarding-recovery-phrase nil))))
|
||||||
(let [{:keys [pairing]} (get-in cofx [:db :hardwallet :secrets])]
|
|
||||||
{:hardwallet/generate-mnemonic {:pairing pairing
|
|
||||||
:words (string/join "\n" mnemonic/dictionary)}}))
|
|
||||||
|
|
||||||
(fx/defn proceed-with-generating-mnemonic
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(let [pin (or (get-in db [:hardwallet :secrets :pin])
|
|
||||||
(common/vector->string (get-in db [:hardwallet :pin :current])))]
|
|
||||||
(if (empty? pin)
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (assoc-in db [:hardwallet :pin] {:enter-step :current
|
|
||||||
:on-verified :hardwallet/generate-mnemonic
|
|
||||||
:current []})}
|
|
||||||
(navigation/navigate-to-cofx :keycard-onboarding-pin nil))
|
|
||||||
(generate-mnemonic cofx))))
|
|
||||||
|
|
||||||
(fx/defn load-generating-mnemonic-screen
|
|
||||||
{:events [:hardwallet/load-generating-mnemonic-screen]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(fx/merge
|
|
||||||
cofx
|
|
||||||
{:db (assoc-in db [:hardwallet :setup-step] :generating-mnemonic)}
|
|
||||||
(common/show-connection-sheet
|
|
||||||
{:on-card-connected :hardwallet/load-generating-mnemonic-screen
|
|
||||||
:handler (common/dispatch-event :hardwallet/generate-mnemonic)})))
|
|
||||||
|
|
||||||
(fx/defn on-generate-mnemonic-error
|
|
||||||
{:events [:hardwallet.callback/on-generate-mnemonic-error]}
|
|
||||||
[{:keys [db] :as cofx} {:keys [error code]}]
|
|
||||||
(log/debug "[hardwallet] generate mnemonic error: " error)
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (assoc-in db [:hardwallet :setup-error] error)}
|
|
||||||
(common/set-on-card-connected :hardwallet/load-generating-mnemonic-screen)
|
|
||||||
(common/process-error code error)))
|
|
||||||
|
|
||||||
(fx/defn proceed-to-generate-mnemonic
|
|
||||||
{:events [:hardwallet/proceed-to-generate-mnemonic]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(log/debug "[hardwallet] proceed-to-generate-mnemonic")
|
|
||||||
(if (= (get-in db [:hardwallet :flow]) :create)
|
|
||||||
(load-generating-mnemonic-screen cofx)
|
|
||||||
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)}))
|
|
||||||
|
|
||||||
(fx/defn load-loading-keys-screen
|
(fx/defn load-loading-keys-screen
|
||||||
{:events [:hardwallet.ui/recovery-phrase-confirm-pressed
|
{:events [:hardwallet.ui/recovery-phrase-confirm-pressed
|
||||||
|
@ -215,24 +215,6 @@
|
|||||||
(show-recover-confirmation))
|
(show-recover-confirmation))
|
||||||
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||||
|
|
||||||
(fx/defn card-ready-next-button-pressed
|
|
||||||
{:events [:hardwallet.ui/card-ready-next-button-pressed]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(log/debug "[hardwallet] card-ready-next-button-pressed")
|
|
||||||
(let [pin (get-in db [:hardwallet :secrets :pin])
|
|
||||||
pin-already-set? (boolean pin)]
|
|
||||||
(if pin-already-set?
|
|
||||||
(if (= (get-in db [:hardwallet :flow]) :create)
|
|
||||||
(mnemonic/load-generating-mnemonic-screen cofx)
|
|
||||||
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)})
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (-> db
|
|
||||||
(assoc-in [:hardwallet :setup-step] :pin)
|
|
||||||
(assoc-in [:hardwallet :pin :enter-step] :current)
|
|
||||||
(assoc-in [:hardwallet :pin :on-verified] :hardwallet/proceed-to-generate-mnemonic)
|
|
||||||
(assoc-in [:hardwallet :pin :current] [])
|
|
||||||
(assoc-in [:hardwallet :pin :original] nil))}))))
|
|
||||||
|
|
||||||
(fx/defn recovery-phrase-next-button-pressed
|
(fx/defn recovery-phrase-next-button-pressed
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(if (= (get-in db [:hardwallet :flow]) :create)
|
(if (= (get-in db [:hardwallet :flow]) :create)
|
||||||
|
@ -85,14 +85,6 @@
|
|||||||
(then on-success)
|
(then on-success)
|
||||||
(catch on-failure))))
|
(catch on-failure))))
|
||||||
|
|
||||||
(defn generate-mnemonic
|
|
||||||
[{:keys [pairing words on-success on-failure]}]
|
|
||||||
(when pairing
|
|
||||||
(.. status-keycard
|
|
||||||
(generateMnemonic pairing words)
|
|
||||||
(then on-success)
|
|
||||||
(catch on-failure))))
|
|
||||||
|
|
||||||
(defn generate-and-load-key
|
(defn generate-and-load-key
|
||||||
[{:keys [mnemonic pairing pin on-success on-failure]}]
|
[{:keys [mnemonic pairing pin on-success on-failure]}]
|
||||||
(when pairing
|
(when pairing
|
||||||
@ -227,8 +219,6 @@
|
|||||||
(install-applet-and-init-card args))
|
(install-applet-and-init-card args))
|
||||||
(keycard/pair [this args]
|
(keycard/pair [this args]
|
||||||
(pair args))
|
(pair args))
|
||||||
(keycard/generate-mnemonic [this args]
|
|
||||||
(generate-mnemonic args))
|
|
||||||
(keycard/generate-and-load-key [this args]
|
(keycard/generate-and-load-key [this args]
|
||||||
(generate-and-load-key args))
|
(generate-and-load-key args))
|
||||||
(keycard/unblock-pin [this args]
|
(keycard/unblock-pin [this args]
|
||||||
|
@ -86,8 +86,6 @@
|
|||||||
(when (= password kk1-password)
|
(when (= password kk1-password)
|
||||||
(later #(on-success kk1-pair))))
|
(later #(on-success kk1-pair))))
|
||||||
|
|
||||||
(defn generate-mnemonic [args])
|
|
||||||
|
|
||||||
(defn generate-and-load-key [{:keys [pin pairing on-success]}]
|
(defn generate-and-load-key [{:keys [pin pairing on-success]}]
|
||||||
(when (and (= pin (get @state :pin))
|
(when (and (= pin (get @state :pin))
|
||||||
(= pairing kk1-pair))
|
(= pairing kk1-pair))
|
||||||
@ -152,8 +150,6 @@
|
|||||||
(install-applet-and-init-card args))
|
(install-applet-and-init-card args))
|
||||||
(keycard/pair [this args]
|
(keycard/pair [this args]
|
||||||
(pair args))
|
(pair args))
|
||||||
(keycard/generate-mnemonic [this args]
|
|
||||||
(generate-mnemonic args))
|
|
||||||
(keycard/generate-and-load-key [this args]
|
(keycard/generate-and-load-key [this args]
|
||||||
(generate-and-load-key args))
|
(generate-and-load-key args))
|
||||||
(keycard/unblock-pin [this args]
|
(keycard/unblock-pin [this args]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user