def make_default_keyUtil(): keychain = KeyTool() private_keys = [ master_sk_to_wallet_sk(MASTER_KEY, uint32(i)) for i in range(10) ] secret_exponents = [int.from_bytes(bytes(_), "big") for _ in private_keys] keychain.add_secret_exponents(secret_exponents) return keychain
def do_test_spend_p2_delegated_puzzle_or_hidden_puzzle_with_delegated_puzzle( self, hidden_pub_key_index): key_lookup = KeyTool() payments, conditions = default_payments_and_conditions(1, key_lookup) hidden_puzzle = p2_conditions.puzzle_for_conditions(conditions) hidden_public_key = public_key_for_index(hidden_pub_key_index, key_lookup) puzzle = p2_delegated_puzzle_or_hidden_puzzle.puzzle_for_public_key_and_hidden_puzzle( hidden_public_key, hidden_puzzle) payable_payments, payable_conditions = default_payments_and_conditions( 5, key_lookup) delegated_puzzle = p2_conditions.puzzle_for_conditions( payable_conditions) delegated_solution = [] synthetic_public_key = p2_delegated_puzzle_or_hidden_puzzle.calculate_synthetic_public_key( hidden_public_key, hidden_puzzle.get_tree_hash()) solution = p2_delegated_puzzle_or_hidden_puzzle.solution_for_delegated_puzzle( delegated_puzzle, delegated_solution) hidden_puzzle_hash = hidden_puzzle.get_tree_hash() synthetic_offset = p2_delegated_puzzle_or_hidden_puzzle.calculate_synthetic_offset( hidden_public_key, hidden_puzzle_hash) hidden_pub_key_point = G1Element.from_bytes(hidden_public_key) assert synthetic_public_key == int_to_public_key( synthetic_offset) + hidden_pub_key_point secret_exponent = key_lookup.get(hidden_public_key) assert int_to_public_key(secret_exponent) == hidden_pub_key_point synthetic_secret_exponent = secret_exponent + synthetic_offset key_lookup.add_secret_exponents([synthetic_secret_exponent]) do_test_spend(puzzle, solution, payable_payments, key_lookup)
def make_default_keyUtil(): keychain = KeyTool() private_keys = [bls_private_key_for_index(_) for _ in range(10)] secret_exponents = [int.from_bytes(bytes(_), "big") for _ in private_keys] keychain.add_secret_exponents(secret_exponents) return keychain
def public_key_for_index(index: int, key_lookup: KeyTool) -> bytes: secret_exponent = secret_exponent_for_index(index) key_lookup.add_secret_exponents([secret_exponent]) return bytes(int_to_public_key(secret_exponent))