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

Create a new batched update.

Absorb an element that must be added to a witness.

Absorb an element that must be deleted from a witness.

Undo an absorbed element’s addition into an update.

Undo an absorbed element’s deletion from an update.

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()
);

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.