Skip to content

Commit

Permalink
Refactor FoldedPolynomialStream partially
Browse files Browse the repository at this point in the history
  • Loading branch information
autquis committed Jan 7, 2024
1 parent f7ee8c6 commit 1ec22f9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions poly-commit/src/streaming_kzg/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where

/// Stream implementation of foleded polynomial.
#[derive(Clone, Copy)]
pub struct FoldedPolynomialStream<'a, F, S>(FoldedPolynomialTree<'a, F, S>, usize);
pub struct FoldedPolynomialStream<'a, F, S>(FoldedPolynomialTree<'a, F, S>);
/// Iterator implementation of foleded polynomial.
pub struct FoldedPolynomialStreamIter<'a, F, I> {
challenges: &'a [F],
Expand All @@ -157,8 +157,7 @@ where
/// Initialize a new folded polynomial stream.
pub fn new(coefficients: &'a S, challenges: &'a [F]) -> Self {
let tree = FoldedPolynomialTree::new(coefficients, challenges);
let len = challenges.len();
Self(tree, len)
Self(tree)
}
}

Expand Down Expand Up @@ -240,7 +239,7 @@ fn test_folded_polynomial() {
let challenges = vec![F::one(), two];
let coefficients_stream = coefficients.as_slice();
let foldstream = FoldedPolynomialTree::new(&coefficients_stream, challenges.as_slice());
let fold_stream = FoldedPolynomialStream(foldstream, 2);
let fold_stream = FoldedPolynomialStream(foldstream);
assert_eq!(fold_stream.len(), 1);
assert_eq!(
fold_stream.iter().next(),
Expand All @@ -252,7 +251,7 @@ fn test_folded_polynomial() {
let challenges = vec![F::one(); 4];
let coefficients_stream = coefficients.as_slice();
let foldstream = FoldedPolynomialTree::new(&coefficients_stream, challenges.as_slice());
let fold_stream = FoldedPolynomialStream(foldstream, 4).iter();
let fold_stream = FoldedPolynomialStream(foldstream).iter();
assert_eq!(fold_stream.last(), Some(coefficients.iter().sum()));
}

Expand Down

0 comments on commit 1ec22f9

Please sign in to comment.