From 01fbab794cb4f37e3eed50601cc9776b655ff867 Mon Sep 17 00:00:00 2001 From: Janus Date: Thu, 28 Jun 2018 16:04:25 +0200 Subject: [PATCH] ln: avoid code duplication --- lib/lnutil.py | 4 ++-- lib/tests/test_lnutil.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/lnutil.py b/lib/lnutil.py index 934122d2e..c5e0ca808 100644 --- a/lib/lnutil.py +++ b/lib/lnutil.py @@ -3,7 +3,7 @@ from .crypto import sha256 import json from collections import namedtuple from .transaction import Transaction -from .ecc import CURVE_ORDER, generator, sig_string_from_der_sig, ECPubkey, string_to_number +from .ecc import CURVE_ORDER, sig_string_from_der_sig, ECPubkey, string_to_number from . import ecc, bitcoin, crypto, transaction from .transaction import opcodes from .bitcoin import push_script @@ -86,7 +86,7 @@ def derive_pubkey(basepoint, per_commitment_point): def derive_privkey(secret, per_commitment_point): assert type(secret) is int - basepoint = (ecc.generator() * secret).get_public_key_bytes() + basepoint = secret_to_pubkey(secret) basepoint = secret + ecc.string_to_number(sha256(per_commitment_point + basepoint)) basepoint %= CURVE_ORDER return basepoint diff --git a/lib/tests/test_lnutil.py b/lib/tests/test_lnutil.py index c214c48ac..9fb1b9659 100644 --- a/lib/tests/test_lnutil.py +++ b/lib/tests/test_lnutil.py @@ -1,6 +1,6 @@ import unittest import json -from lib import bitcoin, ecc +from lib import bitcoin from lib.lnutil import RevocationStore, get_per_commitment_secret_from_seed, make_offered_htlc, make_received_htlc, make_commitment, make_htlc_tx_witness, make_htlc_tx_output, make_htlc_tx_inputs, secret_to_pubkey, derive_blinded_pubkey, derive_privkey, derive_pubkey, make_htlc_tx from lib.util import bh2u, bfh @@ -445,7 +445,7 @@ class TestLNUtil(unittest.TestCase): # actual commitment transaction fee = 0 per_commitment_secret = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100 - per_commitment_point = (ecc.generator() * per_commitment_secret).get_public_key_bytes() + per_commitment_point = secret_to_pubkey(per_commitment_secret) remote_htlcpubkey = remotepubkey local_htlcpubkey = localpubkey