Documentation ¶
Index ¶
- Constants
- Variables
- func AppendProof(base *mt.Proof, sub mt.Proof) (*mt.Proof, error)
- func CarCacheLayerStart(carSize uint64) int
- func CarChallengeCount(carNum uint64) uint64
- func CarChunkParams(carSize uint64) (uint64, uint64)
- func DataPadding(inSlab []byte) []byte
- func GenCarChallenge(randomness uint64, carChallengeIndex uint64, carChallengesCount uint64, ...) uint64
- func GenCommP(buf bytes.Buffer, cachePath string, targetPaddedSize uint64) ([]byte, uint64, error)
- func GenDatasetProof(cachePath string) ([]byte, error)
- func GenLeafChallenge(randomness uint64, carIndex uint64, leafChallengeCount uint64, carSize uint64) ([]uint64, error)
- func GenProof(blocks []mt.DataBlock, leaf mt.DataBlock) (*mt.Proof, []byte, error)
- func GenProofFromCache(leaf mt.DataBlock, file string) (*mt.Proof, []byte, error)
- func GetChallengeChunk(commCid cid.Cid, offset uint64, size uint64) ([]byte, error)
- func LeafChallengeCount(carChallengesCount uint64) []uint64
- func LoadSortCommp(cachePath string) ([][]byte, []uint64)
- func NewDataBlockFromBytes(data []byte) mt.DataBlock
- func NewDataBlocksFromBytes(bt [][]byte) []mt.DataBlock
- func NewHashFunc(data []byte) ([]byte, error)
- func NewPaddedDataBlocksFromBuffer(buf bytes.Buffer, targetPaddedSize uint64) ([]mt.DataBlock, uint64, error)
- func NewPaddedDataBlocksFromDataBlocks(dataBlocks []mt.DataBlock, sourcePaddedSize, targetPaddedSize uint64) ([]mt.DataBlock, error)
- func PadCommP(sourceCommP []byte, sourcePaddedSize, targetPaddedSize uint64) ([]byte, error)
- func SaveCommP(rawCommP []byte, carSize uint64, cachePath string) error
- func VerifyChallengeProof(cachePath string) (bool, error)
- func VerifyDatasetProof(cachePath string, randomness uint64) (bool, *mt.Proof, error)
- type CarChallenge
- type ChallengeProofs
- type DataBlock
- type DatasetMerkletree
- type DatasetProof
- type MappingService
- func (ms *MappingService) GenerateCarWriter(w io.Writer, path string, call bool) io.Writer
- func (ms *MappingService) GenerateChunksFromMappings(path string, srcParent string, mappings []*types.ChunkMapping) error
- func (ms *MappingService) GenerateDagService(ds ipld.DAGService) ipld.DAGService
- func (ms *MappingService) GenerateHelper(params *helpers.DagBuilderParams, spl libs.EnhancedSplitter) (helpers.Helper, error)
- func (ms *MappingService) GenerateNodeFromSource(path string, srcParent string, m *types.ChunkMapping, cidBuilder cid.Builder) (ipld.Node, error)
- func (ms *MappingService) GenerateNodeWithoutData(m *types.ChunkMapping, cidBuilder cid.Builder) (ipld.Node, error)
- func (ms *MappingService) GetAllChunkMappings() ([]*types.ChunkMapping, error)
- func (ms *MappingService) GetChunkMappings(dstOffset uint64, dstSize uint64) ([]*types.ChunkMapping, error)
- func (ms *MappingService) LoadMetaMappings(path string) error
- func (ms *MappingService) MetaPath() string
- func (ms *MappingService) SaveMetaMappings(path string, name string) error
- func (ms *MappingService) SetCarDataRoot(root cid.Cid)
- func (ms *MappingService) SourceParentPath() string
- type Option
- type Options
- type Proofs
Constants ¶
const ( METAS_PATH = "metas" MAPPINGS_PATH = "mappings" MAPPING_FILE_SUFFIX = ".json" )
const ( SOURCE_CHUNK_SIZE = 127 SLAB_CHUNK_SIZE = 128 NODE_SIZE = 32 CHUNK_NODES_NUM = 4 CAR_32GIB_SIZE = uint64(1 << 35) CAR_2MIB_CHUNK_SIZE = uint64(SOURCE_CHUNK_SIZE * CAR_2MIB_NODE_NUM / CHUNK_NODES_NUM) // source data node = 127, no padding CAR_512B_CHUNK_SIZE = uint64(SOURCE_CHUNK_SIZE * CAR_512B_NODE_NUM / CHUNK_NODES_NUM) // source data node = 127, no padding CAR_2MIB_NODE_NUM = uint64(1 << 20 * 2 / NODE_SIZE) // = 2MIB / NODE_SIZE CAR_512B_NODE_NUM = uint64(1 << 9 / NODE_SIZE) // = 512B / NODE_SIZE DATASET_RULE_CHALLENGE_POINTS_PER_AUDITOR = 5 // 5 point per auditor CAR_2MIB_CACHE_LAYER_START = 16 CAR_512B_CACHE_LAYER_START = 4 CACHE_SUFFIX = ".cache" CACHE_DATASET_PROOF_PATH = "dataset.proof" CACHE_CHALLENGE_PROOFS_PATH = "challenges.proofs" PROOFS_PATH = "proofs" // MaxLayers is the current maximum height of the rust-fil-proofs proving tree. MaxLayers = uint(31) // result of log2( 64 GiB / 32 ) // MaxPieceSize is the current maximum size of the rust-fil-proofs proving tree. MaxPieceSize = uint64(1 << (MaxLayers + 5)) )
Variables ¶
var ( StackedNulPadding [MaxLayers][]byte SumChunkCount uint64 CommpHashConfig = &mt.Config{ HashFunc: NewHashFunc, DisableLeafHashing: true, Mode: mt.ModeTreeBuild, RunInParallel: true, } Once sync.Once )
Functions ¶
func AppendProof ¶
Append base and sub proof
func CarCacheLayerStart ¶
CarCacheLayerStart returns the start index of the cache layer for a given CAR size. It takes the size of the CAR as input. It returns the start index of the cache layer.
func CarChunkParams ¶
CarChunkParams returns the chunk size and node number for a given CAR size. It takes the size of the CAR as input. It returns the chunk size and the number of nodes.
func GenCarChallenge ¶
func GenCarChallenge(randomness uint64, carChallengeIndex uint64, carChallengesCount uint64, carNum uint64) uint64
GenCarChallenge generates a car challenge index using randomness, the car challenge index, and the total number of car challenges. It returns the generated car challenge index.
func GenDatasetProof ¶
Generate commPs Merkle-Tree root to .tcache, proofs{rootHash, leafHashes[]} cachePath: store to file path
func GenLeafChallenge ¶
func GenLeafChallenge(randomness uint64, carIndex uint64, leafChallengeCount uint64, carSize uint64) ([]uint64, error)
GenLeafChallenge generates a leaf challenge index using randomness, the car index, the leaf challenge index, and the size of the car. It returns the generated leaf challenge index.
func GenProof ¶
GenProof generates a Merkle tree proof for the specified leaf block. It takes a slice of data blocks and the leaf block as input. It returns the proof, the root hash of the Merkle tree, and any error encountered.
func GenProofFromCache ¶
GenProofFromCache generates a Merkle tree proof for the specified leaf block using a level cache. It takes the leaf block and the cache file path as input. It returns the proof, the root hash of the Merkle tree, and any error encountered.
func GetChallengeChunk ¶
Use this function to generate data fragments of the CAR file at challenge points when creating challenge proofs.
func LeafChallengeCount ¶
Car leaf challenge count.
func LoadSortCommp ¶
LoadSortCommp loads and sorts the CommP values from the cache file. It takes the cache file path as input. It returns a slice of CommP values and a slice of their corresponding indices.
func NewDataBlockFromBytes ¶
No padding DataBlock
func NewDataBlocksFromBytes ¶
No padding DataBlock
func NewHashFunc ¶
SHA256 hash generate function for commp
func NewPaddedDataBlocksFromBuffer ¶
func NewPaddedDataBlocksFromBuffer(buf bytes.Buffer, targetPaddedSize uint64) ([]mt.DataBlock, uint64, error)
Padding DataBlock, commp leaf node use targetPaddedSize = 0 use default paddedSize
func NewPaddedDataBlocksFromDataBlocks ¶
func NewPaddedDataBlocksFromDataBlocks(dataBlocks []mt.DataBlock, sourcePaddedSize, targetPaddedSize uint64) ([]mt.DataBlock, error)
Padding DataBlock, commp leaf node use targetPaddedSize = 0 use default paddedSize
func VerifyChallengeProof ¶
Verify challenge nodes Proof
Types ¶
type CarChallenge ¶
CarChallenge struct represents the challenge information of a car, including the car index and corresponding challenges.
func GenChallenges ¶
func GenChallenges(randomness uint64, carNum uint64, carSize []uint64) ([]CarChallenge, error)
GenChallenges function generates challenge information for cars and returns a sequentially traversable structure.
type ChallengeProofs ¶
type ChallengeProofs struct { RandomSeed uint64 Leaves []string Siblings [][]string Paths []string }
ChallengeProofs represents the challenge proofs data structure.
func NewChallengeProofs ¶
func NewChallengeProofs(randomness uint64, proofs Proofs) *ChallengeProofs
NewChallengeProofs creates a new ChallengeProofs instance from the provided randomness and proof map.
func NewChallengeProofsFromFile ¶
func NewChallengeProofsFromFile(filePath string) (*ChallengeProofs, error)
NewChallengeProofsFromFile creates a new ChallengeProofs instance by reading from the provided file path.
type DataBlock ¶
type DataBlock struct {
Data []byte
}
DataBlock is a implementation of the DataBlock interface.
type DatasetMerkletree ¶
DatasetMerkletree represents the structure of a dataset Merkle tree.
type DatasetProof ¶
DatasetProof represents the data structure of dataset proofs.
func NewDatasetProof ¶
func NewDatasetProof(proof DatasetMerkletree, leafSizes []uint64) *DatasetProof
NewDatasetProof creates a new DatasetProof instance based on the provided DatasetMerkletree.
func NewDatasetProofFromFile ¶
func NewDatasetProofFromFile(filePath string) (*DatasetProof, error)
NewDatasetProofFromFile creates a new DatasetProof instance from the provided file path.
type MappingService ¶
type MappingService struct {
// contains filtered or unexported fields
}
MappingService generates the mapping relationship from the source file to the car file.
func MappingServiceInstance ¶
func MappingServiceInstance(opts ...Option) *MappingService
func New ¶
func New(opts ...Option) *MappingService
func (*MappingService) GenerateCarWriter ¶
Wrapping the io.Writer interface to implement mapping recording for writing CAR files.
func (*MappingService) GenerateChunksFromMappings ¶
func (ms *MappingService) GenerateChunksFromMappings(path string, srcParent string, mappings []*types.ChunkMapping) error
Generating a data fragment file of a CAR file based on contiguous mapping information and data obtained from the source file. For example, generating a 2MB data fragment for which a consistency proof needs to be challenged.
func (*MappingService) GenerateDagService ¶
func (ms *MappingService) GenerateDagService(ds ipld.DAGService) ipld.DAGService
Creating an encapsulation interface for ipld.DAGService to implement recording of mapping files during the process of writing nodes
func (*MappingService) GenerateHelper ¶
func (ms *MappingService) GenerateHelper(params *helpers.DagBuilderParams, spl libs.EnhancedSplitter) (helpers.Helper, error)
Implementing the Helper interface of go-unixfs.
func (*MappingService) GenerateNodeFromSource ¶
func (ms *MappingService) GenerateNodeFromSource(path string, srcParent string, m *types.ChunkMapping, cidBuilder cid.Builder) (ipld.Node, error)
Node construction involving the source data.
func (*MappingService) GenerateNodeWithoutData ¶
func (ms *MappingService) GenerateNodeWithoutData(m *types.ChunkMapping, cidBuilder cid.Builder) (ipld.Node, error)
Node construction without involving the source data.
func (*MappingService) GetAllChunkMappings ¶
func (ms *MappingService) GetAllChunkMappings() ([]*types.ChunkMapping, error)
Getting all mapping information from the MappingService cache.
func (*MappingService) GetChunkMappings ¶
func (ms *MappingService) GetChunkMappings(dstOffset uint64, dstSize uint64) ([]*types.ChunkMapping, error)
Getting mapping information for data fragments associated with a given offset and size of car.
func (*MappingService) LoadMetaMappings ¶
func (ms *MappingService) LoadMetaMappings(path string) error
Loading mapping information from a file into the MappingService cache.
func (*MappingService) MetaPath ¶
func (ms *MappingService) MetaPath() string
Access path for metadata.
func (*MappingService) SaveMetaMappings ¶
func (ms *MappingService) SaveMetaMappings(path string, name string) error
Saving the cached mapping information to a file.
func (*MappingService) SetCarDataRoot ¶
func (ms *MappingService) SetCarDataRoot(root cid.Cid)
Set the DAG data root for the current CAR file.
func (*MappingService) SourceParentPath ¶
func (ms *MappingService) SourceParentPath() string
Access path for source data.