Stellar
UltraHonk verification on Soroban
Verifying Noir proofs inside a Stellar smart contract.
Overview
A Soroban contract stores the verification key once at deploy time and verifies UltraHonk proofs against it, returning typed errors. Veilum's pool and Clash's game call it to accept private transfers and hidden moves.
The code
packages/contracts/rs-soroban-ultrahonk/src/lib.rsView on GitHub ↗
#[contractimpl]
impl UltraHonkVerifierContract {
/// Initialize the on-chain VK once at deploy time.
pub fn __constructor(env: Env, vk_bytes: Bytes) -> Result<(), Error> {
env.storage().instance().set(&Self::key_vk(), &vk_bytes);
Ok(())
}
/// Verify an UltraHonk proof using the stored VK.
pub fn verify_proof(env: Env, public_inputs: Bytes, proof_bytes: Bytes) -> Result<(), Error> {
if proof_bytes.len() as usize != PROOF_BYTES {
return Err(Error::ProofParseError);
}
let vk_bytes: Bytes = env.storage().instance().get(&Self::key_vk()).ok_or(Error::VkNotSet)?;
let verifier = UltraHonkVerifier::new(&env, &vk_bytes).map_err(|_| Error::VkParseError)?;
verifier.verify(&proof_bytes, &public_inputs).map_err(|_| Error::VerificationFailed)?;
Ok(())
}
}
How it works
- The VK is set in the constructor and read from instance storage
- Proof length is checked before parsing, and every failure maps to a contract error code
- The same verifier is reused across Veilum and Clash