Skip to content

feat(sdk): add solana.Keccak256 - #11

Merged
Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
paulbalaji:syscall-keccak256
Oct 19, 2026
Merged

Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
paulbalaji:syscall-keccak256

Conversation

@paulbalaji

@paulbalaji paulbalaji commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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) uint64 mirrors SHA256's bounded contract and wraps sol_keccak256 (fogo-v0 by name, solana-v3 hash 0xd7793abb). That's Ethereum Keccak with 0x01 padding, not SHA3-256. Out-of-range requests return 2003 without a syscall.

Tests

  • A test-only reference Keccak, checked against published vectors.
  • Native and boundary differentials.
  • Real SBF on both profiles: inputs from 0 to 10,240 bytes, including across the 136-byte rate boundary.

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_sha256 conflicts with the other SDK PRs are mechanical.

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.
@paulbalaji paulbalaji changed the title Add solana.Keccak256 for SDK 2 feat(sdk): add solana.Keccak256 Oct 19, 2026
@Mister-Meeseeks
Mister-Meeseeks merged commit c507a04 into CrocSwap:main Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK 2: bind sol_get_return_data, sol_secp256k1_recover and sol_keccak256

2 participants