-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plonky3 backend integration for witness columns only
- Loading branch information
Showing
18 changed files
with
638 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ members = [ | |
"pil-analyzer", | ||
"pipeline", | ||
"pilopt", | ||
"plonky3", | ||
"asm-to-pil", | ||
"backend", | ||
"ast", | ||
|
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,53 @@ | ||
use std::{io, path::Path}; | ||
|
||
use powdr_ast::analyzed::Analyzed; | ||
use powdr_executor::witgen::WitgenCallback; | ||
use powdr_number::FieldElement; | ||
use powdr_plonky3::Plonky3Prover; | ||
|
||
use crate::{Backend, BackendFactory, BackendOptions, Error, Proof}; | ||
|
||
pub(crate) struct Factory; | ||
|
||
impl<T: FieldElement> BackendFactory<T> for Factory { | ||
fn create<'a>( | ||
&self, | ||
pil: &'a Analyzed<T>, | ||
_fixed: &'a [(String, Vec<T>)], | ||
_output_dir: Option<&'a Path>, | ||
setup: Option<&mut dyn io::Read>, | ||
verification_key: Option<&mut dyn io::Read>, | ||
verification_app_key: Option<&mut dyn io::Read>, | ||
_: BackendOptions, | ||
) -> Result<Box<dyn crate::Backend<'a, T> + 'a>, Error> { | ||
if setup.is_some() { | ||
return Err(Error::NoSetupAvailable); | ||
} | ||
if verification_key.is_some() { | ||
return Err(Error::NoVerificationAvailable); | ||
} | ||
if verification_app_key.is_some() { | ||
return Err(Error::NoAggregationAvailable); | ||
} | ||
Ok(Box::new(Plonky3Prover::new(pil))) | ||
} | ||
} | ||
|
||
impl<'a, T: FieldElement> Backend<'a, T> for Plonky3Prover<'a, T> { | ||
fn verify(&self, proof: &[u8], instances: &[Vec<T>]) -> Result<(), Error> { | ||
Ok(self.verify(proof, instances)?) | ||
} | ||
|
||
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); | ||
} | ||
|
||
Ok(self.prove(witness, witgen_callback)?) | ||
} | ||
} |
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,3 @@ | ||
# Plonky3 | ||
|
||
powdr partially supports [plonky3](https://github.com/Plonky3/Plonky3) with the Goldilocks field. Progress is tracked [here](https://github.com/powdr-labs/powdr/issues/1468). |
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
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
Oops, something went wrong.