security

package
v0.8.83 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0, AGPL-3.0-or-later, Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCiphertextTooShort = errors.New("security: ciphertext too short")
	ErrEmptyPassword      = errors.New("security: empty password")
)
View Source
var (
	ErrPSKNetworkRequired = errors.New("psk: network required")
	ErrPSKVersionRequired = errors.New("psk: version required")
)
View Source
var ErrEmptySeed = errors.New("empty seed")
View Source
var ErrNoiseKeyCorrupted = errors.New("security: noise static key file is corrupted")
View Source
var ErrSignatureVerificationFailed = errors.New("signature verification failed")

Functions

func ConvertToSHA256

func ConvertToSHA256(input []byte) []byte

func DecryptAES added in v0.8.77

func DecryptAES(sealed, password []byte) ([]byte, error)

func DeriveDatabaseKey added in v0.8.77

func DeriveDatabaseKey(username, password string) ([]byte, error)

func DeriveIdentityKey added in v0.8.77

func DeriveIdentityKey(username, password, network string) (ed25519.PrivateKey, error)

func DeriveWalletSeed added in v0.8.77

func DeriveWalletSeed(identityKey ed25519.PrivateKey, network, username string) []byte

func EncryptAES

func EncryptAES(plainData, password []byte) ([]byte, error)

EncryptAES seals plainData with AES-256-GCM under an Argon2id-derived key. The random salt and nonce are public and travel with the ciphertext.

func GenerateKeyFromSeed

func GenerateKeyFromSeed(seed []byte) (ed25519.PrivateKey, error)

func GenerateNoiseKey added in v0.8.77

func GenerateNoiseKey() (noise.DHKey, error)

func LoadOrCreateNoiseStaticKey added in v0.8.77

func LoadOrCreateNoiseStaticKey(path string) (noise.DHKey, error)

func NewWeakPassword added in v0.8.77

func NewWeakPassword() ([]byte, error)

NewWeakPassword draws a single-use password from the bounded space above: small enough that brute force stays possible, expensive enough that it costs a data centre. Wipe returns the bytes to zero once they have been used.

func NoiseFingerprint added in v0.8.77

func NoiseFingerprint(pub []byte) string

func Sign added in v0.4.17

func Sign(privKey, body []byte) string

func VerifySignature added in v0.4.18

func VerifySignature(pubKey, body []byte, signatureStr string) error

func Wipe added in v0.8.77

func Wipe(secret []byte)

Types

type FileSystem

type FileSystem interface {
	ReadDir(name string) ([]fs.DirEntry, error)
	ReadFile(name string) ([]byte, error)
	Open(name string) (fs.File, error)
}

type NoiseSession added in v0.8.77

type NoiseSession struct {
	// contains filtered or unexported fields
}

func NoiseHandshake added in v0.8.77

func NoiseHandshake(static noise.DHKey, read func() ([]byte, error), write func([]byte) error) (*NoiseSession, error)

func NoiseHandshakeInitiator added in v0.8.77

func NoiseHandshakeInitiator(
	static noise.DHKey, read func() ([]byte, error), write func([]byte) error,
) (*NoiseSession, error)

func (*NoiseSession) Decrypt added in v0.8.77

func (s *NoiseSession) Decrypt(frame []byte) ([]byte, error)

func (*NoiseSession) Encrypt added in v0.8.77

func (s *NoiseSession) Encrypt(plain []byte) ([]byte, error)

func (*NoiseSession) RemoteStatic added in v0.8.77

func (s *NoiseSession) RemoteStatic() []byte

type PSK

type PSK []byte

func GeneratePSK

func GeneratePSK(network string, v *semver.Version) (PSK, error)

GeneratePSK - Preshared Secret Key is public for Warpnet goals - it's just separate networks and versions

func (PSK) String

func (s PSK) String() string

type PrivateKey

type PrivateKey crypto.PrivKey

Jump to

Keyboard shortcuts

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