blob

package
v0.0.0-...-abe358f Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BlobDataSize = 131072

BlobDataSize is the standard size of a blob (128 KB)

View Source
const BytesPerFieldElement = 32

BytesPerFieldElement is the number of bytes per field element

View Source
const FieldElementsPerBlob = 4096

FieldElementsPerBlob is the number of field elements in a blob

View Source
const MaxBlobsPerTransaction = 6

MaxBlobsPerTransaction is the maximum number of blobs per transaction

Variables

This section is empty.

Functions

func CalculateBlobGasPrice

func CalculateBlobGasPrice(excessBlobGas uint64) *big.Int

CalculateBlobGasPrice calculates the blob gas price based on excess blob gas Formula: fake_exponential(MIN_BLOB_GASPRICE, excess_blob_gas, BLOB_GASPRICE_UPDATE_FRACTION)

func ComputeCommitment

func ComputeCommitment(blob *kzg4844.Blob) (kzg4844.Commitment, error)

ComputeCommitment computes the KZG commitment for a blob

func ComputeProof

func ComputeProof(blob *kzg4844.Blob, commitment kzg4844.Commitment) (kzg4844.Proof, error)

ComputeProof computes the KZG proof for a blob and commitment

func ComputeVersionedHash

func ComputeVersionedHash(commitment kzg4844.Commitment) common.Hash

ComputeVersionedHash computes the versioned hash from a commitment Format: sha256(commitment)[0] | 0x01

func EstimateBlobCost

func EstimateBlobCost(blobCount int, blobGasPrice *big.Int) (*big.Int, error)

EstimateBlobCost estimates the cost of blob gas for a transaction

func EstimateBlobGas

func EstimateBlobGas(blobCount int) (uint64, error)

EstimateBlobGas estimates the blob gas required for a transaction

func InitKZG

func InitKZG() error

InitKZG initializes the KZG library with trusted setup This must be called before any KZG operations

func ValidateBlobCount

func ValidateBlobCount(count int) error

ValidateBlobCount validates the number of blobs in a transaction

func ValidateBlobGasParameters

func ValidateBlobGasParameters(tx *types.Transaction, excessBlobGas uint64) error

ValidateBlobGasParameters validates blob gas related parameters

func ValidateBlobGasPrice

func ValidateBlobGasPrice(maxFeePerBlobGas *big.Int, excessBlobGas uint64) error

ValidateBlobGasPrice validates the blob gas price against current network conditions

func ValidateBlobSize

func ValidateBlobSize(data []byte) error

ValidateBlobSize validates the size of blob data

func ValidateKZGProof

func ValidateKZGProof(blobData *BlobData) error

ValidateKZGProof validates the KZG proof for blob data

func VerifyProof

func VerifyProof(blob *kzg4844.Blob, commitment kzg4844.Commitment, proof kzg4844.Proof) error

VerifyProof verifies a KZG proof for a blob and commitment

Types

type BlobData

type BlobData struct {
	// Raw data (up to 128 KB)
	Raw []byte

	// Standard blob format (128 KB, properly formatted for KZG)
	Blob kzg4844.Blob

	// KZG commitment to the blob
	Commitment kzg4844.Commitment

	// KZG proof for the commitment
	Proof kzg4844.Proof

	// Versioned hash (sha256(commitment)[0] | 0x01)
	VersionedHash common.Hash
}

BlobData represents a single blob with its cryptographic commitments

func BatchProcessBlobs

func BatchProcessBlobs(rawDataList [][]byte) ([]*BlobData, error)

BatchProcessBlobs processes multiple raw data chunks into BlobData structures

func GenerateBlob

func GenerateBlob(genType GeneratorType, size int) (*BlobData, error)

GenerateBlob generates a single blob with the specified generator and size

func GenerateBlobs

func GenerateBlobs(genType GeneratorType, count int, sizePerBlob int) ([]*BlobData, error)

GenerateBlobs generates multiple blobs

func GenerateRandomBlobs

func GenerateRandomBlobs(count int) ([]*BlobData, error)

GenerateRandomBlobs is a convenience function to generate random blobs

func ProcessBlobData

func ProcessBlobData(rawData []byte) (*BlobData, error)

ProcessBlobData processes raw data into a complete BlobData structure This includes computing the commitment, proof, and versioned hash

type BlobGasParams

type BlobGasParams struct {
	// Current excess blob gas
	ExcessBlobGas uint64

	// Current blob gas price
	BlobGasPrice uint64

	// Max fee per blob gas willing to pay
	MaxFeePerBlobGas uint64
}

BlobGasParams holds blob gas pricing parameters

type BlobTransaction

type BlobTransaction struct {
	// The transaction itself (Type 3)
	Tx *types.Transaction

	// Associated blob data (1-6 blobs)
	Blobs []*BlobData

	// Sidecar format for network transmission
	Sidecars []types.BlobTxSidecar
}

BlobTransaction represents a complete blob transaction with all sidecars

type Generator

type Generator interface {
	// Generate creates blob data of the specified size
	Generate(size int) ([]byte, error)

	// Type returns the generator type
	Type() GeneratorType
}

Generator defines the interface for blob data generators

func NewGenerator

func NewGenerator(genType GeneratorType) (Generator, error)

NewGenerator creates a new generator based on the specified type

type GeneratorType

type GeneratorType string

GeneratorType defines the type of blob data generator

const (
	// GeneratorRandom generates random blob data
	GeneratorRandom GeneratorType = "random"

	// GeneratorPattern generates patterned blob data (for testing)
	GeneratorPattern GeneratorType = "pattern"

	// GeneratorZero generates zero-filled blob data
	GeneratorZero GeneratorType = "zero"

	// GeneratorL2Data simulates L2 rollup data format
	GeneratorL2Data GeneratorType = "l2-data"
)

type L2DataGenerator

type L2DataGenerator struct {
	BatchNumber uint64
	TxCount     int
}

L2DataGenerator simulates L2 rollup data format

func (*L2DataGenerator) Generate

func (g *L2DataGenerator) Generate(size int) ([]byte, error)

func (*L2DataGenerator) Type

func (g *L2DataGenerator) Type() GeneratorType

type PatternGenerator

type PatternGenerator struct {
	Pattern []byte
}

PatternGenerator generates patterned blob data for testing

func (*PatternGenerator) Generate

func (g *PatternGenerator) Generate(size int) ([]byte, error)

func (*PatternGenerator) Type

func (g *PatternGenerator) Type() GeneratorType

type RandomGenerator

type RandomGenerator struct{}

RandomGenerator generates random blob data

func (*RandomGenerator) Generate

func (g *RandomGenerator) Generate(size int) ([]byte, error)

func (*RandomGenerator) Type

func (g *RandomGenerator) Type() GeneratorType

type ZeroGenerator

type ZeroGenerator struct{}

ZeroGenerator generates zero-filled blob data

func (*ZeroGenerator) Generate

func (g *ZeroGenerator) Generate(size int) ([]byte, error)

func (*ZeroGenerator) Type

func (g *ZeroGenerator) Type() GeneratorType

Jump to

Keyboard shortcuts

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