Skip to content

Commit

Permalink
add equality to FerveoVariant python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 13, 2023
1 parent 6c1d4be commit c3b7497
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Sequence, final


@final
class Keypair:
@staticmethod
Expand All @@ -24,6 +25,7 @@ class Keypair:
def public_key(self) -> FerveoPublicKey:
...


@final
class FerveoPublicKey:
@staticmethod
Expand All @@ -40,6 +42,7 @@ class FerveoPublicKey:
def serialized_size() -> int:
...


@final
class Validator:

Expand All @@ -50,6 +53,7 @@ class Validator:

public_key: FerveoPublicKey


@final
class Transcript:
@staticmethod
Expand All @@ -59,6 +63,7 @@ class Transcript:
def __bytes__(self) -> bytes:
...


@final
class DkgPublicKey:
@staticmethod
Expand All @@ -72,6 +77,7 @@ class DkgPublicKey:
def serialized_size() -> int:
...


@final
class ValidatorMessage:

Expand All @@ -85,6 +91,7 @@ class ValidatorMessage:
validator: Validator
transcript: Transcript


@final
class Dkg:

Expand All @@ -106,6 +113,7 @@ class Dkg:
def aggregate_transcripts(self, messages: Sequence[ValidatorMessage]) -> AggregatedTranscript:
...


@final
class Ciphertext:
@staticmethod
Expand All @@ -115,6 +123,7 @@ class Ciphertext:
def __bytes__(self) -> bytes:
...


@final
class DecryptionShareSimple:
@staticmethod
Expand All @@ -123,6 +132,8 @@ class DecryptionShareSimple:

def __bytes__(self) -> bytes:
...


@final
class DecryptionSharePrecomputed:
@staticmethod
Expand All @@ -132,6 +143,7 @@ class DecryptionSharePrecomputed:
def __bytes__(self) -> bytes:
...


@final
class AggregatedTranscript:

Expand Down Expand Up @@ -166,6 +178,7 @@ class AggregatedTranscript:
def __bytes__(self) -> bytes:
...


@final
class SharedSecret:

Expand All @@ -182,6 +195,9 @@ class FerveoVariant:
simple: FerveoVariant
precomputed: FerveoVariant

def __eq__(self, other: object) -> bool:
...


def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext:
...
Expand Down
3 changes: 3 additions & 0 deletions ferveo-python/test/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ def test_public_key_serialization():
def test_ferveo_variant_serialization():
assert str(FerveoVariant.precomputed) == "FerveoVariant::Precomputed"
assert str(FerveoVariant.simple) == "FerveoVariant::Simple"
assert FerveoVariant.precomputed == FerveoVariant.precomputed
assert FerveoVariant.simple == FerveoVariant.simple
assert FerveoVariant.precomputed != FerveoVariant.simple
4 changes: 4 additions & 0 deletions ferveo/src/bindings_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ impl FerveoVariant {
fn __str__(&self) -> String {
self.0.to_string()
}

fn __eq__(&self, other: &Self) -> bool {
self.0 == other.0
}
}

impl From<api::FerveoVariant> for FerveoVariant {
Expand Down

0 comments on commit c3b7497

Please sign in to comment.