From f830939586bb6f1414a55cf1e387c8debebe3fb6 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 30 Mar 2021 18:48:17 +0200 Subject: [PATCH] lnworker: change crypto for onchain static backups Use scripthash as nonce instead of scriptPubKey, as first two bytes of scriptPubKey are static, i.e. wasted. --- electrum/lnworker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 8a7f42f39..5a460f728 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -32,7 +32,7 @@ from .util import NetworkRetryManager, JsonRPCClient from .lnutil import LN_MAX_FUNDING_SAT from .keystore import BIP32_KeyStore from .bitcoin import COIN -from .bitcoin import opcodes, make_op_return, address_to_script +from .bitcoin import opcodes, make_op_return, address_to_scripthash from .transaction import Transaction from .transaction import get_script_type_from_output_script from .crypto import sha256 @@ -1026,13 +1026,13 @@ class LNWallet(LNWorker): return CB_MAGIC_BYTES + node_id[0:16] def decrypt_cb_data(self, encrypted_data, funding_address): - funding_scriptpubkey = bytes.fromhex(address_to_script(funding_address)) - nonce = funding_scriptpubkey[0:12] + funding_scripthash = bytes.fromhex(address_to_scripthash(funding_address)) + nonce = funding_scripthash[0:12] return chacha20_decrypt(key=self.backup_key, data=encrypted_data, nonce=nonce) def encrypt_cb_data(self, data, funding_address): - funding_scriptpubkey = bytes.fromhex(address_to_script(funding_address)) - nonce = funding_scriptpubkey[0:12] + funding_scripthash = bytes.fromhex(address_to_scripthash(funding_address)) + nonce = funding_scripthash[0:12] return chacha20_encrypt(key=self.backup_key, data=data, nonce=nonce) def mktx_for_open_channel(