@@ -136,6 +136,19 @@ func (h *ByronMainBlockHeader) Era() common.Era {
136136 return EraByron
137137}
138138
139+ func (h * ByronMainBlockHeader ) BlockBodyHash () common.Blake2b256 {
140+ // BodyProof is the hash of the block body, encoded as bytes in CBOR
141+ if bodyProofBytes , ok := h .BodyProof .([]byte ); ok &&
142+ len (bodyProofBytes ) == common .Blake2b256Size {
143+ var hash common.Blake2b256
144+ copy (hash [:], bodyProofBytes )
145+ return hash
146+ }
147+ // Return zero hash instead of panicking to prevent DoS in verification path
148+ // This will cause validation to fail gracefully rather than crash
149+ return common.Blake2b256 {}
150+ }
151+
139152type ByronTransaction struct {
140153 cbor.StructAsArray
141154 cbor.DecodeStoreCbor
@@ -731,6 +744,19 @@ func (h *ByronEpochBoundaryBlockHeader) Era() common.Era {
731744 return EraByron
732745}
733746
747+ func (h * ByronEpochBoundaryBlockHeader ) BlockBodyHash () common.Blake2b256 {
748+ // BodyProof is the hash of the block body, encoded as bytes in CBOR
749+ if bodyProofBytes , ok := h .BodyProof .([]byte ); ok &&
750+ len (bodyProofBytes ) == common .Blake2b256Size {
751+ var hash common.Blake2b256
752+ copy (hash [:], bodyProofBytes )
753+ return hash
754+ }
755+ // Return zero hash instead of panicking to prevent DoS in verification path
756+ // This will cause validation to fail gracefully rather than crash
757+ return common.Blake2b256 {}
758+ }
759+
734760type ByronMainBlock struct {
735761 cbor.StructAsArray
736762 cbor.DecodeStoreCbor
@@ -798,6 +824,10 @@ func (b *ByronMainBlock) Utxorpc() (*utxorpc.Block, error) {
798824 return & utxorpc.Block {}, nil
799825}
800826
827+ func (b * ByronMainBlock ) BlockBodyHash () common.Blake2b256 {
828+ return b .Header ().BlockBodyHash ()
829+ }
830+
801831type ByronEpochBoundaryBlock struct {
802832 cbor.StructAsArray
803833 cbor.DecodeStoreCbor
@@ -863,6 +893,10 @@ func (b *ByronEpochBoundaryBlock) Utxorpc() (*utxorpc.Block, error) {
863893 return & utxorpc.Block {}, nil
864894}
865895
896+ func (b * ByronEpochBoundaryBlock ) BlockBodyHash () common.Blake2b256 {
897+ return b .Header ().BlockBodyHash ()
898+ }
899+
866900func NewByronEpochBoundaryBlockFromCbor (
867901 data []byte ,
868902) (* ByronEpochBoundaryBlock , error ) {
0 commit comments