libp2p.security package
Subpackages
- libp2p.security.insecure package
- libp2p.security.noise package
- Subpackages
- Submodules
- libp2p.security.noise.exceptions module
- libp2p.security.noise.io module
- libp2p.security.noise.messages module
NoiseExtensionsNoiseExtensions.early_dataNoiseExtensions.from_protobuf()NoiseExtensions.has_early_data()NoiseExtensions.has_stream_muxers()NoiseExtensions.has_webtransport_certhashes()NoiseExtensions.is_empty()NoiseExtensions.stream_muxersNoiseExtensions.to_protobuf()NoiseExtensions.webtransport_certhashes
NoiseHandshakePayloadmake_data_to_be_signed()make_handshake_payload_sig()verify_handshake_payload_sig()
- libp2p.security.noise.patterns module
- libp2p.security.noise.transport module
TransportTransport.cache_static_key()Transport.clear_static_key_cache()Transport.early_dataTransport.early_data_managerTransport.get_cached_static_key()Transport.get_pattern()Transport.libp2p_privkeyTransport.local_peerTransport.noise_privkeyTransport.rekey_managerTransport.secure_inbound()Transport.secure_outbound()Transport.webtransport_support
- Module contents
- libp2p.security.pnet package
- libp2p.security.secio package
- libp2p.security.tls package
- Submodules
- libp2p.security.tls.certificate module
- libp2p.security.tls.io module
- libp2p.security.tls.transport module
IdentityConfigTLSTransportTLSTransport.create_ssl_context()TLSTransport.early_dataTLSTransport.get_certificate_pem()TLSTransport.get_negotiated_muxer()TLSTransport.get_preferred_muxers()TLSTransport.get_protocol_id()TLSTransport.libp2p_privkeyTLSTransport.local_peerTLSTransport.secure_inbound()TLSTransport.secure_outbound()TLSTransport.trust_peer_cert_pem()
create_tls_transport()
- Module contents
IdentityConfigSignedKeyTLSReadWriterTLSReadWriter.close()TLSReadWriter.connTLSReadWriter.decrypt()TLSReadWriter.encrypt()TLSReadWriter.get_negotiated_protocol()TLSReadWriter.get_peer_certificate()TLSReadWriter.get_remote_address()TLSReadWriter.handshake()TLSReadWriter.read_msg()TLSReadWriter.stream_writerTLSReadWriter.write_msg()
TLSTransportTLSTransport.create_ssl_context()TLSTransport.early_dataTLSTransport.get_certificate_pem()TLSTransport.get_negotiated_muxer()TLSTransport.get_preferred_muxers()TLSTransport.get_protocol_id()TLSTransport.libp2p_privkeyTLSTransport.local_peerTLSTransport.secure_inbound()TLSTransport.secure_outbound()TLSTransport.trust_peer_cert_pem()
create_cert_template()create_tls_transport()generate_certificate()pub_key_from_cert_chain()verify_certificate_chain()
Submodules
libp2p.security.base_session module
- class libp2p.security.base_session.BaseSession(*, local_peer: ID, local_private_key: PrivateKey, remote_peer: ID, remote_permanent_pubkey: PublicKey, is_initiator: bool)
Bases:
ISecureConnBaseSessionis not fully instantiated from its abstract classes as it is only meant to be used in clases that derive from it.- get_local_private_key() PrivateKey
Retrieve the local peer’s private key.
- Returns:
The private key of the local peer.
- get_remote_public_key() PublicKey
Retrieve the remote peer’s public key.
- Returns:
The public key of the remote peer.
- local_private_key: PrivateKey
libp2p.security.base_transport module
- class libp2p.security.base_transport.BaseSecureTransport(local_key_pair: ~libp2p.crypto.keys.KeyPair, secure_bytes_provider: ~collections.abc.Callable[[int], bytes] = <function default_secure_bytes_provider>)
Bases:
ISecureTransportBaseSecureTransportis not fully instantiated from its abstract classes as it is only meant to be used in clases that derive from it.Clients can provide a strategy to get cryptographically secure bytes of a given length. A default implementation is provided using the
secretsmodule from the standard library.
libp2p.security.exceptions module
- exception libp2p.security.exceptions.HandshakeFailure
Bases:
BaseLibp2pError
- exception libp2p.security.exceptions.SecurityError
Bases:
BaseLibp2pError
libp2p.security.secure_session module
- class libp2p.security.secure_session.SecureSession(*, local_peer: ID, local_private_key: PrivateKey, remote_peer: ID, remote_permanent_pubkey: PublicKey, is_initiator: bool, conn: EncryptedMsgReadWriter)
Bases:
BaseSession- buf: BytesIO
libp2p.security.security_multistream module
- class libp2p.security.security_multistream.SecurityMultistream(secure_transports_by_protocol: Mapping[TProtocol, object])
Bases:
ABCSSMuxer is a multistream stream security transport multiplexer.
Go implementation: github.com/libp2p/go-conn-security-multistream/ssms.go
- add_transport(protocol: TProtocol, transport: ISecureTransport) None
Add a protocol and its corresponding transport to multistream- select(multiselect). The order that a protocol is added is exactly the precedence it is negotiated in multiselect.
- Parameters:
protocol – the protocol name, which is negotiated in multiselect.
transport – the corresponding transportation to the
protocol.
- multiselect: Multiselect
- multiselect_client: MultiselectClient
- async secure_inbound(conn: IRawConnection) ISecureConn
Secure the connection, either locally or by communicating with opposing node via conn, for an inbound connection (i.e. we are not the initiator)
- Returns:
secure connection object (that implements secure_conn_interface)
- async secure_outbound(conn: IRawConnection, peer_id: ID) ISecureConn
Secure the connection, either locally or by communicating with opposing node via conn, for an inbound connection (i.e. we are the initiator)
- Returns:
secure connection object (that implements secure_conn_interface)
- async select_transport(conn: IRawConnection, is_initiator: bool) ISecureTransport
Select a transport that both us and the node on the other end of conn support and agree on.
- Parameters:
conn – conn to choose a transport over
is_initiator – true if we are the initiator, false otherwise
- Returns:
selected secure transport
- transports: OrderedDict[TProtocol, ISecureTransport]
- libp2p.security.security_multistream.logger = <Logger libp2p.security.security_multistream (DEBUG)>
Represents a secured connection object, which includes a connection and details about the security involved in the secured connection
Relevant go repo: https://github.com/libp2p/go-conn-security/blob/master/interface.go
Module contents
Security modules for libp2p.
This package provides various security implementations including: - TLS transport - Noise protocol - SECIO protocol - Insecure transport (for testing)