[][src]Struct clacc::Accumulator

pub struct Accumulator<T> where
    T: BigInt
{ /* fields omitted */ }

An accumulator.

Elements may be added and deleted from the acculumator without increasing the size of its internal parameters. That is, the number of digits in the accumulation z will never exceed the number of digits in the modulus n.

Implementations

impl<T> Accumulator<T> where
    T: BigInt
[src]

pub fn with_private_key(p: T, q: T) -> Self[src]

Initialize an accumulator from private key parameters. All accumulators are able to add elements and verify witnesses. An accumulator constructed from a private key is able to delete elements and prove elements after their addition.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
let p = vec![0x3d];
let q = vec![0x35];
let acc = Accumulator::<BigIntGmp>::with_private_key(
    p.as_slice().into(),
    q.as_slice().into()
);

pub fn with_random_key() -> (Accumulator<T>, T, T)[src]

Create an accumulator from a randomly generated private key and return it along with the generated key parameters.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
Accumulator::<BigIntGmp>::with_random_key();

pub fn with_public_key(n: T) -> Self[src]

Initialize an accumulator from a public key. An accumulator constructed from a public key is only able to add elements and verify witnesses.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
let n = vec![0x0c, 0xa1];
let acc = Accumulator::<BigIntGmp>::with_public_key(
    n.as_slice().into()
);

pub fn get_public_key(&self) -> &T[src]

Get an accumulator's public key.

pub fn add<M, N>(&mut self, x: &[u8]) -> Witness<T> where
    M: Mapper,
    N: ArrayLength<u8>, 
[src]

Add an element to an accumulator.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let n = vec![0x0c, 0xa1];
let mut acc = Accumulator::<BigIntGmp>::with_public_key(
    n.as_slice().into()
);
let x = b"abc";
let w = acc.add::<MapBlake2b, U16>(x);
assert!(acc.verify::<MapBlake2b, U16>(x, &w).is_ok());

This works with accumulators constructed from a public key or a private key.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let p = vec![0x3d];
let q = vec![0x35];
let mut acc = Accumulator::<BigIntGmp>::with_private_key(
    p.as_slice().into(),
    q.as_slice().into()
);
let x = b"abc";
let w = acc.add::<MapBlake2b, U16>(x);
assert!(acc.verify::<MapBlake2b, U16>(x, &w).is_ok());

pub fn del<M, N>(&mut self, x: &[u8], w: &Witness<T>) -> Result<T, &'static str> where
    M: Mapper,
    N: ArrayLength<u8>, 
[src]

Delete an element from an accumulator.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let p = vec![0x3d];
let q = vec![0x35];
let mut acc = Accumulator::<BigIntGmp>::with_private_key(
    p.as_slice().into(),
    q.as_slice().into()
);
let x = b"abc";
let w = acc.add::<MapBlake2b, U16>(x);
assert!(acc.del::<MapBlake2b, U16>(x, &w).is_ok());
assert!(acc.verify::<MapBlake2b, U16>(x, &w).is_err());
assert!(acc.del::<MapBlake2b, U16>(x, &w).is_err());

This will only succeed with an accumulator constructed from a private key.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let n = vec![0x0c, 0xa1];
let mut acc = Accumulator::<BigIntGmp>::with_public_key(
    n.as_slice().into()
);
let x = b"abc";
let w = acc.add::<MapBlake2b, U16>(x);
assert!(acc.del::<MapBlake2b, U16>(x, &w).is_err());

pub fn prove<M, N>(&self, x: &[u8]) -> Result<Witness<T>, &'static str> where
    M: Mapper,
    N: ArrayLength<u8>, 
[src]

Generate a witness to an element's addition to the accumulation.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let p = vec![0x3d];
let q = vec![0x35];
let mut acc = Accumulator::<BigIntGmp>::with_private_key(
    p.as_slice().into(),
    q.as_slice().into()
);
let x = b"abc";
acc.add::<MapBlake2b, U16>(x);
let w = acc.prove::<MapBlake2b, U16>(x).unwrap();
assert!(acc.verify::<MapBlake2b, U16>(x, &w).is_ok());

This will only succeed with an accumulator constructed from a private key.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let n = vec![0x0c, 0xa1];
let mut acc = Accumulator::<BigIntGmp>::with_public_key(
    n.as_slice().into()
);
let x = b"abc";
acc.add::<MapBlake2b, U16>(x);
assert!(acc.prove::<MapBlake2b, U16>(x).is_err());

pub fn verify<M, N>(&self, x: &[u8], w: &Witness<T>) -> Result<(), &'static str> where
    M: Mapper,
    N: ArrayLength<u8>, 
[src]

Verify an element is a member of an accumulator.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let n = vec![0x0c, 0xa1];
let mut acc = Accumulator::<BigIntGmp>::with_public_key(
    n.as_slice().into()
);
let x = b"abc";
let w = acc.add::<MapBlake2b, U16>(x);
assert!(acc.verify::<MapBlake2b, U16>(x, &w).is_ok());

This works with accumulators constructed from a public key or a private key.

use clacc::Accumulator;
use clacc::bigint::BigIntGmp;
use clacc::mapper::MapBlake2b;
use clacc::typenum::U16;
let p = vec![0x3d];
let q = vec![0x35];
let mut acc = Accumulator::<BigIntGmp>::with_private_key(
    p.as_slice().into(),
    q.as_slice().into()
);
let x = b"abc";
let w = acc.add::<MapBlake2b, U16>(x);
assert!(acc.verify::<MapBlake2b, U16>(x, &w).is_ok());

pub fn get_value(&self) -> &T[src]

Return the accumulation value as a BigInt.

pub fn set_value(&mut self, z: &T)[src]

Set the accumulation value from a BigInt.

Trait Implementations

impl<T: Clone> Clone for Accumulator<T> where
    T: BigInt
[src]

impl<T: Debug> Debug for Accumulator<T> where
    T: BigInt
[src]

impl<T> Display for Accumulator<T> where
    T: BigInt
[src]

impl<T> VpackAccumulator<T> for Accumulator<T> where
    T: BigInt
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Accumulator<T> where
    T: RefUnwindSafe

impl<T> Send for Accumulator<T>

impl<T> Sync for Accumulator<T>

impl<T> Unpin for Accumulator<T> where
    T: Unpin

impl<T> UnwindSafe for Accumulator<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,