trix

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: EUPL-1.2 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPasswordRequired = errors.New("password is required for encryption")
	ErrDecryptionFailed = errors.New("decryption failed (wrong password?)")
)

Functions

func DeriveKey added in v0.0.2

func DeriveKey(password string) []byte

DeriveKey derives a 32-byte key from a password using SHA-256. This is used for ChaCha20-Poly1305 encryption which requires a 32-byte key. Deprecated: Use DeriveKeyArgon2 for new code; this remains for backward compatibility.

func DeriveKeyArgon2 added in v0.3.0

func DeriveKeyArgon2(password string, salt []byte) []byte

DeriveKeyArgon2 derives a 32-byte key from a password and salt using Argon2id with DefaultArgon2Params. This is the recommended key derivation for new code.

func FromTrix

func FromTrix(data []byte, password string) (*datanode.DataNode, error)

FromTrix converts a Trix byte slice back to a DataNode.

func FromTrixChaCha added in v0.0.2

func FromTrixChaCha(data []byte, password string) (*datanode.DataNode, error)

FromTrixChaCha decrypts a ChaCha-encrypted Trix byte slice back to a DataNode.

func ToTrix

func ToTrix(dn *datanode.DataNode, password string) ([]byte, error)

ToTrix converts a DataNode to the Trix format.

func ToTrixChaCha added in v0.0.2

func ToTrixChaCha(dn *datanode.DataNode, password string) ([]byte, error)

ToTrixChaCha converts a DataNode to encrypted Trix format using ChaCha20-Poly1305.

Types

type Argon2Params added in v0.3.0

type Argon2Params struct {
	Time    uint32
	Memory  uint32 // in KiB
	Threads uint32
}

Argon2Params holds the tunable parameters for Argon2id key derivation.

func DecodeArgon2Params added in v0.3.0

func DecodeArgon2Params(data []byte) Argon2Params

DecodeArgon2Params reads 12 bytes (3 x uint32 little-endian) into Argon2Params.

func DefaultArgon2Params added in v0.3.0

func DefaultArgon2Params() Argon2Params

DefaultArgon2Params returns sensible default parameters for Argon2id.

func (Argon2Params) Encode added in v0.3.0

func (p Argon2Params) Encode() []byte

Encode serialises the Argon2Params as 12 bytes (3 x uint32 little-endian).

Jump to

Keyboard shortcuts

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