> loading_
# ---------------------------------------------------------------------------
# Walkthrough: Using the new sol_sha512 syscall in an on-chain Solana program
# (Rust / Anchor-compatible)
# ---------------------------------------------------------------------------
# 1. Make sure you're on a validator or test environment that includes SIMD-0512.
# As of this writing, the feature gate has been merged but may not yet be
# activated on mainnet. Use a local test-validator with the feature force-
# enabled, or target a devnet/testnet cluster where it's live.
#
# solana-test-validator --features-to-activate <SHA512_FEATURE_GATE_PUBKEY>
# 2. In your on-chain program (lib.rs), import the hash module.
# The solana_program crate will expose `sha512` alongside `sha256` and
# `keccak` once the SDK version supporting SIMD-0512 is published.
# use solana_program::hash_sha512; // expected module path — verify against
# // the SDK release notes
# 3. Call the syscall. It accepts a slice of byte slices (&[&[u8]]) and
# returns a 64-byte Hash512 struct.
# pub fn verify_something(ctx: Context<Verify>, data: Vec<u8>) -> Result<()> {
# // Hash the incoming data using the native SHA-512 syscall
# let digest = solana_program::sha512::hash(&data);
#
# // `digest` is a 64-byte array wrapped in a newtype.
# // You can compare it against an expected value passed in from the client.
# msg!("SHA-512 digest: {:?}", digest.to_bytes());
#
# // For multi-slice hashing (e.g., domain-separated inputs):
# let domain_tag = b"MY_PROTOCOL_v1";
# let multi_digest = solana_program::sha512::hashv(&[
# domain_tag,
# &data,
# ]);
#
# // Use the digest in downstream logic — signature checks, Merkle
# // proofs, cross-chain message validation, etc.
# require!(multi_digest.to_bytes() == ctx.accounts.expected_hash.data,
# MyError::HashMismatch);
#
# Ok(())
# }
# 4. On the client side (TypeScript), nothing special is needed — the syscall
# is invoked internally by the program. But if you want to compute a
# matching SHA-512 digest off-chain for verification:
# import { createHash } from 'crypto';
#
# const domainTag = Buffer.from('MY_PROTOCOL_v1');
# const data = Buffer.from(/* your payload */);
# const digest = createHash('sha512')
# .update(domainTag)
# .update(data)
# .digest();
#
# console.log('Expected SHA-512:', digest.toString('hex'));
# 5. Compute-unit savings: A pure-BPF SHA-512 over a 256-byte input can cost
# ~15,000–50,000 CU depending on implementation. The native syscall is
# expected to land in the low hundreds of CU for the same input, similar
# to the existing SHA-256 syscall cost curve. Profile with
# `solana_program::log::sol_log_compute_units()` before and after the call
# to confirm savings in your specific workload.
# 6. Security note: SHA-512 is NOT a drop-in replacement for SHA-256 in
# existing Merkle trees or PDAs. Only use it where your protocol
# specifically requires a 512-bit digest (Ed25519 internals, HMAC-SHA-512,
# cross-chain proof verification, etc.).
# Happy hashing! Track the feature-gate activation status at:
# https://github.com/solana-labs/solana/labels/feature-gate