Module lightning::util::message_signing[][src]

Expand description

Lightning message signing and verification lives here. These tools can be used to sign messages using the node’s secret so receivers are sure that they come from you. You can also use this to verify that a given message comes from a specific node. Furthermore, these tools can be used to sign / verify messages using ephemeral keys not tied to node’s identities.

Note this is not part of the specs, but follows lnd’s signing and verifying protocol, which can is defined as follows:

signature = zbase32(SigRec(sha256d((“Lightning Signed Message:” + msg))) zbase32 from https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt SigRec has first byte 31 + recovery id, followed by 64 byte sig.

This implementation is compatible with both lnd’s and c-lightning’s

https://lightning.readthedocs.io/lightning-signmessage.7.html https://api.lightning.community/#signmessage

Functions

Recovers the PublicKey of the signer of the message given the message and the signature.

Creates a digital signature of a message given a SecretKey, like the node’s secret. A receiver knowing the PublicKey (e.g. the node’s id) and the message can be sure that the signature was generated by the caller. Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.

Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, and the PublicKey.