How to use the base58.b58encode 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 bigchaindb / bigchaindb / tests / common / test_transaction.py View on Github external
def test_output_deserialization(user_Ed25519, user_pub):
    from bigchaindb.common.transaction import Output

    expected = Output(user_Ed25519, [user_pub], 1)
    cond = {
        'condition': {
            'uri': user_Ed25519.condition_uri,
            'details': {
                'type': 'ed25519-sha-256',
                'public_key': b58encode(user_Ed25519.public_key).decode(),
            },
        },
        'public_keys': [user_pub],
        'amount': '1',
    }
    cond = Output.from_dict(cond)

    assert cond == expected
github hyperledger / indy-node / sovrin_client / client / client.py View on Github external
def doAttrDisclose(self, origin, target, txnId, key):
        box = libnacl.public.Box(b58decode(origin), b58decode(target))

        data = json.dumps({TXN_ID: txnId, SKEY: key})
        nonce, boxedMsg = box.encrypt(data.encode(), pack_nonce=False)

        op = {
            TARGET_NYM: target,
            TXN_TYPE: DISCLO,
            NONCE: b58encode(nonce),
            DATA: b58encode(boxedMsg)
        }
        self.submit(op, identifier=origin)
github eavatar / eavatar-me / src / ava / util / crypto.py View on Github external
"""

    sha256 = hashlib.sha256()
    sha256.update(key)
    key_hash = sha256.digest()

    ripemd = hashlib.new('ripemd')
    ripemd.update(key_hash)
    key_hash = ripemd.digest()

    sha256 = hashlib.sha256()
    sha256.update(FINGER_PREFIX)
    sha256.update(key_hash)
    checksum = sha256.digest()
    result = FINGER_PREFIX+key_hash+checksum[:4]
    return base58.b58encode(result)
github bigchaindb / bigchaindb / bigchaindb / elections / election.py View on Github external
def to_public_key(cls, election_id):
        return base58.b58encode(bytes.fromhex(election_id)).decode()
github sr-gi / bitcoin_tools / bitcoin_tools / wallet.py View on Github external
:return: The corresponding Bitcoin address.
    :rtype: hex str
    """

    # If h160 is passed as hex str, the value is converted into bytes.
    if match('^[0-9a-fA-F]*$', h160):
        h160 = unhexlify(h160)

    # Add the network version leading the previously calculated RIPEMD-160 hash.
    vh160 = chr(v) + h160
    # Double sha256.
    h = sha256(sha256(vh160).digest()).digest()
    # Add the two first bytes of the result as a checksum tailing the RIPEMD-160 hash.
    addr = vh160 + h[0:4]
    # Obtain the Bitcoin address by Base58 encoding the result
    addr = b58encode(addr)

    return addr
github ArcBlock / forge-python-sdk / forge_sdk / utils / crypto.py View on Github external
def multibase_b58encode(data):
    """
    Follow forge's base58 encode convention to encode bytes.

    Args:
        data(bytes): data to be encoded

    Returns:
        string

    Examples:
        >>> multibase_b58encode(b'hello')
        'zCn8eVZg'
    """
    raw = base58.b58encode(data)
    return 'z' + raw.decode()
github aleph-im / pyaleph / src / aleph / services / p2p.py View on Github external
async def decode_msg(msg):
    return {
        'from': base58.b58encode(msg.from_id),
        'data': msg.data,
        'seqno': base58.b58encode(msg.seqno),
        'topicIDs': msg.topicIDs
    }
github schollz / find3 / server / ai / src / server.py View on Github external
def to_base58(family):
    return base58.b58encode(family.encode('utf-8')).decode('utf-8')
github hyperledger / indy-node / scripts / performance / perf_load / perf_utils.py View on Github external
def rawToFriendly(raw):
    return base58.b58encode(raw).decode("utf-8")
github jujugoboom / Bitduino / generate.py View on Github external
def privateKeyGenerator():
    hexstart = "80" + start[0:64]
    bytehex = str(bytearray.fromhex(hexstart))
    hash1 = hashlib.sha256(bytehex).hexdigest()
    bytehex2 = str(bytearray.fromhex(hash1))
    hash2 = hashlib.sha256(bytehex2).hexdigest()
    checksum = hash2[0:8]
    hexfinal = hexstart + checksum
    unencoded_final = str(bytearray.fromhex(hexfinal))
    encoded_final = base58.b58encode(unencoded_final)
    privFile = encoded_final[-8:]
    print("Private Key: " + encoded_final)
    img = qrcode.make(encoded_final)
    img.save("Key_" + privFile + ".png")
    return