11 releases (6 stable)

1.3.0 Oct 17, 2024
1.2.0 Jun 3, 2024
1.0.1 Mar 29, 2024
0.1.4 Sep 2, 2021
0.1.3 Jul 1, 2021

#5 in #stratum

Download history 98/week @ 2024-07-22 41/week @ 2024-07-29 16/week @ 2024-08-05 188/week @ 2024-08-12 128/week @ 2024-08-19 88/week @ 2024-08-26 41/week @ 2024-09-02 23/week @ 2024-09-09 34/week @ 2024-09-16 91/week @ 2024-09-23 34/week @ 2024-09-30 15/week @ 2024-10-07 226/week @ 2024-10-14 56/week @ 2024-10-21 25/week @ 2024-10-28 58/week @ 2024-11-04

366 downloads per month
Used in 9 crates

MIT/Apache

210KB
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:

  • noise_sv2: Enables support for Noise protocol encryption and decryption.
  • with_buffer_pool: Enables buffer pooling for more efficient memory management.
  • with_serde: builds binary_sv2 and buffer_sv2 crates with serde-based encoding and decoding. Note that this feature flag is only used for the Message Generator, and deprecated for any other kind of usage. It will likely be fully deprecated in the future.

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

~9MB
~121K SLoC