Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBlockAlreadyExists = errors.New("block already exists for chunk")
Functions ¶
func GenerateKeyHex ¶
func LoadEncryptionKey ¶
Types ¶
type AESGCMTransformer ¶
type AESGCMTransformer struct {
Key []byte
}
func (*AESGCMTransformer) Decode ¶
func (t *AESGCMTransformer) Decode(_ context.Context, in DecodeInput) (data []byte, err error)
func (*AESGCMTransformer) Encode ¶
func (t *AESGCMTransformer) Encode(_ context.Context, in EncodeInput) (*EncodedBlock, error)
type Codec ¶
type Codec string
func LoadDefaultCodec ¶
LoadDefaultCodec resolves codec from env with a secure default. Precedence: env (COLDKEEP_CODEC) -> default (aes-gcm).
func ParseCodec ¶
type DecodeInput ¶
type DecodeInput struct {
ChunkHash string
Descriptor Descriptor
Payload []byte
}
type Descriptor ¶
type Descriptor struct {
ID int64
ChunkID int64
Codec Codec
FormatVersion int
PlaintextSize int64
StoredSize int64
Nonce []byte
ContainerID int64
BlockOffset int64
CreatedAt time.Time
UpdatedAt time.Time
}
Descriptor represents how a chunk is physically stored in the system. It links logical chunk identity to its encoded representation in a container.
type EncodeInput ¶
type EncodedBlock ¶
type EncodedBlock struct {
Descriptor Descriptor
Payload []byte
}
type PlainTransformer ¶
type PlainTransformer struct{}
PlainTransformer stores chunks as-is without any transformation.
func (*PlainTransformer) Decode ¶
func (t *PlainTransformer) Decode(_ context.Context, in DecodeInput) ([]byte, error)
No transformation needed for plain codec, just return the payload as-is. Phase 6 Step 8: Avoid unnecessary byte copies during restore - Decode returns payload directly without copying - Caller (restore.go) never mutates plaintext after verification - Direct return saves memory allocation and copy time per chunk
func (*PlainTransformer) Encode ¶
func (t *PlainTransformer) Encode(_ context.Context, in EncodeInput) (*EncodedBlock, error)
type Repository ¶
func (*Repository) GetByChunkHash ¶
func (r *Repository) GetByChunkHash(ctx context.Context, chunkHash string) (*Descriptor, error)
func (*Repository) GetByChunkID ¶
func (r *Repository) GetByChunkID(ctx context.Context, chunkID int64) (*Descriptor, error)
func (*Repository) Insert ¶
func (r *Repository) Insert(ctx context.Context, tx *sql.Tx, d *Descriptor) error
type Transformer ¶
type Transformer interface {
Encode(ctx context.Context, in EncodeInput) (*EncodedBlock, error)
Decode(ctx context.Context, in DecodeInput) ([]byte, error)
}
Transformer defines how a chunk is transformed into a stored block and how a stored block is transformed back into plaintext.
func GetBlockTransformer ¶
func GetBlockTransformer(codec Codec) (Transformer, error)
get codec transformer from codec name