Пример #1
0
def new_oas_address(
        user_id: str,
        use_ex_priv: Optional[bool] = False) -> Tuple[str, str, str]:
    hash = hashlib.md5(user_id.encode('utf-8')).digest()
    #base i.e "m/44'/60'/0'"
    bip32 = Bip32.FromExtendedKey(
        oas_config.get("EXTENDED_PUBKEY") if not use_ex_priv else oas_config.
        get("EXTENDED_PRIVKEY"))
    d_path = oas_config.get("EXTENDED_PATH")
    for i in range(2):
        a = struct.unpack('<L', hash[i * 4:(i + 1) * 4])
        idx = a[0] % 1000000
        bip32 = bip32.ChildKey(idx)
        d_path = d_path + "/" + str(idx)

    #now "m/44'/60'/0'/a1/a2", should be treated as geth like key(i.e. only private key use used, not true HD wallet at this level.
    a = BipPublicKey(
        bip32, Bip44Coins.ETHEREUM) if not use_ex_priv else BipPrivateKey(
            bip32, Bip44Coins.ETHEREUM)
    b = a.ToExtended()
    z = py_cryto_hd_wallet_fact.CreateFromExtendedKey("aa", b)
    z.Generate()
    c = z.ToDict()
    return c["addresses"]["address_1"]["address"], d_path, c["addresses"][
        "address_1"]["raw_priv"] if use_ex_priv else None
Пример #2
0
def get_address_for_index(masterKey: Bip32, changePath: str, index: int,
                          chainId, networkID) -> str:

    derivation_path = f"{changePath}/{index}"
    key = derive_master_key(masterKey, derivation_path)
    public_key = BipPublicKey(key, Bip44AVAXMainNet)
    pk = public_key.RawCompressed()
    addr = address_from_publickey(pk)
    return address_to_string(networkID, chainId, addr)
Пример #3
0
    def PublicKey(self):
        """ Return public key bytes.

        Returns:
            BipPublicKey object: BipPublicKey object
        """
        return BipPublicKey(self)
Пример #4
0
    def PublicKey(self):
        """ Return the public key.

        Returns:
            BipPublicKey object: BipPublicKey object

        """
        return BipPublicKey(self.m_bip32, self.m_coin_class)
Пример #5
0
    def PublicKey(self) -> BipPublicKey:
        """ Return public key object.

        Returns:
            BipPublicKey object: BipPublicKey object
        """
        return BipPublicKey(self.EcdsaPublicKey(), self.KeyNetVersions(),
                            self.Depth(), self.ParentFingerPrint(),
                            self.Index(), self.Chain())
Пример #6
0
    def PublicKey(self) -> BipPublicKey:
        """ Return the public key.

        Returns:
            BipPublicKey object: BipPublicKey object

        """
        return BipPublicKey(self.m_bip32.EcdsaPublicKey(),
                            self.m_bip32.KeyNetVersions(),
                            self.m_bip32.Depth(),
                            self.m_bip32.ParentFingerPrint(),
                            self.m_bip32.Index(), self.m_bip32.Chain(),
                            self.m_coin_class)