Documentation ¶
Overview ¶
Package commcid provides helpers to convert between Piece/Data/Replica Commitments and their CID representation
Index ¶
- Constants
- Variables
- func CIDToCommitment(c cid.Cid) (FilMultiCodec, FilMultiHash, []byte, error)
- func CIDToDataCommitmentV1(c cid.Cid) ([]byte, error)
- func CIDToReplicaCommitmentV1(c cid.Cid) ([]byte, error)
- func CommitmentToCID(mc FilMultiCodec, mh FilMultiHash, commX []byte) (cid.Cid, error)
- func DataCommitmentV1ToCID(commD []byte) (cid.Cid, error)
- func ReplicaCommitmentV1ToCID(commR []byte) (cid.Cid, error)
- type FilMultiCodec
- type FilMultiHash
Constants ¶
const FILCODEC_UNDEFINED = FilMultiCodec(0)
FILCODEC_UNDEFINED is just a signifier for "no codec determined
const FILMULTIHASH_UNDEFINED = FilMultiHash(0)
FILMULTIHASH_UNDEFINED is a signifier for "no multihash etermined"
Variables ¶
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") )
var CIDToPieceCommitmentV1 = CIDToDataCommitmentV1
CIDToPieceCommitmentV1 converts a CID to a commP -- it is just a helper function that is equivalent to CIDToDataCommitmentV1.
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 ¶
CIDToDataCommitmentV1 extracts the raw data commitment from a CID after checking for the correct codec and hash types.
func CIDToReplicaCommitmentV1 ¶
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 ¶
DataCommitmentV1ToCID converts a raw data commitment to a CID by adding: - codec: cid.FilCommitmentUnsealed - hash type: multihash.SHA2_256_TRUNC254_PADDED
func ReplicaCommitmentV1ToCID ¶
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