Skip to main content

Crate hypercore_protocol

Crate hypercore_protocol 

Source
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§

BoxedStream
A type-erased bidirectional byte stream for protocol communication.
Channel
A protocol channel.
ChannelReceiver
The receiving side of a channel.
ChannelSendError
An error returned from Sender::send().
ChannelSender
The sending side of a channel.
CommandTx
Send Commands to the Protocol.
HandshakeResult
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§

DiscoveryKey
Discovery key (32 bytes).
Key
Key (32 bytes).