pub struct SecretConnection<Io> { /* private fields */ }Expand description
Encrypted connection between peers in a CometBFT network.
§Sending and receiving messages
The SecretConnection type implements a message-oriented interface which can send and receive
Protobuf-encoded messages that impl the prost::Message trait.
The ReadMsg and WriteMsg traits can be used for sending/receiving Protobuf messages.
§Connection integrity and failures
Due to the underlying encryption mechanism (currently RFC 8439), when a read or write failure occurs, it is necessary to disconnect from the remote peer and attempt to reconnect.
Implementations§
Source§impl<Io: Read + Write + Send + Sync + TryCloneIo> SecretConnection<Io>
impl<Io: Read + Write + Send + Sync + TryCloneIo> SecretConnection<Io>
Sourcepub fn new<Identity>(io: Io, identity_key: &Identity) -> Result<Self>
pub fn new<Identity>(io: Io, identity_key: &Identity) -> Result<Self>
Performs a handshake and returns a new SecretConnection, authenticating ourselves with the
provided Identity (Ed25519 signing key).
The IdentitySecret type can be used as an identity_key.
§Errors
- if sharing of the pubkey fails
- if sharing of the signature fails
- if receiving the signature fails
- if verifying the signature fails
Source§impl<Io: Write> SecretConnection<Io>
impl<Io: Write> SecretConnection<Io>
Source§impl<Io> SecretConnection<Io>
impl<Io> SecretConnection<Io>
Sourcepub fn local_public_key(&self) -> &PublicKey
pub fn local_public_key(&self) -> &PublicKey
Get the local (i.e. our) PublicKey.
Sourcepub fn peer_public_key(&self) -> &PublicKey
pub fn peer_public_key(&self) -> &PublicKey
Returns the remote peer’s PublicKey.
Sourcepub fn split(self) -> (SecretReader<Io>, SecretWriter<Io>)
pub fn split(self) -> (SecretReader<Io>, SecretWriter<Io>)
Split this SecretConnection into a SecretReader and SecretWriter which can be
used independently of each other.