Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Derivation from just a master public key" #11143

Merged
merged 1 commit into from
Apr 13, 2022
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: 0 additions & 7 deletions chia/cmds/keys_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
master_sk_to_pool_sk,
master_sk_to_wallet_sk,
master_sk_to_wallet_sk_unhardened,
master_pk_to_wallet_pk_unhardened,
)


Expand Down Expand Up @@ -98,13 +97,7 @@ def show_all_keys(show_mnemonic: bool, non_observer_derivation: bool):
if non_observer_derivation
else master_sk_to_wallet_sk_unhardened(sk, uint32(0))
)
# Test pk derivation
wallet_root_unhardened = master_pk_to_wallet_pk_unhardened(sk.get_g1(), uint32(0))
wallet_address: str = encode_puzzle_hash(create_puzzlehash_for_pk(first_wallet_sk.get_g1()), prefix)
wallet_address_from_unhard_root: str = encode_puzzle_hash(
create_puzzlehash_for_pk(wallet_root_unhardened), prefix
)
assert wallet_address == wallet_address_from_unhard_root
print(f"First wallet address{' (non-observer)' if non_observer_derivation else ''}: {wallet_address}")
assert seed is not None
if show_mnemonic:
Expand Down
15 changes: 0 additions & 15 deletions chia/wallet/derive_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ def _derive_path(sk: PrivateKey, path: List[int]) -> PrivateKey:
return sk


def _derive_path_pub(pk: G1Element, path: List[int]) -> G1Element:
for index in path:
pk = AugSchemeMPL.derive_child_pk_unhardened(pk, index)
return pk


def _derive_path_unhardened(sk: PrivateKey, path: List[int]) -> PrivateKey:
for index in path:
sk = AugSchemeMPL.derive_child_sk_unhardened(sk, index)
Expand All @@ -44,20 +38,11 @@ def master_sk_to_wallet_sk_intermediate(master: PrivateKey) -> PrivateKey:
return _derive_path(master, [12381, 8444, 2])


def master_pk_to_wallet_pk_intermediate(master: G1Element) -> G1Element:
return _derive_path_pub(master, [12381, 8444, 2])


def master_sk_to_wallet_sk(master: PrivateKey, index: uint32) -> PrivateKey:
intermediate = master_sk_to_wallet_sk_intermediate(master)
return _derive_path(intermediate, [index])


def master_pk_to_wallet_pk_unhardened(master: G1Element, index: uint32) -> G1Element:
intermediate = master_pk_to_wallet_pk_intermediate(master)
return _derive_path_pub(intermediate, [index])


def master_sk_to_wallet_sk_unhardened_intermediate(master: PrivateKey) -> PrivateKey:
return _derive_path_unhardened(master, [12381, 8444, 2])

Expand Down