verification

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0, MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatBlocks

func StatBlocks(ctx context.Context, id principal.Signer, getProofs ContentRetrieveProofGetterFunc, indexer ShardFinder, links []cid.Cid) iter.Seq2[BlockStat, error]

StatBlocks retrieves block statistics for the given CIDs using the provided indexer. It also performs integrity checks on the retrieved blocks. Note: the getProofs function can be nil, in which case no authorization will be sent for retrievals.

func VerifyDAGRetrieval

func VerifyDAGRetrieval(
	ctx context.Context,
	id principal.Signer,
	getProofs ContentRetrieveProofGetterFunc,
	indexer ShardFinder,
	root cid.Cid,
) iter.Seq2[VerifiedBlock, error]

VerifyDAGRetrieval verifies the retrieval of a DAG starting from the given root CID. It uses the provided indexer to find shards and locations, and retrieves blocks while verifying their integrity. The function returns a sequence of VerifiedBlock results. Note: the getProofs function can be nil, in which case no authorization will be sent for retrievals.

Types

type AuthorizeIndexerRetrievalFunc

type AuthorizeIndexerRetrievalFunc func() (delegation.Delegation, error)

AuthorizeIndexerRetrievalFunc is a function that authorizes retrievals from the indexer by returning a delegation that can be used for retrieval.

type BlockStat

type BlockStat struct {
	Codec  uint64              // IPLD codec that was used to decode the block.
	Size   uint64              // Size of the block in bytes.
	Digest multihash.Multihash // Multihash digest of the block.
	Links  []cid.Cid           // CIDs linked from this block, deduped.
	Origin Origin              // Where the block was retrieved from.
}

type ContentRetrieveProofGetterFunc

type ContentRetrieveProofGetterFunc func(space did.DID) ([]delegation.Proof, error)

ContentRetrieveProofGetterFunc is a function that obtains proofs for content retrieval in a given space.

type IndexCache

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

func NewIndexCache

func NewIndexCache() *IndexCache

func (*IndexCache) Add

func (c *IndexCache) Add(root cid.Cid, index blobindex.ShardedDagIndex)

func (*IndexCache) IndexForSlice

func (c *IndexCache) IndexForSlice(slice multihash.Multihash) (blobindex.ShardedDagIndex, bool)

type Indexer

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

func NewIndexer

func NewIndexer(client IndexingServiceClient, authorize AuthorizeIndexerRetrievalFunc) *Indexer

NewIndexer creates a new Indexer with the given indexing service client and authorization function. Note: the authorize function can be nil, in which case no authorization will be sent for indexer queries.

func (*Indexer) FindLocations

func (i *Indexer) FindLocations(ctx context.Context, shard multihash.Multihash) ([]Location, error)

FindLocations finds at least 1 location for the given shard or returns an error.

func (*Indexer) FindShard

FindShard finds the shard and its position for the given slice.

type IndexingServiceClient

type IndexingServiceClient interface {
	QueryClaims(ctx context.Context, query types.Query) (types.QueryResult, error)
}

IndexingServiceClient is the interface for querying the indexing service.

type Location

type Location struct {
	Commitment delegation.Delegation
	// Caveats are the decoded caveats from the commitment delegation.
	Caveats assert.LocationCaveats
}

type LocationCache

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

func NewLocationCache

func NewLocationCache() *LocationCache

func (*LocationCache) Add

func (c *LocationCache) Add(commitment delegation.Delegation)

func (*LocationCache) LocationsForShard

func (c *LocationCache) LocationsForShard(shard multihash.Multihash) []Location

type Origin

type Origin struct {
	Node     did.DID             // The node that provided the data.
	URL      url.URL             // URL of the shard the data came from.
	Shard    multihash.Multihash // Hash of the shard.
	Position blobindex.Position  // Byte range within the shard.
}

type ShardFinder

type ShardFinder interface {
	FindShard(ctx context.Context, slice multihash.Multihash) (multihash.Multihash, blobindex.Position, error)
	FindLocations(ctx context.Context, shard multihash.Multihash) ([]Location, error)
}

ShardFinder finds shards and their locations for content retrieval.

type Slice

type Slice struct {
	Digest   multihash.Multihash
	Bytes    []byte
	Position blobindex.Position
	Location Location
}

type VerifiedBlock

type VerifiedBlock struct {
	Stat BlockStat
}

Jump to

Keyboard shortcuts

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