diff --git a/ferveo-python/ferveo/__init__.pyi b/ferveo-python/ferveo/__init__.pyi index 51f982a6..4b5aaa4c 100644 --- a/ferveo-python/ferveo/__init__.pyi +++ b/ferveo-python/ferveo/__init__.pyi @@ -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: ... diff --git a/ferveo/src/bindings_python.rs b/ferveo/src/bindings_python.rs index c01dffc4..8ee06dbd 100644 --- a/ferveo/src/bindings_python.rs +++ b/ferveo/src/bindings_python.rs @@ -295,6 +295,14 @@ impl FerveoVariant { fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult { richcmp(self, other, op) } + + fn __hash__(&self) -> PyResult { + let bytes = self + .0 + .to_bytes() + .map_err(|err| FerveoPythonError::Other(err.to_string()))?; + hash("FerveoVariant", &bytes) + } } impl fmt::Display for FerveoVariant {