Repository navigation
Conversation
An app could call sign_message and get a signature with no user interaction. AppsApi now asks for consent first, like for tx_send and contract calls. The wallets get a new virtual ClientThread_getSignConsent with the message and the key material. Its default shows the existing contract consent dialog with the message as the comment, no amounts and no fee, so beam-ui, Android and the web wallet ask the user without any change on their side. A wallet can override it for a dedicated dialog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1881.
Problem
sign_messageis allowed for apps (APPS_ALLOWED), andAppsApi::AnyThread_callWalletApiCheckedasks the user only fortx_sendandprocess_invoke_data. Any other allowed method runs right away. So a DApp could get a signature made with a key derived from the wallet's master key, for any message and anykey_material, without the user seeing anything.Change
AppsApisendssign_messageto a consent step, liketx_sendand contract calls. The method runs only after the wallet callsAnyThread_callWalletApiDirectly(request)(approve). A rejection goes throughAnyThread_sendApiError(..., UserRejected), as for the other consents.ClientThread_getSignConsent(request, info).infohasmessage,keyMaterialandisSignMessage: true.ClientThread_getContractConsentwith the message ascomment,fee: 0,isSpend: false,isEnough: trueand no amounts. beam-ui, Android (android/dao) and the web wallet (wasmclient) already implement that dialog (checked against beam-ui1cc4d1a,AppView.qml→send_confirm.qml), so they ask the user right away. A wallet can override the hook later for a dedicated "sign message" dialog.CheckInfouses an enum instead of thesendbool, since there are now three kinds of consent.wallet-api itself (API key owner, not an app) is unchanged.
Tests
New
TestAppsApiSignMessageinwallet_test. It runs end to end: a realWalletClientwith its wallet thread, an app created viaAppsApi::ClientThread_Create, and client-context calls run on the main reactor, as the UI thread does. The test checks that:sign_messageproduces no response and asks for consent, with the message, key material, no fee and no amounts;Without the fix the test fails: the app gets the signature immediately and no consent is requested. With the fix,
wallet_testandwallet_api_testpass (macOS arm64, Ninja RelWithDebInfo). The Android and wasm builds are not built here. They don't override the new hook, so they use the default.