Skip to content

Commit

Permalink
make points public
Browse files Browse the repository at this point in the history
  • Loading branch information
ToufeeqP committed Sep 19, 2024
1 parent 3dd0f80 commit afdb0a4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bindings/rust/src/pippenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ macro_rules! pippenger_mult_impl {
$add:ident,
) => {
pub struct $points {
points: Vec<$point_affine>,
pub points: Vec<$point_affine>,
}

impl<I: SliceIndex<[$point_affine]>> Index<I> for $points {
Expand Down Expand Up @@ -114,13 +114,19 @@ macro_rules! pippenger_mult_impl {
}

pub fn mult(&self, scalars: &[u8], nbits: usize) -> $point {
let npoints = self.points.len();
let nbytes = (nbits + 7) / 8;

if scalars.len() < nbytes * npoints {
panic!("scalars length mismatch");
if scalars.len() > nbytes * self.points.len() {
panic!("too many scalars");
}

if scalars.len() % nbytes != 0 {
panic!("scalars len does not fit in correct number of bytes");
}

let npoints = scalars.len() / nbytes;
let points = &self.points[..npoints];

let pool = mt::da_pool();
let ncpus = pool.max_count();
if ncpus < 2 || npoints < 32 {
Expand Down Expand Up @@ -176,7 +182,6 @@ macro_rules! pippenger_mult_impl {
}
let grid = &grid[..];

let points = &self.points[..];
let sz = unsafe { $scratch_sizeof(0) / 8 };

let mut row_sync: Vec<AtomicUsize> = Vec::with_capacity(ny);
Expand Down

0 comments on commit afdb0a4

Please sign in to comment.