Skip to content

Commit

Permalink
🐛 use fork of stwo for serde compat of StarkProof
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Jul 17, 2024
1 parent d481204 commit 3679dfa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 74 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ license = "MIT"


[workspace.dependencies]
stwo-prover = { git = "https://github.com/starkware-libs/stwo.git" }
#stwo-prover = { git = "https://github.com/starkware-libs/stwo.git" }
# Temporary fork for serde compatibility of StarkProof
stwo-prover = { git = "https://github.com/MSghais/stwo.git", rev = "8401c93" }
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false }
tracing-subscriber = "0.3"
1 change: 0 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ pub mod data_fixture;
pub mod prover_service;
pub mod types;
pub mod verifier_service;
pub mod wrappers;
11 changes: 2 additions & 9 deletions crates/core/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use serde::{Deserialize, Serialize};
use stwo_prover::core::prover::StarkProof;

use crate::wrappers::{ConversionError, StarkProofWrapper};

#[derive(Debug, Serialize, Deserialize)]
pub struct FibonnacciProvingRequest {
pub request_id: String,
Expand All @@ -15,7 +13,7 @@ pub struct FibonnacciProvingResponse {
pub request_id: String,
pub log_size: u32,
pub claim: u32,
pub proof: StarkProofWrapper,
pub proof: StarkProof,
}

impl FibonnacciProvingResponse {
Expand All @@ -24,12 +22,7 @@ impl FibonnacciProvingResponse {
request_id,
log_size,
claim,
proof: proof.into(),
proof,
}
}

pub fn into_stark_proof(self) -> Result<(String, u32, u32, StarkProof), ConversionError> {
let proof = self.proof.try_into().unwrap();
Ok((self.request_id, self.log_size, self.claim, proof))
}
}
19 changes: 6 additions & 13 deletions crates/core/src/verifier_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@ use stwo_prover::core::prover::VerificationError;
use stwo_prover::examples::fibonacci::Fibonacci;

use crate::types::FibonnacciProvingResponse;
use crate::wrappers::ConversionError;

#[derive(Debug, thiserror::Error)]
pub enum VerifierError {
#[error(transparent)]
Verification(#[from] VerificationError),
#[error(transparent)]
Conversion(#[from] ConversionError),
}

#[derive(Debug, Default)]
pub struct VerifierService {}

impl VerifierService {
pub fn verify_proof(&self, response: FibonnacciProvingResponse) -> Result<(), VerifierError> {
let (_, log_size, claim, proof) = response.into_stark_proof()?;
let fib = Fibonacci::new(log_size, BaseField::from(claim));
fib.verify(proof).map_err(VerifierError::Verification)
pub fn verify_proof(
&self,
response: FibonnacciProvingResponse,
) -> Result<(), VerificationError> {
let fib = Fibonacci::new(response.log_size, BaseField::from(response.claim));
fib.verify(response.proof)
}
}
50 changes: 0 additions & 50 deletions crates/core/src/wrappers.rs

This file was deleted.

0 comments on commit 3679dfa

Please sign in to comment.