Caching of ed25519 values for public keys in seed
Based on: https://github.com/emesik/monero-python/issues/42#issuecomment-458780087
This commit is contained in:
parent
c999f68cf1
commit
f59e6c402b
|
@ -61,6 +61,9 @@ class Seed(object):
|
||||||
|
|
||||||
self.word_list = wordlists.get_wordlist(wordlist)
|
self.word_list = wordlists.get_wordlist(wordlist)
|
||||||
|
|
||||||
|
self._ed_pub_spend_key = None
|
||||||
|
self._ed_pub_view_key = None
|
||||||
|
|
||||||
if phrase_or_hex:
|
if phrase_or_hex:
|
||||||
seed_split = phrase_or_hex.split(" ")
|
seed_split = phrase_or_hex.split(" ")
|
||||||
if len(seed_split) >= 24:
|
if len(seed_split) >= 24:
|
||||||
|
@ -137,10 +140,16 @@ class Seed(object):
|
||||||
return self.sc_reduce(h.digest())
|
return self.sc_reduce(h.digest())
|
||||||
|
|
||||||
def public_spend_key(self):
|
def public_spend_key(self):
|
||||||
return ed25519.public_from_secret_hex(self.secret_spend_key())
|
if self._ed_pub_spend_key:
|
||||||
|
return self._ed_pub_spend_key
|
||||||
|
self._ed_pub_spend_key = ed25519.public_from_secret_hex(self.secret_spend_key())
|
||||||
|
return self._ed_pub_spend_key
|
||||||
|
|
||||||
def public_view_key(self):
|
def public_view_key(self):
|
||||||
return ed25519.public_from_secret_hex(self.secret_view_key())
|
if self._ed_pub_view_key:
|
||||||
|
return self._ed_pub_view_key
|
||||||
|
self._ed_pub_view_key = ed25519.public_from_secret_hex(self.secret_view_key())
|
||||||
|
return self._ed_pub_view_key
|
||||||
|
|
||||||
def public_address(self, net='mainnet'):
|
def public_address(self, net='mainnet'):
|
||||||
"""Returns the master :class:`Address <monero.address.Address>` represented by the seed.
|
"""Returns the master :class:`Address <monero.address.Address>` represented by the seed.
|
||||||
|
|
Loading…
Reference in New Issue