pub struct Group {
pub tree: HashedLeanIMT<ELEMENT_SIZE, PoseidonHash>,
}
Fields§
§tree: HashedLeanIMT<ELEMENT_SIZE, PoseidonHash>
Hashed LeanIMT
Implementations§
Source§impl Group
impl Group
Sourcepub fn new(members: &[Element]) -> Result<Self, SemaphoreError>
pub fn new(members: &[Element]) -> Result<Self, SemaphoreError>
Creates a new instance of the Group with optional initial members
Sourcepub fn root(&self) -> Option<Element>
pub fn root(&self) -> Option<Element>
Returns the root hash of the tree, or None if the tree is empty
Sourcepub fn index_of(&self, member: Element) -> Option<usize>
pub fn index_of(&self, member: Element) -> Option<usize>
Returns the index of a member if it exists
Sourcepub fn add_member(&mut self, member: Element) -> Result<(), SemaphoreError>
pub fn add_member(&mut self, member: Element) -> Result<(), SemaphoreError>
Adds a new member to the group
Sourcepub fn add_members(&mut self, members: &[Element]) -> Result<(), SemaphoreError>
pub fn add_members(&mut self, members: &[Element]) -> Result<(), SemaphoreError>
Adds a set of members to the group
Sourcepub fn update_member(
&mut self,
index: usize,
member: Element,
) -> Result<(), SemaphoreError>
pub fn update_member( &mut self, index: usize, member: Element, ) -> Result<(), SemaphoreError>
Updates a group member
Sourcepub fn remove_member(&mut self, index: usize) -> Result<(), SemaphoreError>
pub fn remove_member(&mut self, index: usize) -> Result<(), SemaphoreError>
Removes a member from the group
Sourcepub fn generate_proof(
&self,
index: usize,
) -> Result<MerkleProof, SemaphoreError>
pub fn generate_proof( &self, index: usize, ) -> Result<MerkleProof, SemaphoreError>
Creates a proof of membership for a member
Sourcepub fn verify_proof(proof: &MerkleProof) -> bool
pub fn verify_proof(proof: &MerkleProof) -> bool
Verifies a proof of membership for a member
Trait Implementations§
impl Eq for Group
impl StructuralPartialEq for Group
Auto Trait Implementations§
impl Freeze for Group
impl RefUnwindSafe for Group
impl Send for Group
impl Sync for Group
impl Unpin for Group
impl UnwindSafe for Group
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more