Skip to main content

prover-executable

Note that in type-3 or type-4 markets, Generators don't need to receive inputs or run the prover in an enclave, hence building the prover-executable for such markets isn't required. In the case of type-1 and type-2 markets, the Market Creator is required to build the prover-executable which is used to build the Generator enclave.

The prover-executable is a server that implements the following APIs/webhooks. It is language-agnostic and can be implemented in any programming language of your choice. However, it must be available as an executable.

Note: Please make sure to mention whether the executables you create are built for amd or arm systems.

info

For an executable to run successfully all the API endpoints must be implemented.

A rust-based template for a prover-executable

Repo: https://github.com/marlinprotocol/kalypso-base

  1. Clone the repo

    git clone https://github.com/marlinprotocol/kalypso-base
    cd kalypso-base
  2. The repo contains multiple files and directories. We have to modify ./prover/src/handler.rs.

    ├── bindings
    ├── Cargo.lock
    ├── Cargo.toml
    ├── common
    ├── ivs
    ├── LICENSE
    ├── prover
    │ ├── Cargo.toml
    │ └── src
    │ ├── handler.rs
    │ └── main.rs
    └── README.m

    You will need to add logic for generating proofs in the below API handler

    ./prover/src/handler.rs
    #[post("/generateProof")]
    async fn generate_proof(_jsonbody: web::Json<common::GenerateProofInputs>) -> impl Responder {
    // receive decrypted and encrypted inputs from _jsonbody
    // implement proof generation code here
    common::response(
    "Proof Generation API is not implemented",
    StatusCode::NOT_IMPLEMENTED,
    None,
    )
    }

    Similarily, you need to implement a benchmarking API

    ./prover/src/handler.rs
    #[get("/benchmark")]
    async fn benchmark() -> impl Responder {
    // create/import a sample public input
    // create/import a sample witness input
    // generate proof and return the response time
    common::response(
    "Benchmarking API is not implemented",
    StatusCode::NOT_IMPLEMENTED,
    None,
    )
    }

    A complete example can be found here.

  3. Once done, create the executable. Make sure the right tool chain and setting is used, else the executable won't run inside the enclave.

    .cargo/config.toml
    [build]
    target = "x86_64-unknown-linux-musl"

    [target.'cfg(target_os = "linux")']
    rustflags = ["-C", "target-feature=+crt-static"]

    Build the executable

    cargo build --release

    Copy and save your executable

    cp ./target/x86_64-unknown-linux-musl/release/prover prover-executable