Instantly share code, notes, and snippets.

View gist:22b98f460328d142ff3b9714d63fe437
I am wondering if the first two roundtrips of pre-committing and then revealing R/r in MuSig signing can be moved to the keygen phase and made deterministic. That reduces the amount of messages that need to be exchanged, since keygen is done only once and we want to expand that phase. This would be especially useful for HD wallets so that at the expense of making wallet creation more complicated, signing needs fewer interactions.
The [musig paper](https://eprint.iacr.org/2018/068.pdf) on page 11, "Signing" specifies that signer 1:
1. sends t<sub>1</sub>=H<sub>com</sub>(R<sub>1</sub>)
2. receives t<sub>i</sub>
3. sends R<sub>1</sub>
4. receives R<sub>i</sub>
5. checks that H<sub>com</sub>(R<sub>i</sub>)==t<sub>i</sub>
View electrumx_bug_630.py
import threading
import asyncio
import time
import json
import subprocess
import colorama
import os
from utils import BitcoinRpc
from electrumutils import ElectrumX, ElectrumNode
View gist:e4dbb2fdce9d594a706196bbdf3e170c
Traceback (most recent call last):
File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/plugins/labels/labels.py", line 77, in do_post
return await result.json()
File "/home/janus/.local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 947, in json
return loads(stripped.decode(encoding))
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 2 (char 74)
View gist:ac62b994dc0679fe51b1e5a13f7da872
% rm -rf ../electrumx-db/ && mkdir -p ../electrumx-db && COIN=BitcoinSegwit SSL_KEYFILE=$PWD/key.pem SSL_CERTFILE=$PWD/cert.pem TCP_PORT=51001 SSL_PORT=51002 RPC_PORT=8000 NET=regtest DAEMON_URL=http://doggman:donkey@127.0.0.1:18554 DB_DIRECTORY=$PWD/../electrumx-db ./electrumx_server
WARNING:Env:lowered maximum sessions from 1,000 to 674 because your open file limit is 1,024
INFO:Controller:Python version: 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
INFO:Controller:software version: ElectrumX 1.8.7
INFO:Controller:aiorpcX version: 0.8.1
INFO:Controller:supported protocol versions: 1.1-1.4
INFO:Controller:event loop policy: None
INFO:Controller:reorg limit is 8,000 blocks
INFO:Daemon:daemon #1 at 127.0.0.1:18554/ (current)
View electrum_lnd_test
YOU NEED TO ADJUST PATHS IN THE TWO FOLLOWING SCRIPTS!!!
You need
- expect(1), package expect on Ubuntu
- bitcoind/bitcoin-cli 0.16 (with wallet. tested with 686e97a0c) in $PATH
- lnd (tested with 26f68da5b2883885fcf6a8e79b3fc9bb12cc9eef)
- electrum on lightning
- electrumx
- jq ('lightweight and flexible command-line JSON processor')
View gist:7ce3e7c6346a3b9b035481769176f00d
import socket
import asyncio
futs = []
for i in range(100):
t = asyncio.get_event_loop().getaddrinfo("aa000000aa"+str(i)+".onion.", 80)
futs.append(t)
print(asyncio.get_event_loop().run_until_complete(asyncio.gather(*futs, return_exceptions=True)))
View dump_lnd_sighash_preimage.diff
--- vendor/github.com/roasbeef/btcd/txscript/script2.go 2018-04-17 17:56:48.655160616 +0200
+++ vendor/github.com/roasbeef/btcd/txscript/script.go 2018-04-17 17:57:41.407045406 +0200
@@ -5,6 +5,7 @@
package txscript
import (
+ "encoding/hex"
"bytes"
"encoding/binary"
"fmt"
View gist:9c9ba0fbdbb4d8bfa8cda45b97db767c
ELECTRUM
preimage 0100000005d38084607a52d0ded63a2c745c5b488e302c7a385281edc5d6adf6c37c288118606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe1980fba112766fd98ff726659f78a01a9a499ed2ff81d1a469ad19d34c0d28cf714010000001976a914a98a5c94395a834f56084aae7a19e7a0d052859588ac00e1f50500000000feffffff050438e32146d5e69afb04711538669bc3a1b41b60544f5a77616955d6c011f96c03000001000000
is_complete True
[localhost] localpubkey b'0235f2dbfaa89b57ec7b055afe29849ef7ddfeb1cefdb9ebdc43f5494984db29e5'
[localhost] revocation_pubkey b'036efccd406915ba530019f78ec2d88176ded8f2fbbb8b88d25128a11344d40b4c'
[localhost] local_delayedpubkey b'02619836abd346f29b5809cf4307a3d2fe33857c81e0590a0fc0af44ccad35bead'
[localhost] remotepubkey b'02130c3c1169d39e5cf7baf16a422727ab8a902831bca50027181c72363fa8f0ae'
locktime 538345268 0x20167f34
adding signature for 03507251c60ce6bdbc93e4b17e8892ca8c9b374e69bd7a2e9384cf618cce7e56ec
View gist:e934709fb5f9fc43ce246e88cf69dbb3
commitment_transactions
ours
020000000001018e8a0aafb4ba1c7f1fea0d06dd6f66428f3f33eb1ce27827e1baeef74e4e53130000000000dd7bbd80020000000000000000160014c282726259ff58bfec883d9538e07be6b84744f3901500000000000022002070d4444bac244d7306613ce366796800e7b22c86d842e7ddb8b952a6ab756963feffffffff204e0000000000000400483045022100ba9246d338a631de6ada5f1e876eb505f81ebd5f08d1c9b157e815a593e415bc022064c5b2654298fb97a16d866e7160b247c2f4538f3f3fcbb8d9822b49a9a3fde80101ff47522103507251c60ce6bdbc93e4b17e8892ca8c9b374e69bd7a2e9384cf618cce7e56ec2103cf081ed9b1ad86b78f72d78fde5ec4567da995e719b347d7c344e7b373a1abe952ae80a57520
theirs
020000000113534e4ef7eebae12778e21ceb333f8f42666fdd060dea1f7f1cbab4af0a8a8e0000000000dd7bbd8001204e000000000000160014f64cc897d54e3e06f3b9aa93c46fd54440f25a1580a57520
View gist:41ede482beb22bcc8e079185565d1743
02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a4884890000000000feffffff028096980000000000220020a356f1e075466e95649997c9c65f3cb0fc97542e385d9439cd0a88eedfddff290000000000000000160014aa1df6627a20234c9f04caf1ca67adb9254c3e15feffffffff809698000000000004004830450221009f3301fa336788b914555bcdfb0d859f0f21001fca9927eb913e5b9eec487274022038592a700e2be27f65fc8a3fb6c6df54e6fb78bd99d5afe294ce41bf5fe55b5b0101ff475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae14195238b02b20
02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8002c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de84311054a56a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0400473044022051b75c73198c6deee1a875871c3961832909acd297c6b908d59e3319e5185a46022055c419379c5051a78d00dbbce11b5b664a0c22815fbcc6fcef6b1937c383693901483045022100f51d2e566a70ba740fc5d8c0f07b9b93d