8000 Bonsol Implementation of Verifiable http requests · Issue #31 · bonsol-collective/bonsol · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bonsol Implementation of Verifiable http requests #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
austbot opened this issue Oct 10, 2024 · 1 comment
Open

Bonsol Implementation of Verifiable http requests #31

austbot opened this issue Oct 10, 2024 · 1 comment
Labels
question Further information is requested

Comments

@austbot
Copy link
Contributor
austbot commented Oct 10, 2024

As developers onboard to bonsol, one common usecase appears. "Verifiable http". At first I assumed developers would want to integrate it themselves and leverage proof composition for privacy, but many developers want to remove the layer of trust between the prover and even public and hashable sources. This is because dynamic data sources may change fro the time the execution request is sent to the time the prover pulls the inputs. This makes hashing ahead of time not valid and since the hash committed by the provers zkvm will not match it will force the developer to remove that check in bonsol. This will mean they must implement some further checks on the committed hash later if they want to validate that the data was correctly pulled by the untrusted prover .Instead of forcing developers to build this for themselves bonsol should seek to implement verifiable http by default. This is not straightforward and many companies with much more resources than the bonsol open source community make this their sole aim.

Verifiable http is tricky for a few reasons.

Quick overview of tls (1.3) in the most normal case

  1. Client and Server Exchange Hello with their public keys and nonces
  2. both client and sever generate keys
  3. server sends its cert
  4. Client verifies the cert
  5. Messaging begins (http, or otherwise) authenticated with AEAD

Why its tricky

In tls since the server and client both have the symmetric sending and receiving keys, there is not currently a way just within the tls protocol to tell who encrypted the message. Since the client(in this case bonsol prover) could have forged it. If all http servers had an identity and as a part of the http protocol they signed the response payload with a private key and the public key was at a .well-known location then this would be less tricky. That is not the case and currently tls does not offer a way to to identify the client/server when looking at the payload.

The leading schools of thought agree that in order to do this correctly there must be a way to commit to the payload before the client gets the decryption key, and this would require some form of multy party key handling.

Since bonsol provers run on a server and are supposed to be untrusted entities, this further complicates the matter. While some verifiable web data solutions are geared toward the browser user publishing a claim to some web data, we must prove to the blockchain that the prover called the right url and downloaded and committed to content from that url.

What we are after

In the most ideal case, bonsol input resolution would have a low overhead way to request the inputs and prove to the solana program within the same proof of execution that the inputs were downloaded from the right source.
In order to do this the proofs must be compatible with risc0 stark construction. The most ideal case would be that the proofs would be risc0 succinct receipts that can be fed into the zkvm as assumptions and verified.

Existing protocols around mpc and tls

  • tls notary
  • reclaim
  • zkPass

Attempts using risc0

I have only seen the following https://github.com/mrnerdhair/crunch which seems like a very early prototype.

Possible Solutions In no specific order

  1. Remove the notion of server side input resolution but instead change bonsol nodes to expect the requester to send the data to them directly at a location of the provers choosing after they have claimed.
    This has some pros, the nodes dont have to worry about reaching out to the net to get any inputs which can make the nodes simpler and remove some async management. But with the large cons that devs will need to run more infrastructure to post execution data upon a successful claim. Another con is it complicates the security landscape for provers since now they need to have some open ports to receive the data.

  2. Implement an integration with an existing mpc-tls solution. A major pro here is that the hard work of implementing mpc and tls session verification. Cons include the friction of needing to handle those protocols tokens or web2 pricing models. In the former, there may just not be a suitable bridge, in the latter we would add the burden of managing web2 api keys to the node.

  3. Build this soup to nuts. Major pros here are total control, the ability to pick solid libraries to accelerate development. Major cons are well.... needing to build this.

@austbot austbot added the question Further information is requested label Oct 16, 2024
@augchan42
Copy link
Contributor

Let me analyze this systematically:

  1. Current State & Core Issues
  • Developers want verifiable HTTP for data source integrity
  • Current TLS doesn't provide server-specific message authentication
  • Need proof that prover called correct URL and received authentic data
  • Must be compatible with RISC0 STARK construction
  • Timing gap between request and prover data fetch can invalidate hashes
  1. Incremental Approach Possibilities

First Stage - Expired Claims Infrastructure:

// Add to ClaimStateV1
pub struct ClaimStateV1 {
    pub claimer: Pubkey,
    pub claimed_at: u64,
    pub block_commitment: u64,
    pub retry_count: u8,        // Track retries
    pub last_attempt: u64,      // Track last attempt time
    pub execution_value: u64,   // Track economic value
}

This foundation would help:

  • Track failed/expired claims
  • Enable retry mechanisms
  • Provide metrics on claim performance
  • Set up infrastructure for verifiable input tracking

Second Stage - Input Resolution Framework:

pub enum InputSource {
    Direct(Vec<u8>),              // Direct input
    Http {
        url: String,
        method: String,
        headers: HashMap<String, String>,
        verification_data: Option<HttpVerificationData>,
    },
    // Future: Add more source types
}

pub struct HttpVerificationData {
    timestamp: u64,
    server_cert: Vec<u8>,
    proof_data: Vec<u8>,          // Extensible for different proof types
}

This would:

  • Create abstraction for different input sources
  • Allow gradual addition of verification methods
  • Support both direct and HTTP inputs
  • Enable metrics collection on input resolution

Third Stage - Hybrid Approach:

  1. Start with the "Remove server-side resolution" approach but make it optional:
pub enum InputResolutionMode {
    ServerSide,           // Prover fetches
    ClientPush,          // Client pushes to prover
    Hybrid {             // Both allowed
        preferred: InputResolutionPreference,
        timeout: u64,
    }
}
  1. Add infrastructure for verification proofs:
pub trait VerificationProof {
    fn verify(&self) -> Result<(), VerificationError>;
    fn to_risc0_assumption(&self) -> Result<Vec<u8>, ProofError>;
}

// Can implement different proof types:
pub struct TlsNotaryProof(/* ... */);
pub struct DirectPushProof(/* ... */);
pub struct MpcTlsProof(/* ... */);

Benefits of this incremental approach:

  1. Immediate Value

    • Fixes expired claims issue
    • Provides better metrics and monitoring
    • Improves developer experience incrementally
  2. Flexibility

    • Can start with simpler direct push model
    • Gradually add more sophisticated verification methods
    • Allows experimentation with different approaches
  3. Risk Management

    • Each stage provides value even if later stages face challenges
    • Can learn from usage patterns before committing to complex solutions
    • Easier to pivot based on developer feedback
  4. Technical Foundation

    • Sets up proper abstractions for different verification methods
    • Creates infrastructure for metrics and monitoring
    • Enables gradual security improvements
  5. Developer Experience

    • Provides immediate solution for time-sensitive data
    • Allows developers to choose verification level
    • Can start simple and add verification as needed

Would you like me to elaborate on any of these aspects or explore a specific part of the implementation in more detail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants
0