forked from zcash/halo2
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #272 from privacy-scaling-explorations/feature/pol…
…y-backend Move poly module from common to backend
- Loading branch information
Showing
36 changed files
with
125 additions
and
132 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::poly::Polynomial; | ||
pub(crate) use halo2_common::helpers::{SerdeFormat, SerdePrimeField}; | ||
use halo2_middleware::ff::PrimeField; | ||
use std::io; | ||
|
||
pub(crate) use halo2_common::helpers::{pack, unpack, CurveRead, SerdeCurveAffine}; | ||
|
||
/// Reads a vector of polynomials from buffer | ||
pub fn read_polynomial_vec<R: io::Read, F: SerdePrimeField, B>( | ||
reader: &mut R, | ||
format: SerdeFormat, | ||
) -> io::Result<Vec<Polynomial<F, B>>> { | ||
let mut len = [0u8; 4]; | ||
reader.read_exact(&mut len)?; | ||
let len = u32::from_be_bytes(len); | ||
|
||
(0..len) | ||
.map(|_| Polynomial::<F, B>::read(reader, format)) | ||
.collect::<io::Result<Vec<_>>>() | ||
} | ||
|
||
/// Writes a slice of polynomials to buffer | ||
pub fn write_polynomial_slice<W: io::Write, F: SerdePrimeField, B>( | ||
slice: &[Polynomial<F, B>], | ||
writer: &mut W, | ||
format: SerdeFormat, | ||
) -> io::Result<()> { | ||
writer.write_all(&(slice.len() as u32).to_be_bytes())?; | ||
for poly in slice.iter() { | ||
poly.write(writer, format)?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
/// Gets the total number of bytes of a slice of polynomials, assuming all polynomials are the same length | ||
pub fn polynomial_slice_byte_length<F: PrimeField, B>(slice: &[Polynomial<F, B>]) -> usize { | ||
let field_len = F::default().to_repr().as_ref().len(); | ||
4 + slice.len() * (4 + field_len * slice.get(0).map(|poly| poly.len()).unwrap_or(0)) | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
mod helpers; | ||
pub mod plonk; | ||
pub mod poly; | ||
|
||
// Internal re-exports | ||
pub use halo2_common::arithmetic; | ||
pub use halo2_common::circuit; | ||
pub use halo2_common::helpers; | ||
pub use halo2_common::multicore; | ||
pub use halo2_common::poly; | ||
pub use halo2_common::transcript; | ||
pub use halo2_common::SerdeFormat; |
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.