ThomasV
6 years ago
committed by
SomberNight
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
4 changed files with
7 additions and
6 deletions
-
electrum/lnbase.py
-
electrum/lntransport.py
-
electrum/lnutil.py
-
electrum/tests/test_lnchan.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 |
|
|
|
|
|
|
|
|
|
@ -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() |
|
|
|
|
|
@ -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() |
|
|
|
|
|
@ -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] |
|
|
|
|
|
|
|