func newSecureConn(ctx context.Context, sk ic.PrivKey, insecure iconn.Conn) (iconn.Conn, error) {

	if insecure == nil {
		return nil, errors.New("insecure is nil")
	}
	if insecure.LocalPeer() == "" {
		return nil, errors.New("insecure.LocalPeer() is nil")
	}
	if sk == nil {
		return nil, errors.New("private key is nil")
	}

	// NewSession performs the secure handshake, which takes multiple RTT
	sessgen := secio.SessionGenerator{LocalID: insecure.LocalPeer(), PrivateKey: sk}
	secure, err := sessgen.NewSession(ctx, insecure)
	if err != nil {
		return nil, err
	}

	conn := &secureConn{
		insecure: insecure,
		secure:   secure,
	}
	return conn, nil
}
func newSecureConn(ctx context.Context, sk ic.PrivKey, insecure iconn.Conn) (iconn.Conn, error) {

	if insecure == nil {
		return nil, errors.New("insecure is nil")
	}
	if insecure.LocalPeer() == "" {
		return nil, errors.New("insecure.LocalPeer() is nil")
	}
	if sk == nil {
		return nil, errors.New("private key is nil")
	}

	
	sessgen := secio.SessionGenerator{LocalID: insecure.LocalPeer(), PrivateKey: sk}
	secure, err := sessgen.NewSession(ctx, insecure)
	if err != nil {
		return nil, err
	}

	conn := &secureConn{
		insecure: insecure,
		secure:   secure,
	}
	return conn, nil
}
func newSecureConn ( ctx context . Context , sk ic . PrivKey , insecure iconn . Conn ) ( iconn . Conn , error ) { if insecure == nil { return nil , errors . New ( " " ) } if insecure . LocalPeer ( ) == " " { return nil , errors . New ( " " ) } if sk == nil { return nil , errors . New ( " " ) } // NewSession performs the secure handshake, which takes multiple RTT sessgen := secio . SessionGenerator { LocalID : insecure . LocalPeer ( ) , PrivateKey : sk } secure , err := sessgen . NewSession ( ctx , insecure ) if err != nil { return nil , err } conn := & secureConn { insecure : insecure , secure : secure , } return conn , nil }
// newConn constructs a new connection
newConn constructs a new connection