pythnet_sdk/
accumulators.rs

1//! Accumulators
2//!
3//! This module defines the Accumulator abstraction as well as the implementation details for
4//! several different accumulators. This library can be used for interacting with PythNet state
5//! proofs for account content.
6
7pub mod merkle;
8pub mod mul;
9
10/// The Accumulator trait defines the interface for an accumulator.
11///
12/// This trait assumes an accumulator has an associated proof type that can be used to prove
13/// membership of a specific item. The choice to return Proof makes this the most generic
14/// implementation possible for any accumulator.
15pub trait Accumulator<'a>
16where
17    Self: Sized,
18    Self::Proof: 'a,
19    Self::Proof: Sized,
20{
21    type Proof;
22
23    /// Prove an item is a member of the accumulator.
24    fn prove(&'a self, item: &[u8]) -> Option<Self::Proof>;
25
26    /// Verify an item is a member of the accumulator.
27    fn check(&'a self, proof: Self::Proof, item: &[u8]) -> bool;
28
29    /// Create an accumulator from a set of items.
30    fn from_set(items: impl Iterator<Item = &'a [u8]>) -> Option<Self>;
31}