Repository navigation
feat(sdk): add solana.Keccak256 - #11
Merged
Merged
Conversation
Keccak256(c, input, offset, length, output, outOffset) mirrors SHA256's bounded single-region contract and calls the runtime's sol_keccak256 syscall (by name on fogo-v0, by its static hash 0xd7793abb on solana-v3): Ethereum's Keccak-256 with the original 0x01 padding. Out-of-range requests return 2003 without a syscall; native contexts supply a Keccak callback, and a missing callback returns 2009. The C adapter lives in keccak.c.txt and is emitted only for programs that call Keccak256 (usesSDK), so every existing program keeps byte-identical C and ELFs; the pre-Check corpus still matches. Tests: native bounds/copy checks, a test-only reference Keccak-256 checked against published vectors, a native-Go/generated-C boundary differential, and a real-SBF suite on both profiles that compares whole and partial inputs from 0 to 10,240 bytes, across the 136-byte rate boundary, with the reference. The committed SDK-2 example snapshots are refreshed for the new API file.
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Keccak-256 hashing runs on every Hyperlane message (message id, merkle tree, EIP-191). Without the syscall it has to be done in software in Go, which is far more expensive.
Solution
solana.Keccak256(c, input, offset, length, output, outOffset) uint64mirrorsSHA256's bounded contract and wrapssol_keccak256(fogo-v0 by name, solana-v3 hash0xd7793abb). That's Ethereum Keccak with 0x01 padding, not SHA3-256. Out-of-range requests return 2003 without a syscall.Tests
Linked work
Closes #1, together with #9, #10. If this merges first, #1 should stay open until the rest land. Used by hyperlane-xyz/hyperlane-monorepo#9852. Refreshes example SDK snapshots;
sdk_sha256conflicts with the other SDK PRs are mechanical.