mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
wallet: allow signing a message with spend or view key
This commit is contained in:
parent
5946002105
commit
743608ec16
16 changed files with 178 additions and 43 deletions
|
@ -43,8 +43,10 @@ from framework.wallet import Wallet
|
|||
class MessageSigningTest():
|
||||
def run_test(self):
|
||||
self.create()
|
||||
self.check_signing(False)
|
||||
self.check_signing(True)
|
||||
self.check_signing(False, False)
|
||||
self.check_signing(False, True)
|
||||
self.check_signing(True, False)
|
||||
self.check_signing(True, True)
|
||||
|
||||
def create(self):
|
||||
print('Creating wallets')
|
||||
|
@ -66,8 +68,8 @@ class MessageSigningTest():
|
|||
assert res.address == self.address[i]
|
||||
assert res.seed == seeds[i]
|
||||
|
||||
def check_signing(self, subaddress):
|
||||
print('Signing/verifing messages with ' + ('subaddress' if subaddress else 'standard address'))
|
||||
def check_signing(self, subaddress, spend_key):
|
||||
print('Signing/verifing messages with ' + ('subaddress' if subaddress else 'standard address') + ' ' + ('spend key' if spend_key else 'view key'))
|
||||
messages = ['foo', '']
|
||||
if subaddress:
|
||||
address = []
|
||||
|
@ -84,11 +86,14 @@ class MessageSigningTest():
|
|||
account_index = 0
|
||||
address_index = 0
|
||||
for message in messages:
|
||||
res = self.wallet[0].sign(message, account_index = account_index, address_index = address_index)
|
||||
res = self.wallet[0].sign(message, account_index = account_index, address_index = address_index, signature_type = 'spend' if spend_key else 'view')
|
||||
signature = res.signature
|
||||
for i in range(2):
|
||||
res = self.wallet[i].verify(message, address[0], signature)
|
||||
assert res.good
|
||||
assert not res.old
|
||||
assert res.version == 2
|
||||
assert res.signature_type == 'spend' if spend_key else 'view'
|
||||
res = self.wallet[i].verify('different', address[0], signature)
|
||||
assert not res.good
|
||||
res = self.wallet[i].verify(message, address[1], signature)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue