def test_eth_account_encrypt(acct, web3js_key, web3js_password):
    encrypted = acct.encrypt(web3js_key, web3js_password)

    assert encrypted['address'] == '2c7536e3605d9c16a7a3d7b1898e529396a65c23'
    assert encrypted['version'] == 3

    decrypted_key = acct.decrypt(encrypted, web3js_password)

    assert decrypted_key == to_bytes(hexstr=web3js_key)
Beispiel #2
0
    def sha3(primitive=None, text=None, hexstr=None):
        if isinstance(primitive, (bytes, int, type(None))):
            input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)
            return keccak(input_bytes)

        raise TypeError(
            "You called sha3 with first arg %r and keywords %r. You must call it with one of "
            "these approaches: sha3(text='txt'), sha3(hexstr='0x747874'), "
            "sha3(b'\\x74\\x78\\x74'), or sha3(0x747874)." % (primitive, {
                'text': text,
                'hexstr': hexstr
            }))
Beispiel #3
0
def sm3_tobech32_testaddress(publickey):
    publickeyhash=sm3.sm3_hash(func.bytes_to_list(to_bytes(hexstr=publickey.to_bytes())))
    publickey_bytes=to_bytes(hexstr=publickeyhash)[-20:]
    return address_bytes_to_bech32_address(publickey_bytes)