Commit Graph

296 Commits

Author SHA1 Message Date
Rusty Russell
f710ba7c37 scripts/test.sh: boost CSV time to 512 seconds.
As per BIP68, that's the minimum.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell
4e23f9916d script: encode numbers minimally.
This happens for CSV, for example (3-byte encoding), and bitcoind treats
too-long encodings as non-standard.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell
0ef2b9a32e test-cli: fix htlc balance on fulfill, and add assert that total is invariant.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell
deb2e7b654 daemon/jsmn: Add submodule for jsmn.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:37:13 +10:30
Rusty Russell
45e0ab11ff Merge branch 'onion' 2016-01-22 06:35:11 +10:30
Rusty Russell
5de21f80de Regenerate PDF.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-11-20 06:45:19 +10:30
Douglas Roark
6394d2de16 Minor "Reaching the Ground With Lightning" fixes.
- Added a reference to BIP112 and to the deployment of BIP68.
- Minor typo, grammar and formatting fixes.
2015-11-18 09:54:41 +10:30
Rusty Russell
6b2d844f2a bitcoin: use ccan/mem instead of rolling own check_mem function.
Reported-by: John Newbery
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-26 21:06:23 +10:30
Rusty Russell
be58e45ee4 README.md: A few more details about what we're doing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-24 14:41:10 +10:30
Rusty Russell
2ab9e3bd7f doc/deployable-lightning: corrections and fixes.
1) Note incorrect label in txs in Fig1 of LN paper.
2) "an atomic-swap an on-chain.." -> "an atomic-swap *to* an on-chain"
3) "By using a dual anchor and escape transactions" -> "By using a rebalanced single anchor"
4) References to appendices fixed.
5) Move escape transaction scripts out to escape appendix.
6) Fix URL in bibliography (missing comma).

Reported-by: John Newbery
Closes: #11
Closes: #12
Reported-by:
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-19 10:54:49 +10:30
Rusty Russell
57f0c3b38c test-cli/scripts: use setmocktime.
TIL about setmocktime.

Suggested-by: Gavin <gavinandresen@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-16 11:59:45 +10:30
Rusty Russell
32fe988fe8 bitcoin: signature fixes.
The libsecp change broke signature checking.  Disable it for now,
with a big FIXME.  The next version should have a method for S value
checking, and also compact serialization.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-12 10:45:02 +10:30
Anthony Towns
cadaa348e3 test_onion.py: drop repeated sha calculation 2015-10-07 13:22:44 +10:00
Rusty Russell
beb702054b test_onion: minor protocol change; use single SHA to create both IVs.
Suggested-by: Anthony Towns <aj@erisian.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-07 13:08:04 +10:30
Rusty Russell
0c4eb06e26 test_onion: remove gratuitous dynamic alloc, cleanup on exit.
We skipped freeing the context in the too-many-hops case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-07 12:34:45 +10:30
Rusty Russell
064cf6cc39 test/onion_key: code cleanup.
Use ccan/opt, make arguments bool, remove commented-out code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-07 12:05:14 +10:30
Anthony Towns
b66852f1ab Makefile: add python onion tests 2015-10-06 23:49:52 +10:00
Anthony Towns
626be23180 test_onion.py: control generate/decode from command line 2015-10-06 23:49:52 +10:00
Anthony Towns
beafbe1c19 test_onion.c: generate message predictably
Generate sample encrypted payload based on actual pubkey, not
libsecp256k1's internal representation of the pubkey.
2015-10-06 23:49:52 +10:00
Anthony Towns
9ffac49c6f onion_key: allowing both odd and even pubkeys
output compressed public keys; accept compressed pubkey in test_onion
2015-10-06 23:49:52 +10:00
Anthony Towns
2042e1cdb7 onion_key: generate multiple keys at once 2015-10-06 23:49:52 +10:00
Rusty Russell
ed46dd355d test_onion: split encode and decode, drive from cmdline.
This lets us test interaction with python code, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:53 +10:30
Rusty Russell
7c36a3e058 test_onion: get rid of dummy crypto options.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:31 +10:30
Rusty Russell
32a08ce6c5 test/onion_key: helper to generate deterministic key pairs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:09 +10:30
Rusty Russell
9aa8907e38 test_onion: Rename struct pubkey to struct onion_pubkey.
And move to onion_key.h for next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:03 +10:30
Rusty Russell
8e9944bc37 test: add .gitignore
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:00:26 +10:30
Rusty Russell
f693060068 test_onion: fix random padding.
Randomness is now at start; thanks valgrind!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:00:12 +10:30
Anthony Towns
8b0635f7d3 test_onion.py: make it possible to build an onion
switched from pyelliptic to hmac/binascii/cryptography for standard
functions

use our own ECDH implementation to better match the one from secp256k1

finally, add function to create an encrypted onion
2015-10-06 00:44:03 +10:00
Anthony Towns
bb26fc3026 test_onion.py: drop unused part of message secrets 2015-10-05 17:44:49 +10:00
Anthony Towns
53e13e69c9 test_onion.py: drop separate padding method 2015-10-04 15:21:06 +10:00
Anthony Towns
75dceaf254 test_onion.py: alternative onion peeling implementation 2015-10-04 15:02:51 +10:00
Anthony Towns
b2c86c650a test_onion: dump more output 2015-10-04 15:02:30 +10:00
Rusty Russell
e165d0009c test_onion: Switch from AES256 to AES128.
AFAICT, if SHA256 is good enough, and secp256k1 is good enough, AES128
is good enough.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 15:16:44 +09:30
Rusty Russell
927bc28c8e test_onion: always generate 0x2 keys.
This means they're 32 bytes, which works better for everything.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 15:04:33 +09:30
Rusty Russell
90794d8ebf test_onion: generate onion in place.
Rather than keeping each hop, we can generate it in place since we only
need the first hop result.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 15:04:04 +09:30
Rusty Russell
6aae8d6257 test_onion: keep hmacs rather than padding.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 15:03:21 +09:30
Rusty Russell
154b917680 test_onion: put padding at the front.
This means we can save the partial HMAC of the padding for each step,
rather than the padding itself, when generating it.

Each step now takes the *last*, not *first* part of the onion array.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 15:02:53 +09:30
Rusty Russell
0b50a7c9eb Fix test scripts for alpha.
Doesn't support getblockheader, also some occasional weirdness
with sequence enforcement for mempool?  Occasionally I could get
my spend tx into the mempool (doesn't happen with bitcoin).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 10:40:07 +09:30
Rusty Russell
f36ba8f8e1 Makefile: only erase protobuf and PDF files with maintainer-clean.
Reported-by: Anthony Towns
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell
401bde5c6b secp256k1: add "ignored" files.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell
3120bc6231 secp256k1: update to cc3141a00368c8d83dc35243f4936694304d62dc
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell
81d35294f4 test/test_onion: demo program to show onion routing crypto.
We can make this more efficient, but this works for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell
b47d4bbe6a ccan: add ccan/mem.
Onion test program wants memcheck().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell
c895d4a135 ccan: update to latest.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:01 +09:30
Rusty Russell
242fa1b2dd pubkey: pubkey_eq helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:38:58 +09:30
Rusty Russell
e7856e6e69 Update libsecp to git@github.com:bitcoin/secp256k1.git 52fd03f
We want the ecdh stuff for onion routing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:37:21 +09:30
Rusty Russell
17f457568a Makefile: generate libsecpk1 properly.
And clean it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 10:54:54 +09:30
Rusty Russell
454a3867e5 BIP68 support (nSequence enforcement)
The latest version of the BIP doesn't use inversion, but does use
bitshifts.

It also uncovered a bug in the test scripts: the block timestamps
creep forward when we generate large numbers of blocks (UpdateTime
insists it be > GetMedianTimePast() so it's valid).  We need to take
this into account when waiting for the median to move (reduced it from
60 to 30 seconds, since that adds about 14 seconds).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 10:54:11 +09:30
Rusty Russell
845d09ce68 check: simple Makefile target.
This makes it much easier to run all the test scripts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-29 17:02:02 +09:30
Rusty Russell
1ac08e3b11 test_state_coverage: test all accept_pkt failure paths.
Reveals a number of places where we don't handle errors correctly.

Note: this takes about 14.5 GB to test on my x86-64 box.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-29 09:47:56 +09:30