encryption

package
v0.0.0-...-df8f024 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTLSConfig

func CreateTLSConfig(certFile, keyFile string) (*tls.Config, error)

CreateTLSConfig loads a TLS certificate and key from files and returns a TLS configuration. In production, certificates and keys should be managed securely.

func DialAddrContext

func DialAddrContext(ctx context.Context, addr string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.Connection, error)

DialAddrContext dials a QUIC server with a given context, TLS configuration, and QUIC configuration.

func DialAddrContextWithRetry

func DialAddrContextWithRetry(ctx context.Context, addr string, tlsConfig *tls.Config, quicConfig *quic.Config, retries int, initialDelay time.Duration) (quic.Connection, error)

DialAddrContextWithRetry attempts to dial a QUIC server with retries and exponential backoff. retries: number of additional attempts (total attempts = retries + 1) initialDelay: delay for the first retry attempt.

func GenerateKeyPair

func GenerateKeyPair() (crypto.PrivKey, crypto.PubKey, error)

GenerateKeyPair creates a new Ed25519 key pair for P2P security.

func SecureChannelWithTLS

func SecureChannelWithTLS(addr string, tlsConfig *tls.Config, quicConfig *quic.Config) error

SecureChannelWithTLS starts a QUIC listener on the given address using the provided TLS and QUIC configurations. It accepts incoming connections and handles streams concurrently, echoing received data back.

func SecureP2PNode

func SecureP2PNode() (host.Host, error)

SecureP2PNode creates and returns a secure libp2p node using a newly generated key pair. Additional libp2p options can be added here as needed.

func StartQUICClient

func StartQUICClient(addr string, tlsConfig *tls.Config, quicConfig *quic.Config) error

StartQUICClient connects to a QUIC server using our custom dialer with retry logic, sends a test message over a new stream, and logs the echoed response.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL