commcid

package module
v0.0.0-...-efbe8a9 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0, MIT Imports: 6 Imported by: 5

README

go-qoin-commcid

Documentation

Overview

Package commcid provides helpers to convert between Piece/Data/Replica Commitments and their CID representation

Index

Constants

View Source
const FILCODEC_UNDEFINED = FilMultiCodec(0)

FILCODEC_UNDEFINED is just a signifier for "no codec determined

View Source
const FILMULTIHASH_UNDEFINED = FilMultiHash(0)

FILMULTIHASH_UNDEFINED is a signifier for "no multihash etermined"

Variables

View Source
var (
	// ErrIncorrectCodec means the codec for a CID is a block format that does not match
	// a commitment hash
	ErrIncorrectCodec = errors.New("unexpected commitment codec")
	// ErrIncorrectHash means the hash function for this CID does not match the expected
	// hash for this type of commitment
	ErrIncorrectHash = errors.New("incorrect hashing function for data commitment")
)
View Source
var CIDToPieceCommitmentV1 = CIDToDataCommitmentV1

CIDToPieceCommitmentV1 converts a CID to a commP -- it is just a helper function that is equivalent to CIDToDataCommitmentV1.

View Source
var PieceCommitmentV1ToCID = DataCommitmentV1ToCID

PieceCommitmentV1ToCID converts a commP to a CID -- it is just a helper function that is equivalent to DataCommitmentV1ToCID.

Functions

func CIDToCommitment

func CIDToCommitment(c cid.Cid) (FilMultiCodec, FilMultiHash, []byte, error)

CIDToCommitment extracts the raw commitment bytes, the FilMultiCodec and FilMultiHash from a CID, after validating that the codec and hash type are consistent

func CIDToDataCommitmentV1

func CIDToDataCommitmentV1(c cid.Cid) ([]byte, error)

CIDToDataCommitmentV1 extracts the raw data commitment from a CID after checking for the correct codec and hash types.

func CIDToReplicaCommitmentV1

func CIDToReplicaCommitmentV1(c cid.Cid) ([]byte, error)

CIDToReplicaCommitmentV1 extracts the raw replica commitment from a CID after checking for the correct codec and hash types.

func CommitmentToCID

func CommitmentToCID(mc FilMultiCodec, mh FilMultiHash, commX []byte) (cid.Cid, error)

CommitmentToCID converts a raw commitment hash to a CID by adding: - the given filecoin codec type - the given filecoin hash type

func DataCommitmentV1ToCID

func DataCommitmentV1ToCID(commD []byte) (cid.Cid, error)

DataCommitmentV1ToCID converts a raw data commitment to a CID by adding: - codec: cid.FilCommitmentUnsealed - hash type: multihash.SHA2_256_TRUNC254_PADDED

func ReplicaCommitmentV1ToCID

func ReplicaCommitmentV1ToCID(commR []byte) (cid.Cid, error)

ReplicaCommitmentV1ToCID converts a raw data commitment to a CID by adding: - codec: cid.FilCommitmentSealed - hash type: multihash.POSEIDON_BLS12_381_A1_FC1

Types

type FilMultiCodec

type FilMultiCodec uint64

FilMultiCodec is a uint64-sized type representing a Filecoin-specific codec

type FilMultiHash

type FilMultiHash uint64

FilMultiHash is a uint64-sized type representing a Filecoin-specific multihash

Jump to

Keyboard shortcuts

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