def _CKD_pub(cK, c, s): I = hmac_oneshot(c, cK + s, hashlib.sha512) pubkey = ecc.ECPrivkey(I[0:32]) + ecc.ECPubkey(cK) if pubkey.is_at_infinity(): raise ecc.InvalidECPointException() cK_n = pubkey.get_public_key_bytes(compressed=True) c_n = I[32:] return cK_n, c_n
def is_old_mpk(mpk: str) -> bool: try: int(mpk, 16) except: return False if len(mpk) != 128: return False try: ecc.ECPubkey(bfh('04' + mpk)) except: return False return True
def get_pubkey_from_mpk(self, mpk, for_change, n): z = self.get_sequence(mpk, for_change, n) master_public_key = ecc.ECPubkey(bfh('04' + mpk)) public_key = master_public_key + z * ecc.generator() return public_key.get_public_key_hex(compressed=False)
def _CKD_pub(cK, c, s): I = hmac.new(c, cK + s, hashlib.sha512).digest() pubkey = ecc.ECPrivkey(I[0:32]) + ecc.ECPubkey(cK) cK_n = pubkey.get_public_key_bytes(compressed=True) c_n = I[32:] return cK_n, c_n