🔄

SnapDeals Data Flows

Sector Key - "original" replica

Not sure when the cache paths are needed but I will figure it out.

Workflows

Adding data to an existing replica

EncodeInto(newReplicaPath, newCachePath, sectorKeyPath, sectorKeyCachePath, stagedDataPath, pieces []abi.PieceInfo, CommSectorKey) NewCommR, NewCommD

Encodes the stagedData into sectorKey and writes it to newReplicaPath by generating CommD from PieceInfos and running the encoding process. Returns the new CommR

newReplica[i] = sectorKey[i] + data[i] * rand(i)
NewCommR = Comm(newReplica)

This is the core workflow of the protocol.

Extracting data from existing replica and sector key

DecodeFrom(outDataPath, replicaPath, sectorKeyPath, sectorKeyCache, CommD, CommR, CommSectorKey)

Runs decoding process by generating encoding randomness from CommD and CommR and writing the result into outDataPath.

data[i] = (replica[i] - sectorKey[i]) * (rand(i)^-1)

This will be probably used very little but still useful.

(TODO API call for generating sector key).

Decoding replica into sector key by use of deal data

RemoveData[different name](sectorKeyPath, sectorKeyCache, replicaPath, replicaCachePath, dataPath, CommD, CommR, CommSectorKey)

Removes encoded data and produces SectorKey

sectorKey[i] = replica[i] - data[i] * rand(i)

Encoding new data into sector with data without explicit sector key

This won't work, as sectorKey needed for proof. We may be able to work it around but (create sectorKey ad-hoc but that is added complexity).

Allows for subsequent updates of to the sector in single pass manner.

EncodeSwap(newReplicaPath, newCachePath, newDataPath, pieces []abi.PieceInfo oldReplicaPath, oldReplicaCachePath, oldDataPath, oldCommD, CommSectorKey) NewCommR, NewCommD

Decodes the oldReplica and encodes newData into it at the same time.

newReplica[i] = oldReplica[i] - oldData[i] * oldRand(i) + newData[i] * newRand(i)
NewCommR = Comm(newReplica)

In theory EncodeInto is not needed given this function if we allow oldDataPath = nil or oldDataPath = /dev/zero .

Computing UpdateProof

ComputeUpdateProof(replicaPath, cachePath, dataPath, sectorKeyPath, sectorInfo) []byte

Split it into compute vanilla and generate snark.

dataflow