def __init__(self, *, mnemonic: str, index: int, amount: int): self.signing_key_path = 'm/12381/3600/%s/0' % index self.signing_sk = mnemonic_and_path_to_key(mnemonic=mnemonic, path=self.signing_key_path) self.withdrawal_sk = mnemonic_and_path_to_key( mnemonic=mnemonic, path=self.signing_key_path + '/0') self.amount = amount
def __init__(self, *, mnemonic: str, mnemonic_password: str, index: int, amount: int, chain_setting: BaseChainSetting, withdrawal_pk: str, withdrawal_credentials: str): # Set path as EIP-2334 format # https://eips.ethereum.org/EIPS/eip-2334 purpose = '12381' coin_type = '3600' account = str(index) withdrawal_key_path = f'm/{purpose}/{coin_type}/{account}/0' self.signing_key_path = f'{withdrawal_key_path}/0' if withdrawal_pk and withdrawal_credentials: raise ValidationError( "Simultaneous use of withdrawal_credentials and withdrawal_pk is incompatible. Use only one of them." ) if withdrawal_pk: self.custom_withdrawal_pk = validate_withdrawal_pk( withdrawal_pk=withdrawal_pk) else: self.custom_withdrawal_pk = None if withdrawal_credentials: self.custom_withdrawal_credentials = validate_withdrawal_credentials( withdrawal_credentials=withdrawal_credentials) else: self.custom_withdrawal_credentials = None self.withdrawal_sk = mnemonic_and_path_to_key( mnemonic=mnemonic, path=withdrawal_key_path, password=mnemonic_password) self.signing_sk = mnemonic_and_path_to_key(mnemonic=mnemonic, path=self.signing_key_path, password=mnemonic_password) self.amount = amount self.chain_setting = chain_setting
def test_mnemonic_and_path_to_key(test_vector) -> None: mnemonic = test_vector['mnemonic'] password = test_vector['password'] path = test_vector['path'] key = test_vector['child_SK'] assert mnemonic_and_path_to_key(mnemonic=mnemonic, path=path, password=password) == key
def __init__(self, *, mnemonic: str, mnemonic_password: str, index: int, amount: int, chain_setting: BaseChainSetting): # Set path as EIP-2334 format # https://eips.ethereum.org/EIPS/eip-2334 purpose = '12381' coin_type = '3600' account = str(index) withdrawal_key_path = f'm/{purpose}/{coin_type}/{account}/0' self.signing_key_path = f'{withdrawal_key_path}/0' self.withdrawal_sk = mnemonic_and_path_to_key( mnemonic=mnemonic, path=withdrawal_key_path, password=mnemonic_password) self.signing_sk = mnemonic_and_path_to_key(mnemonic=mnemonic, path=self.signing_key_path, password=mnemonic_password) self.amount = amount self.chain_setting = chain_setting
def __init__(self, *, mnemonic: str, index: int, amount: int, fork_version: bytes): # Set path as EIP-2334 format # https://eips.ethereum.org/EIPS/eip-2334 purpose = '12381' coin_type = '3600' account = str(index) withdrawal_key_path = f'm/{purpose}/{coin_type}/{account}/0' self.signing_key_path = f'{withdrawal_key_path}/0' # Do NOT use password for seed generation. self.withdrawal_sk = mnemonic_and_path_to_key(mnemonic=mnemonic, path=withdrawal_key_path, password='') self.signing_sk = mnemonic_and_path_to_key(mnemonic=mnemonic, path=self.signing_key_path, password='') self.amount = amount self.fork_version = fork_version