-
Notifications
You must be signed in to change notification settings - Fork 450
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
base: master
Are you sure you want to change the base?
Feat/eip4844 precompile #1489
Conversation
afbd5b4
to
7c23ab0
Compare
There was a problem hiding this 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
gnark/std/evmprecompiles/10-kzg_point_evaluation.go
Lines 63 to 74 in 7c23ab0
// 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) | |
} |
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 👎
Description
Implementation of the EIP4844 precompile.
Type of change
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 fieldUnmarshalCompressed
#constraints: 585600 when compiled on BN254, emulating BLS12-381 base fieldKzgPointEvaluation
#constraints: 3772424 when compiled on BN254, emulating BLS12-381 base fieldChecklist:
golangci-lint
does not output errors locally