Title: stratum v2 - noise nx - python
Post by: legerde on August 09, 2021, 12:16:04 AM
Greetings, I am attempting to communicate with slush servers using python. I am NOT getting a response when I begin the NX_Noise process. I am quite sure I am confused. I understand that NX_Noise is used: NX: -> e <- e, ee, s, es I can see that my side sends a 32-byte TCP message containing only 'e'. Then I get no response. Is the stratum server unhappy with me connecting to TCP port 3336 on host "v2.us-east.stratum.slushpool.com"? What is required by the stratum v2 server to respond? Sample code below. :( # These are for NX Transport Layer Security from dissononce.processing.impl.handshakestate import HandshakeState from dissononce.processing.impl.symmetricstate import SymmetricState from dissononce.processing.impl.cipherstate import CipherState from dissononce.processing.modifiers.psk import PSKPatternModifier from dissononce.processing.handshakepatterns.interactive.NX import NXHandshakePattern from dissononce.cipher.chachapoly import ChaChaPolyCipher from dissononce.dh.x25519.x25519 import X25519DH from dissononce.hash.blake2s import Blake2sHash import dissononce,logging
# import base58, socket from jsonrpcclient.clients.http_client import HTTPClient
# Handshake: N = No static key for initiator, X = Static key for responder Xmitted ("transmitted") to initiator # NX: # -> e # <- e, ee, s, es
hostname = "v2.stratum.slushpool.com" port = 3336 pubkey = "u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt"
dissononce.logger.setLevel(logging.DEBUG) our_s_keypair = X25519DH().generate_keypair() our_e_keypair = X25519DH().generate_keypair() pool_keypair = X25519DH().generate_keypair() pool_s_pubkey = dissononce.dh.x25519.public.PublicKey(base58.b58decode_check(pubkey.encode('ascii'))) print(pool_s_pubkey.data)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print("Connecting to ",hostname," port ", port) sock.connect((hostname,port)) print("Connected.")
# prepare handshakestate objects for initiator and responder our_handshakestate = HandshakeState( SymmetricState( CipherState( ChaChaPolyCipher() #chacha20poly1305 ), Blake2sHash() #chacha20poly1305 ), X25519DH() )
slush_handshakestate = HandshakeState( SymmetricState( CipherState( ChaChaPolyCipher() #chacha20poly1305 ), Blake2sHash() #chacha20poly1305 ), X25519DH() )
our_handshakestate.initialize(NXHandshakePattern(), True, b'', s=our_s_keypair, rs=pool_s_pubkey)
# 0: -> e message_buffer = bytearray() our_handshakestate.write_message(b'', message_buffer) num_sent = sock.send(message_buffer) print("sock.send(",num_sent,") ",message_buffer)
# 1: <- e, ee, s, es, SIGNATURE_NOISE_MESSAGE ciphertext = sock.recv(4096) print("ciphertext = ", ciphertext)
|