Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: IBC Version 2 Specification #1143

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ICS4: Create 32 byte commitment (#1168)
* move protocol version inside final hash

* Update spec/core/v2/ics-004-packet-semantics/PACKET.md

Co-authored-by: DimitrisJim <[email protected]>

---------

Co-authored-by: DimitrisJim <[email protected]>
AdityaSripal and DimitrisJim authored Nov 18, 2024
commit 0e286246529eb0d3f90d7725056819714fb4164c
11 changes: 8 additions & 3 deletions spec/core/v2/ics-004-channel-and-packet-semantics/PACKET.md
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ func commitPayload(payload: Payload): bytes {
// Note: SourceChannel and the sequence are omitted since they will be included in the key
// Every other field of the packet is committed to in the packet which will be stored in the
// packet commitment value
// The final hash will be prepended by the byte 0x02 in order to clearly define the protocol version
// The final preimage will be prepended by the byte 0x02 before hashing in order to clearly define the protocol version
// and allow for future upgradability
func commitV2Packet(packet: Packet) {
timeoutBytes = LittleEndian(packet.timeout)
@@ -96,7 +96,8 @@ func commitV2Packet(packet: Packet) {
buffer = sha256.Hash(packet.destChannel)
buffer = append(buffer, sha256.hash(timeoutBytes))
buffer = append(buffer, sha256.hash(appBytes))
return append([]byte{0x02}, sha256.Hash(buffer))
buffer = append([]byte{0x02}, buffer)
return sha256.Hash(buffer)
}
```

@@ -123,11 +124,15 @@ interface Acknowledgement {
All acknowledgements must be committed to and stored under the ICS24 acknowledgment path.

```typescript
// commitV2Acknowledgement hashes each app acknowledgment and hashes them together
// the final preimage will be prepended with the byte 0x02 before hashing in order to clearly define the protocol version
// and allow for future upgradability
func commitV2Acknowledgment(ack: Acknowledgement) {
var buffer: bytes
for appAck in ack.appAcknowledgement {
buffer = append(buffer, sha256.Hash(appAck))
}
return append([]byte{0x02}, sha256.Hash(buffer))
buffer = append([]byte{0x02}, buffer)
return sha256.Hash(buffer)
}
```