mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-24 11:26:01 +00:00
Rename getNewSecretKey
This commit is contained in:
parent
0e2be676db
commit
4b23834af8
10 changed files with 40 additions and 40 deletions
|
@ -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:
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue