crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 10 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

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 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

Jump to

Keyboard shortcuts

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