Sign and Verify messages
See original GitHub issueDescription of the Feature or Idea
Add the ability for websites to request the visitor’s LN node to sign or verify a message according to the WebLN provider spec https://github.com/wbobeirne/webln#provider-spec.
/* Prompts the user to sign a message with their private key */
signMessage(message: string): Promise<SignMessageResponse>;
/* Shows the user a view that verifies a signed message */
verifyMessage(signedMessage: string, rawMessage: string): Promise<void>;
Limitations
LND requires nodes be routable between each other in order to verify a message. In other words, given the lightning networks A -> B -> C
& D <- E
. If A
signs a message, then B
and C
are able to verify that message but D
and E
are not.
The lncli verifymessage
command returns valid: false
in these two cases:
- the message and signature do not match
- the signing node is not reachable from the verifying node on the network
Joule will not be able to inform the website if the failure is one or the other.
Use Cases
Sign The obvious use case is for authentication. The website can give the user a message to sign using Joule then take the signature and verify it on the backend to confirm the identity of the user’s node.
Verify ??? 🤔
I’ve started implementing this functionality. I’m creating this PR to open the floor for suggestions or ideas for improvements
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
As noted in https://github.com/BlueWallet/BlueWallet/issues/578, for the authentication use-case, it would be ideal to use a purely JS implementation of verifyMessage.
There is an implementation available at https://github.com/nerddan/ln-crypto for reference.
I’ve implemented both prompts already. I’m not 100% satisfied with the UI for verify. I’ll create a PR tomorrow with what i have so far to get your feedback.