Expand description
§Introduction
Hypercore protocol is a streaming, message based protocol. This is a rust port of the wire protocol implementation in the original Javascript version aiming for interoperability with LTS version.
This crate is built on top of the hypercore crate, which defines some structs used here.
§Design
This crate expects to receive a pre-encrypted, message-framed connection (e.g., from hyperswarm).
The underlying stream should implement Stream<Item = Vec<u8>> + Sink<Vec<u8>>.
After construction, each side can request any number of channels on the protocol. A channel is opened with a Key, a 32 byte buffer. Channels are only opened if both peers opened a channel for the same key. It is automatically verified that both parties know the key without transmitting the key itself using the handshake hash from the underlying connection.
On a channel, the predefined messages, including a custom Extension message, of the Hypercore protocol can be sent and received.
Modules§
- schema
- The wire messages used by the protocol.
Structs§
- Boxed
Stream - A type-erased bidirectional byte stream for protocol communication.
- Channel
- A protocol channel.
- Channel
Receiver - The receiving side of a channel.
- Channel
Send Error - An error returned from
Sender::send(). - Channel
Sender - The sending side of a channel.
- Command
Tx - Send
Commands to theProtocol. - Handshake
Result - Result of a Noise handshake, used for capability verification.
- Protocol
- A Protocol stream for replicating hypercores over an encrypted connection.
Enums§
- Command
- A protocol command.
- Error
- Error type for this crate
- Event
- A protocol event.
- Message
- A protocol message.
Functions§
- discovery_
key - Calculate the discovery key of a key.
Type Aliases§
- Discovery
Key - Discovery key (32 bytes).
- Key
- Key (32 bytes).