fix: join community with keycard (#15635)
* fix: keycard signature add 27 * fix: hash message before signing on keycard
This commit is contained in:
parent
c3761ebd61
commit
3202413501
|
@ -15,6 +15,7 @@ import app_service/service/keycard/service as keycard_service
|
||||||
import app_service/common/types
|
import app_service/common/types
|
||||||
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||||
import app_service/service/network/network_item
|
import app_service/service/network/network_item
|
||||||
|
import ../../../../backend/general as status_general
|
||||||
|
|
||||||
const UNIQUE_COMMUNITIES_MODULE_AUTH_IDENTIFIER* = "CommunitiesModule-Authentication"
|
const UNIQUE_COMMUNITIES_MODULE_AUTH_IDENTIFIER* = "CommunitiesModule-Authentication"
|
||||||
const UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER* = "CommunitiesModule-Signing"
|
const UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER* = "CommunitiesModule-Signing"
|
||||||
|
@ -466,9 +467,10 @@ proc runSignFlow(self: Controller, pin, path, dataToSign: string) =
|
||||||
self.keycardService.startSignFlow(path, dataToSign, pin)
|
self.keycardService.startSignFlow(path, dataToSign, pin)
|
||||||
|
|
||||||
proc runSigningOnKeycard*(self: Controller, keyUid: string, path: string, dataToSign: string, pin: string) =
|
proc runSigningOnKeycard*(self: Controller, keyUid: string, path: string, dataToSign: string, pin: string) =
|
||||||
var finalDataToSign = dataToSign
|
var finalDataToSign = status_general.hashMessageForSigning(dataToSign)
|
||||||
if finalDataToSign.startsWith("0x"):
|
if finalDataToSign.startsWith("0x"):
|
||||||
finalDataToSign = finalDataToSign[2..^1]
|
finalDataToSign = finalDataToSign[2..^1]
|
||||||
|
|
||||||
if pin.len == 0:
|
if pin.len == 0:
|
||||||
let data = SharedKeycarModuleSigningArgs(uniqueIdentifier: UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER,
|
let data = SharedKeycarModuleSigningArgs(uniqueIdentifier: UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER,
|
||||||
keyUid: keyUid,
|
keyUid: keyUid,
|
||||||
|
|
|
@ -732,10 +732,12 @@ method onDataSigned*(self: Module, keyUid: string, path: string, r: string, s: s
|
||||||
# being here is not an error
|
# being here is not an error
|
||||||
return
|
return
|
||||||
|
|
||||||
|
let vFixed = toLower(uint8(parseUint(v) + 27).toHex())
|
||||||
|
|
||||||
for address, details in self.joiningCommunityDetails.addressesToShare.pairs:
|
for address, details in self.joiningCommunityDetails.addressesToShare.pairs:
|
||||||
if details.keyUid != keyUid or details.path != path:
|
if details.keyUid != keyUid or details.path != path:
|
||||||
continue
|
continue
|
||||||
self.joiningCommunityDetails.addressesToShare[address].signature = "0x" & r & s & v
|
self.joiningCommunityDetails.addressesToShare[address].signature = "0x" & r & s & vFixed
|
||||||
break
|
break
|
||||||
self.signSharedAddressesForKeypair(keyUid, pin)
|
self.signSharedAddressesForKeypair(keyUid, pin)
|
||||||
|
|
||||||
|
|
|
@ -85,3 +85,12 @@ proc backupData*(): RpcResponse[JsonNode] =
|
||||||
|
|
||||||
proc parseSharedUrl*(url: string): RpcResponse[JsonNode] =
|
proc parseSharedUrl*(url: string): RpcResponse[JsonNode] =
|
||||||
result = callPrivateRPC("parseSharedURL".prefix, %*[url])
|
result = callPrivateRPC("parseSharedURL".prefix, %*[url])
|
||||||
|
|
||||||
|
proc hashMessageForSigning*(message: string): string =
|
||||||
|
try:
|
||||||
|
let response = status_go.hashMessage(message)
|
||||||
|
let jsonResponse = parseJson(response)
|
||||||
|
return jsonResponse{"result"}.getStr()
|
||||||
|
except Exception as e:
|
||||||
|
error "hashMessage: failed to parse json response", error = e.msg
|
||||||
|
return ""
|
||||||
|
|
Loading…
Reference in New Issue