How to use the base58.encode function in base58

To help you get started, we’ve selected a few base58 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitcoinembassy / morphis / mcc.py View on Github external
dbase = init_db(args)
    de = dmail.DmailEngine(mc, dbase)

    log.info("Processing command requests...")

    if args.stat:
        r = yield from mc.send_command("stat")
        print(r.decode("UTF-8"), end='')

    if args.create_dmail:
        log.info("Creating and uploading dmail site.")

        privkey, data_key, dms, storing_nodes =\
            yield from de.generate_dmail_address(args.prefix)

        print("privkey: {}".format(base58.encode(privkey._encode_key())))
        print("x: {}".format(base58.encode(sshtype.encodeMpint(dms.dh.x))))
        print("dmail address: {}".format(mbase32.encode(data_key)))
        print("storing_nodes=[{}]."\
            .format(base58.encode(privkey._encode_key())))

    if args.send_dmail:
        log.info("Sending dmail.")

        if args.i:
            with open(args.i, "rb") as fh:
                dmail_data = fh.read().decode()
        else:
            dmail_data = stdin.read()

        if log.isEnabledFor(logging.DEBUG):
            log.debug("dmail_data=[{}].".format(dmail_data))
github bitcoinembassy / morphis / client_engine.py View on Github external
return

        if log.isEnabledFor(logging.INFO):
            log.info("Failed to fetch dmail site [{}]; republishing."\
                .format(mbase32.encode(dmail_address.site_key)))

        private_key = rsakey.RsaKey(privdata=dmail_address.site_privatekey)

        dh = dhgroup14.DhGroup14()
        dh.x = sshtype.parseMpint(dmail_address.keys[0].x)[1]
        dh.generate_e()

        dms = dmail.DmailSite()
        root = dms.root
        root["ssm"] = "mdh-v1"
        root["sse"] = base58.encode(sshtype.encodeMpint(dh.e))
        root["target"] =\
            mbase32.encode(dmail_address.keys[0].target_key)
        root["difficulty"] = int(dmail_address.keys[0].difficulty)

        storing_nodes =\
            yield from self._dmail_engine.publish_dmail_site(private_key, dms)

        if log.isEnabledFor(logging.INFO):
            log.info("Republished Dmail site with [{}] storing nodes."\
                .format(storing_nodes))
github bitcoinembassy / morphis / maalstroom / dmail.py View on Github external
else:
                return False

        dmail_address = yield from\
            _process_dmail_address(\
                dispatcher, processor, site_key=mbase32.decode(addr_enc),\
                fetch_keys=True)

        dh = dhgroup14.DhGroup14()
        dh.x = sshtype.parseMpint(dmail_address.keys[0].x)[1]
        dh.generate_e()

        dms = dmail.DmailSite()
        root = dms.root
        root["ssm"] = "mdh-v1"
        root["sse"] = base58.encode(sshtype.encodeMpint(dh.e))
        root["target"] =\
            mbase32.encode(dmail_address.keys[0].target_key)
        root["difficulty"] = int(difficulty)

        private_key = rsakey.RsaKey(privdata=dmail_address.site_privatekey)

        de = dmail.DmailEngine(\
            dispatcher.node.chord_engine.tasks, dispatcher.node.db)

        storing_nodes = yield from de.publish_dmail_site(private_key, dms)

        if storing_nodes:
            dispatcher.send_content(\
                templates.dmail_addr_settings_edit_success_content[0]\
                    .format(addr_enc, addr_enc[:32]).encode())
        else:
github bitcoinembassy / morphis / client_engine.py View on Github external
def __init__(self, engine, db):
        assert type(engine) is chord.ChordEngine

        self.engine = engine
        self.db = db
        self.loop = engine.loop

        self.latest_version_number = None
        self.latest_version_data = None

        self.auto_publish_enabled = True
        self.auto_scan_enabled = True

        self.csrf_token = base58.encode(os.urandom(64))

        self._dmail_engine = None

        self._running = False

        self._data_key =\
            mbase32.decode("sp1nara3xhndtgswh7fznt414we4mi3y6kdwbkz4jmt8ocb6x"\
                "4w1faqjotjkcrefta11swe3h53dt6oru3r13t667pr7cpe3ocxeuma")
        self._path = b"latest_version"

        self._dmail_autoscan_processes = {}
github bitcoinembassy / morphis / client.py View on Github external
def send_store_updateable_key(\
            self, data, privkey, path=None, version=None, store_key=True,\
            key_callback=None):
        privkey_enc = base58.encode(privkey._encode_key())
        data_enc = base58.encode(data)

        cmd = "storeukeyenc {} {} {} {}"\
            .format(privkey_enc, data_enc, version, store_key)

        r = yield from self.send_command(cmd)

        if not r:
            return 0

        if key_callback:
            p1 = r.find(b']', 10)
            r = r[10:p1].decode()
            key_enc = r
            key_callback(mbase32.decode(key_enc))

        return 1 #FIXME: The shell API doesn't return this value as of yet.
github bitcoinembassy / morphis / mcc.py View on Github external
de = dmail.DmailEngine(mc, dbase)

    log.info("Processing command requests...")

    if args.stat:
        r = yield from mc.send_command("stat")
        print(r.decode("UTF-8"), end='')

    if args.create_dmail:
        log.info("Creating and uploading dmail site.")

        privkey, data_key, dms, storing_nodes =\
            yield from de.generate_dmail_address(args.prefix)

        print("privkey: {}".format(base58.encode(privkey._encode_key())))
        print("x: {}".format(base58.encode(sshtype.encodeMpint(dms.dh.x))))
        print("dmail address: {}".format(mbase32.encode(data_key)))
        print("storing_nodes=[{}]."\
            .format(base58.encode(privkey._encode_key())))

    if args.send_dmail:
        log.info("Sending dmail.")

        if args.i:
            with open(args.i, "rb") as fh:
                dmail_data = fh.read().decode()
        else:
            dmail_data = stdin.read()

        if log.isEnabledFor(logging.DEBUG):
            log.debug("dmail_data=[{}].".format(dmail_data))
github bitcoinembassy / morphis / clientengine / dmail.py View on Github external
return

        if log.isEnabledFor(logging.INFO):
            log.info("Failed to fetch dmail site [{}]; republishing."\
                .format(mbase32.encode(dmail_address.site_key)))

        private_key = rsakey.RsaKey(privdata=dmail_address.site_privatekey)

        dh = dhgroup14.DhGroup14()
        dh.x = sshtype.parseMpint(dmail_address.keys[0].x)[1]
        dh.generate_e()

        dms = dmail.DmailSite()
        root = dms.root
        root["ssm"] = "mdh-v1"
        root["sse"] = base58.encode(sshtype.encodeMpint(dh.e))
        root["target"] =\
            mbase32.encode(dmail_address.keys[0].target_key)
        root["difficulty"] = int(dmail_address.keys[0].difficulty)

        storing_nodes =\
            yield from self.dmail_engine.publish_dmail_site(private_key, dms)

        if log.isEnabledFor(logging.INFO):
            log.info("Republished Dmail site with [{}] storing nodes."\
                .format(storing_nodes))
github bitcoinembassy / morphis / maalstroom / dispatcher.py View on Github external
self.send_content(\
                    templates.main_css, content_type="text/css")
#TODO: Have a UI where the user can enable this on a per portal basis only.
#            elif rpath == "csrf_token":
#                self.send_content(self.client_engine.csrf_token)
            else:
                self.send_error(errcode=400)
            return
        elif rpath == ".images/favicon.ico":
            self.send_content(\
                templates.favicon_content, content_type="image/png")
            return
        elif rpath.startswith(".upload") and maalstroom.upload_enabled:
            if rpath.startswith(".upload/generate"):
                priv_key =\
                    base58.encode(\
                        rsakey.RsaKey.generate(bits=4096)._encode_key())

                self.send_response(307)
                self.send_header("Location", "{}".format(priv_key))
                self.send_header("Content-Length", 0)
                self.end_headers()
                self.finish_response()
                return

            if rpath == ".upload" or rpath == ".upload/":
                if (self.handle_cache(rpath)):
                    return

                template = templates.main_combined_upload[0]

                template = template.format(\
github bitcoinembassy / morphis / maalstroom / dmail.py View on Github external
dispatcher.client_engine.csrf_token)
        content = content.replace(\
            "${DIFFICULTY}",\
            str(dmail_address.keys[0].difficulty))
        content = content.replace(\
            "${DMAIL_ADDRESS_SHORT}", addr_enc[:32])
        content = content.replace(\
            "${DMAIL_ADDRESS}", addr_enc)
        content = content.replace(\
            "${PRIVATE_KEY}",\
            base58.encode(dmail_address.site_privatekey))
        content = content.replace(\
            "${X}", base58.encode(dmail_address.keys[0].x))
        content = content.replace(\
            "${TARGET_KEY}",\
            base58.encode(dmail_address.keys[0].target_key))

        dispatcher.send_content([content, None])
##### OLD ACTIONS:
    elif req.startswith("/create_address/make_it_so?"):
        query = req[27:]

        qdict = parse_qs(query, keep_blank_values=True)

        prefix = qdict["prefix"][0]
        difficulty = int(qdict["difficulty"][0])
        csrf_token = qdict["csrf_token"][0]

        if not dispatcher.check_csrf_token(csrf_token):
            return

        log.info("prefix=[{}].".format(prefix))
github bitcoinembassy / morphis / dmail.py View on Github external
def generate_ss(self):
        self.dh = dh = dhgroup14.DhGroup14()
        dh.generate_x()
        dh.generate_e()

        if log.isEnabledFor(logging.INFO):
            log.info("dmail e=[{}].".format(dh.e))

        self.root["ssm"] = _dh_method_name
        self.root["sse"] = base58.encode(sshtype.encodeMpint(dh.e))