Documentation ¶
Index ¶
- Constants
- Variables
- func Get(kr KeyReader, cw ChunkWriter, conf Config) error
- func Move(kr KeyReader, kw KeyWriter, conf Config) error
- func Put(cr ChunkReader, kw KeyWriter, conf Config) error
- type ChunkReader
- type ChunkWriter
- type Config
- type K
- type KeyHash
- type KeyIndex
- type KeyReader
- type KeyWriter
- type RemoteStore
- type Secret
- type Store
- type StoreMap
Constants ¶
const (
//KeySize describes the byte size of each chunk key
KeySize = 32
)
const (
//SecretSize describes the byte size of the AES-GCM shared secret
SecretSize = 32
)
Variables ¶
var ( //ErrNoSuchKey is returned when a given key could not be found ErrNoSuchKey = errors.New("no such key") )
var ZeroSecret = Secret{}
ZeroSecret is secret with only 0x00 bytes, it can be used to check if a secret is empty
Functions ¶
func Get ¶
func Get(kr KeyReader, cw ChunkWriter, conf Config) error
Get will read and decrypt chunks for keys provided by the key reader and write each chunk's contents to chunk writer 'cw' in order of key appearance. Chunks are fetched concurrently (locally or remote) but are guaranteed to arrive in order to writer 'cw' for assembly in the original format
func Move ¶
Move will attempt to move all keys read from key reader 'kr' to the (remote)store configured in Config 'conf' and outputs pushed keys to key writer 'kw'.
func Put ¶
func Put(cr ChunkReader, kw KeyWriter, conf Config) error
Put reads chunks from a chunk reader and stores each chunk encrypted under a content-based key 'k' in the configured store. Compute intensive operations are run concurrently but keys are guaranteed to arrive at 'kw' in order, i.e: key of the first chunk will be writtern first
Types ¶
type ChunkReader ¶
ChunkReader allows reading one piece of input at a time
type Config ¶
type Config struct { AEAD cipher.AEAD KeyHash KeyHash PutConcurrency int MoveConcurrency int GetConcurrency int Stores StoreMap Index KeyIndex }
Config describes how the library's Split, Join and Push behaves
func DefaultConf ¶
DefaultConf sets up sensible configs
type K ¶
type K [32]byte
K is the key of a single chunk it is both used to store each piece as well as to encrypt it
type RemoteStore ¶
RemoteStore stores chunks at a distant location such that an indexing mechanism is economic to prevent movement of chunks that are already present
type Secret ¶
type Secret [SecretSize]byte
Secret is the 32 byte key that scopes the deduplication and facilitates end-to-end encryption. The first 8 bytes are always a polynomial that can be used for CBC the rest should always be randomly generated bytes
func DecodeSecret ¶
DecodeSecret attempts to decode a secret from a byte slice
func GenerateSecret ¶
GenerateSecret will create a new secret with a random (irreducable) polynomial and random bytes to fill up the space.
type Store ¶
type Store interface { //will do nothing if exists, must be atomic Put(k K, chunk []byte) error //returns os.NotExist if the chunk doesnt exist Get(k K) (chunk []byte, err error) }
Store holds chunks and is expected to have such a low latency that checking existence before put call is economic per key
type StoreMap ¶
StoreMap hols our store configurations and allows retrieval of stores for various purposes thoughout our code
func (StoreMap) GetSrcs ¶
GetSrcs returns an ordered list of stores for getting chunks for the current store configuration. this can be a default or explictely overwitten by the user @TODO store by 'localness' or 'likelyhood of having chunks'
func (StoreMap) MoveDst ¶
MoveDst returns a store to which chunks will be moved for the current store configration. this can be the default or overwitten by user preference