Skip to content
celestiaorgPublic

About

Go implementation of two dimensional Reed-Solomon merkle tree data availability scheme.

Resources

Contributing

Security policy

Stars

169 stars

Watchers

8 watching

Forks

Latest commit

 

History

405 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rsmt2d

Go implementation of two dimensional Reed-Solomon Merkle tree data availability scheme.

Tests Codecov GoDoc

Example

package main

import (
    "bytes"

    "github.com/celestiaorg/rsmt2d"
)

func main() {
    // shareSize is the size of each share (in bytes).
    shareSize := 512
    // Init new codec
    codec := rsmt2d.NewLeoRSCodec()

    ones := bytes.Repeat([]byte{1}, shareSize)
    twos := bytes.Repeat([]byte{2}, shareSize)
    threes := bytes.Repeat([]byte{3}, shareSize)
    fours := bytes.Repeat([]byte{4}, shareSize)

    // Compute parity shares
    eds, err := rsmt2d.ComputeExtendedDataSquare(
        [][]byte{
            ones, twos,
            threes, fours,
        },
        codec,
        rsmt2d.NewDefaultTree,
    )
    if err != nil {
        // ComputeExtendedDataSquare failed
    }

    rowRoots, err := eds.RowRoots()
    if err != nil {
    // RowRoots failed
    }
    colRoots, err := eds.ColRoots()
    if err != nil {
    // ColRoots failed
    }

    flattened := eds.Flattened()

    // Delete some shares, just enough so that repairing is possible.
    flattened[0], flattened[2], flattened[3] = nil, nil, nil
    flattened[4], flattened[5], flattened[6], flattened[7] = nil, nil, nil, nil
    flattened[8], flattened[9], flattened[10] = nil, nil, nil
    flattened[12], flattened[13] = nil, nil

    // Re-import the data square.
    eds, err = rsmt2d.ImportExtendedDataSquare(flattened, codec, rsmt2d.NewDefaultTree)
    if err != nil {
        // ImportExtendedDataSquare failed
    }

    // Repair square.
    err = eds.Repair(
        rowRoots,
        colRoots,
    )
    if err != nil {
        // err contains information to construct a fraud proof
        // See extendeddatacrossword_test.go
    }
}

Contributing

PR titles follow conventional commits and must start the subject with [high], [medium], or [low] to indicate the review thoroughness needed. For example: fix!: [high] correct repair of byzantine rows or docs: [low] clarify codec usage. Include the same tag in the PR description and explain why you chose it.

  • [high]: Deep review for consensus, security, or other changes with significant risk, e.g. erasure coding/codecs, extended data square construction, repair, or root computation.
  • [medium]: Standard review for code changes with limited impact and well-understood behavior.
  • [low]: Focused review for straightforward docs, tests, or tooling changes with low risk.

Choose the higher level when unsure. A small diff can still need deep review. CI checks the title format; reviewers should confirm the chosen level. Dependabot defaults to [high] for Go dependencies and [medium] for GitHub Actions. The required review policy documents how the tier sets the number of independent approvals.

  1. Install Go 1.24+
  2. Install golangci-lint

Helpful Commands

# Build the project
make build

# Run unit tests
make test

# Run benchmarks
make bench

# Run each fuzz target for 30s (override with FUZZTIME=5m)
make fuzz

# Run linter
make lint

Fuzzing

make fuzz runs each native Go fuzz target for FUZZTIME (default 30s). The fuzz workflow runs every target for 60s on pull requests and pushes, and for 10m nightly. A crashing input can describe an exploitable bug, so outside pull requests the workflow prints only PASS or FAIL. Outside pull requests, a failing target files a PROTOCO Linear issue (or comments on the open one) with the output and the complete crashing corpus file. This needs the LINEAR_API_KEY repository secret. To reproduce, save that file as testdata/fuzz/<target>/<name> and run go test -run '^<target>$' .. Keep crash details out of public PRs and issues.

Audits

Informal Systems audited rsmt2d v0.9.0 in Q2 of 2023. See informal-systems.pdf.

About

Go implementation of two dimensional Reed-Solomon merkle tree data availability scheme.

Resources

Contributing

Security policy

Stars

169 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages