# Path: python3-src/graphenebase/base58.py
# def ripemd160(s):
#     ripemd160 = hashlib.new('ripemd160')
#     ripemd160.update(unhexlify(s))
#     return ripemd160.digest()
# 
# class Base58(object):
#     """Base58 base class
# 
#     This class serves as an abstraction layer to deal with base58 encoded
#     strings and their corresponding hex and binary representation throughout the
#     library.
# 
#     :param data: Data to initialize object, e.g. pubkey data, address data, ...
#     :type data: hex, wif, bip38 encrypted wif, base58 string
#     :param str prefix: Prefix to use for Address/PubKey strings (defaults to ``GPH``)
#     :return: Base58 object initialized with ``data``
#     :rtype: Base58
#     :raises ValueError: if data cannot be decoded
# 
#     * ``bytes(Base58)``: Returns the raw data
#     * ``str(Base58)``:   Returns the readable ``Base58CheckEncoded`` data.
#     * ``repr(Base58)``:  Gives the hex representation of the data.
#     *  ``format(Base58,_format)`` Formats the instance according to ``_format``:
#         * ``"btc"``: prefixed with ``0x80``. Yields a valid btc address
#         * ``"wif"``: prefixed with ``0x00``. Yields a valid wif key
#         * ``"bts"``: prefixed with ``BTS``
#         * etc.
# 
#     """
#     def __init__(self, data, prefix=PREFIX):
#         self._prefix = prefix
#         if all(c in string.hexdigits for c in data):
#             self._hex = data
#         elif data[0] == "5" or data[0] == "6":
#             self._hex = base58CheckDecode(data)
#         elif data[0] == "K" or data[0] == "L":
#             self._hex = base58CheckDecode(data)[:-2]
#         elif data[:len(self._prefix)] == self._prefix:
#             self._hex = gphBase58CheckDecode(data[len(self._prefix):])
#         else:
#             raise ValueError("Error loading Base58 object")
# 
#     def __format__(self, _format):
#         """ Format output according to argument _format (wif,btc,...)
# 
#             :param str _format: Format to use
#             :return: formatted data according to _format
#             :rtype: str
# 
#         """
#         if _format.upper() == "WIF":
#             return base58CheckEncode(0x80, self._hex)
#         elif _format.upper() == "ENCWIF":
#             return base58encode(self._hex)
#         elif _format.upper() == "BTC":
#             return base58CheckEncode(0x00, self._hex)
#         elif _format.upper() in known_prefixes:
#             return _format.upper() + str(self)
#         else:
#             log.warn("Format %s unkown. You've been warned!\n" % _format)
#             return _format.upper() + str(self)
# 
#     def __repr__(self):
#         """ Returns hex value of object
# 
#             :return: Hex string of instance's data
#             :rtype: hex string
#         """
#         return self._hex
# 
#     def __str__(self):
#         """ Return graphene-base58CheckEncoded string of data
# 
#             :return: Base58 encoded data
#             :rtype: str
#         """
#         return gphBase58CheckEncode(self._hex)
# 
#     def __bytes__(self):
#         """ Return raw bytes
# 
#             :return: Raw bytes of instance
#             :rtype: bytes
# 
#         """
#         return unhexlify(self._hex)


import ecdsa
import hashlib
import sys
import re
import os
            import os
from binascii import hexlify, unhexlify
from .base58 import ripemd160, Base58
from .dictionary import words as BrainKeyDictionary

class Address(object):
    """ Address class

        This class serves as an address representation for Public Keys.

        :param str address: Base58 encoded address (defaults to ``None``)
        :param str pubkey: Base58 encoded pubkey (defaults to ``None``)
        :param str prefix: Network prefix (defaults to ``GPH``)

        Example::

           Address("GPHFN9r6VYzBK8EKtMewfNbfiGCr56pHDBFi")

    """
    def __init__(self, address=None, pubkey=None, prefix="GPH"):
        self.prefix = prefix
        if pubkey is not None:
            self._pubkey = Base58(pubkey, prefix=prefix)
            self._address = None
        elif address is not None:
            self._pubkey = None
            self._address = Base58(address, prefix=prefix)
        else:
            raise Exception("Address has to be initialized by either the " +
                            "pubkey or the address.")

    def derivesha256address(self):
        """ Derive address using ``RIPEMD160(SHA256(x))`` """
        pkbin = unhexlify(repr(self._pubkey))

# Path: python3-src/graphenebase/base58.py
# def ripemd160(s):
#     ripemd160 = hashlib.new('ripemd160')
#     ripemd160.update(unhexlify(s))
#     return ripemd160.digest()
# 
# class Base58(object):
#     """Base58 base class
# 
#     This class serves as an abstraction layer to deal with base58 encoded
#     strings and their corresponding hex and binary representation throughout the
#     library.
# 
#     :param data: Data to initialize object, e.g. pubkey data, address data, ...
#     :type data: hex, wif, bip38 encrypted wif, base58 string
#     :param str prefix: Prefix to use for Address/PubKey strings (defaults to ``GPH``)
#     :return: Base58 object initialized with ``data``
#     :rtype: Base58
#     :raises ValueError: if data cannot be decoded
# 
#     * ``bytes(Base58)``: Returns the raw data
#     * ``str(Base58)``:   Returns the readable ``Base58CheckEncoded`` data.
#     * ``repr(Base58)``:  Gives the hex representation of the data.
#     *  ``format(Base58,_format)`` Formats the instance according to ``_format``:
#         * ``"btc"``: prefixed with ``0x80``. Yields a valid btc address
#         * ``"wif"``: prefixed with ``0x00``. Yields a valid wif key
#         * ``"bts"``: prefixed with ``BTS``
#         * etc.
# 
#     """
#     def __init__(self, data, prefix=PREFIX):
#         self._prefix = prefix
#         if all(c in string.hexdigits for c in data):
#             self._hex = data
#         elif data[0] == "5" or data[0] == "6":
#             self._hex = base58CheckDecode(data)
#         elif data[0] == "K" or data[0] == "L":
#             self._hex = base58CheckDecode(data)[:-2]
#         elif data[:len(self._prefix)] == self._prefix:
#             self._hex = gphBase58CheckDecode(data[len(self._prefix):])
#         else:
#             raise ValueError("Error loading Base58 object")
# 
#     def __format__(self, _format):
#         """ Format output according to argument _format (wif,btc,...)
# 
#             :param str _format: Format to use
#             :return: formatted data according to _format
#             :rtype: str
# 
#         """
#         if _format.upper() == "WIF":
#             return base58CheckEncode(0x80, self._hex)
#         elif _format.upper() == "ENCWIF":
#             return base58encode(self._hex)
#         elif _format.upper() == "BTC":
#             return base58CheckEncode(0x00, self._hex)
#         elif _format.upper() in known_prefixes:
#             return _format.upper() + str(self)
#         else:
#             log.warn("Format %s unkown. You've been warned!\n" % _format)
#             return _format.upper() + str(self)
# 
#     def __repr__(self):
#         """ Returns hex value of object
# 
#             :return: Hex string of instance's data
#             :rtype: hex string
#         """
#         return self._hex
# 
#     def __str__(self):
#         """ Return graphene-base58CheckEncoded string of data
# 
#             :return: Base58 encoded data
#             :rtype: str
#         """
#         return gphBase58CheckEncode(self._hex)
# 
#     def __bytes__(self):
#         """ Return raw bytes
# 
#             :return: Raw bytes of instance
#             :rtype: bytes
# 
#         """
#         return unhexlify(self._hex)


# Path: python3-src/graphenebase/account.py
import ecdsa
import hashlib
import sys
import re
import os
            import os
from binascii import hexlify, unhexlify
from .base58 import ripemd160, Base58
from .dictionary import words as BrainKeyDictionary


class Address(object):
    """ Address class

        This class serves as an address representation for Public Keys.

        :param str address: Base58 encoded address (defaults to ``None``)
        :param str pubkey: Base58 encoded pubkey (defaults to ``None``)
        :param str prefix: Network prefix (defaults to ``GPH``)

        Example::

           Address("GPHFN9r6VYzBK8EKtMewfNbfiGCr56pHDBFi")

    """
    def __init__(self, address=None, pubkey=None, prefix="GPH"):
        self.prefix = prefix
        if pubkey is not None:
            self._pubkey = Base58(pubkey, prefix=prefix)
            self._address = None
        elif address is not None:
            self._pubkey = None
            self._address = Base58(address, prefix=prefix)
        else:
            raise Exception("Address has to be initialized by either the " +
                            "pubkey or the address.")

    def derivesha256address(self):
        """ Derive address using ``RIPEMD160(SHA256(x))`` """
        pkbin = unhexlify(repr(self._pubkey))

        addressbin = ripemd160(hexlify(hashlib.sha256(pkbin).digest()))