コード例 #1
0
ファイル: auth.py プロジェクト: yjmyzz/py-evm
def decode_ack_eip8(
        ciphertext: bytes, privkey: datatypes.PrivateKey
) -> Tuple[datatypes.PublicKey, bytes, int]:
    """Decrypts and decodes a EIP-8 auth ack message.

    Returns the remote's ephemeral pubkey, nonce and protocol version.
    """
    # The length of the actual msg is stored in plaintext on the first two bytes.
    encoded_size = ciphertext[:2]
    auth_ack = ciphertext[2:]
    message = ecies.decrypt(auth_ack, privkey, shared_mac_data=encoded_size)
    values = rlp.decode(message, sedes=eip8_ack_sedes, strict=False)
    pubkey_bytes, nonce, version = values[:3]
    return keys.PublicKey(pubkey_bytes), nonce, version
コード例 #2
0
ファイル: auth.py プロジェクト: yjmyzz/py-evm
def decode_auth_plain(
    ciphertext: bytes, privkey: datatypes.PrivateKey
) -> Tuple[datatypes.Signature, datatypes.PublicKey, bytes, int]:
    """Decode legacy pre-EIP-8 auth message format"""
    message = ecies.decrypt(ciphertext, privkey)
    if len(message) != AUTH_MSG_LEN:
        raise ValueError("Unexpected size for auth message: {}".format(
            len(message)))
    signature = keys.Signature(signature_bytes=message[:SIGNATURE_LEN])
    pubkey_start = SIGNATURE_LEN + HASH_LEN
    pubkey = keys.PublicKey(message[pubkey_start:pubkey_start + PUBKEY_LEN])
    nonce_start = pubkey_start + PUBKEY_LEN
    nonce = message[nonce_start:nonce_start + HASH_LEN]
    return signature, pubkey, nonce, SUPPORTED_RLPX_VERSION
コード例 #3
0
ファイル: auth.py プロジェクト: zhengger/py-evm
def decode_ack_plain(
        ciphertext: bytes, privkey: datatypes.PrivateKey
) -> Tuple[datatypes.PublicKey, bytes, int]:
    """Decrypts and decodes a legacy pre-EIP-8 auth ack message.

    Returns the remote's ephemeral pubkey, nonce and protocol version.
    """
    message = ecies.decrypt(ciphertext, privkey)
    if len(message) != AUTH_ACK_LEN:
        raise ValueError("Unexpected size for ack message: {}".format(
            len(message)))
    eph_pubkey = keys.PublicKey(message[:PUBKEY_LEN])
    nonce = message[PUBKEY_LEN:PUBKEY_LEN + HASH_LEN]
    return eph_pubkey, nonce, SUPPORTED_RLPX_VERSION
コード例 #4
0
ファイル: auth.py プロジェクト: hiteshramani/py-evm
def decode_auth_eip8(ciphertext: bytes, privkey: datatypes.PrivateKey) -> Tuple[
        datatypes.Signature, datatypes.PublicKey, bytes, int]:
    """Decode EIP-8 auth message format"""
    # The length of the actual msg is stored in plaintext on the first two bytes.
    encoded_size = ciphertext[:2]
    auth_msg = ciphertext[2:]
    message = ecies.decrypt(auth_msg, privkey, shared_mac_data=encoded_size)
    values = rlp.decode(message, sedes=eip8_auth_sedes, strict=False)
    signature_bytes, pubkey_bytes, nonce, version = values[:4]
    return (
        keys.Signature(signature_bytes=signature_bytes),
        keys.PublicKey(pubkey_bytes),
        nonce,
        version
    )
コード例 #5
0
    def generate_keys(self):
        eth_btc_root_public_key = HD_ROOT_KEYS['ETH-BTC']['public']
        root_key = BIP32Key.fromExtendedKey(eth_btc_root_public_key,
                                            public=True)
        child_key = root_key.ChildKey(self.id)

        self.btc_address = child_key.Address()
        self.eth_address = keys.PublicKey(
            child_key.K.to_string()).to_checksum_address().lower()

        duc_root_public_key = HD_ROOT_KEYS['DUC']['public']
        duc_root_key = DucatusWallet.deserialize(duc_root_public_key)
        self.duc_address = duc_root_key.get_child(self.id,
                                                  is_prime=False).to_address()

        self.save()
コード例 #6
0
ファイル: __init__.py プロジェクト: humanprotocol/hmt-escrow
def encrypt(public_key: bytes, msg: str) -> bytes:
    """
    Use ECIES to encrypt a message with a given public key and optional MAC.

    Args:
        public_key (bytes): The public_key to encrypt the message with.
        msg (str): The message to be encrypted.

    Returns:
        bytes: returns the cryptotext encrypted with the public key.

    """
    pub_key = eth_keys.PublicKey(codecs.decode(public_key, "hex"))
    msg_bytes = msg.encode("utf-8")
    return encryption.encrypt(msg_bytes,
                              pub_key,
                              shared_mac_data=SHARED_MAC_DATA)
コード例 #7
0
ファイル: storage.py プロジェクト: PaddyMc/hmt-escrow
def _encrypt(public_key: bytes, msg: str) -> bytes:
    """Use ECIES to encrypt a message with a given public key and optional MAC.

    Args:
        public_key (bytes): The public_key to encrypt the message with.
        msg (str): The message to be encrypted.
    
    Returns:
        bytes: returns the cryptotext encrypted with the public key.

    >>> priv_key = "28e516f1e2f99e96a48a23cea1f94ee5f073403a1c68e818263f0eb898f1c8e5"
    >>> pub_key = b"2dbc2c2c86052702e7c219339514b2e8bd4687ba1236c478ad41b43330b08488c12c8c1797aa181f3a4596a1bd8a0c18344ea44d6655f61fa73e56e743f79e0d"
    >>> msg = "test"
    >>> _decrypt(priv_key, _encrypt(pub_key, msg)) == msg
    True
    """
    pub_key = keys.PublicKey(codecs.decode(public_key, 'hex'))
    msg_bytes = msg.encode(encoding='utf-8')
    return ecies.encrypt(msg_bytes, pub_key, shared_mac_data=SHARED_MAC_DATA)
コード例 #8
0
def decrypt(data: bytes,
            privkey: datatypes.PrivateKey,
            shared_mac_data: bytes = b'') -> bytes:
    """Decrypt data with ECIES method using the given private key

    1) generate shared-secret = kdf( ecdhAgree(myPrivKey, msg[1:65]) )
    2) verify tag
    3) decrypt

    ecdhAgree(r, recipientPublic) == ecdhAgree(recipientPrivate, R)
    [where R = r*G, and recipientPublic = recipientPrivate*G]

    """
    if data[:1] != b'\x04':
        raise DecryptionError("wrong ecies header")

    #  1) generate shared-secret = kdf( ecdhAgree(myPrivKey, msg[1:65]) )
    shared = data[1:1 + PUBKEY_LEN]
    try:
        key_material = ecdh_agree(privkey, keys.PublicKey(shared))
    except _InvalidPublicKey as exc:
        raise DecryptionError(
            f"Failed to generate shared secret with pubkey {shared}: {exc}"
        ) from exc
    key = kdf(key_material)
    key_enc, key_mac = key[:KEY_LEN // 2], key[KEY_LEN // 2:]
    key_mac = sha256(key_mac).digest()
    tag = data[-KEY_LEN:]

    # 2) Verify tag
    expected_tag = hmac_sha256(key_mac,
                               data[1 + PUBKEY_LEN:-KEY_LEN] + shared_mac_data)
    if not bytes_eq(expected_tag, tag):
        raise DecryptionError("Failed to verify tag")

    # 3) Decrypt
    algo = CIPHER(key_enc)
    blocksize = algo.block_size // 8
    iv = data[1 + PUBKEY_LEN:1 + PUBKEY_LEN + blocksize]
    ciphertext = data[1 + PUBKEY_LEN + blocksize:-KEY_LEN]
    ctx = Cipher(algo, MODE(iv), default_backend()).decryptor()
    return ctx.update(ciphertext) + ctx.finalize()
コード例 #9
0
ファイル: storage.py プロジェクト: todicus/hmt-escrow
def _encrypt(public_key: bytes, msg: str):
    pub_key = keys.PublicKey(codecs.decode(public_key, 'hex'))
    msg_bytes = msg.encode(encoding='utf-8')
    return ecies.encrypt(msg_bytes, pub_key, shared_mac_data=SHARED_MAC_DATA)
コード例 #10
0
ファイル: kademlia.py プロジェクト: AYCH-Inc/aych.eth.client
 def from_enode_uri(cls: Type[TNode], uri: str) -> TNode:
     validate_enode_uri(uri)  # Be no more permissive than the validation
     parsed = urlparse.urlparse(uri)
     pubkey = keys.PublicKey(decode_hex(parsed.username))
     return cls.from_pubkey_and_addr(
         pubkey, Address(parsed.hostname, parsed.port, parsed.port))
コード例 #11
0
ファイル: test_kademlia.py プロジェクト: sunxivincent/py-evm
def random_pubkey():
    pk = int_to_big_endian(random.getrandbits(kademlia.k_pubkey_size))
    return keys.PublicKey(b'\x00' * (kademlia.k_pubkey_size // 8 - len(pk)) +
                          pk)
コード例 #12
0
ファイル: test_ecies.py プロジェクト: ycdk/py-evm
def test_ecdh(privkey_hex, pubkey_hex, ecdh_expected):
    privkey = keys.PrivateKey(decode_hex(privkey_hex))
    pubkey = keys.PublicKey(decode_hex(pubkey_hex))
    assert ecdh_expected == encode_hex(ecies.ecdh_agree(privkey, pubkey))
コード例 #13
0
def _extract_nodes_from_payload(
        payload: List[Tuple[str, str, str, str]]) -> Generator[kademlia.Node, None, None]:
    for item in payload:
        ip, udp_port, tcp_port, node_id = item
        address = kademlia.Address.from_endpoint(ip, udp_port, tcp_port)
        yield kademlia.Node(keys.PublicKey(node_id), address)
コード例 #14
0
ファイル: ProjectHex.py プロジェクト: gochady1337/ProjectHex
def seek(r):
    while True:
        c1 = str(random.choice("01"))
        c2 = str(random.choice("01"))
        c3 = str(random.choice("01"))
        c4 = str(random.choice("01"))
        c5 = str(random.choice("01"))
        c6 = str(random.choice("01"))
        c7 = str(random.choice("01"))
        c8 = str(random.choice("01"))
        c9 = str(random.choice("01"))
        c10 = str(random.choice("01"))
        c11 = str(random.choice("01"))
        c12 = str(random.choice("01"))
        c13 = str(random.choice("01"))
        c14 = str(random.choice("01"))
        c15 = str(random.choice("01"))
        c16 = str(random.choice("01"))
        c17 = str(random.choice("01"))
        c18 = str(random.choice("01"))
        c19 = str(random.choice("01"))
        c20 = str(random.choice("01"))
        c21 = str(random.choice("01"))
        c22 = str(random.choice("01"))
        c23 = str(random.choice("01"))
        c24 = str(random.choice("01"))
        c25 = str(random.choice("01"))
        c26 = str(random.choice("01"))
        c27 = str(random.choice("01"))
        c28 = str(random.choice("01"))
        c29 = str(random.choice("01"))
        c30 = str(random.choice("01"))
        c31 = str(random.choice("01"))
        c32 = str(random.choice("01"))
        c33 = str(random.choice("01"))
        c34 = str(random.choice("01"))
        c35 = str(random.choice("01"))
        c36 = str(random.choice("01"))
        c37 = str(random.choice("01"))
        c38 = str(random.choice("01"))
        c39 = str(random.choice("01"))
        c40 = str(random.choice("01"))
        c41 = str(random.choice("01"))
        c42 = str(random.choice("01"))
        c43 = str(random.choice("01"))
        c44 = str(random.choice("01"))
        c45 = str(random.choice("01"))
        c46 = str(random.choice("01"))
        c47 = str(random.choice("01"))
        c48 = str(random.choice("01"))
        c49 = str(random.choice("01"))
        c50 = str(random.choice("01"))
        c51 = str(random.choice("01"))
        c52 = str(random.choice("01"))
        c53 = str(random.choice("01"))
        c54 = str(random.choice("01"))
        c55 = str(random.choice("01"))
        c56 = str(random.choice("01"))
        c57 = str(random.choice("01"))
        c58 = str(random.choice("01"))
        c59 = str(random.choice("01"))
        c60 = str(random.choice("01"))
        c61 = str(random.choice("01"))
        c62 = str(random.choice("01"))
        c63 = str(random.choice("01"))
        c64 = str(random.choice("01"))
        c65 = str(random.choice("01"))
        c66 = str(random.choice("01"))
        c67 = str(random.choice("01"))
        c68 = str(random.choice("01"))
        c69 = str(random.choice("01"))
        c70 = str(random.choice("01"))
        c71 = str(random.choice("01"))
        c72 = str(random.choice("01"))
        c73 = str(random.choice("01"))
        c74 = str(random.choice("01"))
        c75 = str(random.choice("01"))
        c76 = str(random.choice("01"))
        c77 = str(random.choice("01"))
        c78 = str(random.choice("01"))
        c79 = str(random.choice("01"))
        c80 = str(random.choice("01"))
        c81 = str(random.choice("01"))
        c82 = str(random.choice("01"))
        c83 = str(random.choice("01"))
        c84 = str(random.choice("01"))
        c85 = str(random.choice("01"))
        c86 = str(random.choice("01"))
        c87 = str(random.choice("01"))
        c88 = str(random.choice("01"))
        c89 = str(random.choice("01"))
        c90 = str(random.choice("01"))
        c91 = str(random.choice("01"))
        c92 = str(random.choice("01"))
        c93 = str(random.choice("01"))
        c94 = str(random.choice("01"))
        c95 = str(random.choice("01"))
        c96 = str(random.choice("01"))
        c97 = str(random.choice("01"))
        c98 = str(random.choice("01"))
        c99 = str(random.choice("01"))
        c100 = str(random.choice("01"))
        c101 = str(random.choice("01"))
        c102 = str(random.choice("01"))
        c103 = str(random.choice("01"))
        c104 = str(random.choice("01"))
        c105 = str(random.choice("01"))
        c106 = str(random.choice("01"))
        c107 = str(random.choice("01"))
        c108 = str(random.choice("01"))
        c109 = str(random.choice("01"))
        c110 = str(random.choice("01"))
        c111 = str(random.choice("01"))
        c112 = str(random.choice("01"))
        c113 = str(random.choice("01"))
        c114 = str(random.choice("01"))
        c115 = str(random.choice("01"))
        c116 = str(random.choice("01"))
        c117 = str(random.choice("01"))
        c118 = str(random.choice("01"))
        c119 = str(random.choice("01"))
        c120 = str(random.choice("01"))
        c121 = str(random.choice("01"))
        c122 = str(random.choice("01"))
        c123 = str(random.choice("01"))
        c124 = str(random.choice("01"))
        c125 = str(random.choice("01"))
        c126 = str(random.choice("01"))
        c127 = str(random.choice("01"))
        c128 = str(random.choice("01"))
        c129 = str(random.choice("01"))
        c130 = str(random.choice("01"))
        c131 = str(random.choice("01"))
        c132 = str(random.choice("01"))
        c133 = str(random.choice("01"))
        c134 = str(random.choice("01"))
        c135 = str(random.choice("01"))
        c136 = str(random.choice("01"))
        c137 = str(random.choice("01"))
        c138 = str(random.choice("01"))
        c139 = str(random.choice("01"))
        c140 = str(random.choice("01"))
        c141 = str(random.choice("01"))
        c142 = str(random.choice("01"))
        c143 = str(random.choice("01"))
        c144 = str(random.choice("01"))
        c145 = str(random.choice("01"))
        c146 = str(random.choice("01"))
        c147 = str(random.choice("01"))
        c148 = str(random.choice("01"))
        c149 = str(random.choice("01"))
        c150 = str(random.choice("01"))
        c151 = str(random.choice("01"))
        c152 = str(random.choice("01"))
        c153 = str(random.choice("01"))
        c154 = str(random.choice("01"))
        c155 = str(random.choice("01"))
        c156 = str(random.choice("01"))
        c157 = str(random.choice("01"))
        c158 = str(random.choice("01"))
        c159 = str(random.choice("01"))
        c160 = str(random.choice("01"))
        c161 = str(random.choice("01"))
        c162 = str(random.choice("01"))
        c163 = str(random.choice("01"))
        c164 = str(random.choice("01"))
        c165 = str(random.choice("01"))
        c166 = str(random.choice("01"))
        c167 = str(random.choice("01"))
        c168 = str(random.choice("01"))
        c169 = str(random.choice("01"))
        c170 = str(random.choice("01"))
        c171 = str(random.choice("01"))
        c172 = str(random.choice("01"))
        c173 = str(random.choice("01"))
        c174 = str(random.choice("01"))
        c175 = str(random.choice("01"))
        c176 = str(random.choice("01"))
        c177 = str(random.choice("01"))
        c178 = str(random.choice("01"))
        c179 = str(random.choice("01"))
        c180 = str(random.choice("01"))
        c181 = str(random.choice("01"))
        c182 = str(random.choice("01"))
        c183 = str(random.choice("01"))
        c184 = str(random.choice("01"))
        c185 = str(random.choice("01"))
        c186 = str(random.choice("01"))
        c187 = str(random.choice("01"))
        c188 = str(random.choice("01"))
        c189 = str(random.choice("01"))
        c190 = str(random.choice("01"))
        c191 = str(random.choice("01"))
        c192 = str(random.choice("01"))
        c193 = str(random.choice("01"))
        c194 = str(random.choice("01"))
        c195 = str(random.choice("01"))
        c196 = str(random.choice("01"))
        c197 = str(random.choice("01"))
        c198 = str(random.choice("01"))
        c199 = str(random.choice("01"))
        c200 = str(random.choice("01"))
        c201 = str(random.choice("01"))
        c202 = str(random.choice("01"))
        c203 = str(random.choice("01"))
        c204 = str(random.choice("01"))
        c205 = str(random.choice("01"))
        c206 = str(random.choice("01"))
        c207 = str(random.choice("01"))
        c208 = str(random.choice("01"))
        c209 = str(random.choice("01"))
        c210 = str(random.choice("01"))
        c211 = str(random.choice("01"))
        c212 = str(random.choice("01"))
        c213 = str(random.choice("01"))
        c214 = str(random.choice("01"))
        c215 = str(random.choice("01"))
        c216 = str(random.choice("01"))
        c217 = str(random.choice("01"))
        c218 = str(random.choice("01"))
        c219 = str(random.choice("01"))
        c220 = str(random.choice("01"))
        c221 = str(random.choice("01"))
        c222 = str(random.choice("01"))
        c223 = str(random.choice("01"))
        c224 = str(random.choice("01"))
        c225 = str(random.choice("01"))
        c226 = str(random.choice("01"))
        c227 = str(random.choice("01"))
        c228 = str(random.choice("01"))
        c229 = str(random.choice("01"))
        c230 = str(random.choice("01"))
        c231 = str(random.choice("01"))
        c232 = str(random.choice("01"))
        c233 = str(random.choice("01"))
        c234 = str(random.choice("01"))
        c235 = str(random.choice("01"))
        c236 = str(random.choice("01"))
        c237 = str(random.choice("01"))
        c238 = str(random.choice("01"))
        c239 = str(random.choice("01"))
        c240 = str(random.choice("01"))
        c241 = str(random.choice("01"))
        c242 = str(random.choice("01"))
        c243 = str(random.choice("01"))
        c244 = str(random.choice("01"))
        c245 = str(random.choice("01"))
        c246 = str(random.choice("01"))
        c247 = str(random.choice("01"))
        c248 = str(random.choice("01"))
        c249 = str(random.choice("01"))
        c250 = str(random.choice("01"))
        c251 = str(random.choice("01"))
        c252 = str(random.choice("01"))
        c253 = str(random.choice("01"))
        c254 = str(random.choice("01"))
        c255 = str(random.choice("01"))
        c256 = str(random.choice("01"))

        magic = (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11 + c12 +
                 c13 + c14 + c15 + c16 + c17 + c18 + c19 + c20 + c21 + c22 +
                 c23 + c24 + c25 + c26 + c27 + c28 + c29 + c30 + c31 + c32 +
                 c33 + c34 + c35 + c36 + c37 + c38 + c39 + c40 + c41 + c42 +
                 c43 + c44 + c45 + c46 + c47 + c48 + c49 + c50 + c51 + c52 +
                 c53 + c54 + c55 + c56 + c57 + c58 + c59 + c60 + c61 + c62 +
                 c63 + c64 + c65 + c66 + c67 + c68 + c69 + c70 + c71 + c72 +
                 c73 + c74 + c75 + c76 + c77 + c78 + c79 + c80 + c81 + c82 +
                 c83 + c84 + c85 + c86 + c87 + c88 + c89 + c90 + c91 + c92 +
                 c93 + c94 + c95 + c96 + c97 + c98 + c99 + c100 + c101 + c102 +
                 c103 + c104 + c105 + c106 + c107 + c108 + c109 + c110 + c111 +
                 c112 + c113 + c114 + c115 + c116 + c117 + c118 + c119 + c120 +
                 c121 + c122 + c123 + c124 + c125 + c126 + c127 + c128 + c129 +
                 c130 + c131 + c132 + c133 + c134 + c135 + c136 + c137 + c138 +
                 c139 + c140 + c141 + c142 + c143 + c144 + c145 + c146 + c147 +
                 c148 + c149 + c150 + c151 + c152 + c153 + c154 + c155 + c156 +
                 c157 + c158 + c159 + c160 + c161 + c162 + c163 + c164 + c165 +
                 c166 + c167 + c168 + c169 + c170 + c171 + c172 + c173 + c174 +
                 c175 + c176 + c177 + c178 + c179 + c180 + c181 + c182 + c183 +
                 c184 + c185 + c186 + c187 + c188 + c189 + c190 + c191 + c192 +
                 c193 + c194 + c195 + c196 + c197 + c198 + c199 + c200 + c201 +
                 c202 + c203 + c204 + c205 + c206 + c207 + c208 + c209 + c210 +
                 c211 + c212 + c213 + c214 + c215 + c216 + c217 + c218 + c219 +
                 c220 + c221 + c222 + c223 + c224 + c225 + c226 + c227 + c228 +
                 c229 + c230 + c231 + c232 + c233 + c234 + c235 + c236 + c237 +
                 c238 + c239 + c240 + c241 + c242 + c243 + c244 + c245 + c246 +
                 c247 + c248 + c249 + c250 + c251 + c252 + c253 + c254 + c255 +
                 c256)
        dec = int(magic, 2)
        key1 = Key.from_int(dec)
        wif = bytes_to_wif(key1.to_bytes(),
                           compressed=False)  #Uncompressed WIF
        wif2 = bytes_to_wif(key1.to_bytes(), compressed=True)  #compressed WIF
        key2 = Key(wif)
        caddr = key1.address  #Legacy compressed address
        uaddr = key2.address  #Legacy uncompressed address
        saddr = key1.segwit_address
        pub1 = hexlify(key1.public_key).decode()
        pub2 = hexlify(key2.public_key).decode()
        pubk1 = PublicKey.unhexlify(pub1)
        pubk2 = PublicKey.unhexlify(pub2)
        bcaddr = P2wpkhAddress(
            pubk1.hash(), version=0,
            mainnet=True)  #Segwit (bech32) compressed address
        buaddr = P2wpkhAddress(
            pubk2.hash(), version=0,
            mainnet=True)  #Segwit (bech32) uncompressed address
        myhex = "%064x" % dec
        private_key = myhex[:64]
        private_key_bytes = bytes.fromhex(private_key)
        public_key_hex = keys.PrivateKey(private_key_bytes).public_key
        public_key_bytes = bytes.fromhex(str(public_key_hex)[2:])
        eaddr = keys.PublicKey(public_key_bytes).to_address()  #Eth address
        if caddr in add:
            print("Nice One Found!!!", dec, caddr, wif2,
                  private_key)  #Legacy compressed address
            s1 = str(dec)
            s2 = caddr
            s3 = wif2
            s4 = private_key
            f = open(u"CompressedWinner.txt",
                     "a")  #Output File of Legacy compressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            break  #break or continue
        if uaddr in add:
            print("Nice One Found!!!", dec, uaddr, wif,
                  private_key)  #Legacy uncompressed address
            s1 = str(dec)
            s2 = uaddr
            s3 = wif
            s4 = private_key
            f = open(u"UncompressedWinner.txt",
                     "a")  #Output File of Legacy uncompressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            break  #break or continue
        if saddr in add:
            print("Nice One Found!!!", dec, saddr, wif,
                  private_key)  #Segwit address
            s1 = str(dec)
            s2 = saddr
            s3 = wif
            s4 = private_key
            f = open(u"Winner3.txt", "a")  #Output File of Segwit Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            break  #break or continue
        if str(bcaddr) in add:
            print("Nice One Found!!!", dec,
                  str(bcaddr))  #Segwit (bech32) compressed address
            s1 = str(dec)
            s2 = str(bcaddr)
            s3 = wif
            s4 = private_key
            f = open(
                u"bech32CompressedWinner.txt",
                "a")  #Output File of Segwit (bech32) compressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            break  #break or continue
        if str(buaddr) in add:
            print("Nice One Found!!!", dec,
                  str(buaddr))  #Segwit (bech32) uncompressed address
            s1 = str(dec)
            s2 = str(buaddr)
            s3 = wif
            s4 = private_key
            f = open(
                u"bechUncompressedWinner.txt",
                "a")  #Output File of Segwit (bech32) uncompressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            break  #break or continue
        if eaddr in add:
            print("Nice One Found!!!", dec, private_key, eaddr)  #Eth address
            s1 = str(dec)
            s2 = eaddr
            s3 = wif
            s4 = private_key
            f = open(u"EthWinner.txt", "a")  #Output File of Eth Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            break  #break or continue
        else:
            colour_cyan = '\033[36m'
            colour_reset = '\033[0;0;39m'
            colour_red = '\033[31m'
            print("\n " + colour_cyan + "ProjectHex---" + colour_red +
                  "---Good--Luck--Happy--Hunting--Mizogg.co.uk&Chad---" +
                  colour_cyan + "---ProjectHex" +
                  colour_reset)  # Running Display Output
            print(myhex)
            print(caddr)
            print(uaddr)
            print(saddr)
            print(bcaddr)
            print(buaddr)
            print(eaddr)
            print(colour_cyan + seconds_to_str())
コード例 #15
0
            # Yield control to ensure we process any disconnection requests from peers. Otherwise
            # we could return peers that should have been disconnected already.
            await asyncio.sleep(0)
            try:
                peer = next(self.iter)
                if not peer.is_closing:
                    return peer
            except StopIteration:
                raise StopAsyncIteration


DEFAULT_PREFERRED_NODES: Dict[int, Tuple[Node, ...]] = {
    MAINNET_NETWORK_ID: (
        Node(
            keys.PublicKey(
                decode_hex(
                    "1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"
                )),  # noqa: E501
            Address("52.74.57.123", 30303, 30303)),
        Node(
            keys.PublicKey(
                decode_hex(
                    "78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"
                )),  # noqa: E501
            Address("191.235.84.50", 30303, 30303)),
        Node(
            keys.PublicKey(
                decode_hex(
                    "ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286"
                )),  # noqa: E501
            Address("52.231.202.145", 30303, 30303)),
        Node(
コード例 #16
0
ファイル: peer.py プロジェクト: FLYChain/py-evm
    def get_nodes_to_connect(self) -> Generator[Node, None, None]:
        from evm.chains.ropsten import RopstenChain
        from evm.chains.mainnet import MainnetChain
        if self.network_id == MainnetChain.network_id:
            nodes = [
                Node(keys.PublicKey(decode_hex("1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082")),  # noqa: E501
                     Address("52.74.57.123", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d")),  # noqa: E501
                     Address("191.235.84.50", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286")),  # noqa: E501
                     Address("52.231.202.145", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99")),  # noqa: E501
                     Address("13.93.211.84", 30303, 30303)),
            ]
        elif self.network_id == RopstenChain.network_id:
            nodes = [
                Node(keys.PublicKey(decode_hex("60ce95dc5b6873e1c53897815496c28132fa50a1227935c58fbffc30a25bf9df68594f7bdc63b1d33c2911c96013b5b058dcfc9184a78082e9af5ace05fe5486")),  # noqa: E501
                     Address("79.98.29.93", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("a147a3adde1daddc0d86f44f1a76404914e44cee018c26d49248142d4dc8a9fb0e7dd14b5153df7e60f23b037922ae1f33b8f318844ef8d2b0453b9ab614d70d")),  # noqa: E501
                     Address("72.36.89.11", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("d8714127db3c10560a2463c557bbe509c99969078159c69f9ce4f71c2cd1837bcd33db3b9c3c3e88c971b4604bbffa390a0a7f53fc37f122e2e6e0022c059dfd")),  # noqa: E501
                     Address("51.15.217.106", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("efc75f109d91cdebc62f33be992ca86fce2637044d49a954a8bdceb439b1239afda32e642456e9dfd759af5b440ef4d8761b9bda887e2200001c5f3ab2614043")),  # noqa: E501
                     Address("34.228.166.142", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("c8b9ec645cd7fe570bc73740579064c528771338c31610f44d160d2ae63fd00699caa163f84359ab268d4a0aed8ead66d7295be5e9c08b0ec85b0198273bae1f")),  # noqa: E501
                     Address("178.62.246.6", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("7a34c02d5ef9de43475580cbb88fb492afb2858cfc45f58cf5c7088ceeded5f58e65be769b79c31c5ae1f012c99b3e9f2ea9ef11764d553544171237a691493b")),  # noqa: E501
                     Address("35.227.38.243", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("bbb3ad8be9684fa1d67ac057d18f7357dd236dc01a806fef6977ac9a259b352c00169d092c50475b80aed9e28eff12d2038e97971e0be3b934b366e86b59a723")),  # noqa: E501
                     Address("81.169.153.213", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606")),  # noqa: E501
                     Address("52.176.7.10", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("02508da84b37a1b7f19f77268e5b69acc9e9ab6989f8e5f2f8440e025e633e4277019b91884e46821414724e790994a502892144fc1333487ceb5a6ce7866a46")),  # noqa: E501
                     Address("54.175.255.230", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("0eec3472a46f0b637045e41f923ce1d4a585cd83c1c7418b183c46443a0df7405d020f0a61891b2deef9de35284a0ad7d609db6d30d487dbfef72f7728d09ca9")),  # noqa: E501
                     Address("181.168.193.197", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("643c31104d497e3d4cd2460ff0dbb1fb9a6140c8bb0fca66159bbf177d41aefd477091c866494efd3f1f59a0652c93ab2f7bb09034ed5ab9f2c5c6841aef8d94")),  # noqa: E501
                     Address("34.198.237.7", 30303, 30303)),
            ]
        else:
            raise ValueError("Unknown network_id: {}".format(self.network_id))

        random.shuffle(nodes)
        for node in nodes:
            yield node
コード例 #17
0
 async def get_nodes_to_connect(self) -> List[kademlia.Node]:
     # TODO: This should use the Discovery service to lookup nodes to connect to, but our
     # current implementation only supports v4 and with that it takes an insane amount of time
     # to find any LES nodes with the same network ID as us, so for now we hard-code some nodes
     # that seem to have a good uptime.
     from evm.chains.ropsten import RopstenChain
     from evm.chains.mainnet import MainnetChain
     if self.network_id == MainnetChain.network_id:
         return [
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"
                     )),  # noqa: E501
                 kademlia.Address("52.74.57.123", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"
                     )),  # noqa: E501
                 kademlia.Address("191.235.84.50", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286"
                     )),  # noqa: E501
                 kademlia.Address("52.231.202.145", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99"
                     )),  # noqa: E501
                 kademlia.Address("13.93.211.84", 30303, 30303)),
         ]
     elif self.network_id == RopstenChain.network_id:
         return [
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "88c2b24429a6f7683fbfd06874ae3f1e7c8b4a5ffb846e77c705ba02e2543789d66fc032b6606a8d8888eb6239a2abe5897ce83f78dcdcfcb027d6ea69aa6fe9"
                     )),  # noqa: E501
                 kademlia.Address("163.172.157.61", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "a1ef9ba5550d5fac27f7cbd4e8d20a643ad75596f307c91cd6e7f85b548b8a6bf215cca436d6ee436d6135f9fe51398f8dd4c0bd6c6a0c332ccb41880f33ec12"
                     )),  # noqa: E501
                 kademlia.Address("51.15.218.125", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "e80276aabb7682a4a659f4341c1199de79d91a2e500a6ee9bed16ed4ce927ba8d32ba5dea357739ffdf2c5bcc848d3064bb6f149f0b4249c1f7e53f8bf02bfc8"
                     )),  # noqa: E501
                 kademlia.Address("51.15.39.57", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "584c0db89b00719e9e7b1b5c32a4a8942f379f4d5d66bb69f9c7fa97fa42f64974e7b057b35eb5a63fd7973af063f9a1d32d8c60dbb4854c64cb8ab385470258"
                     )),  # noqa: E501
                 kademlia.Address("51.15.35.2", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "d40871fc3e11b2649700978e06acd68a24af54e603d4333faecb70926ca7df93baa0b7bf4e927fcad9a7c1c07f9b325b22f6d1730e728314d0e4e6523e5cebc2"
                     )),  # noqa: E501
                 kademlia.Address("51.15.132.235", 30303, 30303)),
             kademlia.Node(
                 keys.PublicKey(
                     decode_hex(
                         "482484b9198530ee2e00db89791823244ca41dcd372242e2e1297dd06f6d8dd357603960c5ad9cc8dc15fcdf0e4edd06b7ad7db590e67a0b54f798c26581ebd7"
                     )),  # noqa: E501
                 kademlia.Address("51.15.75.138", 30303, 30303)),
         ]
     else:
         raise ValueError("Unknown network_id: %s", self.network_id)
コード例 #18
0
    logging.basicConfig(level=logging.DEBUG,
                        format='%(levelname)s: %(message)s')

    # The default remoteid can be used if you pass nodekeyhex as above to geth.
    nodekey = keys.PrivateKey(
        decode_hex(
            "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8")
    )
    remoteid = nodekey.public_key.to_hex()
    parser = argparse.ArgumentParser()
    parser.add_argument('-remoteid', type=str, default=remoteid)
    parser.add_argument('-db', type=str)
    parser.add_argument('-mainnet', action="store_true")
    args = parser.parse_args()

    remote = Node(keys.PublicKey(decode_hex(args.remoteid)),
                  Address('127.0.0.1', 30303, 30303))

    if args.db is not None:
        chaindb = BaseChainDB(LevelDB(args.db))
    else:
        chaindb = BaseChainDB(MemoryDB())

    genesis_header = ROPSTEN_GENESIS_HEADER
    chain_class = RopstenChain
    if args.mainnet:
        genesis_header = MAINNET_GENESIS_HEADER
        chain_class = MainnetChain

    try:
        chaindb.get_canonical_head()
コード例 #19
0
 def get_nodes_to_connect(self) -> Generator[Node, None, None]:
     from evm.chains.ropsten import RopstenChain
     from evm.chains.mainnet import MainnetChain
     if self.network_id == MainnetChain.network_id:
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"
                 )),  # noqa: E501
             Address("52.74.57.123", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"
                 )),  # noqa: E501
             Address("191.235.84.50", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286"
                 )),  # noqa: E501
             Address("52.231.202.145", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99"
                 )),  # noqa: E501
             Address("13.93.211.84", 30303, 30303))
     elif self.network_id == RopstenChain.network_id:
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "88c2b24429a6f7683fbfd06874ae3f1e7c8b4a5ffb846e77c705ba02e2543789d66fc032b6606a8d8888eb6239a2abe5897ce83f78dcdcfcb027d6ea69aa6fe9"
                 )),  # noqa: E501
             Address("163.172.157.61", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "a1ef9ba5550d5fac27f7cbd4e8d20a643ad75596f307c91cd6e7f85b548b8a6bf215cca436d6ee436d6135f9fe51398f8dd4c0bd6c6a0c332ccb41880f33ec12"
                 )),  # noqa: E501
             Address("51.15.218.125", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "e80276aabb7682a4a659f4341c1199de79d91a2e500a6ee9bed16ed4ce927ba8d32ba5dea357739ffdf2c5bcc848d3064bb6f149f0b4249c1f7e53f8bf02bfc8"
                 )),  # noqa: E501
             Address("51.15.39.57", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "584c0db89b00719e9e7b1b5c32a4a8942f379f4d5d66bb69f9c7fa97fa42f64974e7b057b35eb5a63fd7973af063f9a1d32d8c60dbb4854c64cb8ab385470258"
                 )),  # noqa: E501
             Address("51.15.35.2", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "d40871fc3e11b2649700978e06acd68a24af54e603d4333faecb70926ca7df93baa0b7bf4e927fcad9a7c1c07f9b325b22f6d1730e728314d0e4e6523e5cebc2"
                 )),  # noqa: E501
             Address("51.15.132.235", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "482484b9198530ee2e00db89791823244ca41dcd372242e2e1297dd06f6d8dd357603960c5ad9cc8dc15fcdf0e4edd06b7ad7db590e67a0b54f798c26581ebd7"
                 )),  # noqa: E501
             Address("51.15.75.138", 30303, 30303))
         yield Node(
             keys.PublicKey(
                 decode_hex(
                     "30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606"
                 )),  # noqa: E501
             Address("52.176.7.10", 30303, 30303))
     else:
         raise ValueError("Unknown network_id: {}".format(self.network_id))
コード例 #20
0
while ran > 7:
    key1 = Key.from_int(ran)
    wif = bytes_to_wif(key1.to_bytes(), compressed=False)
    key2 = Key(wif)
    caddr = key1.address
    uaddr = key2.address
    saddr = key1.segwit_address
    pub1 = hexlify(key1.public_key).decode()
    pub2 = hexlify(key2.public_key).decode()
    myhex = "%064x" % ran  #eth from line 21 to 26
    private_key = myhex[:64]
    myhash = sha256(myhex)
    private_key_bytes = bytes.fromhex(private_key)
    public_key_hex = keys.PrivateKey(private_key_bytes).public_key
    public_key_bytes = bytes.fromhex(str(public_key_hex)[2:])
    eaddr = keys.PublicKey(public_key_bytes).to_address()
    if caddr in add:
        print("found!!!", ran, caddr)
        s1 = str(ran)
        s2 = caddr
        f = open(u"win1.txt", "a")
        f.write(s1)
        f.write(s2)
        f.close()
        break
    if uaddr in add:
        print("found!!!", ran, uaddr)
        s1 = str(ran)
        s2 = uaddr
        f = open(u"win2.txt", "a")
        f.write(s1)
コード例 #21
0
from hp2p.kademlia import Address, Node

# The default timeout for a round trip API request and response from a peer.
ROUND_TRIP_TIMEOUT = 20.0

# Timeout used when performing the check to ensure peers are on the same side of chain splits as
# us.
CHAIN_SPLIT_CHECK_TIMEOUT = 15

# The defalt preferred nodes
DEFAULT_PREFERRED_NODES: Dict[int, Tuple[Node, ...]] = {
    MAINNET_NETWORK_ID: (
        Node(
            keys.PublicKey(
                decode_hex(
                    "1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"
                )),  # noqa: E501
            Address("52.74.57.123", 30303, 30303)),
        Node(
            keys.PublicKey(
                decode_hex(
                    "78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"
                )),  # noqa: E501
            Address("191.235.84.50", 30303, 30303)),
        Node(
            keys.PublicKey(
                decode_hex(
                    "ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286"
                )),  # noqa: E501
            Address("52.231.202.145", 30303, 30303)),
        Node(
コード例 #22
0
ファイル: peer.py プロジェクト: yjmyzz/py-evm
    def get_nodes_to_connect(self) -> Generator[Node, None, None]:
        from evm.chains.ropsten import RopstenChain
        from evm.chains.mainnet import MainnetChain
        if self.network_id == MainnetChain.network_id:
            nodes = [
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082"
                        )),  # noqa: E501
                    Address("52.74.57.123", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d"
                        )),  # noqa: E501
                    Address("191.235.84.50", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286"
                        )),  # noqa: E501
                    Address("52.231.202.145", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99"
                        )),  # noqa: E501
                    Address("13.93.211.84", 30303, 30303)),
            ]
        elif self.network_id == RopstenChain.network_id:
            nodes = [
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "0d7f627a9a139c1fbff6731d6e0123561738c5155908e32c3a1eea00a3e0c3b460d97c8aea1935c19bfb4e7013651488b8d328b9c142c0b820e221fde7894253"
                        )),  # noqa: E501
                    Address("58.250.0.61", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "360aeace83f0771dd671f253a023b4757e920aca3598563779d8edb2f4d4ca001b5dc2f900ec1547edcd34cfd5cf858e717647e9b5c1f88cef1934081337678b"
                        )),  # noqa: E501
                    Address("34.212.25.61", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "49f9e25549aaa9d2bbbedb32bc22029833a8ce457ce54310e44ed8097082379ac94ff5319ff57da0afa91584c271d17324bc3ea3a74e01a9684fbe9a392b239d"
                        )),  # noqa: E501
                    Address("34.237.139.163", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "5740300afd843ce51b2ca734e30ec690f1b61b163f67a289888757e8962f8046d46f8b6a8d2663246f0b81a75cbc7604619721567054309f15bc360490c8c4da"
                        )),  # noqa: E501
                    Address("172.104.183.123", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "7f3c9e7472a28904c7b5066bce561ac230801147fb6cffae10967baf058a9fcffe03e386c55e5c1397172aef36d78b9f35b6d4f0dc831707c66530194f4867fb"
                        )),  # noqa: E501
                    Address("114.242.249.161", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "8d24ff3d32b0fc70bf41cf828b98940e2ef18ab82fc37de779c206cbec88d5c11a3e3af9700953b9f5e6582f73cddd76f90fc1688992fbdf3b9216228c80654c"
                        )),  # noqa: E501
                    Address("202.9.6.81", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "bbb3ad8be9684fa1d67ac057d18f7357dd236dc01a806fef6977ac9a259b352c00169d092c50475b80aed9e28eff12d2038e97971e0be3b934b366e86b59a723"
                        )),  # noqa: E501
                    Address("81.169.153.213", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "a147a3adde1daddc0d86f44f1a76404914e44cee018c26d49248142d4dc8a9fb0e7dd14b5153df7e60f23b037922ae1f33b8f318844ef8d2b0453b9ab614d70d"
                        )),  # noqa: E501
                    Address("72.36.89.11", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "bd2867892d879b57734d571b208bb7adc04fa412fbdfe73b89b1a0ec5b7978932cc776609e4ac7bac231049975ecb22c74988da36cbc5111d116b1edf7d44802"
                        )),  # noqa: E501
                    Address("185.68.101.99", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "c2bb011038530b60b40a342705246a84e6d2d22d9f8d8d3df4ae1c7464f302396e7be7673a3971b2de16ebd66574ade262fc292b6de7715983f0f15f9c9922ea"
                        )),  # noqa: E501
                    Address("36.225.32.203", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "d8714127db3c10560a2463c557bbe509c99969078159c69f9ce4f71c2cd1837bcd33db3b9c3c3e88c971b4604bbffa390a0a7f53fc37f122e2e6e0022c059dfd"
                        )),  # noqa: E501
                    Address("51.15.217.106", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "efc75f109d91cdebc62f33be992ca86fce2637044d49a954a8bdceb439b1239afda32e642456e9dfd759af5b440ef4d8761b9bda887e2200001c5f3ab2614043"
                        )),  # noqa: E501
                    Address("34.228.166.142", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "c8b9ec645cd7fe570bc73740579064c528771338c31610f44d160d2ae63fd00699caa163f84359ab268d4a0aed8ead66d7295be5e9c08b0ec85b0198273bae1f"
                        )),  # noqa: E501
                    Address("178.62.246.6", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "7a34c02d5ef9de43475580cbb88fb492afb2858cfc45f58cf5c7088ceeded5f58e65be769b79c31c5ae1f012c99b3e9f2ea9ef11764d553544171237a691493b"
                        )),  # noqa: E501
                    Address("35.227.38.243", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "bbb3ad8be9684fa1d67ac057d18f7357dd236dc01a806fef6977ac9a259b352c00169d092c50475b80aed9e28eff12d2038e97971e0be3b934b366e86b59a723"
                        )),  # noqa: E501
                    Address("81.169.153.213", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606"
                        )),  # noqa: E501
                    Address("52.176.7.10", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "02508da84b37a1b7f19f77268e5b69acc9e9ab6989f8e5f2f8440e025e633e4277019b91884e46821414724e790994a502892144fc1333487ceb5a6ce7866a46"
                        )),  # noqa: E501
                    Address("54.175.255.230", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "0eec3472a46f0b637045e41f923ce1d4a585cd83c1c7418b183c46443a0df7405d020f0a61891b2deef9de35284a0ad7d609db6d30d487dbfef72f7728d09ca9"
                        )),  # noqa: E501
                    Address("181.168.193.197", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "643c31104d497e3d4cd2460ff0dbb1fb9a6140c8bb0fca66159bbf177d41aefd477091c866494efd3f1f59a0652c93ab2f7bb09034ed5ab9f2c5c6841aef8d94"
                        )),  # noqa: E501
                    Address("34.198.237.7", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "88c2b24429a6f7683fbfd06874ae3f1e7c8b4a5ffb846e77c705ba02e2543789d66fc032b6606a8d8888eb6239a2abe5897ce83f78dcdcfcb027d6ea69aa6fe9"
                        )),  # noqa: E501
                    Address("163.172.157.61", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "a1ef9ba5550d5fac27f7cbd4e8d20a643ad75596f307c91cd6e7f85b548b8a6bf215cca436d6ee436d6135f9fe51398f8dd4c0bd6c6a0c332ccb41880f33ec12"
                        )),  # noqa: E501
                    Address("51.15.218.125", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "e80276aabb7682a4a659f4341c1199de79d91a2e500a6ee9bed16ed4ce927ba8d32ba5dea357739ffdf2c5bcc848d3064bb6f149f0b4249c1f7e53f8bf02bfc8"
                        )),  # noqa: E501
                    Address("51.15.39.57", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "584c0db89b00719e9e7b1b5c32a4a8942f379f4d5d66bb69f9c7fa97fa42f64974e7b057b35eb5a63fd7973af063f9a1d32d8c60dbb4854c64cb8ab385470258"
                        )),  # noqa: E501
                    Address("51.15.35.2", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "d40871fc3e11b2649700978e06acd68a24af54e603d4333faecb70926ca7df93baa0b7bf4e927fcad9a7c1c07f9b325b22f6d1730e728314d0e4e6523e5cebc2"
                        )),  # noqa: E501
                    Address("51.15.132.235", 30303, 30303)),
                Node(
                    keys.PublicKey(
                        decode_hex(
                            "482484b9198530ee2e00db89791823244ca41dcd372242e2e1297dd06f6d8dd357603960c5ad9cc8dc15fcdf0e4edd06b7ad7db590e67a0b54f798c26581ebd7"
                        )),  # noqa: E501
                    Address("51.15.75.138", 30303, 30303)),
            ]
        else:
            raise ValueError("Unknown network_id: {}".format(self.network_id))

        random.shuffle(nodes)
        for node in nodes:
            yield node
コード例 #23
0
ファイル: ProjectR.py プロジェクト: gochady1337/ProjectR
def seek(r):
    while True:
        ran = secrets.SystemRandom().randrange(
            1,
            115792089237316195423570985008687907852837564279074904382605163141518161494337
        )  #Puzzle 1-20 #Use Examples
        key1 = Key.from_int(ran)
        wif = bytes_to_wif(key1.to_bytes(),
                           compressed=False)  #Uncompressed WIF
        wif2 = bytes_to_wif(key1.to_bytes(), compressed=True)  #compressed WIF
        key2 = Key(wif)
        caddr = key1.address  #Legacy compressed address
        uaddr = key2.address  #Legacy uncompressed address
        saddr = key1.segwit_address  #Segwit address
        pub1 = hexlify(key1.public_key).decode()
        pub2 = hexlify(key2.public_key).decode()
        pubk1 = PublicKey.unhexlify(pub1)
        pubk2 = PublicKey.unhexlify(pub2)
        bcaddr = P2wpkhAddress(
            pubk1.hash(), version=0,
            mainnet=True)  #Segwit (bech32) compressed address
        buaddr = P2wpkhAddress(
            pubk2.hash(), version=0,
            mainnet=True)  #Segwit (bech32) uncompressed address
        myhex = "%064x" % ran
        private_key = myhex[:64]
        private_key_bytes = bytes.fromhex(private_key)
        public_key_hex = keys.PrivateKey(private_key_bytes).public_key
        public_key_bytes = bytes.fromhex(str(public_key_hex)[2:])
        eaddr = keys.PublicKey(public_key_bytes).to_address()  #Eth address
        if caddr in add:
            print("Nice One Found!!!", ran, caddr, wif2,
                  private_key)  #Legacy compressed address
            s1 = str(ran)
            s2 = caddr
            s3 = wif2
            s4 = private_key
            f = open(u"CompressedWinner.txt",
                     "a")  #Output File of Legacy compressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            continue  #break or continue
        if uaddr in add:
            print("Nice One Found!!!", ran, uaddr, wif,
                  private_key)  #Legacy uncompressed address
            s1 = str(ran)
            s2 = uaddr
            s3 = wif
            s4 = private_key
            f = open(u"UncompressedWinner.txt",
                     "a")  #Output File of Legacy uncompressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            continue  #break or continue
        if saddr in add:
            print("Nice One Found!!!", ran, saddr, wif,
                  private_key)  #Segwit address
            s1 = str(ran)
            s2 = saddr
            s3 = wif
            s4 = private_key
            f = open(u"Winner3.txt", "a")  #Output File of Segwit Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            continue  #break or continue
        if str(bcaddr) in add:
            print("Nice One Found!!!", ran,
                  str(bcaddr))  #Segwit (bech32) compressed address
            s1 = str(ran)
            s2 = str(bcaddr)
            s3 = wif
            s4 = private_key
            f = open(
                u"bech32CompressedWinner.txt",
                "a")  #Output File of Segwit (bech32) compressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            continue  #break or continue
        if str(buaddr) in add:
            print("Nice One Found!!!", ran,
                  str(buaddr))  #Segwit (bech32) uncompressed address
            s1 = str(ran)
            s2 = str(buaddr)
            s3 = wif
            s4 = private_key
            f = open(
                u"bechUncompressedWinner.txt",
                "a")  #Output File of Segwit (bech32) uncompressed Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            continue  #break or continue
        if eaddr in add:
            print("Nice One Found!!!", ran, private_key, eaddr)  #Eth address
            s1 = str(ran)
            s2 = eaddr
            s3 = wif
            s4 = private_key
            f = open(u"EthWinner.txt", "a")  #Output File of Eth Wallet Found
            f.write(s1 + ":" + s2 + ":" + s3 + ":" + s4)
            f.write("\n")
            f.close()
            continue  #break or continue
        else:
            colour_cyan = '\033[36m'
            colour_reset = '\033[0;0;39m'
            colour_red = '\033[31m'
            print("\n " + colour_cyan + "ProjectR---" + colour_red +
                  "---Good--Luck--Happy--Hunting--Mizogg.co.uk&Chad---" +
                  colour_cyan + "---ProjectR" +
                  colour_reset)  # Running Display Output
            print(myhex)
            print(caddr)
            print(uaddr)
            print(saddr)
            print(bcaddr)
            print(buaddr)
            print(eaddr)
            print("\n ")
            print(colour_cyan + seconds_to_str())
コード例 #24
0
ファイル: peer.py プロジェクト: sunfinite/py-evm
    def get_nodes_to_connect(self) -> Generator[Node, None, None]:
        from evm.chains.ropsten import RopstenChain
        from evm.chains.mainnet import MainnetChain
        if self.network_id == MainnetChain.network_id:
            nodes = [
                Node(keys.PublicKey(decode_hex("1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082")),  # noqa: E501
                     Address("52.74.57.123", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d")),  # noqa: E501
                     Address("191.235.84.50", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("ddd81193df80128880232fc1deb45f72746019839589eeb642d3d44efbb8b2dda2c1a46a348349964a6066f8afb016eb2a8c0f3c66f32fadf4370a236a4b5286")),  # noqa: E501
                     Address("52.231.202.145", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99")),  # noqa: E501
                     Address("13.93.211.84", 30303, 30303)),
            ]
        elif self.network_id == RopstenChain.network_id:
            nodes = [
                Node(keys.PublicKey(decode_hex("c8b9ec645cd7fe570bc73740579064c528771338c31610f44d160d2ae63fd00699caa163f84359ab268d4a0aed8ead66d7295be5e9c08b0ec85b0198273bae1f")),  # noqa: E501
                     Address("178.62.246.6", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("7a34c02d5ef9de43475580cbb88fb492afb2858cfc45f58cf5c7088ceeded5f58e65be769b79c31c5ae1f012c99b3e9f2ea9ef11764d553544171237a691493b")),  # noqa: E501
                     Address("35.227.38.243", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("bbb3ad8be9684fa1d67ac057d18f7357dd236dc01a806fef6977ac9a259b352c00169d092c50475b80aed9e28eff12d2038e97971e0be3b934b366e86b59a723")),  # noqa: E501
                     Address("81.169.153.213", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606")),  # noqa: E501
                     Address("52.176.7.10", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("02508da84b37a1b7f19f77268e5b69acc9e9ab6989f8e5f2f8440e025e633e4277019b91884e46821414724e790994a502892144fc1333487ceb5a6ce7866a46")),  # noqa: E501
                     Address("54.175.255.230", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("0eec3472a46f0b637045e41f923ce1d4a585cd83c1c7418b183c46443a0df7405d020f0a61891b2deef9de35284a0ad7d609db6d30d487dbfef72f7728d09ca9")),  # noqa: E501
                     Address("181.168.193.197", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("643c31104d497e3d4cd2460ff0dbb1fb9a6140c8bb0fca66159bbf177d41aefd477091c866494efd3f1f59a0652c93ab2f7bb09034ed5ab9f2c5c6841aef8d94")),  # noqa: E501
                     Address("34.198.237.7", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("88c2b24429a6f7683fbfd06874ae3f1e7c8b4a5ffb846e77c705ba02e2543789d66fc032b6606a8d8888eb6239a2abe5897ce83f78dcdcfcb027d6ea69aa6fe9")),  # noqa: E501
                     Address("163.172.157.61", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("a1ef9ba5550d5fac27f7cbd4e8d20a643ad75596f307c91cd6e7f85b548b8a6bf215cca436d6ee436d6135f9fe51398f8dd4c0bd6c6a0c332ccb41880f33ec12")),  # noqa: E501
                     Address("51.15.218.125", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("e80276aabb7682a4a659f4341c1199de79d91a2e500a6ee9bed16ed4ce927ba8d32ba5dea357739ffdf2c5bcc848d3064bb6f149f0b4249c1f7e53f8bf02bfc8")),  # noqa: E501
                     Address("51.15.39.57", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("584c0db89b00719e9e7b1b5c32a4a8942f379f4d5d66bb69f9c7fa97fa42f64974e7b057b35eb5a63fd7973af063f9a1d32d8c60dbb4854c64cb8ab385470258")),  # noqa: E501
                     Address("51.15.35.2", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("d40871fc3e11b2649700978e06acd68a24af54e603d4333faecb70926ca7df93baa0b7bf4e927fcad9a7c1c07f9b325b22f6d1730e728314d0e4e6523e5cebc2")),  # noqa: E501
                     Address("51.15.132.235", 30303, 30303)),
                Node(keys.PublicKey(decode_hex("482484b9198530ee2e00db89791823244ca41dcd372242e2e1297dd06f6d8dd357603960c5ad9cc8dc15fcdf0e4edd06b7ad7db590e67a0b54f798c26581ebd7")),  # noqa: E501
                     Address("51.15.75.138", 30303, 30303)),
            ]
        else:
            raise ValueError("Unknown network_id: {}".format(self.network_id))

        random.shuffle(nodes)
        for node in nodes:
            yield node
コード例 #25
0
ファイル: kademlia.py プロジェクト: zhengger/py-evm
 def from_uri(cls, uri: bytes) -> 'Node':
     ip, port, pubkey_bytes = host_port_pubkey_from_uri(uri)
     pubkey = keys.PublicKey(pubkey_bytes)
     return cls(pubkey, Address(ip.decode(), port))
コード例 #26
0
ファイル: peer.py プロジェクト: sunfinite/py-evm
def _test():
    """
    Create a Peer instance connected to a local geth instance and log messages exchanged with it.

    Use the following command line to run geth:

        ./build/bin/geth -vmodule p2p=4,p2p/discv5=0,eth/*=0 \
          -nodekeyhex 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8 \
          -testnet -lightserv 90
    """
    import argparse
    import signal
    from evm.chains.ropsten import RopstenChain, ROPSTEN_GENESIS_HEADER
    from evm.db.backends.memory import MemoryDB
    from tests.p2p.integration_test_helpers import FakeAsyncChainDB
    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s')

    # The default remoteid can be used if you pass nodekeyhex as above to geth.
    nodekey = keys.PrivateKey(decode_hex(
        "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"))
    remoteid = nodekey.public_key.to_hex()
    parser = argparse.ArgumentParser()
    parser.add_argument('-remoteid', type=str, default=remoteid)
    parser.add_argument('-light', action='store_true', help="Connect as a light node")
    args = parser.parse_args()

    peer_class = ETHPeer  # type: ignore
    if args.light:
        peer_class = LESPeer  # type: ignore
    remote = Node(
        keys.PublicKey(decode_hex(args.remoteid)),
        Address('127.0.0.1', 30303, 30303))
    chaindb = FakeAsyncChainDB(MemoryDB())
    chaindb.persist_header(ROPSTEN_GENESIS_HEADER)
    network_id = RopstenChain.network_id
    loop = asyncio.get_event_loop()
    peer = loop.run_until_complete(
        asyncio.wait_for(
            handshake(remote, ecies.generate_privkey(), peer_class, chaindb, network_id),
            HANDSHAKE_TIMEOUT))

    async def request_stuff():
        # Request some stuff from ropsten's block 2440319
        # (https://ropsten.etherscan.io/block/2440319), just as a basic test.
        nonlocal peer
        block_hash = decode_hex(
            '0x59af08ab31822c992bb3dad92ddb68d820aa4c69e9560f07081fa53f1009b152')
        if peer_class == ETHPeer:
            peer = cast(ETHPeer, peer)
            peer.sub_proto.send_get_block_headers(block_hash, 1)
            peer.sub_proto.send_get_block_bodies([block_hash])
            peer.sub_proto.send_get_receipts([block_hash])
        else:
            peer = cast(LESPeer, peer)
            request_id = 1
            peer.sub_proto.send_get_block_headers(block_hash, 1, request_id)
            peer.sub_proto.send_get_block_bodies([block_hash], request_id + 1)
            peer.sub_proto.send_get_receipts(block_hash, request_id + 2)

    for sig in [signal.SIGINT, signal.SIGTERM]:
        loop.add_signal_handler(sig, peer.cancel_token.trigger)

    asyncio.ensure_future(request_stuff())
    loop.run_until_complete(peer.run())
    loop.close()
コード例 #27
0
 def get_nodes_to_connect(self):
     nodekey = keys.PrivateKey(decode_hex(
         "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"))
     remoteid = nodekey.public_key.to_hex()
     yield kademlia.Node(keys.PublicKey(decode_hex(remoteid)),
                         kademlia.Address('127.0.0.1', 30303, 30303))
コード例 #28
0
ファイル: connection.py プロジェクト: wangroot/trinity
 def remote_public_key(self) -> keys.PublicKey:
     return keys.PublicKey(self._devp2p_receipt.remote_public_key)
コード例 #29
0
 def from_uri(cls, uri: str) -> 'Node':
     parsed = urlparse.urlparse(uri)
     pubkey = keys.PublicKey(decode_hex(parsed.username))
     return cls(pubkey, Address(parsed.hostname, parsed.port))
コード例 #30
0
 def from_uri(cls, uri: str) -> 'Node':
     validate_enode_uri(uri)  # Be no more permissive than the validation
     parsed = urlparse.urlparse(uri)
     pubkey = keys.PublicKey(decode_hex(parsed.username))
     return cls(pubkey, Address(parsed.hostname, parsed.port))