verify

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BytesPerSymbol     = 31
	MaxCodingRatio     = 8
	SrsOrder           = 1 << 28 // 2^28
	MaxAllowedBlobSize = uint64(SrsOrder * BytesPerSymbol / MaxCodingRatio)
)
View Source
const (
	HoleskySVCManagerV1Address = "0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
)

Variables

View Source
var (
	// cert verification flags
	CertVerificationDisabledFlagName = withFlagPrefix("cert-verification-disabled")

	// kzg flags
	G1PathFlagName         = withFlagPrefix("g1-path")
	G2PowerOf2PathFlagName = withFlagPrefix("g2-power-of-2-path")
	CachePathFlagName      = withFlagPrefix("cache-path")
	MaxBlobLengthFlagName  = withFlagPrefix("max-blob-length")
)
View Source
var (
	// cert verification flags
	DeprecatedCertVerificationEnabledFlagName = withDeprecatedFlagPrefix("cert-verification-enabled")
	DeprecatedEthRPCFlagName                  = withDeprecatedFlagPrefix("eth-rpc")
	DeprecatedSvcManagerAddrFlagName          = withDeprecatedFlagPrefix("svc-manager-addr")
	DeprecatedEthConfirmationDepthFlagName    = withDeprecatedFlagPrefix("eth-confirmation-depth")

	// kzg flags
	DeprecatedG1PathFlagName        = withDeprecatedFlagPrefix("g1-path")
	DeprecatedG2TauFlagName         = withDeprecatedFlagPrefix("g2-tau-path")
	DeprecatedCachePathFlagName     = withDeprecatedFlagPrefix("cache-path")
	DeprecatedMaxBlobLengthFlagName = withDeprecatedFlagPrefix("max-blob-length")
)

TODO: we should also upstream these deprecated flags into the eigenda client if we upstream the changes before removing the deprecated flags

View Source
var MaxBlobLengthBytes uint64

MaxBlobLengthBytes ... there's def a better way to deal with this... perhaps a generic flag that can parse the string into a uint64? this var is set by the action in the MaxBlobLengthFlagName flag

Functions

func CLIFlags added in v1.5.0

func CLIFlags(envPrefix, category string) []cli.Flag

CLIFlags ... used for Verifier configuration category is used to group the flags in the help output (see https://cli.urfave.org/v2/examples/flags/#grouping)

func DeprecatedCLIFlags added in v1.5.0

func DeprecatedCLIFlags(envPrefix, category string) []cli.Flag

CLIFlags ... used for Verifier configuration category is used to group the flags in the help output (see https://cli.urfave.org/v2/examples/flags/#grouping)

func HashBatchHashedMetadata added in v1.1.1

func HashBatchHashedMetadata(batchHeaderHash [32]byte, signatoryRecordHash [32]byte, blockNumber uint32) (geth_common.Hash, error)

HashBatchHashedMetadata hashes the given metadata into the commitment that will be stored in the contract replicates: https://github.com/Layr-Labs/eigenda-utils/blob/c4cbc9ec078aeca3e4a04bd278e2fb136bf3e6de/src/libraries/EigenDAHasher.sol#L19-L25

func HashBatchMetadata added in v1.1.1

func HashBatchMetadata(bh *binding.IEigenDAServiceManagerBatchHeader, sigHash [32]byte, blockNum uint32) (geth_common.Hash, error)

HashBatchMetadata regenerates a batch data hash replicates: https://github.com/Layr-Labs/eigenda-utils/blob/c4cbc9ec078aeca3e4a04bd278e2fb136bf3e6de/src/libraries/EigenDAHasher.sol#L46-L54

func HashBlobHeader added in v1.1.1

func HashBlobHeader(blobHeader BlobHeader) (geth_common.Hash, error)

HashBlobHeader function to hash BlobHeader

func HashEncodeBlobHeader added in v1.1.1

func HashEncodeBlobHeader(header BlobHeader) (geth_common.Hash, error)

Function to hash and encode header

func ProcessInclusionProof added in v1.1.1

func ProcessInclusionProof(proof []byte, leaf common.Hash, index uint64) (common.Hash, error)

ProcessInclusionProof computes the merkle root hash based on the provided leaf and proof, returning the result. An error is returned if the proof param is malformed.

index is the index of the leaf in the tree, starting from the bottom left of the tree at 0.

If the proof length is 0, then the leaf hash is returned.

NOTE: this method returning a nil error does NOT indicate that the proof is valid. Rather, it merely indicates that the proof was well-formed. The hash returned by this method must be compared to the claimed root hash, to determine if the proof is valid.

This method is a reimplementation of the on-chain verification method [processInclusionProofKeccak] (https://github.com/Layr-Labs/eigenlayer-contracts/blob/dev/src/contracts/libraries/Merkle.sol#L49-L76)

Types

type BlobHeader added in v1.2.0

type BlobHeader struct {
	Commitment       G1Point
	DataLength       uint32
	QuorumBlobParams []QuorumBlobParam
}

BlobHeader struct to represent BlobHeader in Solidity

type CertVerifier added in v1.1.1

type CertVerifier struct {
	// contains filtered or unexported fields
}

CertVerifier verifies the DA certificate against on-chain EigenDA contracts to ensure disperser returned fields haven't been tampered with

func NewCertVerifier added in v1.1.1

func NewCertVerifier(cfg *Config, l log.Logger) (*CertVerifier, error)

type Certificate added in v1.2.0

type Certificate disperser.BlobInfo

func (*Certificate) BatchHeaderRoot added in v1.2.0

func (c *Certificate) BatchHeaderRoot() []byte

func (*Certificate) BlobIndex added in v1.2.0

func (c *Certificate) BlobIndex() uint32

func (*Certificate) NoNilFields added in v1.6.2

func (c *Certificate) NoNilFields() error

NoNilFields ... checks if any referenced fields in the certificate are nil and returns an error if so

func (*Certificate) Proof added in v1.2.0

func (*Certificate) ReadBlobHeader added in v1.2.0

func (c *Certificate) ReadBlobHeader() BlobHeader

type Config added in v1.1.1

type Config struct {
	KzgConfig   *kzg.KzgConfig
	VerifyCerts bool
	// below fields are only required if VerifyCerts is true
	RPCURL               string
	SvcManagerAddr       string
	EthConfirmationDepth uint64
	WaitForFinalization  bool
}

func ReadConfig added in v1.5.0

func ReadConfig(ctx *cli.Context, edaClientConfig clients.EigenDAClientConfig) Config

ReadConfig takes an eigendaClientConfig as input because the verifier config reuses some configs that are also used by the eigenda client. Not sure if urfave has a way to do flag aliases so opted for this approach.

func (Config) MarshalJSON added in v1.6.0

func (c Config) MarshalJSON() ([]byte, error)

Custom MarshalJSON function to control what gets included in the JSON output

type G1Point added in v1.2.0

type G1Point struct {
	X *big.Int
	Y *big.Int
}

G1Point struct to represent G1Point in Solidity

type QuorumBlobParam added in v1.2.0

type QuorumBlobParam struct {
	QuorumNumber                    uint8
	AdversaryThresholdPercentage    uint8
	ConfirmationThresholdPercentage uint8
	ChunkLength                     uint32
}

QuorumBlobParam struct to represent QuorumBlobParam in Solidity

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

TODO: right now verification and confirmation depth are tightly coupled. we should decouple them

func NewVerifier

func NewVerifier(cfg *Config, l log.Logger) (*Verifier, error)

func (*Verifier) Commit

func (v *Verifier) Commit(blob []byte) (*bn254.G1Affine, error)

compute kzg-bn254 commitment of raw blob data using SRS

func (*Verifier) VerifyCert added in v1.1.1

func (v *Verifier) VerifyCert(ctx context.Context, cert *Certificate) error

verifies V0 eigenda certificate type

func (*Verifier) VerifyCommitment added in v1.1.1

func (v *Verifier) VerifyCommitment(certCommitment *common.G1Commitment, blob []byte) error

Verify regenerates a commitment from the blob and asserts equivalence to the commitment in the certificate TODO: Optimize implementation by opening a point on the commitment instead

Jump to

Keyboard shortcuts

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