mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-24 19:35:51 +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():
|
def curve_type():
|
||||||
return Curves.secp256k1
|
return Curves.secp256k1
|
||||||
|
|
||||||
def getNewSecretKey(self) -> bytes:
|
def getNewRandomKey(self) -> bytes:
|
||||||
return i2b(getSecretInt())
|
return i2b(getSecretInt())
|
||||||
|
|
||||||
def getPubkey(self, privkey: bytes) -> bytes:
|
def getPubkey(self, privkey: bytes) -> bytes:
|
||||||
|
|
|
@ -240,7 +240,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
def createSCLockTx(self, value: int, script: bytearray, vkbv: bytes) -> bytes:
|
def createSCLockTx(self, value: int, script: bytearray, vkbv: bytes) -> bytes:
|
||||||
|
|
||||||
# Nonce is derived from vkbv, ephemeral_key isn't used
|
# Nonce is derived from vkbv, ephemeral_key isn't used
|
||||||
ephemeral_key = self.getNewSecretKey()
|
ephemeral_key = self.getNewRandomKey()
|
||||||
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
||||||
assert len(ephemeral_pubkey) == 33
|
assert len(ephemeral_pubkey) == 33
|
||||||
nonce = self.getScriptLockTxNonce(vkbv)
|
nonce = self.getScriptLockTxNonce(vkbv)
|
||||||
|
@ -307,7 +307,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
lock_tx_obj = self.rpc("decoderawtransaction", [tx_lock_bytes.hex()])
|
lock_tx_obj = self.rpc("decoderawtransaction", [tx_lock_bytes.hex()])
|
||||||
assert self.getTxid(tx_lock_bytes).hex() == lock_tx_obj["txid"]
|
assert self.getTxid(tx_lock_bytes).hex() == lock_tx_obj["txid"]
|
||||||
# Nonce is derived from vkbv, ephemeral_key isn't used
|
# Nonce is derived from vkbv, ephemeral_key isn't used
|
||||||
ephemeral_key = self.getNewSecretKey()
|
ephemeral_key = self.getNewRandomKey()
|
||||||
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
||||||
assert len(ephemeral_pubkey) == 33
|
assert len(ephemeral_pubkey) == 33
|
||||||
nonce = self.getScriptLockTxNonce(vkbv)
|
nonce = self.getScriptLockTxNonce(vkbv)
|
||||||
|
@ -348,7 +348,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
dummy_witness_stack = [x.hex() for x in dummy_witness_stack]
|
dummy_witness_stack = [x.hex() for x in dummy_witness_stack]
|
||||||
|
|
||||||
# Use a junk change pubkey to avoid adding unused keys to the wallet
|
# 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)
|
zero_change_pubkey = self.getPubkey(zero_change_key)
|
||||||
inputs_info = {
|
inputs_info = {
|
||||||
"0": {
|
"0": {
|
||||||
|
@ -428,7 +428,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
dummy_witness_stack = [x.hex() for x in dummy_witness_stack]
|
dummy_witness_stack = [x.hex() for x in dummy_witness_stack]
|
||||||
|
|
||||||
# Use a junk change pubkey to avoid adding unused keys to the wallet
|
# 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)
|
zero_change_pubkey = self.getPubkey(zero_change_key)
|
||||||
inputs_info = {
|
inputs_info = {
|
||||||
"0": {
|
"0": {
|
||||||
|
@ -745,7 +745,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
dummy_witness_stack = self.getScriptLockTxDummyWitness(script_lock)
|
dummy_witness_stack = self.getScriptLockTxDummyWitness(script_lock)
|
||||||
|
|
||||||
# Use a junk change pubkey to avoid adding unused keys to the wallet
|
# 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)
|
zero_change_pubkey = self.getPubkey(zero_change_key)
|
||||||
inputs_info = {
|
inputs_info = {
|
||||||
"0": {
|
"0": {
|
||||||
|
@ -949,7 +949,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
dummy_witness_stack = [x.hex() for x in dummy_witness_stack]
|
dummy_witness_stack = [x.hex() for x in dummy_witness_stack]
|
||||||
|
|
||||||
# Use a junk change pubkey to avoid adding unused keys to the wallet
|
# 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)
|
zero_change_pubkey = self.getPubkey(zero_change_key)
|
||||||
inputs_info = {
|
inputs_info = {
|
||||||
"0": {
|
"0": {
|
||||||
|
|
|
@ -326,7 +326,7 @@ class XMRInterface(CoinInterface):
|
||||||
|
|
||||||
return float(self.format_amount(fee_per_k_bytes)), "get_fee_estimate"
|
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
|
# Note: Returned bytes are in big endian order
|
||||||
return i2b(edu.get_secret())
|
return i2b(edu.get_secret())
|
||||||
|
|
||||||
|
|
|
@ -879,7 +879,7 @@ class Test(BaseTest):
|
||||||
|
|
||||||
ci = DCRInterface(coin_settings, "mainnet")
|
ci = DCRInterface(coin_settings, "mainnet")
|
||||||
|
|
||||||
k = ci.getNewSecretKey()
|
k = ci.getNewRandomKey()
|
||||||
K = ci.getPubkey(k)
|
K = ci.getPubkey(k)
|
||||||
|
|
||||||
pkh = ci.pkh(K)
|
pkh = ci.pkh(K)
|
||||||
|
@ -1417,8 +1417,8 @@ class Test(BaseTest):
|
||||||
# fee_rate is in sats/kvB
|
# fee_rate is in sats/kvB
|
||||||
fee_rate: int = 10000
|
fee_rate: int = 10000
|
||||||
|
|
||||||
a = ci.getNewSecretKey()
|
a = ci.getNewRandomKey()
|
||||||
b = ci.getNewSecretKey()
|
b = ci.getNewRandomKey()
|
||||||
|
|
||||||
A = ci.getPubkey(a)
|
A = ci.getPubkey(a)
|
||||||
B = ci.getPubkey(b)
|
B = ci.getPubkey(b)
|
||||||
|
@ -1477,8 +1477,8 @@ class Test(BaseTest):
|
||||||
assert expect_size - size_actual < 10
|
assert expect_size - size_actual < 10
|
||||||
|
|
||||||
# Test chain b (no-script) lock tx size
|
# Test chain b (no-script) lock tx size
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
||||||
test_delay_event.wait(1)
|
test_delay_event.wait(1)
|
||||||
|
|
|
@ -410,8 +410,8 @@ class Test(TestFunctions):
|
||||||
fee_rate: int = 1000000
|
fee_rate: int = 1000000
|
||||||
|
|
||||||
# Test chain b (no-script) lock tx size
|
# Test chain b (no-script) lock tx size
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
||||||
test_delay_event.wait(1)
|
test_delay_event.wait(1)
|
||||||
|
|
|
@ -513,8 +513,8 @@ class TestBCH(BasicSwapTest):
|
||||||
# fee_rate is in sats/B
|
# fee_rate is in sats/B
|
||||||
fee_rate: int = 1
|
fee_rate: int = 1
|
||||||
|
|
||||||
a = ci.getNewSecretKey()
|
a = ci.getNewRandomKey()
|
||||||
b = ci.getNewSecretKey()
|
b = ci.getNewRandomKey()
|
||||||
|
|
||||||
A = ci.getPubkey(a)
|
A = ci.getPubkey(a)
|
||||||
B = ci.getPubkey(b)
|
B = ci.getPubkey(b)
|
||||||
|
|
|
@ -1147,8 +1147,8 @@ class BasicSwapTest(TestFunctions):
|
||||||
# fee_rate is in sats/kvB
|
# fee_rate is in sats/kvB
|
||||||
fee_rate: int = 1000
|
fee_rate: int = 1000
|
||||||
|
|
||||||
a = ci.getNewSecretKey()
|
a = ci.getNewRandomKey()
|
||||||
b = ci.getNewSecretKey()
|
b = ci.getNewRandomKey()
|
||||||
|
|
||||||
A = ci.getPubkey(a)
|
A = ci.getPubkey(a)
|
||||||
B = ci.getPubkey(b)
|
B = ci.getPubkey(b)
|
||||||
|
@ -1217,8 +1217,8 @@ class BasicSwapTest(TestFunctions):
|
||||||
assert expect_vsize - vsize_actual < 10
|
assert expect_vsize - vsize_actual < 10
|
||||||
|
|
||||||
# Test chain b (no-script) lock tx size
|
# Test chain b (no-script) lock tx size
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
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 = {"rpcport": 0, "rpcauth": "none"}
|
||||||
coin_settings.update(REQUIRED_SETTINGS)
|
coin_settings.update(REQUIRED_SETTINGS)
|
||||||
ci = BTCInterface(coin_settings, "regtest")
|
ci = BTCInterface(coin_settings, "regtest")
|
||||||
vk_sign = ci.getNewSecretKey()
|
vk_sign = ci.getNewRandomKey()
|
||||||
vk_encrypt = ci.getNewSecretKey()
|
vk_encrypt = ci.getNewRandomKey()
|
||||||
|
|
||||||
pk_sign = ci.getPubkey(vk_sign)
|
pk_sign = ci.getPubkey(vk_sign)
|
||||||
pk_encrypt = ci.getPubkey(vk_encrypt)
|
pk_encrypt = ci.getPubkey(vk_encrypt)
|
||||||
|
@ -209,7 +209,7 @@ class Test(unittest.TestCase):
|
||||||
coin_settings.update(REQUIRED_SETTINGS)
|
coin_settings.update(REQUIRED_SETTINGS)
|
||||||
ci = BTCInterface(coin_settings, "regtest")
|
ci = BTCInterface(coin_settings, "regtest")
|
||||||
|
|
||||||
vk = ci.getNewSecretKey()
|
vk = ci.getNewRandomKey()
|
||||||
pk = ci.getPubkey(vk)
|
pk = ci.getPubkey(vk)
|
||||||
|
|
||||||
message = "test signing message"
|
message = "test signing message"
|
||||||
|
@ -224,7 +224,7 @@ class Test(unittest.TestCase):
|
||||||
coin_settings.update(REQUIRED_SETTINGS)
|
coin_settings.update(REQUIRED_SETTINGS)
|
||||||
ci = BTCInterface(coin_settings, "regtest")
|
ci = BTCInterface(coin_settings, "regtest")
|
||||||
|
|
||||||
vk = ci.getNewSecretKey()
|
vk = ci.getNewRandomKey()
|
||||||
pk = ci.getPubkey(vk)
|
pk = ci.getPubkey(vk)
|
||||||
sig = ci.signCompact(vk, "test signing message")
|
sig = ci.signCompact(vk, "test signing message")
|
||||||
assert len(sig) == 64
|
assert len(sig) == 64
|
||||||
|
@ -239,7 +239,7 @@ class Test(unittest.TestCase):
|
||||||
coin_settings.update(REQUIRED_SETTINGS)
|
coin_settings.update(REQUIRED_SETTINGS)
|
||||||
ci = BTCInterface(coin_settings, "regtest")
|
ci = BTCInterface(coin_settings, "regtest")
|
||||||
|
|
||||||
vk = ci.getNewSecretKey()
|
vk = ci.getNewRandomKey()
|
||||||
pk = ci.getPubkey(vk)
|
pk = ci.getPubkey(vk)
|
||||||
sig = ci.signRecoverable(vk, "test signing message")
|
sig = ci.signRecoverable(vk, "test signing message")
|
||||||
assert len(sig) == 65
|
assert len(sig) == 65
|
||||||
|
@ -264,7 +264,7 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
ci = XMRInterface(coin_settings, "regtest")
|
ci = XMRInterface(coin_settings, "regtest")
|
||||||
|
|
||||||
key = ci.getNewSecretKey()
|
key = ci.getNewRandomKey()
|
||||||
proof = ci.proveDLEAG(key)
|
proof = ci.proveDLEAG(key)
|
||||||
assert ci.verifyDLEAG(proof)
|
assert ci.verifyDLEAG(proof)
|
||||||
|
|
||||||
|
|
|
@ -141,9 +141,9 @@ class Test(BaseTest):
|
||||||
# fee_rate is in sats/kvB
|
# fee_rate is in sats/kvB
|
||||||
fee_rate: int = 1000
|
fee_rate: int = 1000
|
||||||
|
|
||||||
vkbv = ci.getNewSecretKey()
|
vkbv = ci.getNewRandomKey()
|
||||||
a = ci.getNewSecretKey()
|
a = ci.getNewRandomKey()
|
||||||
b = ci.getNewSecretKey()
|
b = ci.getNewRandomKey()
|
||||||
|
|
||||||
A = ci.getPubkey(a)
|
A = ci.getPubkey(a)
|
||||||
B = ci.getPubkey(b)
|
B = ci.getPubkey(b)
|
||||||
|
@ -210,8 +210,8 @@ class Test(BaseTest):
|
||||||
assert ci.rpc("sendrawtransaction", [lock_spend_tx.hex()]) == txid
|
assert ci.rpc("sendrawtransaction", [lock_spend_tx.hex()]) == txid
|
||||||
|
|
||||||
# Test chain b (no-script) lock tx size
|
# Test chain b (no-script) lock tx size
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
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 is in sats/kvB
|
||||||
fee_rate: int = 1000
|
fee_rate: int = 1000
|
||||||
|
|
||||||
a = ci.getNewSecretKey()
|
a = ci.getNewRandomKey()
|
||||||
b = ci.getNewSecretKey()
|
b = ci.getNewRandomKey()
|
||||||
|
|
||||||
A = ci.getPubkey(a)
|
A = ci.getPubkey(a)
|
||||||
B = ci.getPubkey(b)
|
B = ci.getPubkey(b)
|
||||||
|
@ -1147,8 +1147,8 @@ class Test(BaseTest):
|
||||||
assert expect_vsize - vsize_actual < 10
|
assert expect_vsize - vsize_actual < 10
|
||||||
|
|
||||||
# Test chain b (no-script) lock tx size
|
# Test chain b (no-script) lock tx size
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
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)
|
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?
|
fee_rate: int = 1000 # TODO: How to set feerate for rpc functions?
|
||||||
|
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
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)
|
ci = swap_clients[1].ci(Coins.PART_ANON)
|
||||||
amount: int = ci.make_int(random.uniform(0.1, 2.0), r=1)
|
amount: int = ci.make_int(random.uniform(0.1, 2.0), r=1)
|
||||||
fee_rate: int = 1000
|
fee_rate: int = 1000
|
||||||
v = ci.getNewSecretKey()
|
v = ci.getNewRandomKey()
|
||||||
s = ci.getNewSecretKey()
|
s = ci.getNewRandomKey()
|
||||||
S = ci.getPubkey(s)
|
S = ci.getPubkey(s)
|
||||||
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
lock_tx_b_txid = ci.publishBLockTx(v, S, amount, fee_rate)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue