libp2p.security package¶
Subpackages¶
- libp2p.security.insecure package
- libp2p.security.noise package
- libp2p.security.secio package
Submodules¶
libp2p.security.base_session module¶
-
class
libp2p.security.base_session.
BaseSession
(*, local_peer: libp2p.peer.id.ID, local_private_key: libp2p.crypto.keys.PrivateKey, remote_peer: libp2p.peer.id.ID, remote_permanent_pubkey: libp2p.crypto.keys.PublicKey, is_initiator: bool)¶ Bases:
libp2p.security.secure_conn_interface.ISecureConn
BaseSession
is not fully instantiated from its abstract classes as it is only meant to be used in clases that derive from it.-
get_local_peer
() → libp2p.peer.id.ID¶
-
get_local_private_key
() → libp2p.crypto.keys.PrivateKey¶
-
get_remote_peer
() → libp2p.peer.id.ID¶
-
get_remote_public_key
() → Optional[libp2p.crypto.keys.PublicKey]¶
-
local_peer
: ID = None¶
-
local_private_key
: PrivateKey = None¶
-
remote_peer
: ID = None¶
-
remote_permanent_pubkey
: PublicKey = None¶
-
libp2p.security.base_transport module¶
-
class
libp2p.security.base_transport.
BaseSecureTransport
(local_key_pair: libp2p.crypto.keys.KeyPair, secure_bytes_provider: Callable[[int], bytes] = <function default_secure_bytes_provider>)¶ Bases:
libp2p.security.secure_transport_interface.ISecureTransport
BaseSecureTransport
is 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
secrets
module from the standard library.
-
libp2p.security.base_transport.
default_secure_bytes_provider
(n: int) → bytes¶
libp2p.security.secure_conn_interface module¶
-
class
libp2p.security.secure_conn_interface.
AbstractSecureConn
¶ Bases:
abc.ABC
-
abstract
get_local_peer
() → libp2p.peer.id.ID¶
-
abstract
get_local_private_key
() → libp2p.crypto.keys.PrivateKey¶
-
abstract
get_remote_peer
() → libp2p.peer.id.ID¶
-
abstract
get_remote_public_key
() → libp2p.crypto.keys.PublicKey¶
-
abstract
-
class
libp2p.security.secure_conn_interface.
ISecureConn
¶ Bases:
libp2p.security.secure_conn_interface.AbstractSecureConn
,libp2p.network.connection.raw_connection_interface.IRawConnection
-
is_initiator
= None¶
-
libp2p.security.secure_transport_interface module¶
-
class
libp2p.security.secure_transport_interface.
ISecureTransport
¶ Bases:
abc.ABC
-
abstract async
secure_inbound
(conn: libp2p.network.connection.raw_connection_interface.IRawConnection) → libp2p.security.secure_conn_interface.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)
-
abstract async
secure_outbound
(conn: libp2p.network.connection.raw_connection_interface.IRawConnection, peer_id: libp2p.peer.id.ID) → libp2p.security.secure_conn_interface.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)
-
abstract async
libp2p.security.security_multistream module¶
-
class
libp2p.security.security_multistream.
SecurityMultistream
(secure_transports_by_protocol: Mapping[NewType.<locals>.new_type, libp2p.security.secure_transport_interface.ISecureTransport])¶ Bases:
abc.ABC
SSMuxer is a multistream stream security transport multiplexer.
Go implementation: github.com/libp2p/go-conn-security-multistream/ssms.go
-
add_transport
(protocol: NewType.<locals>.new_type, transport: libp2p.security.secure_transport_interface.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 = None¶
-
multiselect_client
: MultiselectClient = None¶
-
async
secure_inbound
(conn: libp2p.network.connection.raw_connection_interface.IRawConnection) → libp2p.security.secure_conn_interface.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: libp2p.network.connection.raw_connection_interface.IRawConnection, peer_id: libp2p.peer.id.ID) → libp2p.security.secure_conn_interface.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: libp2p.network.connection.raw_connection_interface.IRawConnection, is_initiator: bool) → libp2p.security.secure_transport_interface.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]' = None¶
-