crypto

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectKeySize       = 32 // 256 bits for XSalsa20Poly1305 (NaCl secretbox)
	X25519PrivateKeySize = 32 // X25519 private key size
	SecretboxNonceSize   = 24 // XSalsa20Poly1305 nonce size (NaCl secretbox)
	UserTokenSize        = 32 // User authentication token size
)

Variables

This section is empty.

Functions

func Decode

func Decode(encoded string) ([]byte, error)

Decode provides general base64 decoding for binary data Tries multiple base64 formats for compatibility

func DecryptSecretValue

func DecryptSecretValue(ciphertext []byte, nonce []byte, projectKey []byte) (string, error)

DecryptSecretValue decrypts a secret value using ChaCha20Poly1305

func Encode

func Encode(data []byte) string

Encode provides general base64 encoding for binary data (like wrapped keys)

func EncodeEd25519PublicKey

func EncodeEd25519PublicKey(publicKey ed25519.PublicKey) (string, error)

EncodeEd25519PublicKey encodes an Ed25519 public key for API transmission

func EncodeEd25519Signature

func EncodeEd25519Signature(signature []byte) (string, error)

EncodeEd25519Signature encodes an Ed25519 signature for authentication headers

func EncodeX25519PublicKey

func EncodeX25519PublicKey(publicKey []byte) (string, error)

EncodeX25519PublicKey encodes an X25519 public key for API transmission

func EncryptSecretValue

func EncryptSecretValue(value string, projectKey []byte) ([]byte, []byte, error)

EncryptSecretValue encrypts a secret value using ChaCha20Poly1305

func GenerateEd25519Keypair

func GenerateEd25519Keypair() (ed25519.PublicKey, ed25519.PrivateKey, error)

GenerateEd25519Keypair generates a new Ed25519 keypair

func GenerateX25519Keypair

func GenerateX25519Keypair() ([]byte, []byte, error)

GenerateX25519Keypair generates a new X25519 keypair

func UnwrapProjectKey added in v0.4.0

func UnwrapProjectKey(wrappedKey string, devicePrivateKey []byte) ([]byte, error)

UnwrapProjectKey unwraps a project key with a device private key

func WrapProjectKey added in v0.4.0

func WrapProjectKey(projectKey []byte, devicePublicKey []byte) (string, error)

WrapProjectKey wraps a project key with a device public key

Types

This section is empty.

Jump to

Keyboard shortcuts

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