commitment

package
v0.0.4-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package commitment defines cryptographic commitment interfaces. Primitive backends in this package are restart-safe and do not rely on RAM-only state for correctness.

Package commitment defines abstract interfaces for cryptographic commitment schemes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidProof is returned when a cryptographic proof fails verification.
	ErrInvalidProof = errors.New("invalid proof")

	// ErrInvalidCommitment is returned when a commitment value is malformed or invalid.
	ErrInvalidCommitment = errors.New("invalid commitment")

	// ErrArcSetTooSmall is returned when the arc set has insufficient entries for the operation.
	ErrArcSetTooSmall = errors.New("arc set too small")
)

Sentinel errors for commitment operations.

Functions

func ExtractSortedPathsValues

func ExtractSortedPathsValues(arcs arcset.ArcSet) ([]string, []cid.Cid)

ExtractSortedPathsValues extracts sorted paths and values from an arc set. This is used when higher layers need a deterministic path-to-index mapping.

Types

type Cell

type Cell []byte

Cell is the opaque, canonically encoded value authenticated at one index. Semantic layers decide how to encode their state into cells; primitive backends only authenticate the resulting bytes.

func CellFromCID

func CellFromCID(value cid.Cid) Cell

CellFromCID encodes a CID-valued slot as a commitment cell.

func CloneCells

func CloneCells(values []Cell) []Cell

CloneCells deep-copies a cell slice.

func ExtractSortedPathsCells

func ExtractSortedPathsCells(arcs arcset.ArcSet) ([]string, []Cell)

ExtractSortedPathsCells extracts sorted paths and cell-encoded values from an arc set. CID-valued arcs are encoded as CID bytes.

func NewCell

func NewCell(data []byte) Cell

NewCell clones raw bytes into a new commitment cell.

func (Cell) AsCID

func (c Cell) AsCID() (cid.Cid, error)

AsCID decodes a CID-valued cell. Empty cells decode to cid.Undef.

func (Cell) Bytes

func (c Cell) Bytes() []byte

Bytes returns a cloned byte slice for the cell.

func (Cell) Defined

func (c Cell) Defined() bool

Defined reports whether the cell carries any bytes.

func (Cell) Equal

func (c Cell) Equal(other Cell) bool

Equal compares two cells.

type IndexCommitment

type IndexCommitment interface {
	// MaxValues returns the maximum number of authenticated values per root.
	MaxValues() int

	// Commit generates a commitment to a stable indexed cell vector.
	Commit(values []Cell) (cid.Cid, error)

	// Prove generates a proof for one index and returns the proved cell.
	Prove(values []Cell, index uint64) (root cid.Cid, value Cell, proof []byte, err error)

	// BatchProve generates one proof payload for an ordered index list and
	// returns the proved cells in the same order as indices.
	BatchProve(values []Cell, indices []uint64) (root cid.Cid, proved []Cell, proof []byte, err error)

	// VerifyIndex verifies a proof for one index against the expected cell.
	VerifyIndex(root cid.Cid, index uint64, value Cell, proof []byte) (bool, error)

	// BatchVerify verifies a proof payload for an ordered index list against
	// the expected cells in the same order as indices.
	BatchVerify(root cid.Cid, indices []uint64, values []Cell, proof []byte) (bool, error)

	// VerifyProof verifies a proof that already carries its own index metadata.
	VerifyProof(root cid.Cid, value Cell, proof []byte) (bool, error)

	// Replace performs an index-stable replacement and returns the new root.
	Replace(values []Cell, index uint64, oldValue, newValue Cell) (cid.Cid, error)
}

IndexCommitment is the semantic-neutral primitive interface for index-addressed authenticated values.

Directories

Path Synopsis
Package ipa provides an IPA (Inner Product Argument) commitment backend.
Package ipa provides an IPA (Inner Product Argument) commitment backend.
Package kzg provides a KZG polynomial commitment backend.
Package kzg provides a KZG polynomial commitment backend.

Jump to

Keyboard shortcuts

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