(commit common.Hash, blobData []byte)
| 332 | var EmptyBlobCommit = make([]byte, HashSizeInContract) |
| 333 | |
| 334 | func checkCommit(commit common.Hash, blobData []byte) error { |
| 335 | // commit is empty 0x00..00 |
| 336 | if bytes.Equal(commit[0:HashSizeInContract], EmptyBlobCommit) { |
| 337 | // blob is empty 0x00...00 |
| 338 | for _, b := range blobData { |
| 339 | if b != 0 { |
| 340 | return fmt.Errorf("empty commit but blob is not empty") |
| 341 | } |
| 342 | } |
| 343 | return nil |
| 344 | } |
| 345 | |
| 346 | // kzg blob |
| 347 | blob := kzg4844.Blob{} |
| 348 | copy(blob[:], blobData) |
| 349 | // Generate VersionedHash |
| 350 | commitment, err := kzg4844.BlobToCommitment(&blob) |
| 351 | if err != nil { |
| 352 | return fmt.Errorf("could not convert blob to commitment: %v", err) |
| 353 | } |
| 354 | versionedHash := eth.KZGToVersionedHash(eth.KZGCommitment(commitment)) |
| 355 | // Get the hash and only take 24 bits |
| 356 | return CompareCommits(commit.Bytes(), versionedHash[:]) |
| 357 | } |
| 358 | |
| 359 | // Write a value of the KV to the store using a customized encoder. |
| 360 | func (ds *DataShard) WriteWith(kvIdx uint64, b []byte, commit common.Hash, encoder func([]byte, uint64) []byte) error { |
no test coverage detected