Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions secret_sdk/client/lcd/lcdclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(
self,
url: str,
chain_id: Optional[str] = None,
encryption_seed: Optional[bytes] = None,
gas_prices: Optional[Coins.Input] = default_gas_prices,
gas_adjustment: Optional[Numeric.Input] = default_gas_adjustment,
custom_fees: Optional[dict] = default_fees,
Expand Down Expand Up @@ -121,7 +122,7 @@ def __init__(
consensus_io_pub_key = mainnetConsensusIoPubKey
else:
consensus_io_pub_key = RegistrationAPI(self).consensus_io_pub_key()
self.encrypt_utils = EncryptionUtils(consensus_io_pub_key)
self.encrypt_utils = EncryptionUtils(consensus_io_pub_key, encryption_seed)

def wallet(self, key: Key) -> AsyncWallet:
"""Creates a :class:`AsyncWallet` object from a key.
Expand Down Expand Up @@ -273,6 +274,7 @@ def __init__(
self,
url: str,
chain_id: str = None,
encryption_seed: Optional[bytes] = None,
gas_prices: Optional[Coins.Input] = default_gas_prices,
gas_adjustment: Optional[Numeric.Input] = default_gas_adjustment,
custom_fees: Optional[dict] = default_fees,
Expand All @@ -282,6 +284,7 @@ def __init__(
super().__init__(
url,
chain_id,
encryption_seed,
gas_prices,
gas_adjustment,
custom_fees,
Expand Down Expand Up @@ -310,7 +313,7 @@ def __init__(
consensus_io_pub_key = mainnetConsensusIoPubKey
else:
consensus_io_pub_key = self.registration.consensus_io_pub_key()
self.encrypt_utils = EncryptionUtils(consensus_io_pub_key)
self.encrypt_utils = EncryptionUtils(consensus_io_pub_key, encryption_seed)

async def __aenter__(self):
raise NotImplementedError(
Expand Down
8 changes: 6 additions & 2 deletions secret_sdk/util/encrypt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ def index_by_pub_key(m: Dict[str, Any], o: Any):


class EncryptionUtils():
def __init__(self, consensus_io_pubkey: bytes):
self.seed = self.generate_new_seed()
def __init__(self, consensus_io_pubkey: bytes, encryption_seed: bytes = None):
if encryption_seed:
self.seed = encryption_seed
else:
self.seed = self.generate_new_seed()

self.privkey, self.pubkey = self.generate_new_key_pair_from_seed(self.seed)
self.consensus_io_pubkey = consensus_io_pubkey

Expand Down