commit 409a336071853fd887165b1cf4893de74ae530c2
parent 445252284fa01412f9760dfb6c2aff2825b90443
Author: ThomasV <thomasv@electrum.org>
Date: Mon, 15 Oct 2018 11:16:35 +0200
fix tests (follow-up previous commit)
Diffstat:
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/electrum/lnbase.py b/electrum/lnbase.py
@@ -28,7 +28,7 @@ from .lnutil import (Outpoint, LocalConfig, ChannelConfig,
funding_output_script, get_per_commitment_secret_from_seed,
secret_to_pubkey, LNPeerAddr, PaymentFailure, LnLocalFeatures,
LOCAL, REMOTE, HTLCOwner, generate_keypair, LnKeyFamily,
- get_ln_flag_pair_of_bit)
+ get_ln_flag_pair_of_bit, privkey_to_pubkey)
from .lnutil import LightningPeerConnectionClosed, HandshakeFailed
from .lnrouter import NotFoundChanAnnouncementForUpdate, RouteEdge
diff --git a/electrum/lntransport.py b/electrum/lntransport.py
@@ -3,7 +3,7 @@ import hashlib
import cryptography.hazmat.primitives.ciphers.aead as AEAD
from .crypto import sha256
-from .lnutil import get_ecdh
+from .lnutil import get_ecdh, privkey_to_pubkey
from .lnutil import LightningPeerConnectionClosed, HandshakeFailed
from . import ecc
@@ -71,8 +71,6 @@ def act1_initiator_message(hs, epriv, epub):
assert len(msg) == 50
return msg
-def privkey_to_pubkey(priv: bytes) -> bytes:
- return ecc.ECPrivkey(priv[:32]).get_public_key_bytes()
def create_ephemeral_key() -> (bytes, bytes):
privkey = ecc.ECPrivkey.generate_random_key()
diff --git a/electrum/lnutil.py b/electrum/lnutil.py
@@ -162,6 +162,9 @@ def secret_to_pubkey(secret: int) -> bytes:
assert type(secret) is int
return ecc.ECPrivkey.from_secret_scalar(secret).get_public_key_bytes(compressed=True)
+def privkey_to_pubkey(priv: bytes) -> bytes:
+ return ecc.ECPrivkey(priv[:32]).get_public_key_bytes()
+
def derive_pubkey(basepoint: bytes, per_commitment_point: bytes) -> bytes:
p = ecc.ECPubkey(basepoint) + ecc.generator() * ecc.string_to_number(sha256(per_commitment_point + basepoint))
return p.get_public_key_bytes()
diff --git a/electrum/tests/test_lnchan.py b/electrum/tests/test_lnchan.py
@@ -88,8 +88,8 @@ def create_test_channels(feerate=6000, local=None, remote=None):
remote_amount = remote if remote is not None else (funding_sat * 1000 // 2)
alice_raw = [ bip32("m/" + str(i)) for i in range(5) ]
bob_raw = [ bip32("m/" + str(i)) for i in range(5,11) ]
- alice_privkeys = [lnutil.Keypair(lnbase.privkey_to_pubkey(x), x) for x in alice_raw]
- bob_privkeys = [lnutil.Keypair(lnbase.privkey_to_pubkey(x), x) for x in bob_raw]
+ alice_privkeys = [lnutil.Keypair(lnutil.privkey_to_pubkey(x), x) for x in alice_raw]
+ bob_privkeys = [lnutil.Keypair(lnutil.privkey_to_pubkey(x), x) for x in bob_raw]
alice_pubkeys = [lnutil.OnlyPubkeyKeypair(x.pubkey) for x in alice_privkeys]
bob_pubkeys = [lnutil.OnlyPubkeyKeypair(x.pubkey) for x in bob_privkeys]