An implementation of rgb on core lightning This fork of cln is maintained by Vincenzo Palazzo
Go to file
Rusty Russell 74f294e36c daemon: encrypted communication (version 3)
After useful feedback from Anthony Towns and Mats Jerratsch (of
thunder.network fame), this is the third version of inter-node crypto.

1) First, each side sends a 33-byte session pubkey.  This is a
   bitcoin-style compressed EC key, unique for each session.
  
2) ECDH is used to derive a shared secret.  From this we generate
   the following transmission encoding parameters for each side:
   Session AES-128 key: SHA256(shared-secret || my-sessionpubkey || 0)
   Session HMAC key: SHA256(shared-secret || my-sessionpubkey || 1)
   IV for AES: SHA256(shared-secret || my-sessionpubkey || 2)

3) All packets from then on are encrypted of form:
	/* HMAC, covering totlen and data */
	struct sha256 hmac;
	/* Total data transmitted (including this). */
	le64 totlen;
	/* Encrypted contents, rounded up to 16 byte boundary. */
	u8 data[];

4) The first packet is an Authenticate protobuf, containing this node's
   pubkey, and a bitcoin-style EC signature of the other side's session
   pubkey.

5) Unknown protobuf fields are handled in the protocol as follows
   (including in the initial Authenticate packet):

   1) Odd numbered fields are optional, and backwards compatible.
   2) Even numbered fields are required; abort if you get one.

Currently both sides just send an error packet "hello" after the
handshake, and make sure they receive the same.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:48 +10:30
bitcoin bitcoin: hand in a secp256k1_context to all routines. 2016-01-22 06:41:47 +10:30
ccan ccan: update and add more. 2016-01-22 06:41:45 +10:30
daemon daemon: encrypted communication (version 3) 2016-01-22 06:41:48 +10:30
doc Regenerate PDF. 2015-11-20 06:45:19 +10:30
secp256k1 secp256k1: add "ignored" files. 2015-09-30 16:39:02 +09:30
test pkt_err: make it variadic. 2016-01-22 06:41:47 +10:30
test-cli close_tx: don't use protobufs. 2016-01-22 06:41:47 +10:30
.gitignore Version number, name, and build details. 2015-08-08 20:45:49 +09:30
.gitmodules daemon/jsmn: Add submodule for jsmn. 2016-01-22 06:37:13 +10:30
LICENSE licensing: Make license explicit. 2016-01-22 06:41:46 +10:30
Makefile daemon: configuration directory (default ~/.lightning). 2016-01-22 06:41:48 +10:30
README.md README.md: A few more details about what we're doing. 2015-10-24 14:41:10 +10:30
close_tx.c close_tx: don't use protobufs. 2016-01-22 06:41:47 +10:30
close_tx.h close_tx: don't use protobufs. 2016-01-22 06:41:47 +10:30
commit_tx.c funding: remove protobufs. 2016-01-22 06:41:47 +10:30
commit_tx.h create_commit_tx: don't use protobufs in the API. 2016-01-22 06:41:47 +10:30
find_p2sh_out.c source cleanup: sort include lines into alpha order 2016-01-22 06:38:08 +10:30
find_p2sh_out.h header cleanup: sort include lines into alpha order, after config.h 2016-01-22 06:38:08 +10:30
funding.c funding: adjust_fee() to allow fee alterations. 2016-01-22 06:41:47 +10:30
funding.h funding: adjust_fee() to allow fee alterations. 2016-01-22 06:41:47 +10:30
lightning.pb-c.c daemon: encrypted communication (version 3) 2016-01-22 06:41:48 +10:30
lightning.pb-c.h daemon: encrypted communication (version 3) 2016-01-22 06:41:48 +10:30
lightning.proto daemon: encrypted communication (version 3) 2016-01-22 06:41:48 +10:30
names.c names: generate names for command_status and state_peercond. 2016-01-22 06:41:46 +10:30
names.h names: generate names for command_status and state_peercond. 2016-01-22 06:41:46 +10:30
opt_bits.c opt_bits: parsing routines for 'bits' == 100 satoshi. 2015-06-07 13:52:04 +09:30
opt_bits.h header cleanup: sort include lines into alpha order, after config.h 2016-01-22 06:38:08 +10:30
overflows.h header cleanup: sort include lines into alpha order, after config.h 2016-01-22 06:38:08 +10:30
permute_tx.c source cleanup: sort include lines into alpha order 2016-01-22 06:38:08 +10:30
permute_tx.h header cleanup: sort include lines into alpha order, after config.h 2016-01-22 06:38:08 +10:30
protobuf_convert.c bitcoin: hand in a secp256k1_context to all routines. 2016-01-22 06:41:47 +10:30
protobuf_convert.h bitcoin: hand in a secp256k1_context to all routines. 2016-01-22 06:41:47 +10:30
state.c state: add peer_unwatch_close_timeout() call. 2016-01-22 06:41:47 +10:30
state.h pkt_err: make it variadic. 2016-01-22 06:41:47 +10:30
state_types.h state: add async anchor creation. 2016-01-22 06:41:47 +10:30
version.c source cleanup: sort include lines into alpha order 2016-01-22 06:38:08 +10:30
version.h header cleanup: sort include lines into alpha order, after config.h 2016-01-22 06:38:08 +10:30

README.md

Lightning Protocol Reference Implementation

In this repository we're developing a reference implementation of bitcoin lightning (see: http://lightning.network which proposed the original "lightning network").

The first step was to develop a wire protocol for nodes to talk to each other. The wire protocol is documented in lightning.proto (a protobuf definition file). There are command line utilities to create and process various packets in test-cli.

The second step is to create a daemon which uses that protocol to communicate with others to set up channels and make simple payments. This also involves monitoring the blockchain for transactions. This is where development is currently occurring.

Later steps will enhance the protocol to network individual daemons, advertize their IP addresses, publish routes and fees, and use that information to pay specific nodes. These details are currently being hashed out on the mailing list and the IRC channel #lightning-dev on Freenode.

The protocol requires features not currently in bitcoin, so by default it runs on top of the sidechain Elements Alpha. It can be tested with bitcoin (on testnet) with OP_NOP substitution, at the top level Makefile.

Final note: This is very much a testbed and work in progress; expect All The Things to change, all the time.

Welcome aboard!

Rusty.