-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### **Progress on Integrating `Stwo`** This PR makes incremental progress towards integrating the `stwo` prover, refer to issue #1833 . It includes the following changes: - **Add `stwo` feature to `Cargo.toml`:** The `Cargo.toml` files for the `cli`, `pipeline`, and `backend` components have been updated to include the `stwo` feature. - **Implement `StwoProverFactory`:** A skeleton structure for `StwoProverFactory` has been introduced. This structure implements the `BackendFactory` trait. - **Implement `StwoProver`:** Similarly, a skeleton implementation of `StwoProver` has been created, implementing the `Backend` trait. . ### **Commands to run:** ```bash # Run the project with the `stwo` feature cargo run --features stwo pil test_data/pil/fibonacci.pil -o output -f --field m31 --prove-with stwo --------- Co-authored-by: Thibaut Schaeffer <[email protected]> Co-authored-by: Georg Wiese <[email protected]>
- Loading branch information
1 parent
612a0f9
commit 57d3c83
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use std::io; | ||
use std::path::PathBuf; | ||
use std::sync::Arc; | ||
|
||
use crate::{Backend, BackendFactory, BackendOptions, Error, Proof}; | ||
use powdr_ast::analyzed::Analyzed; | ||
use powdr_executor::constant_evaluator::{get_uniquely_sized_cloned, VariablySizedColumn}; | ||
use powdr_executor::witgen::WitgenCallback; | ||
use powdr_number::FieldElement; | ||
use prover::StwoProver; | ||
|
||
mod prover; | ||
|
||
#[allow(dead_code)] | ||
pub(crate) struct StwoProverFactory; | ||
|
||
impl<F: FieldElement> BackendFactory<F> for StwoProverFactory { | ||
#[allow(unreachable_code)] | ||
#[allow(unused_variables)] | ||
fn create( | ||
&self, | ||
pil: Arc<Analyzed<F>>, | ||
fixed: Arc<Vec<(String, VariablySizedColumn<F>)>>, | ||
_output_dir: Option<PathBuf>, | ||
setup: Option<&mut dyn io::Read>, | ||
verification_key: Option<&mut dyn io::Read>, | ||
verification_app_key: Option<&mut dyn io::Read>, | ||
options: BackendOptions, | ||
) -> Result<Box<dyn crate::Backend<F>>, Error> { | ||
if pil.degrees().len() > 1 { | ||
return Err(Error::NoVariableDegreeAvailable); | ||
} | ||
let fixed = Arc::new( | ||
get_uniquely_sized_cloned(&fixed).map_err(|_| Error::NoVariableDegreeAvailable)?, | ||
); | ||
let stwo = Box::new(StwoProver::new(pil, fixed, setup)?); | ||
Ok(stwo) | ||
} | ||
} | ||
|
||
impl<T: FieldElement> Backend<T> for StwoProver<T> { | ||
#[allow(unused_variables)] | ||
fn verify(&self, proof: &[u8], instances: &[Vec<T>]) -> Result<(), Error> { | ||
assert!(instances.len() == 1); | ||
unimplemented!() | ||
} | ||
#[allow(unreachable_code)] | ||
#[allow(unused_variables)] | ||
fn prove( | ||
&self, | ||
witness: &[(String, Vec<T>)], | ||
prev_proof: Option<Proof>, | ||
witgen_callback: WitgenCallback<T>, | ||
) -> Result<Proof, Error> { | ||
if prev_proof.is_some() { | ||
return Err(Error::NoAggregationAvailable); | ||
} | ||
unimplemented!() | ||
} | ||
#[allow(unused_variables)] | ||
fn export_verification_key(&self, output: &mut dyn io::Write) -> Result<(), Error> { | ||
unimplemented!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use powdr_ast::analyzed::Analyzed; | ||
use std::io; | ||
use std::sync::Arc; | ||
|
||
use powdr_number::FieldElement; | ||
|
||
#[allow(unused_variables)] | ||
pub struct StwoProver<F> { | ||
_analyzed: Arc<Analyzed<F>>, | ||
_fixed: Arc<Vec<(String, Vec<F>)>>, | ||
/// Proving key placeholder | ||
_proving_key: Option<()>, | ||
/// Verifying key placeholder | ||
_verifying_key: Option<()>, | ||
} | ||
|
||
impl<F: FieldElement> StwoProver<F> { | ||
#[allow(dead_code)] | ||
#[allow(unused_variables)] | ||
pub fn new( | ||
_analyzed: Arc<Analyzed<F>>, | ||
_fixed: Arc<Vec<(String, Vec<F>)>>, | ||
setup: Option<&mut dyn io::Read>, | ||
) -> Result<Self, io::Error> { | ||
Ok(Self { | ||
_analyzed, | ||
_fixed, | ||
_proving_key: None, | ||
_verifying_key: None, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters