Add a batch of members in the accumulator. Reads and writes to state. Described in section 3 of the paper
(
&self,
elements: Vec<G::ScalarField>,
sk: &SecretKey<G::ScalarField>,
initial_elements_store: &dyn InitialElementsStore<G::ScalarField>,
state: &mut dyn State
| 282 | |
| 283 | /// Add a batch of members in the accumulator. Reads and writes to state. Described in section 3 of the paper |
| 284 | pub fn add_batch( |
| 285 | &self, |
| 286 | elements: Vec<G::ScalarField>, |
| 287 | sk: &SecretKey<G::ScalarField>, |
| 288 | initial_elements_store: &dyn InitialElementsStore<G::ScalarField>, |
| 289 | state: &mut dyn State<G::ScalarField>, |
| 290 | ) -> Result<Self, VBAccumulatorError> { |
| 291 | if self.max_size() < (state.size() + elements.len() as u64) { |
| 292 | return Err(VBAccumulatorError::BatchExceedsAccumulatorCapacity); |
| 293 | } |
| 294 | for element in elements.iter() { |
| 295 | if !self.is_element_acceptable(element, initial_elements_store) { |
| 296 | return Err(VBAccumulatorError::ProhibitedElement); |
| 297 | } |
| 298 | } |
| 299 | let (mut d_alpha, V) = self._add_batch(elements, sk, state)?; |
| 300 | let f_V = d_alpha * self.f_V; |
| 301 | d_alpha.zeroize(); |
| 302 | Ok(self.get_updated(f_V, V)) |
| 303 | } |
| 304 | |
| 305 | /// Compute new accumulated value after removal |
| 306 | pub fn compute_new_post_remove( |