13 releases (8 stable)

2.0.0 Mar 28, 2025
1.3.1 Dec 27, 2024
1.3.0 Oct 17, 2024
1.2.0 Jun 3, 2024
0.1.3 Jul 1, 2021

#6 in #stratum

Download history 11/week @ 2024-12-18 127/week @ 2024-12-25 75/week @ 2025-01-01 34/week @ 2025-01-08 30/week @ 2025-01-15 20/week @ 2025-01-22 878/week @ 2025-01-29 1284/week @ 2025-02-05 1172/week @ 2025-02-12 1449/week @ 2025-02-19 1421/week @ 2025-02-26 1956/week @ 2025-03-05 834/week @ 2025-03-12 376/week @ 2025-03-19 211/week @ 2025-03-26 20/week @ 2025-04-02

1,707 downloads per month
Used in 10 crates

MIT/Apache

255KB
3.5K SLoC

codec_sv2

crates.io docs.rs rustc+ license codecov

codec_sv2 provides the message encoding and decoding functionality for the Stratum V2 (Sv2) protocol, handling secure communication between Sv2 roles. This crate abstracts the complexity of message encoding/decoding with optional Noise protocol support, ensuring both regular and encrypted messages can be serialized, transmitted, and decoded consistently and reliably.

Main Components

  • Encoder: Encodes Sv2 messages with or without Noise protocol support.
  • Decoder: Decodes Sv2 messages with or without Noise protocol support.
  • Handshake State: Manages the current Noise protocol handshake state of the codec.

Usage

To include this crate in your project, run:

cargo add codec_sv2

This crate can be built with the following feature flags:

  • std: Enable usage of rust std library, enabled by default.
  • noise_sv2: Enables support for Noise protocol encryption and decryption.
  • with_buffer_pool: Enables buffer pooling for more efficient memory management.

In order to use this crate in a #![no_std] environment, use the --no-default-features to remove the std feature.

Examples

This crate provides two examples demonstrating how to encode and decode Sv2 frames:

  1. Unencrypted Example: Encode and decode standard Sv2 frames, detailing the message serialization and transmission process for unencrypted communications.

  2. Encrypted Example: Encode and decode Sv2 frames with Noise protocol encryption, detailing the entire encryption handshake and transport phase and serialization and transmission process for encrypted communications.

Dependencies

~1.4–2.9MB
~48K SLoC