Help us shape the future of Go! Take the 2026 Go Developer Survey

crypto

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeySize is the size of AES-256 keys in bytes
	KeySize = 32
	// NonceSize is the size of AES-GCM nonces in bytes
	NonceSize = 12
	// SaltSize is the size of PBKDF2 salts in bytes
	SaltSize = 32
	// PBKDF2Iterations is the number of iterations for key derivation
	PBKDF2Iterations = 100000
	// KyberPublicKeySize is the size of Kyber public keys
	KyberPublicKeySize = 32
	// KyberSecretKeySize is the size of Kyber secret keys
	KyberSecretKeySize = 32
	// KyberCiphertextSize is the size of Kyber ciphertexts
	KyberCiphertextSize = 32
)

Variables

View Source
var (
	// Suite is the cryptographic suite we use for post-quantum operations
	Suite = edwards25519.NewBlakeSHA256Ed25519()
)

Functions

func DeriveColumnKey

func DeriveColumnKey(masterKey []byte, columnName string, salt []byte) []byte

DeriveColumnKey derives a column-specific key from master key and column name

func LoadPlugin added in v0.3.0

func LoadPlugin(path string) error

LoadPlugin dynamically loads a module from a Go plugin. The plugin must expose a symbol named "Module" that implements Module.

func RegisterModule added in v0.3.0

func RegisterModule(m Module)

RegisterModule registers a cryptographic module.

Types

type ColumnEncryptor

type ColumnEncryptor struct {

	// PQ components
	KyberPublicKey kyber.Point
	KyberSecretKey kyber.Scalar
	// contains filtered or unexported fields
}

ColumnEncryptor handles encryption/decryption for column data

func NewColumnEncryptor

func NewColumnEncryptor(key []byte) (*ColumnEncryptor, error)

NewColumnEncryptor creates a new column encryptor with hybrid encryption

func (*ColumnEncryptor) Decrypt

func (ce *ColumnEncryptor) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts data using hybrid classical + post-quantum decryption

func (*ColumnEncryptor) Encrypt

func (ce *ColumnEncryptor) Encrypt(plaintext []byte) ([]byte, error)

Encrypt encrypts data using hybrid classical + post-quantum encryption

func (*ColumnEncryptor) Sign added in v0.2.0

func (ce *ColumnEncryptor) Sign(data []byte) ([]byte, error)

Sign signs data using the Kyber keypair

func (*ColumnEncryptor) Verify added in v0.2.0

func (ce *ColumnEncryptor) Verify(data, signature []byte) (bool, error)

Verify verifies a signature

type Encryptor added in v0.3.0

type Encryptor interface {
	Encrypt([]byte) ([]byte, error)
	Decrypt([]byte) ([]byte, error)
	Sign([]byte) ([]byte, error)
	Verify([]byte, []byte) (bool, error)
}

Encryptor defines encryption operations used by the rest of the system.

type Key

type Key struct {
	Data []byte
	Salt []byte
	// PQ components
	KyberPublicKey kyber.Point
	KyberSecretKey kyber.Scalar
}

Key represents an encryption key with associated metadata

func DeriveKey

func DeriveKey(password string, salt []byte) *Key

DeriveKey derives a key from password and salt, with optional PQ components

func NewKey

func NewKey(password string) (*Key, error)

NewKey generates a new encryption key from a password with post-quantum protection

type Module added in v0.3.0

type Module interface {
	Name() string
	NewKey(password string) (*Key, error)
	DeriveKey(password string, salt []byte) *Key
	NewEncryptor(key []byte) (Encryptor, error)
}

Module provides cryptographic primitives. Different modules can implement alternative algorithms such as homomorphic encryption.

func GetModule added in v0.3.0

func GetModule(name string) (Module, bool)

GetModule retrieves a registered module by name.

Jump to

Keyboard shortcuts

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