Skip to content

Contracts for onchain verification of SP1 in CosmWasm

License

Notifications You must be signed in to change notification settings

timewave-computer/cw-sp1-verifier

 
 

Repository files navigation

CosmWasm SP1 Verifier Contract

This is a CosmWasm contract that verifies SP1 proofs. It can be used to verify plonk proofs if built with the plonk feature, or groth16 proofs if built with the groth16 feature.

This contract uses cosmwasm optimizer to build both the groth16 and plonk versions of the contract. The optimizer is a tool that allows you to build multiple versions of a contract with different features enabled.

To build the contracts, run the following command:

just build-optimize

This will build the contracts under the artifacts directory.

Usage

This contract is meant to be queried by other contracts/clients to verify SP1 proofs. As such, it only has one query message, VerifyProof, which takes the following form:

/// The query messages supported by the contract.
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    /// Verifies an SP1 proof.
    #[returns(cosmwasm_std::Empty)]
    VerifyProof(VerifyProofMsg),
}

/// Verifies an SP1 proof.
#[cw_serde]
pub struct VerifyProofMsg {
    /// The proof to verify.
    pub proof: Binary,
    /// The public values to verify the proof against.
    pub public_values: Binary,
    /// The verification key of the sp1 program.
    pub vk_hash: String,
}

About

Contracts for onchain verification of SP1 in CosmWasm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 79.7%
  • Rust 16.4%
  • Just 2.0%
  • Nix 1.9%