Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove assertion and add test #759

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions ec/src/scalar_mul/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@ impl<T: ScalarMul> BatchMulPreprocessing<T> {
}

pub fn batch_mul(&self, v: &[T::ScalarField]) -> Vec<T::MulBase> {
assert!(
v.len() <= self.max_num_scalars,
"number of scalars exceeds the maximum number of scalars supported by this table"
);
let result = cfg_iter!(v)
.map(|e| self.windowed_mul(e))
.collect::<Vec<_>>();
let result: Vec<_> = cfg_iter!(v).map(|e| self.windowed_mul(e)).collect();
T::batch_convert_to_mul_base(&result)
}

Expand Down
12 changes: 12 additions & 0 deletions test-templates/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ macro_rules! __test_group {
assert_eq!(context.mul_with_table(&bad_table, &b), None);
}
}

// The table size is only determined by the number of non-zero entries.
let mut scalars = vec![ScalarField::rand(&mut rng); 100];
scalars[0] = ScalarField::zero();
let table = BatchMulPreprocessing::new(a, scalars.len() - 1);
let result = table.batch_mul(&scalars);
let naive_result = scalars
.iter()
.enumerate()
.map(|(i, s)| a * s)
.collect::<Vec<_>>();
assert_eq!(result, naive_result);
}
}

Expand Down
Loading