From 4b23834af8bc47b47600c76f059f06845f0422cb Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 12 Dec 2024 14:37:07 +0200 Subject: [PATCH] Rename getNewSecretKey --- basicswap/interface/base.py | 2 +- basicswap/interface/part.py | 12 ++++++------ basicswap/interface/xmr.py | 2 +- tests/basicswap/extended/test_dcr.py | 10 +++++----- tests/basicswap/extended/test_doge.py | 4 ++-- tests/basicswap/test_bch_xmr.py | 4 ++-- tests/basicswap/test_btc_xmr.py | 8 ++++---- tests/basicswap/test_other.py | 12 ++++++------ tests/basicswap/test_partblind_xmr.py | 10 +++++----- tests/basicswap/test_xmr.py | 16 ++++++++-------- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/basicswap/interface/base.py b/basicswap/interface/base.py index bb1ae63..ec821c2 100644 --- a/basicswap/interface/base.py +++ b/basicswap/interface/base.py @@ -188,7 +188,7 @@ class Secp256k1Interface(CoinInterface, AdaptorSigInterface): def curve_type(): return Curves.secp256k1 - def getNewSecretKey(self) -> bytes: + def getNewRandomKey(self) -> bytes: return i2b(getSecretInt()) def getPubkey(self, privkey: bytes) -> bytes: diff --git a/basicswap/interface/part.py b/basicswap/interface/part.py index 49caad2..894a371 100644 --- a/basicswap/interface/part.py +++ b/basicswap/interface/part.py @@ -240,7 +240,7 @@ class PARTInterfaceBlind(PARTInterface): def createSCLockTx(self, value: int, script: bytearray, vkbv: bytes) -> bytes: # Nonce is derived from vkbv, ephemeral_key isn't used - ephemeral_key = self.getNewSecretKey() + ephemeral_key = self.getNewRandomKey() ephemeral_pubkey = self.getPubkey(ephemeral_key) assert len(ephemeral_pubkey) == 33 nonce = self.getScriptLockTxNonce(vkbv) @@ -307,7 +307,7 @@ class PARTInterfaceBlind(PARTInterface): lock_tx_obj = self.rpc("decoderawtransaction", [tx_lock_bytes.hex()]) assert self.getTxid(tx_lock_bytes).hex() == lock_tx_obj["txid"] # Nonce is derived from vkbv, ephemeral_key isn't used - ephemeral_key = self.getNewSecretKey() + ephemeral_key = self.getNewRandomKey() ephemeral_pubkey = self.getPubkey(ephemeral_key) assert len(ephemeral_pubkey) == 33 nonce = self.getScriptLockTxNonce(vkbv) @@ -348,7 +348,7 @@ class PARTInterfaceBlind(PARTInterface): dummy_witness_stack = [x.hex() for x in dummy_witness_stack] # Use a junk change pubkey to avoid adding unused keys to the wallet - zero_change_key = self.getNewSecretKey() + zero_change_key = self.getNewRandomKey() zero_change_pubkey = self.getPubkey(zero_change_key) inputs_info = { "0": { @@ -428,7 +428,7 @@ class PARTInterfaceBlind(PARTInterface): dummy_witness_stack = [x.hex() for x in dummy_witness_stack] # Use a junk change pubkey to avoid adding unused keys to the wallet - zero_change_key = self.getNewSecretKey() + zero_change_key = self.getNewRandomKey() zero_change_pubkey = self.getPubkey(zero_change_key) inputs_info = { "0": { @@ -745,7 +745,7 @@ class PARTInterfaceBlind(PARTInterface): dummy_witness_stack = self.getScriptLockTxDummyWitness(script_lock) # Use a junk change pubkey to avoid adding unused keys to the wallet - zero_change_key = self.getNewSecretKey() + zero_change_key = self.getNewRandomKey() zero_change_pubkey = self.getPubkey(zero_change_key) inputs_info = { "0": { @@ -949,7 +949,7 @@ class PARTInterfaceBlind(PARTInterface): dummy_witness_stack = [x.hex() for x in dummy_witness_stack] # Use a junk change pubkey to avoid adding unused keys to the wallet - zero_change_key = self.getNewSecretKey() + zero_change_key = self.getNewRandomKey() zero_change_pubkey = self.getPubkey(zero_change_key) inputs_info = { "0": { diff --git a/basicswap/interface/xmr.py b/basicswap/interface/xmr.py index 8614822..b947643 100644 --- a/basicswap/interface/xmr.py +++ b/basicswap/interface/xmr.py @@ -326,7 +326,7 @@ class XMRInterface(CoinInterface): return float(self.format_amount(fee_per_k_bytes)), "get_fee_estimate" - def getNewSecretKey(self) -> bytes: + def getNewRandomKey(self) -> bytes: # Note: Returned bytes are in big endian order return i2b(edu.get_secret()) diff --git a/tests/basicswap/extended/test_dcr.py b/tests/basicswap/extended/test_dcr.py index 6fbef2d..907338f 100644 --- a/tests/basicswap/extended/test_dcr.py +++ b/tests/basicswap/extended/test_dcr.py @@ -879,7 +879,7 @@ class Test(BaseTest): ci = DCRInterface(coin_settings, "mainnet") - k = ci.getNewSecretKey() + k = ci.getNewRandomKey() K = ci.getPubkey(k) pkh = ci.pkh(K) @@ -1417,8 +1417,8 @@ class Test(BaseTest): # fee_rate is in sats/kvB fee_rate: int = 10000 - a = ci.getNewSecretKey() - b = ci.getNewSecretKey() + a = ci.getNewRandomKey() + b = ci.getNewRandomKey() A = ci.getPubkey(a) B = ci.getPubkey(b) @@ -1477,8 +1477,8 @@ class Test(BaseTest): assert expect_size - size_actual < 10 # Test chain b (no-script) lock tx size - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate) test_delay_event.wait(1) diff --git a/tests/basicswap/extended/test_doge.py b/tests/basicswap/extended/test_doge.py index cf95c56..0bcc63f 100644 --- a/tests/basicswap/extended/test_doge.py +++ b/tests/basicswap/extended/test_doge.py @@ -410,8 +410,8 @@ class Test(TestFunctions): fee_rate: int = 1000000 # Test chain b (no-script) lock tx size - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate) test_delay_event.wait(1) diff --git a/tests/basicswap/test_bch_xmr.py b/tests/basicswap/test_bch_xmr.py index fd247bb..8b526a6 100644 --- a/tests/basicswap/test_bch_xmr.py +++ b/tests/basicswap/test_bch_xmr.py @@ -513,8 +513,8 @@ class TestBCH(BasicSwapTest): # fee_rate is in sats/B fee_rate: int = 1 - a = ci.getNewSecretKey() - b = ci.getNewSecretKey() + a = ci.getNewRandomKey() + b = ci.getNewRandomKey() A = ci.getPubkey(a) B = ci.getPubkey(b) diff --git a/tests/basicswap/test_btc_xmr.py b/tests/basicswap/test_btc_xmr.py index c4cd896..69a7c36 100644 --- a/tests/basicswap/test_btc_xmr.py +++ b/tests/basicswap/test_btc_xmr.py @@ -1147,8 +1147,8 @@ class BasicSwapTest(TestFunctions): # fee_rate is in sats/kvB fee_rate: int = 1000 - a = ci.getNewSecretKey() - b = ci.getNewSecretKey() + a = ci.getNewRandomKey() + b = ci.getNewRandomKey() A = ci.getPubkey(a) B = ci.getPubkey(b) @@ -1217,8 +1217,8 @@ class BasicSwapTest(TestFunctions): assert expect_vsize - vsize_actual < 10 # Test chain b (no-script) lock tx size - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate) diff --git a/tests/basicswap/test_other.py b/tests/basicswap/test_other.py index f57a404..04aee32 100644 --- a/tests/basicswap/test_other.py +++ b/tests/basicswap/test_other.py @@ -185,8 +185,8 @@ class Test(unittest.TestCase): coin_settings = {"rpcport": 0, "rpcauth": "none"} coin_settings.update(REQUIRED_SETTINGS) ci = BTCInterface(coin_settings, "regtest") - vk_sign = ci.getNewSecretKey() - vk_encrypt = ci.getNewSecretKey() + vk_sign = ci.getNewRandomKey() + vk_encrypt = ci.getNewRandomKey() pk_sign = ci.getPubkey(vk_sign) pk_encrypt = ci.getPubkey(vk_encrypt) @@ -209,7 +209,7 @@ class Test(unittest.TestCase): coin_settings.update(REQUIRED_SETTINGS) ci = BTCInterface(coin_settings, "regtest") - vk = ci.getNewSecretKey() + vk = ci.getNewRandomKey() pk = ci.getPubkey(vk) message = "test signing message" @@ -224,7 +224,7 @@ class Test(unittest.TestCase): coin_settings.update(REQUIRED_SETTINGS) ci = BTCInterface(coin_settings, "regtest") - vk = ci.getNewSecretKey() + vk = ci.getNewRandomKey() pk = ci.getPubkey(vk) sig = ci.signCompact(vk, "test signing message") assert len(sig) == 64 @@ -239,7 +239,7 @@ class Test(unittest.TestCase): coin_settings.update(REQUIRED_SETTINGS) ci = BTCInterface(coin_settings, "regtest") - vk = ci.getNewSecretKey() + vk = ci.getNewRandomKey() pk = ci.getPubkey(vk) sig = ci.signRecoverable(vk, "test signing message") assert len(sig) == 65 @@ -264,7 +264,7 @@ class Test(unittest.TestCase): ci = XMRInterface(coin_settings, "regtest") - key = ci.getNewSecretKey() + key = ci.getNewRandomKey() proof = ci.proveDLEAG(key) assert ci.verifyDLEAG(proof) diff --git a/tests/basicswap/test_partblind_xmr.py b/tests/basicswap/test_partblind_xmr.py index 9fbfe8e..087fd49 100644 --- a/tests/basicswap/test_partblind_xmr.py +++ b/tests/basicswap/test_partblind_xmr.py @@ -141,9 +141,9 @@ class Test(BaseTest): # fee_rate is in sats/kvB fee_rate: int = 1000 - vkbv = ci.getNewSecretKey() - a = ci.getNewSecretKey() - b = ci.getNewSecretKey() + vkbv = ci.getNewRandomKey() + a = ci.getNewRandomKey() + b = ci.getNewRandomKey() A = ci.getPubkey(a) B = ci.getPubkey(b) @@ -210,8 +210,8 @@ class Test(BaseTest): assert ci.rpc("sendrawtransaction", [lock_spend_tx.hex()]) == txid # Test chain b (no-script) lock tx size - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate) diff --git a/tests/basicswap/test_xmr.py b/tests/basicswap/test_xmr.py index 7f6a3d2..d479fd7 100644 --- a/tests/basicswap/test_xmr.py +++ b/tests/basicswap/test_xmr.py @@ -1077,8 +1077,8 @@ class Test(BaseTest): # fee_rate is in sats/kvB fee_rate: int = 1000 - a = ci.getNewSecretKey() - b = ci.getNewSecretKey() + a = ci.getNewRandomKey() + b = ci.getNewRandomKey() A = ci.getPubkey(a) B = ci.getPubkey(b) @@ -1147,8 +1147,8 @@ class Test(BaseTest): assert expect_vsize - vsize_actual < 10 # Test chain b (no-script) lock tx size - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate) @@ -1176,8 +1176,8 @@ class Test(BaseTest): amount: int = ci.make_int(random.uniform(0.1, 2.0), r=1) fee_rate: int = 1000 # TODO: How to set feerate for rpc functions? - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate) @@ -2083,8 +2083,8 @@ class Test(BaseTest): ci = swap_clients[1].ci(Coins.PART_ANON) amount: int = ci.make_int(random.uniform(0.1, 2.0), r=1) fee_rate: int = 1000 - v = ci.getNewSecretKey() - s = ci.getNewSecretKey() + v = ci.getNewRandomKey() + s = ci.getNewRandomKey() S = ci.getPubkey(s) lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)