cosmos / ibc-go

Inter-Blockchain Communication Protocol (IBC) implementation in Golang.
https://ibc.cosmos.network/
MIT License
553 stars 596 forks source link

Make packet commitments fixed length (32 bytes) #7563

Closed gjermundgaraba closed 2 weeks ago

gjermundgaraba commented 2 weeks ago

Currently, in IBC Eureka, the packet commitments are 33 bytes due to the addition of a fixed-length preimage after the final hashing of the key.

This causes issues in Solidity where variable-length arrays are much more expensive and cumbersome to handle. To be able to use bytes32 in Solidity, we should add the fixed-length preimage to the byte array before doing the final hash.

Something like this:

buf = append([]byte{byte(2)}, buf...)

hash := sha256.Sum256(buf)
return hash[:]