gdat

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Base64Alphabet = cadata.Base64Alphabet
	RefSize        = blobcache.CIDSize + DEKSize
)
View Source
const DEKSize = 32

Variables

This section is empty.

Functions

func AppendRef

func AppendRef(out []byte, x Ref) []byte

func Copy

func Copy(ctx context.Context, src stores.Reading, dst stores.Writing, ref *Ref) error

Copy copies the data at ref from src to dst.

func DeriveKey

func DeriveKey(out []byte, secret *[32]byte, additional []byte)

DeriveKey uses the blake2b XOF to fill out. The input to the XOF is additional and secret is used to key the XOF.

func DeriveStream

func DeriveStream(secret *[32]byte, additional []byte) io.Reader

DeriveStream returns a cryptographically secure psuedorandom stream derived from a high entropy secret, and arbitrary additional bytes.

func Equal

func Equal(a, b Ref) bool

func Hash

func Hash(x []byte) blobcache.CID

Types

type DEK

type DEK [DEKSize]byte

func Convergent

func Convergent(ptextHash blobcache.CID) DEK

Convergent generates a DEK depending only on ptextHash

func (DEK) MarshalText

func (dek DEK) MarshalText() ([]byte, error)

func (*DEK) String

func (*DEK) String() string

func (*DEK) UnmarshalText

func (dek *DEK) UnmarshalText(data []byte) error

type KeyFunc

type KeyFunc func(ptextHash blobcache.CID) DEK

KeyFunc produces a key for a given blob

func SaltedConvergent

func SaltedConvergent(salt *[32]byte) KeyFunc

SaltedConvergent uses salt to generate convergent keys for each blob.

type Machine

type Machine struct {
	// contains filtered or unexported fields
}

func NewMachine

func NewMachine(opts ...Option) *Machine

func (*Machine) GetF

func (a *Machine) GetF(ctx context.Context, s stores.Reading, ref Ref, fn func(data []byte) error) error

func (*Machine) Post

func (a *Machine) Post(ctx context.Context, s stores.Writing, data []byte) (*Ref, error)

func (*Machine) Read

func (a *Machine) Read(ctx context.Context, s stores.Reading, ref Ref, buf []byte) (int, error)

type Option

type Option = func(*Machine)

func WithCacheSize

func WithCacheSize(n int) Option

func WithSalt

func WithSalt(salt *[32]byte) Option

type Ref

type Ref struct {
	CID blobcache.CID
	DEK DEK
}

func ParseRef

func ParseRef(x []byte) (ret Ref, _ error)

func (Ref) IsZero

func (r Ref) IsZero() bool

func (*Ref) Marshal

func (r *Ref) Marshal() []byte

func (Ref) MarshalBinary

func (r Ref) MarshalBinary() ([]byte, error)

func (Ref) MarshalText

func (r Ref) MarshalText() ([]byte, error)

func (Ref) String

func (r Ref) String() string

func (*Ref) Unmarshal

func (r *Ref) Unmarshal(data []byte) error

func (*Ref) UnmarshalBinary

func (ref *Ref) UnmarshalBinary(x []byte) error

func (*Ref) UnmarshalText

func (r *Ref) UnmarshalText(data []byte) error

Jump to

Keyboard shortcuts

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