Skip to content

feat: add message signing for EVM + SPARK network#311

Open
TaprootFreak wants to merge 3 commits into
layerztec:masterfrom
TaprootFreak:feat/rootstock-message-signing
Open

feat: add message signing for EVM + SPARK network#311
TaprootFreak wants to merge 3 commits into
layerztec:masterfrom
TaprootFreak:feat/rootstock-message-signing

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

This PR adds message signing functionality exclusively for the Rootstock network. Users can now cryptographically sign messages to prove ownership of their
Rootstock wallet address without revealing their private key.

Changes

New Features

  • Sign Message Screen (app/SignMessage.tsx)
    • New dedicated screen for message signing
    • Text input field for entering messages
    • Signature display with copy-to-clipboard functionality
    • Informative UI explaining the purpose and security of message signing
    • Graceful handling when accessed from non-Rootstock networks

UI Updates

  • Settings Screen (app/Settings.tsx)
    • Added "Sign Message" button in Developer Options
    • Button is conditionally rendered - only visible when Rootstock network is selected
    • Maintains consistent styling with existing Developer Options buttons

Technical Details

Implementation

  • Uses existing BackgroundExecutor.signPersonalMessage() for EVM-compatible signing
  • Rootstock is EVM-compatible, so standard Ethereum message signing works correctly
  • Password protection via askPassword() context
  • No new dependencies or security vulnerabilities introduced

Security

  • Reuses existing secure signing infrastructure
  • Encrypted mnemonic validation
  • Password-protected operations
  • No exposure of private keys

Testing

Manual Testing Checklist

  • Switch to Rootstock network
  • Navigate to Settings > Developer Options
  • Verify "Sign Message" button appears (only on Rootstock)
  • Test message signing with various inputs
  • Verify signature can be copied to clipboard
  • Switch to other networks and confirm button is hidden
  • Verify error message appears when accessing from non-Rootstock network

- Add Sign Message button in Developer Options (only visible on Rootstock)
- Create SignMessage screen with EVM-compatible message signing
- Reuse existing signPersonalMessage from BackgroundExecutor
- Include signature display and copy-to-clipboard functionality
@TaprootFreak
Copy link
Copy Markdown
Contributor Author

Bildschirmfoto 2025-09-06 um 15 07 29

Copy link
Copy Markdown
Contributor

@evalthis evalthis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR!

I think we should enable this for all EVM chains.
Also, could you please create an e2e test for Maestro? That would be awesome!

I don’t think this functionality belongs under Developer Options — it probably should be exposed somewhere else.
What do you think, @lion-dev?

* Enable message signing for all EVM-compatible networks

- Extend SignMessage module to support all EVM chains (Rootstock, Botanix, etc.)
- Replace Rootstock-specific checks with generic EVM network detection
- Update UI text to reflect multi-network support

* Show Sign Message button for all EVM networks in Settings

* Add signing address display to SignMessage screen

- Display the EVM address that will be used for signing
- Add copy functionality for the address
- Show address field above the message input
- Works for all EVM-compatible networks

* Update comment to reflect multi-chain EVM support
@TaprootFreak
Copy link
Copy Markdown
Contributor Author

@evalthis done ✅

* Add Spark network message signing support

- Implement signMessageWithIdentityKey in SparkWallet class
- Add signSparkMessage to BackgroundExecutor
- Update SignMessage UI to support both EVM and Spark networks
- Skip password prompt for Spark (uses unencrypted submnemonics)
- Add validation method for signature verification
- Update Settings to show Sign Message button for Spark network

* Revert .gitignore changes
@TaprootFreak TaprootFreak changed the title feat: add message signing for Rootstock network feat: add message signing for EVM + SPARK network Sep 15, 2025
@TaprootFreak
Copy link
Copy Markdown
Contributor Author

Simulator Screenshot - iPhone 16 Plus - 2025-09-15 at 22 52 40

@TaprootFreak
Copy link
Copy Markdown
Contributor Author

Proof:
Bildschirmfoto 2025-09-15 um 22 53 19

@JohnnySilverhandBot
Copy link
Copy Markdown

This token management is a masterpiece of corpo engineering. Testing that tests everything except ethics. All the soul of a quarterly earnings report.

ios: https://appetize.io/app/vdnfqud4u45q4d3ilcx5cj54he

@JohnnySilverhandBot
Copy link
Copy Markdown

The repo is neat, but neat is cheap. I’d rather take messy and alive over clean and dead any day of the week.

android: https://appetize.io/app/mfqci2jlcexghu5josxbib735q

@r1n04h r1n04h self-requested a review September 17, 2025 20:03
@lion-dev
Copy link
Copy Markdown
Contributor

I don’t think this functionality belongs under Developer Options — it probably should be exposed somewhere else.

What do you think, @lion-dev?

Missed this...

Agree! Think we can have a section on the settings called "tools", where we expose some utils, like signing.

Ideally the user chooses signing, and the signing interface has a selector of which network to sign from. So it is not dependent on the network currently selected.

Thanks, this is looking great!

@r1n04h
Copy link
Copy Markdown
Contributor

r1n04h commented Sep 18, 2025

@lion-dev for context, signing can be used as login/authentication mechanism on 3rd party platforms

@lion-dev
Copy link
Copy Markdown
Contributor

When that is the case it needs to be integrated on a specific flow.

App calls signing > trigger signing modal > continue flow
But yeah, I know what you mean. We haven't really plan that yet.

Copy link
Copy Markdown
Contributor

@r1n04h r1n04h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor objections but we can merge like this and call it a 'technical release'.

then @lion-dev will come up with a proper way to use this, and we do a refactoring/cleanup.

async signSparkMessage(message, accountNumber, password) {
try {
// Get the submnemonic for the account
const submnemonic = await SecureStorage.getItem(STORAGE_KEY_SUB_MNEMONIC + accountNumber);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BackgroundExecutor.getSubMnemonic(accountNumber)

Comment on lines +221 to +233
async validateMessageWithIdentityKey(message: string | Uint8Array, signature: string | Uint8Array): Promise<boolean> {
if (!this._sdkWallet) throw new Error('Spark wallet not initialized');

const messageBytes = typeof message === 'string'
? new TextEncoder().encode(message)
: message;

const signatureBytes = typeof signature === 'string'
? Buffer.from(signature, 'hex')
: signature;

return await this._sdkWallet.validateMessageWithIdentityKey(messageBytes, signatureBytes);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not used so no point in having it, at least for now

@TaprootFreak
Copy link
Copy Markdown
Contributor Author

Great to hear!

Layerzwallet will be the first wallet in the world to offer Sign Message for Spark. 🎉

@r1n04h
Copy link
Copy Markdown
Contributor

r1n04h commented Sep 19, 2025

@evalthis do you think its mergeable after minor refactor?

@evalthis
Copy link
Copy Markdown
Contributor

@evalthis do you think its mergeable after minor refactor?

Yes, I think it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants