From c180f34f6695964958c13a2eb30bd86441d86305 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sun, 24 Jan 2021 17:53:41 +0200 Subject: [PATCH] Sum keys in libsecp256k1 --- basicswap/interface_xmr.py | 13 +++++++------ tests/basicswap/extended/test_xmr_persistent.py | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/basicswap/interface_xmr.py b/basicswap/interface_xmr.py index 618f2ef..666618c 100644 --- a/basicswap/interface_xmr.py +++ b/basicswap/interface_xmr.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2020 tecnovert +# Copyright (c) 2020-2021 tecnovert # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. @@ -11,7 +11,10 @@ import logging import basicswap.contrib.ed25519_fast as edf import basicswap.ed25519_fast_util as edu import basicswap.util_xmr as xmr_util -from coincurve.ed25519 import ed25519_get_pubkey +from coincurve.ed25519 import ( + ed25519_get_pubkey, + ed25519_scalar_add, + ed25519_add) from coincurve.keys import PrivateKey from coincurve.dleag import ( verify_ed25519_point, @@ -191,12 +194,10 @@ class XMRInterface(CoinInterface): return i def sumKeys(self, ka, kb): - return i2b((b2i(ka) + b2i(kb)) % edf.l) + return ed25519_scalar_add(ka, kb) def sumPubkeys(self, Ka, Kb): - Ka_d = edf.decodepoint(Ka) - Kb_d = edf.decodepoint(Kb) - return self.encodePubkey(edf.edwards_add(Ka_d, Kb_d)) + return ed25519_add(Ka, Kb) def publishBLockTx(self, Kbv, Kbs, output_amount, feerate): self.rpc_wallet_cb('open_wallet', {'filename': self._wallet_filename}) diff --git a/tests/basicswap/extended/test_xmr_persistent.py b/tests/basicswap/extended/test_xmr_persistent.py index 7af6e65..17e54f7 100644 --- a/tests/basicswap/extended/test_xmr_persistent.py +++ b/tests/basicswap/extended/test_xmr_persistent.py @@ -69,6 +69,8 @@ BASE_PART_RPC_PORT = 19792 BASE_BTC_RPC_PORT = 19796 NUM_NODES = 3 +EXTRA_CONFIG_JSON = json.loads(os.getenv('EXTRA_CONFIG_JSON', '{}')) + logger = logging.getLogger() logger.level = logging.DEBUG @@ -176,6 +178,8 @@ class Test(unittest.TestCase): for ip in range(NUM_NODES): if ip != i: fp.write('connect=127.0.0.1:{}\n'.format(BITCOIN_PORT_BASE + ip + PORT_OFS)) + for opt in EXTRA_CONFIG_JSON.get('btc{}'.format(i), []): + fp.write(opt + '\n') with open(os.path.join(client_path, 'monero', 'monerod.conf'), 'a') as fp: fp.write('p2p-bind-ip=127.0.0.1\n')