mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 07:51:27 +00:00
ln: avoid code duplication
This commit is contained in:
parent
414da3942c
commit
bdac56aa19
2 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue