Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateSharesProofs(row, fromCol, toCol, size int, rowShares []libshare.Share) (*nmt.Proof, error)
- func ParseNamespace(rawShares [][]libshare.Share, startShare, endShare int) (libshare.Namespace, error)
- func RangeCoordsFromIdx(edsIndex, length, edsSize int) (SampleCoords, SampleCoords, error)
- func SampleCoordsAs1DIndex(idx SampleCoords, edsSize int) (int, error)
- func ShareFromProto(s *pb.Share) (libshare.Share, error)
- func SharesFromProto(shrs []*pb.Share) ([]libshare.Share, error)
- func SharesToProto(shrs []libshare.Share) []*pb.Share
- type Accessor
- type AxisHalf
- type EdsID
- func (eid EdsID) AppendBinary(data []byte) ([]byte, error)
- func (eid *EdsID) Equals(other EdsID) bool
- func (eid EdsID) Height() uint64
- func (eid EdsID) MarshalBinary() ([]byte, error)
- func (eid EdsID) Name() string
- func (eid *EdsID) ReadFrom(r io.Reader) (int64, error)
- func (eid EdsID) ResponseReader(_ context.Context, acc Accessor) (io.Reader, error)
- func (eid EdsID) Validate() error
- func (eid EdsID) WriteTo(w io.Writer) (int64, error)
- type Getter
- type NamespaceData
- type NamespaceDataID
- func (ndid NamespaceDataID) AppendBinary(data []byte) ([]byte, error)
- func (ndid *NamespaceDataID) Equals(other NamespaceDataID) bool
- func (ndid NamespaceDataID) MarshalBinary() ([]byte, error)
- func (ndid NamespaceDataID) Name() string
- func (ndid *NamespaceDataID) ReadFrom(r io.Reader) (int64, error)
- func (ndid NamespaceDataID) ResponseReader(ctx context.Context, acc Accessor) (io.Reader, error)
- func (ndid NamespaceDataID) Validate() error
- func (ndid NamespaceDataID) WriteTo(w io.Writer) (int64, error)
- type RangeNamespaceData
- func (rngdata *RangeNamespaceData) Flatten() []libshare.Share
- func (rngdata *RangeNamespaceData) IsEmpty() bool
- func (rngdata *RangeNamespaceData) ToProto() *pb.RangeNamespaceData
- func (rngdata *RangeNamespaceData) VerifyInclusion(from SampleCoords, to SampleCoords, odsSize int, roots [][]byte) error
- func (rngdata *RangeNamespaceData) VerifyNamespace(from SampleCoords, to SampleCoords, odsSize int, roots [][]byte) error
- type RangeNamespaceDataID
- func (rngid *RangeNamespaceDataID) Equals(other RangeNamespaceDataID) bool
- func (rngid RangeNamespaceDataID) MarshalBinary() ([]byte, error)
- func (rngid *RangeNamespaceDataID) ReadFrom(r io.Reader) (int64, error)
- func (rngid RangeNamespaceDataID) Validate() error
- func (rngid RangeNamespaceDataID) Verify(odsSize int) error
- func (rngid RangeNamespaceDataID) WriteTo(w io.Writer) (int64, error)
- type Row
- type RowID
- func (rid RowID) AppendBinary(data []byte) ([]byte, error)
- func (rid *RowID) Equals(other RowID) bool
- func (rid RowID) MarshalBinary() ([]byte, error)
- func (rid *RowID) ReadFrom(r io.Reader) (int64, error)
- func (rid RowID) Validate() error
- func (rid RowID) Verify(edsSize int) error
- func (rid RowID) WriteTo(w io.Writer) (int64, error)
- type RowNamespaceData
- func (rnd RowNamespaceData) IsEmpty() bool
- func (rnd *RowNamespaceData) ReadFrom(reader io.Reader) (int64, error)
- func (rnd RowNamespaceData) ToProto() *pb.RowNamespaceData
- func (rnd RowNamespaceData) Verify(roots *share.AxisRoots, namespace libshare.Namespace, rowIdx int) error
- func (rnd RowNamespaceData) WriteTo(writer io.Writer) (int64, error)
- type RowNamespaceDataID
- func (rndid RowNamespaceDataID) AppendBinary(data []byte) ([]byte, error)
- func (rndid *RowNamespaceDataID) Equals(other RowNamespaceDataID) bool
- func (rndid RowNamespaceDataID) MarshalBinary() ([]byte, error)
- func (rndid *RowNamespaceDataID) ReadFrom(r io.Reader) (int64, error)
- func (rndid RowNamespaceDataID) Validate() error
- func (rndid RowNamespaceDataID) Verify(edsSize int) error
- func (rndid RowNamespaceDataID) WriteTo(w io.Writer) (int64, error)
- type RowSide
- type Sample
- type SampleCoords
- type SampleID
- func (sid SampleID) AppendBinary(data []byte) ([]byte, error)
- func (sid *SampleID) Equals(other SampleID) bool
- func (sid SampleID) MarshalBinary() ([]byte, error)
- func (sid *SampleID) ReadFrom(r io.Reader) (int64, error)
- func (sid SampleID) Validate() error
- func (sid SampleID) Verify(edsSize int) error
- func (sid SampleID) WriteTo(w io.Writer) (int64, error)
Constants ¶
const EdsIDSize = 8
EdsIDSize defines the byte size of the EdsID.
const NamespaceDataIDSize = EdsIDSize + libshare.NamespaceSize
NamespaceDataIDSize defines the total size of a NamespaceDataID in bytes, combining the size of a EdsID and the size of a Namespace.
const RangeNamespaceDataIDSize = EdsIDSize + 4
RangeNamespaceDataIDSize defines the size of the RangeNamespaceDataIDSize in bytes, combining EdsIDSize size and 4 additional bytes for the start and end ODS indexes of share of the range.
const RowIDSize = EdsIDSize + 2
RowIDSize defines the size in bytes of RowID, consisting of the size of EdsID and 2 bytes for RowIndex.
const RowName = "row_v0"
RowName is the name identifier for the row container.
const RowNamespaceDataIDSize = RowIDSize + libshare.NamespaceSize
RowNamespaceDataIDSize defines the total size of a RowNamespaceDataID in bytes, combining the size of a RowID and the size of a Namespace.
const RowNamespaceDataName = "rnd_v0"
RowNamespaceDataName is the name identifier for the row namespace data container.
const SampleIDSize = RowIDSize + 2
SampleIDSize defines the size of the SampleID in bytes, combining RowID size and 2 additional bytes for the ShareIndex.
const SampleName = "sample_v0"
SampleName is the name identifier for the sample container.
Variables ¶
var ( // ErrOperationNotSupported is used to indicate that the operation is not supported by the // implementation of the getter interface. ErrOperationNotSupported = errors.New("operation is not supported") // ErrNotFound is used to indicate that requested data could not be found. ErrNotFound = errors.New("data not found") // ErrInvalidID is used to indicate that an ID failed validation. ErrInvalidID = errors.New("invalid shwap ID") // ErrOutOfBounds is used to indicate that a passed row or column index is out of bounds of the // square size. ErrOutOfBounds = fmt.Errorf("index out of bounds: %w", ErrInvalidID) // ErrNoSampleIndicies is used to indicate that no indicies where given to process. ErrNoSampleIndicies = errors.New("no sample indicies to fetch") )
var ErrFailedVerification = errors.New("failed to verify inclusion")
ErrFailedVerification is returned when inclusion proof verification fails. It is returned when the data and the proof do not match trusted data root.
var ErrNamespaceOutsideRange = errors.New("target namespace is outside of namespace range for the given root")
ErrNamespaceOutsideRange is returned by RowNamespaceDataFromShares when the target namespace is outside of the namespace range for the given row. In this case, the implementation cannot return the non-inclusion proof and will return ErrNamespaceOutsideRange.
Functions ¶
func GenerateSharesProofs ¶ added in v0.25.3
func GenerateSharesProofs( row, fromCol, toCol, size int, rowShares []libshare.Share, ) (*nmt.Proof, error)
GenerateSharesProofs generates a nmt proof for a range of shares within a specific row. It builds a Namespaced Merkle Tree from the provided row shares and creates a proof that the shares in the specified column range are valid
Parameters:
- row: the row index in the data square
- fromCol: the starting column index (inclusive) for the proof range
- toCol: the ending column index (exclusive) for the proof range
- size: the size of the original data in th row.
- rowShares: slice of shares representing the complete row data
Returns a nmt proof that can be used to verify that shares in were included in the specified row.
Returns an error if:
- tree construction fails when pushing any share
- proof generation fails for the specified range.
func ParseNamespace ¶ added in v0.25.3
func ParseNamespace(rawShares [][]libshare.Share, startShare, endShare int) (libshare.Namespace, error)
ParseNamespace validates the share range, checks if it only contains one namespace and returns that namespace. The provided range, defined by startShare and endShare, is end-exclusive.
func RangeCoordsFromIdx ¶ added in v0.25.3
func RangeCoordsFromIdx(edsIndex, length, edsSize int) (SampleCoords, SampleCoords, error)
RangeCoordsFromIdx accepts the start index and the length of the range and computes `shwap.SampleCoords` of the first and the last sample of this range. * edsIndex is the index of the first sample inside the eds; * length is the amount of *ORIGINAL* samples that are expected to get(including the first sample);
func SampleCoordsAs1DIndex ¶ added in v0.20.4
func SampleCoordsAs1DIndex(idx SampleCoords, edsSize int) (int, error)
func ShareFromProto ¶
ShareFromProto converts a protobuf Share object to the application's internal share representation. It returns nil if the input protobuf Share is nil, ensuring safe handling of nil values.
func SharesFromProto ¶
SharesFromProto converts a slice of protobuf Share objects to the application's internal slice of Shares. It ensures that each Share is correctly transformed using the ShareFromProto function.
Types ¶
type Accessor ¶ added in v0.26.4
type Accessor interface {
AxisRoots(context.Context) (*share.AxisRoots, error)
RowNamespaceData(context.Context, libshare.Namespace, int) (RowNamespaceData, error)
Reader() (io.Reader, error)
}
Accessor is used to access the data from the shwap containers.
type AxisHalf ¶ added in v0.26.4
type AxisHalf struct {
// IsParity indicates whether the half is parity or data.
IsParity bool
}
AxisHalf represents a half of data for a row or column in the EDS.
type EdsID ¶
type EdsID struct {
// contains filtered or unexported fields
}
EdsID represents a unique identifier for a row, using the height of the block to identify the data square in the chain.
func EdsIDFromBinary ¶
EdsIDFromBinary decodes a byte slice into an EdsID, validating the length of the data. It returns an error if the data slice does not match the expected size of an EdsID.
func (EdsID) AppendBinary ¶ added in v0.21.9
AppendBinary helps in the binary encoding of EdsID by appending the binary form of Height to the given byte slice.
func (EdsID) MarshalBinary ¶
MarshalBinary encodes an EdsID into its binary form, primarily for storage or network transmission.
func (EdsID) ResponseReader ¶ added in v0.26.4
type Getter ¶
type Getter interface {
// GetSamples retrieves multiple shares from the Extended Data Square (EDS) at the specified
// coordinates. The coordinates are provided as a slice of SampleCoords, and the method returns
// a slice of samples in the same order as the requested coordinates. If some samples cannot be
// found, the corresponding positions in the returned slice will be empty, but the method will
// still return the available samples without error.
GetSamples(
ctx context.Context,
header *header.ExtendedHeader,
indices []SampleCoords,
) ([]Sample, error)
// GetEDS retrieves the complete Extended Data Square (EDS) identified by the given header.
// The EDS contains all shares organized in a 2D matrix format with erasure coding.
// This method is useful when full access to all shares in the square is required.
GetEDS(
ctx context.Context,
header *header.ExtendedHeader,
) (*rsmt2d.ExtendedDataSquare, error)
// GetRow retrieves all shares from a specific row in the Extended Data Square (EDS).
// The row is identified by its index (rowIdx) and the header. This method is useful
// for operations that need to process all shares in a particular row of the EDS.
GetRow(
ctx context.Context,
header *header.ExtendedHeader,
rowIdx int,
) (Row, error)
// GetNamespaceData retrieves all shares that belong to the specified namespace within
// the Extended Data Square (EDS). The shares are returned in a row-by-row order,
// maintaining the original layout if the namespace spans multiple rows. The returned
// data can be verified for inclusion using the Verify method on NamespacedShares.
// If no shares are found for the target namespace, non-inclusion can be verified
// using the same Verify method.
GetNamespaceData(
ctx context.Context,
header *header.ExtendedHeader,
namespace libshare.Namespace,
) (NamespaceData, error)
// GetRangeNamespaceData retrieves a range of shares within a specific namespace in the
// Extended Data Square (EDS). The range is defined by from and to indexes, which
// specify the start and end points of the desired range, where `from` is inclusive
// and `to` is exclusive indexes. The shares are returned in a row-by-row order
// if the range spans multiple rows.
GetRangeNamespaceData(
ctx context.Context,
header *header.ExtendedHeader,
from, to int,
) (RangeNamespaceData, error)
}
Getter interface provides a set of accessors for shares by the Root. Automatically verifies integrity of shares(exceptions possible depending on the implementation).
type NamespaceData ¶
type NamespaceData []RowNamespaceData
NamespaceData stores collections of RowNamespaceData, each representing shares and their proofs within a namespace. NOTE: NamespaceData does not have it protobuf Container representation and its only *streamed* as RowNamespaceData. The protobuf might be added as need comes.
func (NamespaceData) Flatten ¶
func (nd NamespaceData) Flatten() []libshare.Share
Flatten combines all shares from all rows within the namespace into a single slice.
func (*NamespaceData) ReadFrom ¶
func (nd *NamespaceData) ReadFrom(reader io.Reader) (int64, error)
ReadFrom reads NamespaceData from the provided reader implementing io.ReaderFrom. It reads series of length-delimited RowNamespaceData until EOF draining the stream.
type NamespaceDataID ¶
type NamespaceDataID struct {
// Embedding EdsID to include the block height.
EdsID
// DataNamespace will be used to identify the data within the EDS.
DataNamespace libshare.Namespace
}
NamespaceDataID filters the data in the EDS by a specific namespace.
func NamespaceDataIDFromBinary ¶
func NamespaceDataIDFromBinary(data []byte) (NamespaceDataID, error)
NamespaceDataIDFromBinary deserializes a NamespaceDataID from its binary form. It returns an error if the binary data's length does not match the expected size.
func NewNamespaceDataID ¶
func NewNamespaceDataID(height uint64, namespace libshare.Namespace) (NamespaceDataID, error)
NewNamespaceDataID creates a new NamespaceDataID with the specified parameters. It validates the namespace and returns an error if it is invalid.
func (NamespaceDataID) AppendBinary ¶ added in v0.21.9
func (ndid NamespaceDataID) AppendBinary(data []byte) ([]byte, error)
AppendBinary helps in appending the binary form of DataNamespace to the serialized RowID data.
func (*NamespaceDataID) Equals ¶
func (ndid *NamespaceDataID) Equals(other NamespaceDataID) bool
Equals checks equality of NamespaceDataID.
func (NamespaceDataID) MarshalBinary ¶
func (ndid NamespaceDataID) MarshalBinary() ([]byte, error)
MarshalBinary encodes NamespaceDataID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (NamespaceDataID) Name ¶ added in v0.26.4
func (ndid NamespaceDataID) Name() string
func (*NamespaceDataID) ReadFrom ¶
func (ndid *NamespaceDataID) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads the binary form of NamespaceDataID from the provided reader.
func (NamespaceDataID) ResponseReader ¶ added in v0.26.4
func (NamespaceDataID) Validate ¶
func (ndid NamespaceDataID) Validate() error
Validate checks if the NamespaceDataID is valid. It checks the validity of the EdsID and the DataNamespace.
type RangeNamespaceData ¶ added in v0.25.3
type RangeNamespaceData struct {
FirstIncompleteRowProof *nmt.Proof `json:"first_row_proof,omitempty"`
LastIncompleteRowProof *nmt.Proof `json:"last_row_proof,omitempty"`
}
RangeNamespaceData represents a contiguous segment of shares from an original part of the data square (ODS) that belong to a specific namespace. It encapsulates both the share data and the cryptographic proofs for the incomplete rows necessary to verify the shares' inclusion to the respective row roots.
This structure is typically constructed using RangeNamespaceDataFromShares, which extracts a rectangular subset of shares from the EDS and populates minimal proof information.
Fields:
- Shares: A 2D slice of shares where each inner slice represents a row. The shares must all belong to the same namespace and fall within the [from, to] coordinate range.
- FirstIncompleteRowProof: A Proof object (contains proofs for the first row of a data range)
- LastIncompleteRowProof: A Proof object (contains proofs for the last row of a data range)
Notes:
- Consumers of this struct should ensure that Verify() is called to validate the data against the respective row roots using the populated or generated proofs.
- This structure is commonly used in blob availability proofs, light client verification, and namespace-scoped retrieval over the shwap or DAS interfaces.
- FirstIncompleteRowProof, LastIncompleteRowProof can be empty
func RangeNamespaceDataFromProto ¶ added in v0.25.3
func RangeNamespaceDataFromProto(nd *pb.RangeNamespaceData) (RangeNamespaceData, error)
func RangeNamespaceDataFromShares ¶ added in v0.25.3
func RangeNamespaceDataFromShares( extendedRowShares [][]libshare.Share, from, to SampleCoords, ) (RangeNamespaceData, error)
RangeNamespaceDataFromShares constructs a RangeNamespaceData structure from a selection of namespaced shares within an ODS.
Parameters:
- shares: A 2D slice of shares grouped by rows (each inner slice represents a row). These shares should cover the range between the 'from' and 'to' coordinates, inclusive.
- from: The starting coordinate (row, column) of the range within the ODS.
- to: The ending coordinate (row, column) of the range (inclusive).
Returns:
- A RangeNamespaceData containing the shares and Merkle proofs for the incomplete rows.
- An error if the range is invalid or extraction fails.
func (*RangeNamespaceData) Flatten ¶ added in v0.25.3
func (rngdata *RangeNamespaceData) Flatten() []libshare.Share
Flatten returns a single slice containing all shares from all rows within the namespace.
If the RangeNamespaceData is empty (i.e., contains no shares), Flatten returns nil. Otherwise, it returns a flattened slice of libshare.Share combining shares from all rows.
func (*RangeNamespaceData) IsEmpty ¶ added in v0.25.3
func (rngdata *RangeNamespaceData) IsEmpty() bool
func (*RangeNamespaceData) ToProto ¶ added in v0.25.3
func (rngdata *RangeNamespaceData) ToProto() *pb.RangeNamespaceData
func (*RangeNamespaceData) VerifyInclusion ¶ added in v0.25.3
func (rngdata *RangeNamespaceData) VerifyInclusion( from SampleCoords, to SampleCoords, odsSize int, roots [][]byte, ) error
VerifyInclusion checks whether the shares stored within the RangeNamespaceData (`rngdata.Shares`) are valid and provably included in the provided rowRoots.
func (*RangeNamespaceData) VerifyNamespace ¶ added in v0.25.3
func (rngdata *RangeNamespaceData) VerifyNamespace( from SampleCoords, to SampleCoords, odsSize int, roots [][]byte, ) error
VerifyNamespace checks whether the shares stored within the RangeNamespaceData (`rngdata.Shares`) are valid and provably included in the provided rowRoots. It does exactly the same as `VerifyInclusion` with 1 extra condition: it checks whether the provided data are complete under the namespace.
type RangeNamespaceDataID ¶ added in v0.25.3
type RangeNamespaceDataID struct {
EdsID
// From specifies the index of the first share in the range.
From int
// To specifies the index of the last share in the range(exclusively).
To int
}
RangeNamespaceDataID uniquely identifies a continuous range of shares within an Original DataSquare (ODS) The range is defined by the indexes of the first (`From`) and last (`To`) (exclusively) shares in the range. This struct is used to reference and verify a subset of shares (e.g., for a blob or a namespace proof) within the ODS.
Fields:
- EdsID: to identify the height
- From: The index of the first share in the range.
- To: The index of the last share in the range(exclusively).
Example usage:
id := RangeNamespaceDataID{
EdsID: ...,
From: 0,
To: 4,
}
func NewRangeNamespaceDataID ¶ added in v0.25.3
func NewRangeNamespaceDataID( edsID EdsID, from, to, odsSize int, ) (RangeNamespaceDataID, error)
func RangeNamespaceDataIDFromBinary ¶ added in v0.25.3
func RangeNamespaceDataIDFromBinary(data []byte) (RangeNamespaceDataID, error)
RangeNamespaceDataIDFromBinary deserializes a RangeNamespaceDataID from its binary form.
func (*RangeNamespaceDataID) Equals ¶ added in v0.25.3
func (rngid *RangeNamespaceDataID) Equals(other RangeNamespaceDataID) bool
Equals checks equality of RangeNamespaceDataID.
func (RangeNamespaceDataID) MarshalBinary ¶ added in v0.25.3
func (rngid RangeNamespaceDataID) MarshalBinary() ([]byte, error)
MarshalBinary encodes RangeNamespaceDataID into binary form.
func (*RangeNamespaceDataID) ReadFrom ¶ added in v0.25.3
func (rngid *RangeNamespaceDataID) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads the binary form of RangeNamespaceDataID from the provided reader.
func (RangeNamespaceDataID) Validate ¶ added in v0.25.3
func (rngid RangeNamespaceDataID) Validate() error
Validate performs basic fields validation.
func (RangeNamespaceDataID) Verify ¶ added in v0.25.3
func (rngid RangeNamespaceDataID) Verify(odsSize int) error
Verify validates the RangeNamespaceDataID fields and verifies that number of the requested shares does not exceed the number of shares inside the ODS.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row represents a portion of a row in an EDS, either left or right half.
func RowFromEDS ¶ added in v0.21.5
RowFromEDS constructs a new Row from an EDS based on the specified row index and side.
func RowFromProto ¶
RowFromProto converts a protobuf Row to a Row structure.
func (Row) MarshalJSON ¶ added in v0.21.5
MarshalJSON encodes row to the json encoded bytes.
func (*Row) Shares ¶
Shares reconstructs the complete row shares from the half provided, using RSMT2D for data recovery if needed. It caches the reconstructed shares for future use and converts Row to Both side.
func (*Row) UnmarshalJSON ¶ added in v0.21.5
UnmarshalJSON decodes json bytes to the row.
type RowID ¶
type RowID struct {
EdsID // Embedding EdsID to include the block height in RowID.
RowIndex int // RowIndex specifies the position of the row within the data share.
}
RowID uniquely identifies a row in the data square of a blockchain block, combining block height with the row's index.
func NewRowID ¶
NewRowID creates a new RowID with the specified block height, row index, and EDS size. It returns an error if the validation fails, ensuring the RowID conforms to expected constraints.
func RowIDFromBinary ¶
RowIDFromBinary decodes a RowID from its binary representation. It returns an error if the input data does not conform to the expected size or content format.
func (RowID) AppendBinary ¶ added in v0.21.9
AppendBinary assists in binary encoding of RowID by appending the encoded fields to the given byte slice.
func (RowID) MarshalBinary ¶
MarshalBinary encodes the RowID into a binary form for storage or network transmission.
type RowNamespaceData ¶
type RowNamespaceData struct {
Proof *nmt.Proof `json:"proof"` // Proof of the shares' inclusion in the namespace.
}
RowNamespaceData holds shares and their corresponding proof for a single row within a namespace.
func RowNamespaceDataFromProto ¶
func RowNamespaceDataFromProto(row *pb.RowNamespaceData) (RowNamespaceData, error)
RowNamespaceDataFromProto constructs RowNamespaceData out of its protobuf representation.
func RowNamespaceDataFromShares ¶
func RowNamespaceDataFromShares( shares []libshare.Share, namespace libshare.Namespace, rowIndex int, ) (RowNamespaceData, error)
RowNamespaceDataFromShares extracts and constructs a RowNamespaceData from shares within the specified namespace.
func (RowNamespaceData) IsEmpty ¶
func (rnd RowNamespaceData) IsEmpty() bool
IsEmpty reports whether the RowNamespaceData is empty, i.e. doesn't contain a proof.
func (*RowNamespaceData) ReadFrom ¶
func (rnd *RowNamespaceData) ReadFrom(reader io.Reader) (int64, error)
ReadFrom reads length-delimited protobuf representation of RowNamespaceData implementing io.ReaderFrom.
func (RowNamespaceData) ToProto ¶
func (rnd RowNamespaceData) ToProto() *pb.RowNamespaceData
ToProto converts RowNamespaceData to its protobuf representation for serialization.
type RowNamespaceDataID ¶
type RowNamespaceDataID struct {
RowID // Embedded RowID representing the specific row in the EDS.
// DataNamespace is used to facilitate comparisons.
DataNamespace libshare.Namespace
}
RowNamespaceDataID uniquely identifies a piece of namespaced data within a row of an Extended Data Square (EDS).
func NewRowNamespaceDataID ¶
func NewRowNamespaceDataID( height uint64, rowIdx int, namespace libshare.Namespace, edsSize int, ) (RowNamespaceDataID, error)
NewRowNamespaceDataID creates a new RowNamespaceDataID with the specified parameters. It validates the RowNamespaceDataID against the provided EDS size.
func RowNamespaceDataIDFromBinary ¶
func RowNamespaceDataIDFromBinary(data []byte) (RowNamespaceDataID, error)
RowNamespaceDataIDFromBinary deserializes a RowNamespaceDataID from its binary form. It returns an error if the binary data's length does not match the expected size.
func (RowNamespaceDataID) AppendBinary ¶ added in v0.21.9
func (rndid RowNamespaceDataID) AppendBinary(data []byte) ([]byte, error)
AppendBinary helps in appending the binary form of DataNamespace to the serialized RowID data.
func (*RowNamespaceDataID) Equals ¶
func (rndid *RowNamespaceDataID) Equals(other RowNamespaceDataID) bool
Equals checks equality of RowNamespaceDataID.
func (RowNamespaceDataID) MarshalBinary ¶
func (rndid RowNamespaceDataID) MarshalBinary() ([]byte, error)
MarshalBinary encodes RowNamespaceDataID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (*RowNamespaceDataID) ReadFrom ¶
func (rndid *RowNamespaceDataID) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads the binary form of RowNamespaceDataID from the provided reader.
func (RowNamespaceDataID) Validate ¶
func (rndid RowNamespaceDataID) Validate() error
Validate performs basic field validation.
func (RowNamespaceDataID) Verify ¶
func (rndid RowNamespaceDataID) Verify(edsSize int) error
Verify validates the RowNamespaceDataID and verifies the embedded RowID.
type RowSide ¶
type RowSide int
RowSide enumerates the possible sides of a row within an Extended Data Square (EDS).
func (RowSide) ToProto ¶
func (s RowSide) ToProto() pb.Row_HalfSide
ToProto converts a RowSide to its protobuf representation.
type Sample ¶
type Sample struct {
Proof *nmt.Proof // Proof is the Merkle Proof validating the share's inclusion.
ProofType rsmt2d.Axis // ProofType indicates whether the proof is against a row or a column.
}
Sample represents a data share along with its Merkle proof, used to validate the share's inclusion in a data square.
func SampleFromProto ¶
SampleFromProto converts a protobuf Sample back into its domain model equivalent.
func SampleFromShares ¶
func SampleFromShares(shares []libshare.Share, proofType rsmt2d.Axis, idx SampleCoords) (Sample, error)
SampleFromShares creates a Sample from a list of shares, using the specified proof type and the share index to be included in the sample.
func (Sample) MarshalJSON ¶ added in v0.21.5
MarshalJSON encodes sample to the json encoded bytes.
func (Sample) ToProto ¶
ToProto converts a Sample into its protobuf representation for serialization purposes.
func (*Sample) UnmarshalJSON ¶ added in v0.21.5
UnmarshalJSON decodes bytes to the Sample.
type SampleCoords ¶ added in v0.20.4
func SampleCoordsFrom1DIndex ¶ added in v0.20.4
func SampleCoordsFrom1DIndex(idx, squareSize int) (SampleCoords, error)
func (SampleCoords) String ¶ added in v0.25.3
func (s SampleCoords) String() string
type SampleID ¶
type SampleID struct {
RowID // Embeds RowID to incorporate block height and row index.
}
SampleID uniquely identifies a specific sample within a row of an Extended Data Square (EDS).
func NewSampleID ¶
func NewSampleID(height uint64, idx SampleCoords, edsSize int) (SampleID, error)
NewSampleID constructs a new SampleID using the provided block height, sample index, and EDS size. It calculates the row and share index based on the sample index and EDS size.
func SampleIDFromBinary ¶
SampleIDFromBinary deserializes a SampleID from binary data, ensuring the data length matches the expected size.
func (SampleID) AppendBinary ¶ added in v0.21.9
AppendBinary helps in constructing the binary representation by appending the encoded ShareIndex to the serialized RowID.
func (SampleID) MarshalBinary ¶
MarshalBinary encodes SampleID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
|
p2p
|
|
|
shrex
Package shrex provides functionality that powers the share exchange protocols used by celestia-node.
|
Package shrex provides functionality that powers the share exchange protocols used by celestia-node. |
|
shrex/peers
Package peers provides a peer manager that handles peer discovery and peer selection for the shrex getter.
|
Package peers provides a peer manager that handles peer discovery and peer selection for the shrex getter. |
|
shrex/shrexsub
This package defines a protocol that is used to broadcast shares to peers over a pubsub network.
|
This package defines a protocol that is used to broadcast shares to peers over a pubsub network. |