crypto

package
v0.0.0-...-54ed9d2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package crypto provides cryptographic utilities for Helix Cluster OS.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKey        = errors.New("invalid key")
	ErrVerifyFailed      = errors.New("signature verification failed")
	ErrInvalidCiphertext = errors.New("invalid ciphertext")
)

Functions

func Decrypt

func Decrypt(key []byte, ciphertextHex string) ([]byte, error)

Decrypt decrypts AES-GCM ciphertext (hex-encoded with nonce prepended).

func DeriveKey

func DeriveKey(password, salt []byte, iterations, keyLen int) []byte

DeriveKey derives a key of the specified length using PBKDF2 with SHA-256.

func Encrypt

func Encrypt(key, plaintext []byte) (string, error)

Encrypt encrypts plaintext with AES-GCM using the provided key. The key must be 16, 24, or 32 bytes (AES-128, AES-192, AES-256). Returns hex-encoded ciphertext with the nonce prepended.

func GenerateKey

func GenerateKey(seed string) string

GenerateKey generates a deterministic placeholder key.

func Hash

func Hash(data []byte) string

Hash returns the SHA-256 hex digest of data.

func Sign

func Sign(privateKey ed25519.PrivateKey, message []byte) (string, error)

Sign signs message with the given Ed25519 private key and returns the hex-encoded signature.

func Verify

func Verify(publicKey ed25519.PublicKey, message []byte, signatureHex string) error

Verify verifies an Ed25519 signature (hex-encoded) against a message.

Types

type KeyPair

type KeyPair struct {
	Public  ed25519.PublicKey
	Private ed25519.PrivateKey
}

KeyPair holds an Ed25519 signing key pair.

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair generates a new Ed25519 key pair using crypto/rand.

Jump to

Keyboard shortcuts

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