Documentation
¶
Overview ¶
Package storage provides secure encrypted storage for TSS key shares
Index ¶
- Variables
- type EncryptedKeyShare
- type FileStorage
- func (fs *FileStorage) Backup(backupPath string) error
- func (fs *FileStorage) ChangePassword(oldPassword, newPassword string) error
- func (fs *FileStorage) Delete() error
- func (fs *FileStorage) Exists() bool
- func (fs *FileStorage) GetMetadata() (*StorageMetadata, error)
- func (fs *FileStorage) Load(password string) (*keygen.KeyShare, error)
- func (fs *FileStorage) Restore(backupPath, password string) error
- func (fs *FileStorage) Save(share *keygen.KeyShare, password string) error
- func (fs *FileStorage) Verify(password string) error
- type KDFParams
- type KeyShareStorage
- type StorageConfig
- type StorageMetadata
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidPassword = errors.New("invalid password") ErrStorageCorrupted = errors.New("storage corrupted") ErrInvalidFormat = errors.New("invalid storage format") ErrPermissionDenied = errors.New("permission denied") ErrWeakPassword = errors.New("password too weak") ErrInvalidSalt = errors.New("invalid salt") ErrInvalidNonce = errors.New("invalid nonce") ErrEncryptionFailed = errors.New("encryption failed") ErrDecryptionFailed = errors.New("decryption failed") ErrBackupFailed = errors.New("backup failed") ErrRestoreFailed = errors.New("restore failed") ErrInvalidMetadata = errors.New("invalid metadata") ErrVersionMismatch = errors.New("version mismatch") ErrChecksumMismatch = errors.New("checksum mismatch") )
Storage errors
Functions ¶
This section is empty.
Types ¶
type EncryptedKeyShare ¶
type EncryptedKeyShare struct {
}
EncryptedKeyShare represents an encrypted key share on disk
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage implements KeyShareStorage using encrypted files
func NewFileStorage ¶
func NewFileStorage(config *StorageConfig) (*FileStorage, error)
NewFileStorage creates a new file-based key share storage
func (*FileStorage) Backup ¶
func (fs *FileStorage) Backup(backupPath string) error
Backup creates an encrypted backup of the key share
func (*FileStorage) ChangePassword ¶
func (fs *FileStorage) ChangePassword(oldPassword, newPassword string) error
ChangePassword re-encrypts the key share with a new password
func (*FileStorage) Delete ¶
func (fs *FileStorage) Delete() error
Delete securely deletes the stored key share
func (*FileStorage) Exists ¶
func (fs *FileStorage) Exists() bool
Exists checks if a key share exists in storage
func (*FileStorage) GetMetadata ¶
func (fs *FileStorage) GetMetadata() (*StorageMetadata, error)
GetMetadata returns storage metadata without decrypting
func (*FileStorage) Load ¶
func (fs *FileStorage) Load(password string) (*keygen.KeyShare, error)
Load decrypts and loads a key share from disk
func (*FileStorage) Restore ¶
func (fs *FileStorage) Restore(backupPath, password string) error
Restore restores a key share from backup
func (*FileStorage) Save ¶
func (fs *FileStorage) Save(share *keygen.KeyShare, password string) error
Save encrypts and saves a key share to disk
func (*FileStorage) Verify ¶
func (fs *FileStorage) Verify(password string) error
Verify validates the integrity of stored data
type KDFParams ¶
type KDFParams struct {
Time uint32 `json:"time"`
Memory uint32 `json:"memory"`
Threads uint8 `json:"threads"`
KeyLen uint32 `json:"key_len"`
Salt []byte `json:"salt"`
}
KDFParams contains key derivation function parameters
type KeyShareStorage ¶
type KeyShareStorage interface {
Save(share *keygen.KeyShare, password string) error
Load(password string) (*keygen.KeyShare, error)
Delete() error
Exists() bool
Backup(backupPath string) error
Restore(backupPath, password string) error
GetMetadata() (*StorageMetadata, error)
ChangePassword(oldPassword, newPassword string) error
Verify(password string) error
}
KeyShareStorage defines the interface for key share storage
type StorageConfig ¶
type StorageConfig struct {
// FilePath is the path where the key share is stored
FilePath string
// FileMode is the Unix file permissions (default: 0600)
FileMode os.FileMode
// Argon2 KDF parameters
Argon2Time uint32 // Time cost (iterations)
Argon2Memory uint32 // Memory cost (KB)
Argon2Threads uint8 // Parallelism
Argon2KeyLen uint32 // Derived key length
// MinPasswordLength is the minimum password length
MinPasswordLength int
// EnableBackup enables automatic backups
EnableBackup bool
// BackupDir is the directory for backups
BackupDir string
}
StorageConfig contains configuration for key share storage
func DefaultStorageConfig ¶
func DefaultStorageConfig(filePath string) *StorageConfig
DefaultStorageConfig returns a secure default configuration
func (*StorageConfig) Validate ¶
func (c *StorageConfig) Validate() error
Validate validates the storage configuration
type StorageMetadata ¶
type StorageMetadata struct {
Version string `json:"version"`
PartyID int `json:"party_id"`
Threshold int `json:"threshold"`
TotalParties int `json:"total_parties"`
CreatedAt time.Time `json:"created_at"`
ModifiedAt time.Time `json:"modified_at"`
EncryptionAlg string `json:"encryption_alg"`
KDFAlg string `json:"kdf_alg"`
KDFParams KDFParams `json:"kdf_params"`
Checksum []byte `json:"checksum"`
}
StorageMetadata contains information about stored key shares