Skip to content

Commit

Permalink
Refer to generator rather than indexed randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Jul 5, 2024
1 parent 969d6d5 commit 295f546
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ipa-core/src/protocol/prss/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ impl SharedRandomness for IndexedSharedRandomness {
}

pub struct ChunkIter<'a, Z: ArrayLength> {
inner: &'a IndexedSharedRandomness,
inner: &'a Generator,
index: PrssIndex,
offset: usize,
direction: Direction,
phantom_data: PhantomData<Z>,
}

Expand All @@ -161,12 +160,7 @@ impl<'a, Z: ArrayLength> Iterator for ChunkIter<'a, Z> {

fn next(&mut self) -> Option<Self::Item> {
let chunk = GenericArray::generate(|i| {
let generator = match self.direction {
Direction::Left => &self.inner.left,
Direction::Right => &self.inner.right,
};

generator.generate(self.index.offset(self.offset + i))
self.inner.generate(self.index.offset(self.offset + i))
});

self.offset += Z::USIZE;
Expand All @@ -175,16 +169,19 @@ impl<'a, Z: ArrayLength> Iterator for ChunkIter<'a, Z> {
}

impl<'a, Z: ArrayLength> ChunkIter<'a, Z> {
#[inline]
pub fn new<I: Into<PrssIndex>>(
prss: &'a IndexedSharedRandomness,
index: I,
direction: Direction,
) -> Self {
Self {
inner: prss,
inner: match direction {
Direction::Left => &prss.left,
Direction::Right => &prss.right,
},
index: index.into(),
offset: 0,
direction,
phantom_data: PhantomData,
}
}
Expand Down

0 comments on commit 295f546

Please sign in to comment.