spacemeshos / smcli

Spacemesh command-line tool
https://spacemesh.io/
MIT License
8 stars 9 forks source link

Add a smapp-compatible `wallet sign` subcommand #101

Open xearl4 opened 1 month ago

xearl4 commented 1 month ago

Motivation

smapp has a simple message signing functionality, which uses a wallet's keypair to sign text messages using Ed25519ctx. This functionality is used by, for example, Team24 to authenticate an sm1 address owner. The functionality is also supported by the third-party wallet implementation smeshwallet.com.

Description

This change adds a simple smcli wallet sign subcommand, which takes a wallet JSON and a message as arguments, signs the message, and outputs a smapp-compatible JSON structure of message, signature, and signer public key.

Sample Output

$ smcli wallet sign wallet.json "hey, it's now $(date -u -Is)!"
Enter wallet password: 
{
  "text": "hey, it's now 2024-03-09T22:35:01+00:00!",
  "signature": "0xec4d98c62ba07467b6eaf078d0974ccd3020ff763a638090935828a20913e4af0edd9550d98ad318f2766eb0f24c7b29038f33fa765228e93dc215437f7f7d03",
  "publicKey": "0xba24fa22891ea77c41027d16694858f4bb397b47baf6ca93a1847318e96765de"
}