1
0

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.
This commit is contained in:
SomberNight
2021-03-30 18:48:17 +02:00
parent ce4e556e20
commit f830939586

View File

@@ -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(