Skip to content

Commit

Permalink
feat: switch to REST endpoint && switch to new prover.proto (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
iajoiner authored Oct 23, 2024
2 parents 87ae6e1 + c0c1eed commit a2dcd46
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
8 changes: 8 additions & 0 deletions proto/prover.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ service Prover {
rpc ingest(TableIngest) returns (google.protobuf.Empty) {}
}

// First value of enum is default value, so if no commitment
// scheme is specified in ProverQuery, IPA is chosen by default
enum CommitmentScheme {
IPA = 0;
DORY = 1;
}

message ProverContextRange {
uint64 start = 1;
repeated uint64 ends = 2;
Expand All @@ -24,6 +31,7 @@ message ChosenContextRange {
message ProverQuery {
bytes proof_plan = 1;
map<string, ProverContextRange> query_context = 3;
CommitmentScheme commitment_scheme = 4;
}

message ProverResponse {
Expand Down
24 changes: 14 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ mod auth;
mod substrate;
mod sxt_chain_runtime;

use core::time::Duration;
use dotenv::dotenv;
use proof_of_sql::{
proof_primitive::dory::{
DoryCommitment, DoryEvaluationProof, DoryVerifierPublicSetup, VerifierSetup,
},
sql::{parse::QueryExpr, proof::VerifiableQueryResult},
};
use prover::{prover_client::ProverClient, ProverContextRange, ProverQuery};
use prover::{ProverContextRange, ProverQuery, ProverResponse};
use reqwest::Client;
use std::{collections::HashMap, path::Path};

mod prover {
Expand Down Expand Up @@ -50,16 +50,20 @@ async fn main() -> Result<(), Box<dyn core::error::Error>> {
let prover_query = ProverQuery {
proof_plan: serialized_proof_plan,
query_context,
commitment_scheme: 1,
};
let mut client = ProverClient::connect(prover_url).await?;
let mut request = tonic::Request::new(prover_query);
request.set_timeout(Duration::from_secs(60));
let stringified_verifiable_result = client
.query_with_proof(request)
let client = Client::new();
let apikey = std::env::var("SXT_API_KEY")?;
let access_token = auth::get_access_token(&apikey, &prover_url).await?;
let request = client
.post(format!("{}/v1/prove", prover_url))
.bearer_auth(&access_token)
.json(&prover_query)
.send()
.await?
.get_ref()
.verifiable_result
.clone();
.error_for_status()?;
let prover_response = request.json::<ProverResponse>().await?;
let stringified_verifiable_result = prover_response.verifiable_result.clone();
let verifiable_result: VerifiableQueryResult<DoryEvaluationProof> =
flexbuffers::from_slice(&stringified_verifiable_result)?;
// Verify the proof
Expand Down

0 comments on commit a2dcd46

Please sign in to comment.