keys

package
v0.0.0-...-d095abb Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Unlicense Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PKSize = 29
	SKSize = 32
)
View Source
const (
	PubStart = "copub:"
	SecStart = "cosec:" // lel

)
View Source
const (
	SignOverhead = box.Overhead
	HashSigLen   = 32 + box.Overhead
)
View Source
const AddressLen = 16

Variables

View Source
var ZeroNonce = new([24]byte)

Who needs nonces anyway? Every request is idempotent becaue every computation is deterministic. Exactly-once delivery 4 tha win

View Source
var ZeroPK, ZeroSK = new([32]byte), new([32]byte)

ephemeral 32 keypair that everyone knows

Functions

func GenerateKeys

func GenerateKeys(threads int) (found chan Keypair)

func KeyWorker

func KeyWorker(found chan<- Keypair)

Types

type Address

type Address [AddressLen]byte // can be whatever (probably an ipv6 lel)

func (Address) String

func (a Address) String() string

type HashSig

type HashSig [HashSigLen]byte

type KeyType

type KeyType uint8
const (
	Public KeyType = iota
	Secret
)

type Keypair

type Keypair struct {
	Pk PK
	Sk SK
}

func KeypairSK

func KeypairSK(sk [32]byte) (kp Keypair, err error)

type PK

type PK [PKSize]byte

func DecodePK

func DecodePK(key string) (PK, error)

func DecodePKNoPrefix

func DecodePKNoPrefix(key string) (bf PK, err error)

Takes a string representation of a public key and returns the byte representation of it

func (PK) Encode

func (pk PK) Encode() string

Takes a public key and returns a string representation of it using a custom alphabet

func (PK) EncodeNoPrefix

func (pk PK) EncodeNoPrefix() string

func (PK) Verify

func (pk PK) Verify(sig []byte) (msg []byte, ok bool)

func (PK) VerifyHash

func (pk PK) VerifyHash(sig HashSig, b []byte) (ok bool)

type Peer

type Peer struct {
	Pk       PK
	MainAddr Address
	AltAddrs []Address
	LastSeen time.Time
}

func Decrypt

func Decrypt(kp Keypair, emsg []byte) (from Peer, msg []byte, err error)

todo: version cyphertexts

func (Peer) Equals

func (p Peer) Equals(p2 Peer) bool

type SK

type SK [SKSize]byte

func DecodeSK

func DecodeSK(key string) (SK, error)

func DecodeSKNoPrefix

func DecodeSKNoPrefix(key string) (bf SK, err error)

Takes a string representation of a secret key and returns the byte representation of it

func (SK) Encode

func (sk SK) Encode() string

Takes a secret key and returns a string representation of it using a custom alphabet

func (SK) Sign

func (sk SK) Sign(msg []byte) (sig []byte)

func (SK) SignHash

func (sk SK) SignHash(b []byte) (sig HashSig)

func (SK) TLS

func (sk SK) TLS() (cert tls.Certificate, err error)

type ThisPeer

type ThisPeer struct {
	Peer
	Kp Keypair
}

func (ThisPeer) Encrypt

func (p ThisPeer) Encrypt(msg []byte, to PK) (out []byte, err error)

chunks are chunked because not having to hold the whole thing in memory at the same time (?) we cold do larger chunks but messages larger than 64k will probably be rare (apart from file transfers? large responses? I'll get to tis when I do gateway implementation soon)

Jump to

Keyboard shortcuts

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