Libp2p.SecureConn (libp2p_elixir v0.9.0)
Noise-secured connection wrapper.
- Performs Noise transport message framing (2-byte big-endian length prefix).
- Encrypts/decrypts payloads using
Libp2p.Noise.transport_encrypt/3andLibp2p.Noise.transport_decrypt/3.
This intentionally exposes a small interface; the Swarm/Connection process owns the socket and calls these helpers.
Summary
Functions
Decrypt as many complete Noise transport messages as are currently buffered.
Append raw encrypted bytes received from the socket.
Receive some plaintext bytes (one Noise transport message).
Types
@type cipher_state() :: %{k: binary() | nil, n: non_neg_integer()}
@type t() :: %Libp2p.SecureConn{ cs_in: cipher_state(), cs_out: cipher_state(), recv_buf: binary(), socket: Libp2p.Transport.Tcp.socket() }
Functions
Decrypt as many complete Noise transport messages as are currently buffered.
Returns {plaintext_messages, conn2} where each plaintext message corresponds
to one Noise transport message.
Append raw encrypted bytes received from the socket.
@spec new(Libp2p.Transport.Tcp.socket(), cipher_state(), cipher_state()) :: t()
Receive some plaintext bytes (one Noise transport message).
Returns {bytes, conn2} where bytes may be empty only on protocol errors (raised).