diff --git a/go/enclave/nodetype/sequencer.go b/go/enclave/nodetype/sequencer.go index 24ba59b50..b7b38cbce 100644 --- a/go/enclave/nodetype/sequencer.go +++ b/go/enclave/nodetype/sequencer.go @@ -328,13 +328,34 @@ func (s *sequencer) CreateRollup(ctx context.Context, lastBatchNo uint64) (*comm return nil, fmt.Errorf("failed to encode rollup to blobs: %w", err) } - // Store the blob data + // Calculate blob hash + blobHash, err := ethadapter.ComputeBlobHash(blobs[0]) + if err != nil { + return nil, fmt.Errorf("failed to compute blob hash: %w", err) + } + + // Store blob data and required fields extRollup.BlobData = blobs + extRollup.Header.BlobHash = blobHash + extRollup.Header.MessageRoot = gethcommon.Hash{} // TODO: Implement message root + extRollup.Header.BlockNumber = currentL1Head.Number.Uint64() + extRollup.Header.CompressionL1Head = currentL1Head.Hash() + + // Create composite hash matching the contract expectation + compositeHash := gethcrypto.Keccak256Hash( + blobHash.Bytes(), + extRollup.Header.MessageRoot.Bytes(), + currentL1Head.Hash().Bytes(), + big.NewInt(int64(currentL1Head.Number.Uint64())).Bytes(), + big.NewInt(int64(extRollup.Header.LastBatchSeqNo)).Bytes(), + ) - // Sign the rollup - if err := s.signRollup(extRollup); err != nil { - return nil, fmt.Errorf("failed to sign created rollup: %w", err) + // Sign the composite hash + signature, err := s.enclaveKeyService.Sign(compositeHash) + if err != nil { + return nil, fmt.Errorf("failed to sign rollup: %w", err) } + extRollup.Header.Signature = signature return extRollup, nil } diff --git a/go/ethadapter/blob.go b/go/ethadapter/blob.go index b27d9a914..886b20e9a 100644 --- a/go/ethadapter/blob.go +++ b/go/ethadapter/blob.go @@ -162,5 +162,9 @@ func ComputeBlobHash(blob *kzg4844.Blob) (gethcommon.Hash, error) { return gethcommon.Hash{}, err } - return KZGToVersionedHash(commitment), nil + // Create versioned hash matching EIP-4844 specification + var hash gethcommon.Hash + hash[0] = 0x01 // Version byte + copy(hash[1:], commitment[:]) + return hash, nil }