func (conn *Conn) SetDeadline(t time.Time) error {
	return conn.conn.SetDeadline(t)
}
SetDeadline passes the call to the underlying net.Conn
package secretstream
import (
	"bytes"
	"encoding/base64"
	"errors"
	"net"
	"os"
	"syscall"
	"time"
	"go.cryptoscope.co/secretstream/boxstream"
	"go.cryptoscope.co/netwrap"
)
const NetworkString = "shs-bs"
type Addr struct {
	PubKey []byte
}
func (a Addr) Network() string {
	return NetworkString
}
func (a Addr) String() string {
	return "@" + base64.StdEncoding.EncodeToString(a.PubKey) + ".ed25519"
}
type Conn struct {
	conn net.Conn
	boxer   *boxstream.Boxer
	unboxer *boxstream.Unboxer
	recvMsg []byte  
	local, remote []byte
}
func (conn *Conn) Read(p []byte) (int, error) {
	if len(conn.recvMsg) == 0 {
		msg, err := conn.unboxer.ReadMessage()
		if err != nil {
			return 0, err
		}
		conn.recvMsg = msg
	}
	n := copy(p, conn.recvMsg)
	conn.recvMsg = conn.recvMsg[n:]
	return n, nil
}
func (conn *Conn) Write(p []byte) (int, error) {
	for buf := bytes.NewBuffer(p); buf.Len() > 0; {
		if err := conn.boxer.WriteMessage(buf.Next(boxstream.MaxSegmentSize)); err != nil {
			return 0, err
		}
	}
	return len(p), nil
}
func (conn *Conn) Close() error {
	gerr := conn.boxer.WriteGoodbye()
	if gerr != nil {
		netErr := new(net.OpError)
		if errors.As(gerr, &netErr) {
			var sysCallErr = new(os.SyscallError)
			if errors.As(netErr.Err, &sysCallErr) {
				action := sysCallErr.Unwrap()
				if action == syscall.ECONNRESET || action == syscall.EPIPE {
					return nil
				}
			}
			if netErr.Err.Error() == "use of closed network connection" {
				return nil
			}
		}
		return gerr
	}
	if cerr := conn.conn.Close(); cerr != nil {
		return cerr
	}
	return nil
}
func (conn *Conn) LocalAddr() net.Addr {
	return netwrap.WrapAddr(conn.conn.LocalAddr(), Addr{conn.local})
}
func (conn *Conn) RemoteAddr() net.Addr {
	return netwrap.WrapAddr(conn.conn.RemoteAddr(), Addr{conn.remote})
}