MCPcopy Create free account
hub / github.com/docknetwork/crypto / add_batch

Method add_batch

vb_accumulator/src/universal.rs:284–303  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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(

Callers 1

Calls 8

max_sizeMethod · 0.80
is_element_acceptableMethod · 0.80
_add_batchMethod · 0.80
get_updatedMethod · 0.80
sizeMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
zeroizeMethod · 0.45

Tested by 1