Add Async OHTTP client#145
Conversation
|
Concept ACK, this is a cool ideia. We are, however, in the process of completely dropping |
f09e937 to
7cafe86
Compare
9a12cd7 to
8b7e8b7
Compare
|
I’ve also got a branch that ports this to the current bitreq client and gets the CI passing: I also ended up building a compatible Bitcoin-HPKE OHTTP gateway (obitcoin) so I could actually do end-to-end testing with the client. If any of that is useful, I’m happy to fold the gateway-backed smoke test, CI workflow, or related pieces into this PR, or you can cherry-pick whatever is helpful. |
8caaca9 to
c8d8a58
Compare
This was useful ref for marking certain deps as duplicates. Thank you.
I suppose it could reduce the test boilerplate in this PR. i.e removing my dummy gateway. Do you already have a int. . e2e test that uses your gateway? |
happy to hear that!
e2e test is available here: https://github.com/pseudozach/rust-esplora-client/blob/ohttp-bitreq/tests/ohttp_smoke.rs |
c8d8a58 to
7598f40
Compare
Co-authored-by Alex Lewin <alexlwn123@gmail.com> Co-authored-by pseudozach <git@pseudozach.com> [OHTTP](https://datatracker.ietf.org/doc/rfc9458/) lets a client send encrypted requests through a relay so the server can’t see who sent them and the relay can’t see what they contain. The following commit adds optional configurations to enable clients to proxy their requests through an OHTTP relay and gateway. OHTTP functionality is feature flagged off behind `async-ohttp`. If a client provided OHTTP config it will attempt to use the relay instead of the target resource directly.
Integration tests setups up a ohttp relay and gateway, configures the client accordingly, gets the block hash of the first block and compares it to the results of the normal async client.
7598f40 to
56b5718
Compare
|
Cleaned up the commits. Couple things are bothering me.
The other thing worth revisiting is depending on ohttp vs bitcoin-ohttp. I dont see a compeling reason to use the secp256k1 curve for hpke. I think the main point that justified bitcoin-ohttp was clients already are using the same crypto primitives (secp256k1, sha256, polychaha). The tradeoff is clients that use the bitcoin-ohttp dep cannot use any of the existing ohttp libraries and/or infra. And this becomes a maintaince headache -- esp as new features comes up such as, PQ support and ohttp-streaming |
Yes the same primitives AND the same exact dependencies. So no RustCrypto secp256k1, just the same exact deps rust-bitcoin already has everywhere. This does make it incompatible with existing ohttp libraries unless those were PR'd. Even if there was support for other crypto in this client. Regarding infra, I'm not sure what running OHTTP Infra if any is open for the public to use. My thinking was to use the payjoin infra to bootstrap, along with a new I have not though through post-quantum support or ohttp-streaming story yet because they have not (until now) been demanded by integrators. Lack of demand is a big reason this has been sidelined in the first place. Cake and Bull Bitcoin mobile already sync over Tor by default, so getting OHTTP esplora sync isn't a huge win. It's a bigger win for Cove, though. |
Why can't AEAD and hash primitives use rust-bitcoin deps? IIUC bitcoin-hpke depends directly on RustCrypto's (or some other crate's) chacha20poly1305, sha2, hkdf, and hmac. The tradeoff here to consider: is it worth the maintance overhead of maintaining both bitcoin-hpke and bitcoin-ohttp vs clients will need to use new crypto primitives (namely X25119) to use ohttp. And does the latter then exclude some subset of clients from using ohttp for electrum calls (and why? I understand bitcoin-core wallet does not want to depend on X25119 but who else has this constraint?). Separately: bitcoin-ohttp's rust-hpke feature currently bundles a legacy RustCrypto-based backend as dead code alongside the bitcoin-hpke backend actually in use. That's the source of the duplicate-crate entries in this diff: https://github.com/bitcoindevkit/rust-esplora-client/pull/145/changes#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R83-R97.
Can the directory proxy requersts to electrum servers today? This may be problematic if the payjoin users are also using the same directory for the electrum gateway. |
They can and should.
Where is this demand coming from? My inclination would be to wait until p2p adopts a post quantum scheme and then use that (edit: assuming you're asking about because you want X25519+MLKEM768? ).
Not sure yet. The idea of using the lowest common denominator primitives to remove the entire class of questions / concerns from implementers.
whoops! siccing bots on it overnight. Been a while since either crate has gotten any love
No, directories don't proxy requests, OHTTP Relays do, and Relays cannot proxy requests to esplora servers until they adopt an edit: Alternatively, an esplora server could, (though perhaps shouldn't) be hosted behind an OHTTP Gateway with the payjoin directory BIP 77 specified Electrum is off the table because it's direct streaming over TCP socket, not HTTP requests like esplora which can be encapsulated in OHTTP afaiu.
What problem do you foresee specifically? The relay should see padded-length encrypted payloads (perhaps 1kb) and forward them to esplora servers who have opted in with the |
OHTTP lets a client send encrypted requests through a relay so the server can’t see who sent them and the relay can’t see what they contain. The following commit adds optional configurations to enable clients to proxy their requests through an OHTTP relay and gateway.
OHTTP functionality is feature flagged off behind
async-ohttp. If a client provided OHTTP config it will attempt to use the relay instead of the target resource directly.This work was first started by @alexlwn123
Tested against a blockstream's electrs and running an OHTTP relay and OHTTP Gateway locally. Automated tests are still TODO.
Seeking concept Ack/Nack