@@ -2,15 +2,21 @@ package txlistdecoder
2
2
3
3
import (
4
4
"context"
5
+ "crypto/sha256"
5
6
"math/big"
6
7
7
8
"github.com/ethereum/go-ethereum/common"
8
9
"github.com/ethereum/go-ethereum/core/types"
10
+ "github.com/ethereum/go-ethereum/crypto/kzg4844"
9
11
"github.com/ethereum/go-ethereum/log"
10
12
"github.com/taikoxyz/taiko-client/bindings"
11
13
"github.com/taikoxyz/taiko-client/pkg/rpc"
12
14
)
13
15
16
+ const (
17
+ blobCommitmentVersionKZG uint8 = 0x01 // Version byte for the point evaluation precompile.
18
+ )
19
+
14
20
type BlobFetcher struct {
15
21
rpc * rpc.Client
16
22
}
@@ -38,10 +44,20 @@ func (d *BlobFetcher) Fetch(
38
44
for _ , sidecar := range sidecars {
39
45
log .Info ("Found sidecar" , "KzgCommitment" , sidecar .KzgCommitment , "blobHash" , common .Bytes2Hex (meta .BlobHash [:]))
40
46
41
- if sidecar .KzgCommitment == common .Bytes2Hex (meta .BlobHash [:]) {
47
+ if kZGToVersionedHash (
48
+ kzg4844 .Commitment (common .Hex2Bytes (sidecar .KzgCommitment )[:]),
49
+ ) == common .BytesToHash (meta .BlobHash [:]) {
42
50
return common .Hex2Bytes (sidecar .Blob ), nil
43
51
}
44
52
}
45
53
46
54
return nil , errSidecarNotFound
47
55
}
56
+
57
+ // kZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844
58
+ func kZGToVersionedHash (kzg kzg4844.Commitment ) common.Hash {
59
+ h := sha256 .Sum256 (kzg [:])
60
+ h [0 ] = blobCommitmentVersionKZG
61
+
62
+ return h
63
+ }
0 commit comments