delvingbitcoin

BIP324 Proxy: easy integration of v2 transport protocol for light clients (PoC)

BIP324 Proxy: easy integration of v2 transport protocol for light clients (PoC)

Original Postby theStack

Posted on: March 13, 2024 17:32 UTC

The development of a novel tool aimed at enabling peer-to-peer encryption for Bitcoin clients not yet compliant with BIP324 is underway.

This tool functions by establishing a local process that acts as a translator between the p2p v1 and v2 protocols. It operates by initiating a server socket on the local TCP port 1324, creating a new thread for each incoming v1 connection. The identification of the remote peer address is facilitated through the first VERSION message received, specifically from the addr_recv field as detailed in the Protocol documentation here. Following this, a v2 handshake is executed, after which the initial VERSION message is relayed to the remote node. The proxy then assumes the role of forwarding messages between the two nodes, translating them into the appropriate p2p version format.

This setup necessitates P2P connections to be redirected to localhost:1324 rather than directly to the actual remote peer address at the TCP level, typically requiring minimal adjustments to the client's codebase, ideally through a command-line option. The entire implementation has been crafted in Python3 without the need for any external dependencies. However, it's important to note that most cryptographic elements employed are borrowed from Bitcoin Core's BIP324 implementation within the functional test framework, with acknowledgments to contributors such as stratospher and sipa.

Currently, this project is considered a proof-of-concept, characterized by its slow performance and susceptibility to side-channel attacks, rendering it unsuitable for practical applications beyond testing scenarios. At present, support is limited to signet, albeit extending this to other networks could be easily achieved by altering the NET_MAGIC constant. Future plans include an efficient rewrite of the tool in Rust, although the timeline for this remains uncertain due to the developer's unfamiliarity with the language.

For those interested in further details or contributing to the project, resources including the GitHub repository and a presentation delivered during a Brink engineering call can be found here and here, respectively. The latter includes examples of light clients tested with the BIP324 proxy, highlighting the necessary patches for redirection. Feedback, suggestions, and innovative ideas are highly encouraged to enhance the project's development.