Skip to content

Commit

Permalink
add __hash__ to FerveoVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 14, 2023
1 parent cea467e commit 06321d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ class FerveoVariant:
def __eq__(self, other: object) -> bool:
...

def __hash__(self) -> int:
...


def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext:
...
Expand Down
8 changes: 8 additions & 0 deletions ferveo/src/bindings_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ impl FerveoVariant {
fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult<bool> {
richcmp(self, other, op)
}

fn __hash__(&self) -> PyResult<isize> {
let bytes = self
.0
.to_bytes()
.map_err(|err| FerveoPythonError::Other(err.to_string()))?;
hash("FerveoVariant", &bytes)
}
}

impl fmt::Display for FerveoVariant {
Expand Down

0 comments on commit 06321d7

Please sign in to comment.