Struct clacc::Update [−][src]
pub struct Update<T> where
    T: BigInt,  { /* fields omitted */ }Expand description
A sum of updates to be applied to witnesses.
Implementations
pub fn add<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
pub fn add<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
Absorb an element that must be added to a witness.
pub fn del<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
pub fn del<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
Absorb an element that must be deleted from a witness.
pub fn undo_add<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
pub fn undo_add<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
Undo an absorbed element’s addition into an update.
pub fn undo_del<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
pub fn undo_del<'a, M, N, S, V>(&mut self, v: &'a V, w: &Witness<T>) where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
Undo an absorbed element’s deletion from an update.
pub fn update_witness<'a, M, N, S, V>(
    &self, 
    acc: &Accumulator<T>, 
    v: &'a V, 
    w: &Witness<T>
) -> Witness<T> where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
pub fn update_witness<'a, M, N, S, V>(
    &self, 
    acc: &Accumulator<T>, 
    v: &'a V, 
    w: &Witness<T>
) -> Witness<T> where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>, 
Update a witness. The update will include all additions and deletions previously absorbed into this update struct.
use clacc::{
    Accumulator, Update, RawSerializer,
    blake2::Mapper,
    gmp::BigInt,
    typenum::U16,
};
// In this example, the update will include a deletion, so the
// accumulator must be created with a private key.
let p = vec![0x3d];
let q = vec![0x35];
let mut acc = Accumulator::<BigInt>::with_private_key(
    p.as_slice().into(),
    q.as_slice().into()
);
// Create the static element.
let xs = b"abc".to_vec();
// Create the deletion.
let xd = b"def".to_vec();
// Create the addition.
let xa = b"ghi".to_vec();
// Add the deletion element.
acc.add::<Mapper, U16, RawSerializer, _>(&xd);
// Add the static element to the accumulator.
let mut wxs = acc.add::<Mapper, U16, RawSerializer, _>(&xs);
// Delete the deletion element from the accumulator.
let wxd = acc.prove::<Mapper, U16, RawSerializer, _>(&xd).unwrap();
acc.del::<Mapper, U16, RawSerializer, _>(&xd, &wxd).unwrap();
// Create an update object and absorb the addition and deletion.
let mut u = Update::new();
u.del::<Mapper, U16, RawSerializer, _>(&xd, &wxd);
u.add::<Mapper, U16, RawSerializer, _>(
    &xa,
    &acc.add::<Mapper, U16, RawSerializer, _>(&xa),
);
// Update the static element's witness.
wxs = u.update_witness::<Mapper, U16, RawSerializer, _>(
    &acc,
    &xs,
    &wxs,
);
assert!(acc.verify::<Mapper, U16, RawSerializer, _>(
    &xs,
    &wxs).is_ok()
);pub fn update_witnesses<'a, M, N, S, V, IS, IA>(
    &self, 
    acc: &Accumulator<T>, 
    s: IS, 
    a: IA, 
    thread_count: usize
) -> Result<(), &'static str> where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>,
    IS: Iterator<Item = &'a mut (V, Witness<T>)> + 'a + Send,
    IA: Iterator<Item = &'a mut (V, Witness<T>)> + 'a + Send, 
pub fn update_witnesses<'a, M, N, S, V, IS, IA>(
    &self, 
    acc: &Accumulator<T>, 
    s: IS, 
    a: IA, 
    thread_count: usize
) -> Result<(), &'static str> where
    M: Mapper,
    N: ArrayLength<u8>,
    V: 'a,
    S: ElementSerializer<V>,
    IS: Iterator<Item = &'a mut (V, Witness<T>)> + 'a + Send,
    IA: Iterator<Item = &'a mut (V, Witness<T>)> + 'a + Send, 
Multithreaded version of update_witness that can update multiple
witnesses and automatically manage updates applied to newly added
elements.
It is assumed that the additional elements have been absorbed by the update and that their witnesses are the accumulator’s value before any of the additions or deletions absorbed by this update were applied. Updating the witnesses for each of these additional elements is thus acheived by simply removing its respective element from the update and applying the result to its witness.
Arguments
acc- The current accumulator.s- Iterator to element-witness pairs of static elements.a- Iterator to element-witness pairs of added elements.thread_count- The number of threads to use. Returns an error if 0.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Update<T> where
    T: RefUnwindSafe, 
impl<T> UnwindSafe for Update<T> where
    T: UnwindSafe, 
Blanket Implementations
Mutably borrows from an owned value. Read more