Skip to content

Feat/eip4844 precompile #1489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

ThomasPiellard
Copy link
Collaborator

Description

Implementation of the EIP4844 precompile.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

See marshall_test.go, kzg_point_evaluation_test.go

How has this been benchmarked?

Unmarshall #constraints: 1772 when compiled on BN254, emulating BLS12-381 base field
UnmarshalCompressed #constraints: 585600 when compiled on BN254, emulating BLS12-381 base field
KzgPointEvaluation #constraints: 3772424 when compiled on BN254, emulating BLS12-381 base field

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ivokub ivokub force-pushed the feat/EIP4844-precompile branch from afbd5b4 to 7c23ab0 Compare July 1, 2025 13:02
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: KZG Precompile Hash Size Mismatch

The KZG point evaluation precompile's versioned hash verification contains an array out-of-bounds error. sizeCompressedPoint is incorrectly set to 48 bytes (fp.Bytes), while the EIP-4844 versioned hash is a 32-byte SHA256 output. This causes h.FixedLengthSum to produce a 48-byte hash. The subsequent comparison loop iterates up to 47, attempting to access versionnedHash beyond its 32-byte length, leading to an out-of-bounds panic.

std/evmprecompiles/10-kzg_point_evaluation.go#L63-L74

// verify commitment matches versioned_hash
sizeCompressedPoint := fp.Bytes
h, err := sha2.New(api, hash.WithMinimalLength(sizeCompressedPoint))
if err != nil {
return nil, fmt.Errorf("new sha2: %w", err)
}
h.Write(comSerialised)
hashedKzg := h.FixedLengthSum(sizeCompressedPoint)
api.AssertIsEqual(versionnedHash[0].Val, blobCommitmentVersionKZG)
for i := 1; i < len(hashedKzg); i++ {
api.AssertIsEqual(hashedKzg[i].Val, versionnedHash[i].Val)
}

Fix in Cursor


BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants