[docs]defget_address_from_public_key(self,public_key_hex:str)->str:""" :param public_key_hex: The private key as a hexadecimal string. :return: The DAG address corresponding to the public key (node ID). """iflen(public_key_hex)==128:public_key=PKCS_PREFIX+"04"+public_key_hexeliflen(public_key_hex)==130andpublic_key_hex[:2]=="04":public_key=PKCS_PREFIX+public_key_hexelse:raiseValueError("KeyStore :: Not a valid public key.")public_key=hashlib.sha256(bytes.fromhex(public_key)).hexdigest()public_key=base58.b58encode(bytes.fromhex(public_key)).decode()public_key=public_key[len(public_key)-36:]check_digits="".join([charforcharinpublic_keyifchar.isdigit()])check_digit=0fornincheck_digits:check_digit+=int(n)ifcheck_digit>=9:check_digit=check_digit%9address=f"DAG{check_digit}{public_key}"returnaddress