fix: display the value to sign as a bytes32 hex string if the data is 66 chars long

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Richard Ramos 2020-04-22 13:44:26 -04:00 committed by Andrey Shovkoplyas
parent b891b1b98b
commit 277f65b94d
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
2 changed files with 11 additions and 1 deletions

View File

@ -138,3 +138,13 @@
nil)]
(when normalized-key
(subs (sha3 normalized-key) 26))))
(def ^:const bytes32-length 66) ; length of '0x' + 64 hex values. (a 32bytes value has 64 nibbles)
(defn hex->text
"Converts a hexstring to UTF8 text. If the data received is 32 bytes long,
return the value unconverted"
[data]
(if (= bytes32-length (count (normalized-hex data)))
data ; Assume it's a bytes32
(hex-to-utf8 data)))

View File

@ -195,7 +195,7 @@
:signing/sign {:type (cond pinless? :pinless
keycard-multiaccount? :keycard
:else :password)
:formatted-data (if typed? (types/json->clj data) (ethereum/hex-to-utf8 data))
:formatted-data (if typed? (types/json->clj data) (ethereum/hex->text data))
:keycard-step (when pinless? :connect)})}
(when pinless?
(signing.keycard/hash-message {:data data