Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ rust-version = "1.63.0"

[features]
default = ["std"]
async = ["std", "futures/std"]
tokio = ["std", "tokio/io-util"]
# High-level wrappers using futures traits.
async = ["std", "dep:futures"]
# High-level wrappers using tokio traits - may affect MSRV requirements.
tokio = ["std", "dep:tokio"]
std = ["alloc", "bitcoin/std", "bitcoin_hashes/std", "chacha20-poly1305/std", "rand/std", "rand/std_rng"]
alloc = ["chacha20-poly1305/alloc"]

[dependencies]
futures = { version = "0.3.30", default-features = false, optional = true }
# Must be under 1.39.0 due to MSRV 1.63.0 requirement.
tokio = { version = ">=1.37.0, <1.39.0", default-features = false, optional = true }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, this was previously straight up wrong.

Copy link
Copy Markdown
Collaborator Author

@nyonson nyonson Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong as in, the consumer could always just override a the tokio version with a patch or something and break the MSRV?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong that pinning belongs to Cargo.lock not Cargo.toml. Putting these into Cargo.toml causes huge problems with updates that would be otherwise trivial one-command things.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, using this lib downstream was what made me realize this is painful and not super productive. The intention wasn't to pin, but I forget the justification for the >=1.37.0 floor, at least the <1.39.0 ceiling is attempting to convey useful information to the consumer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lower bound tends to be legitimate (but it's also often too strict) the upper one is the problem.

futures = { version = "0.3.30", default-features = false, optional = true, features = ["std"] }
# The tokio feature may increase the MSRV beyond 1.63.0
# depending on which version of tokio is selected by the caller.
tokio = { version = "1", default-features = false, optional = true, features = ["io-util"] }
rand = { version = "0.8.0", default-features = false }
bitcoin = { version = "0.32.4", default-features = false }
# Depending on hashes directly for HKDF, can drop this and
Expand Down
6 changes: 6 additions & 0 deletions protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ The lower-level `Handshake` and `PacketHandler` types can be directly used by ap
* `async` -- High level wrappers for asynchronous read and write runtimes using agnostic futures-rs traits.
* `tokio` -- Same wrappers as `async`, but using the popular tokio runtime's specific traits instead of futures-rs.

## Minimum Supported Rust Version (MSRV)

This crate has a baseline MSRV of **1.63.0**.

However, the effective MSRV may be higher depending on the specific versions of dependencies selected by the caller. Currently, tokio is known to affect MSRV when using newer versions with the `tokio` feature flag, but other dependencies may also impact the effective MSRV in the future.

## Handshake

Alice and Bob initiate a connection by sending three messages to each other to derive a number of shared secrets. Alice begins the connection by deriving a public/private keypair over `secp256k1`, the typical bitcoin curve. Alice is known as the *initiator*. She encodes the public key in the [Elligator Swift](https://eprint.iacr.org/2022/759.pdf) format (64-bytes), optionally pads it with some random garbage bytes, and sends the message to Bob.
Expand Down