tetsy-libp2p-secio 0.27.1

Secio encryption protocol for libp2p
Documentation

The secio protocol is a middleware that will encrypt and decrypt communications going through a socket (or anything that implements AsyncRead + AsyncWrite).

Usage

The SecioConfig implements [InboundUpgrade] and [OutboundUpgrade] and thus serves as a connection upgrade for authentication of a transport. See authenticate.

# fn main() {
use futures::prelude::*;
use tetsy_libp2p_secio::{SecioConfig, SecioOutput};
use tetsy_libp2p_core::{PeerId, Multiaddr, identity, upgrade};
use tetsy_libp2p_core::transport::Transport;
use tetsy_libp2p_mplex::MplexConfig;
use tetsy_libp2p_tcp::TcpConfig;

// Create a local peer identity.
let local_keys = identity::Keypair::generate_ed25519();

// Create a `Transport`.
let transport = TcpConfig::new()
.upgrade(upgrade::Version::V1)
.authenticate(SecioConfig::new(local_keys.clone()))
.multiplex(MplexConfig::default());

// The transport can be used with a `Network` from `tetsy-libp2p-core`, or a
// `Swarm` from from `tetsy-libp2p-swarm`. See the documentation of these
// crates for mode details.

// let network = Network::new(transport, local_keys.public().into_peer_id());
// let swarm = Swarm::new(transport, behaviour, local_keys.public().into_peer_id());
# }