[][src]Crate libp2p_secio

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.

use futures::prelude::*;
use libp2p_secio::{SecioConfig, SecioOutput};
use libp2p_core::{PeerId, Multiaddr, identity, upgrade};
use libp2p_core::transport::Transport;
use libp2p_mplex::MplexConfig;
use 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 `libp2p-core`, or a
// `Swarm` from from `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());

Structs

SecioConfig

Implementation of the ConnectionUpgrade trait of libp2p_core. Automatically applies secio on any connection.

SecioMiddleware

Wraps around an object that implements AsyncRead and AsyncWrite.

SecioOutput

Output of the secio protocol.

Enums

Cipher

Possible encryption ciphers.

Digest

Possible digest algorithms.

KeyAgreement

Possible key agreement algorithms.

SecioError

Error at the SECIO layer communication.