Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subtract to MultiHash #605

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions fastcrypto/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@
/// Add all the elements of another hash function into this hash function.
fn union(&mut self, other: &Self);

/// Remove all the elements of another hash function from this hash function.
fn subtract(&mut self, other: &Self);

// Note that the "remove" operation is safe even if an item has been removed
// more times than it has been inserted. To see why, consider the following
// example: Suppose an adversary has performed two sets of "insert(x)" and
Expand Down Expand Up @@ -302,6 +305,10 @@
self.accumulator += other.accumulator;
}

fn subtract(&mut self, other: &Self) {
self.accumulator -= other.accumulator;
}

Check warning on line 310 in fastcrypto/src/hash.rs

View check run for this annotation

Codecov / codecov/patch

fastcrypto/src/hash.rs#L308-L310

Added lines #L308 - L310 were not covered by tests

fn remove<Data: AsRef<[u8]>>(&mut self, item: Data) {
self.accumulator -= Self::hash_to_point(item);
}
Expand Down