Documentation
¶
Overview ¶
Copyright (C) 2026 by saba <contact me via issue>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
In addition, no derivative work may use the name or imply association with this application without prior consent.
Copyright (C) 2026 by saba <contact me via issue>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
In addition, no derivative work may use the name or imply association with this application without prior consent.
Index ¶
- Variables
- func EncodePoint(p *edwards25519.Point) string
- func EncodeScalar(s *edwards25519.Scalar) string
- func ParsePrivateScalar(keyHex string) (*edwards25519.Scalar, error)
- func RecoverPublicKey(keyHex string) (*edwards25519.Point, error)
- func SplitPrivateKey(x *edwards25519.Scalar) (string, error)
- type KeyPair
- type RecordConn
Constants ¶
This section is empty.
Variables ¶
var KeyUpdateAfterBytes int64 = 32 << 20 // 32 MiB
KeyUpdateAfterBytes controls automatic key rotation based on plaintext bytes. It is a package var (not config) to enable targeted tests with smaller thresholds.
Functions ¶
func EncodePoint ¶
func EncodePoint(p *edwards25519.Point) string
EncodePoint returns the hex string of the compressed point
func EncodeScalar ¶
func EncodeScalar(s *edwards25519.Scalar) string
EncodeScalar returns the hex string of the scalar
func ParsePrivateScalar ¶
func ParsePrivateScalar(keyHex string) (*edwards25519.Scalar, error)
ParsePrivateScalar parses either a master private scalar (32-byte hex) or a split key (64-byte hex) and returns the corresponding master scalar x.
func RecoverPublicKey ¶
func RecoverPublicKey(keyHex string) (*edwards25519.Point, error)
RecoverPublicKey takes a split private key (r, k) or a master private key (x) and returns the public key P. Input can be: - 32 bytes hex (Master Scalar x) - 64 bytes hex (Split Key r || k)
func SplitPrivateKey ¶
func SplitPrivateKey(x *edwards25519.Scalar) (string, error)
SplitPrivateKey takes a master private key x and returns a new random split key (r, k) such that x = r + k (mod L). Returns hex encoded string of r || k (64 bytes)
Types ¶
type KeyPair ¶
type KeyPair struct {
Private *edwards25519.Scalar
Public *edwards25519.Point
}
KeyPair holds the scalar private key and point public key
func GenerateMasterKey ¶
GenerateMasterKey generates a random master private key (scalar) and its public key (point)
type RecordConn ¶
RecordConn is a framed AEAD net.Conn with:
- deterministic per-record nonce (epoch+seq)
- per-direction key rotation (epoch), driven by plaintext byte counters
- replay/out-of-order protection within the connection (strict seq check)
Wire format per record:
- uint16 bodyLen
- header[12] = epoch(uint32 BE) || seq(uint64 BE) (plaintext)
- ciphertext = AEAD(header as nonce, plaintext, header as AAD)
func NewRecordConn ¶
func (*RecordConn) CloseRead ¶
func (c *RecordConn) CloseRead() error
func (*RecordConn) CloseWrite ¶
func (c *RecordConn) CloseWrite() error
func (*RecordConn) Rekey ¶
func (c *RecordConn) Rekey(baseSend, baseRecv []byte) error