mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
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>
67 lines
2 KiB
Makefile
67 lines
2 KiB
Makefile
#! /usr/bin/make
|
|
|
|
# Designed to be run one level up
|
|
daemon-wrongdir:
|
|
$(MAKE) -C .. daemon-all
|
|
|
|
daemon-all: daemon/lightningd daemon/lightning-cli
|
|
|
|
DAEMON_LIB_SRC := \
|
|
daemon/configdir.c \
|
|
daemon/json.c \
|
|
daemon/log.c \
|
|
daemon/pseudorand.c
|
|
DAEMON_LIB_OBJS := $(DAEMON_LIB_SRC:.c=.o)
|
|
|
|
DAEMON_SRC := \
|
|
daemon/cryptopkt.c \
|
|
daemon/dns.c \
|
|
daemon/jsonrpc.c \
|
|
daemon/lightningd.c \
|
|
daemon/netaddr.c \
|
|
daemon/peer.c \
|
|
daemon/secrets.c \
|
|
daemon/timeout.c
|
|
DAEMON_OBJS := $(DAEMON_SRC:.c=.o)
|
|
|
|
DAEMON_CLI_SRC := daemon/lightning-cli.c
|
|
DAEMON_CLI_OBJS := $(DAEMON_CLI_SRC:.c=.o)
|
|
|
|
DAEMON_JSMN_OBJS := daemon/jsmn.o
|
|
DAEMON_JSMN_HEADERS := daemon/jsmn/jsmn.h
|
|
|
|
DAEMON_HEADERS := \
|
|
daemon/configdir.h \
|
|
daemon/cryptopkt.h \
|
|
daemon/dns.h \
|
|
daemon/json.h \
|
|
daemon/jsonrpc.h \
|
|
daemon/lightningd.h \
|
|
daemon/log.h \
|
|
daemon/netaddr.h \
|
|
daemon/peer.h \
|
|
daemon/pseudorand.h \
|
|
daemon/secrets.h \
|
|
daemon/timeout.h
|
|
|
|
$(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS): $(DAEMON_HEADERS) $(DAEMON_JSMN_HEADERS) $(BITCOIN_HEADERS) $(CORE_HEADERS) $(GEN_HEADERS) $(CCAN_HEADERS)
|
|
$(DAEMON_JSMN_OBJS): $(DAEMON_JSMN_HEADERS)
|
|
|
|
check-source: $(DAEMON_SRC:%=check-src-include-order/%)
|
|
check-source: $(DAEMON_LIB_SRC:%=check-src-include-order/%)
|
|
check-source: $(DAEMON_CLI_SRC:%=check-src-include-order/%)
|
|
check-source: $(DAEMON_HEADERS:%=check-hdr-include-order/%)
|
|
check-daemon-makefile:
|
|
@if [ "`echo daemon/*.h`" != "$(DAEMON_HEADERS)" ]; then echo DAEMON_HEADERS incorrect; exit 1; fi
|
|
|
|
# Git submodules are seriously broken.
|
|
daemon/jsmn/jsmn.c:
|
|
git submodule update daemon/jsmn/
|
|
[ -f $@ ] || git submodule update --init daemon/jsmn/
|
|
|
|
daemon/jsmn.o: daemon/jsmn/jsmn.c
|
|
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<
|
|
|
|
daemon/lightningd: $(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_JSMN_OBJS) $(CORE_OBJS) $(BITCOIN_OBJS) $(CCAN_OBJS) libsecp256k1.a
|
|
|
|
daemon/lightning-cli: $(DAEMON_CLI_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_JSMN_OBJS) $(CORE_OBJS) $(BITCOIN_OBJS) $(CCAN_OBJS) libsecp256k1.a
|