-
Notifications
You must be signed in to change notification settings - Fork 1
feat(stellar-wallet-snap): add signProofOfOwnership client request RPC
#186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stanleyyconsensys
wants to merge
5
commits into
main
Choose a base branch
from
feat/stellar/signproof
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ac01643
feat(stellar-wallet-snap): add `signProofOfOwnership `
stanleyyconsensys bee317a
chore: update chg log
stanleyyconsensys b734373
chore: update docs
stanleyyconsensys 3a5b0d2
Merge branch 'main' into feat/stellar/signproof
stanleyyconsensys e28cee5
chore: update shasum
stanleyyconsensys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
packages/stellar-wallet-snap/docs/use-cases/client-request/signProofOfOwnership.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Use case: `signProofOfOwnership` | ||
|
|
||
| Silently signs a proof-of-ownership message so `@metamask/profile-metrics-controller` can prove the user controls a Stellar address. | ||
|
|
||
| | | | | ||
| | ---------- | --------------------------------------------------------------------------------------------------------------- | | ||
| | **Entry** | `onClientRequest` → `ClientRequestHandler` → `SignProofOfOwnershipHandler` | | ||
| | **Method** | `signProofOfOwnership` (`ClientRequestMethod.SignProofOfOwnership`) | | ||
| | **Source** | [`handlers/clientRequest/signProofOfOwnership.ts`](../../../src/handlers/clientRequest/signProofOfOwnership.ts) | | ||
|
|
||
| This is a **silent sign** — there is no confirmation dialog. That is intentional: the MetaMask client needs an ownership proof without interrupting the user. The method is scoped so it cannot be used as a general sign-message bypass: | ||
|
|
||
| 1. SIP-31 `onClientRequest` is only callable by the MetaMask client. | ||
| 2. The plaintext must be `metamask:proof-of-ownership:{nonce}:{address}`, and the embedded address must match the signing account. | ||
| 3. Signing uses [SEP-0053](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0053.md) (`Wallet.signMessage`). | ||
|
|
||
| ## Request / response (shape) | ||
|
|
||
| **Request params** | ||
|
|
||
| - `accountId` — keyring account UUID | ||
| - `message` — plaintext `metamask:proof-of-ownership:{nonce}:{address}` (nonce may contain colons; the address is the last `:`-separated field) | ||
| - `nonce`, `address` — coerced from `message` internally (clients do not send these) | ||
|
|
||
| **Response** | ||
|
|
||
| - `{ signature }` — standard base64 of the 64-byte ed25519 signature (SEP-0053) | ||
|
|
||
| ## Participants | ||
|
|
||
| | Component | Path | Role in this flow | | ||
| | ----------------------------- | ------------------------ | ---------------------------------------------------- | | ||
| | `ClientRequestHandler` | `handlers/clientRequest` | Routes `signProofOfOwnership` to the handler | | ||
| | `SignProofOfOwnershipHandler` | `handlers/clientRequest` | Validates message, resolves wallet, signs | | ||
| | `AccountResolver` | `handlers/` | Loads keyring account + wallet (no on-chain account) | | ||
| | `Wallet` | `services/wallet` | SEP-0053 `signMessage` | | ||
|
|
||
| ## Step-by-step | ||
|
|
||
| 1. **Route** — `onClientRequest` dispatches to `SignProofOfOwnershipHandler`. | ||
| 2. **Validate** — Request must match `SignProofOfOwnershipJsonRpcRequestStruct` (prefix, nonce, Stellar address). `nonce` and `address` are coerced from `message`. | ||
| 3. **Resolve** — `BaseClientRequestHandler` loads keyring account and wallet only (`RESOLVE_ACCOUNT_KEYRING_AND_WALLET`). The destination account does not need to be activated on-chain. | ||
| 4. **Bind** — The address in the message must equal the signing account address. | ||
| 5. **Sign** — `Wallet.signMessage(message)` (SEP-0053, base64). | ||
|
|
||
| ## Sequence (happy path) | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant Client | ||
| participant Handler as SignProofOfOwnershipHandler | ||
| participant Resolver as AccountResolver | ||
| participant Wallet | ||
|
|
||
| Client->>Handler: signProofOfOwnership { accountId, message } | ||
| Note over Handler: validate coerces nonce + address from message | ||
| Handler->>Resolver: resolve keyring account + wallet | ||
| Resolver-->>Handler: account, wallet | ||
| Handler->>Handler: message address == account.address | ||
| Handler->>Wallet: signMessage (SEP-0053, base64) | ||
| Wallet-->>Handler: signature | ||
| Handler-->>Client: { signature } | ||
| ``` | ||
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace BaseClientRequestHandler with SignProofOfOwnershipHandler (or AccountResolver). That class is the one that actually calls resolveAccount with RESOLVE_ACCOUNT_KEYRING_AND_WALLET.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup the doc is not update, let me update it