Skip to content

Commit

Permalink
chore(linter): add ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Nov 3, 2023
1 parent b31d167 commit f4905e5
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 188 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jobs:
working-directory: ferveo-python

- name: Install pip dependencies
run: pip install pytest mypy
run: pip install pytest mypy ruff

- name: Run pytest
run: pytest
Expand All @@ -186,6 +186,10 @@ jobs:
run: python -m mypy.stubtest ferveo
working-directory: ferveo-python

- name: Run ruff
run: ruff --format=github --check
working-directory: ferveo-python

codecov:
runs-on: ubuntu-latest
needs: [ test ]
Expand Down
245 changes: 69 additions & 176 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,306 +1,199 @@
from typing import Sequence, final


@final
class Keypair:
@staticmethod
def random() -> Keypair:
...

def random() -> Keypair: ...
@staticmethod
def from_secure_randomness(secure_randomness: bytes) -> Keypair:
...

def from_secure_randomness(secure_randomness: bytes) -> Keypair: ...
@staticmethod
def secure_randomness_size() -> int:
...

def secure_randomness_size() -> int: ...
@staticmethod
def from_bytes(data: bytes) -> Keypair:
...

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

def public_key(self) -> FerveoPublicKey:
...

def from_bytes(data: bytes) -> Keypair: ...
def __bytes__(self) -> bytes: ...
def public_key(self) -> FerveoPublicKey: ...

@final
class FerveoPublicKey:
@staticmethod
def from_bytes(data: bytes) -> FerveoPublicKey:
...

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

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

def from_bytes(data: bytes) -> FerveoPublicKey: ...
def __bytes__(self) -> bytes: ...
def __hash__(self) -> int: ...
@staticmethod
def serialized_size() -> int:
...

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

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

@final
class Validator:

def __init__(self, address: str, public_key: FerveoPublicKey):
...
def __init__(self, address: str, public_key: FerveoPublicKey): ...

address: str

public_key: FerveoPublicKey


@final
class Transcript:
@staticmethod
def from_bytes(data: bytes) -> Transcript:
...

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

def from_bytes(data: bytes) -> Transcript: ...
def __bytes__(self) -> bytes: ...

@final
class DkgPublicKey:
@staticmethod
def from_bytes(data: bytes) -> DkgPublicKey:
...

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

def from_bytes(data: bytes) -> DkgPublicKey: ...
def __bytes__(self) -> bytes: ...
@staticmethod
def serialized_size() -> int:
...

def serialized_size() -> int: ...

@final
class ValidatorMessage:

def __init__(
self,
validator: Validator,
transcript: Transcript,
):
...
self,
validator: Validator,
transcript: Transcript,
): ...

validator: Validator
transcript: Transcript


@final
class Dkg:

def __init__(
self,
tau: int,
shares_num: int,
security_threshold: int,
validators: Sequence[Validator],
me: Validator,
):
...
self,
tau: int,
shares_num: int,
security_threshold: int,
validators: Sequence[Validator],
me: Validator,
): ...

public_key: DkgPublicKey

def generate_transcript(self) -> Transcript:
...

def aggregate_transcripts(self, messages: Sequence[ValidatorMessage]) -> AggregatedTranscript:
...

def generate_transcript(self) -> Transcript: ...
def aggregate_transcripts(
self, messages: Sequence[ValidatorMessage]
) -> AggregatedTranscript: ...

@final
class Ciphertext:
header: CiphertextHeader
payload: bytes

@staticmethod
def from_bytes(data: bytes) -> Ciphertext:
...

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

def from_bytes(data: bytes) -> Ciphertext: ...
def __bytes__(self) -> bytes: ...

@final
class CiphertextHeader:
@staticmethod
def from_bytes(data: bytes) -> CiphertextHeader:
...

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

def from_bytes(data: bytes) -> CiphertextHeader: ...
def __bytes__(self) -> bytes: ...

@final
class DecryptionShareSimple:
@staticmethod
def from_bytes(data: bytes) -> DecryptionShareSimple:
...

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

def from_bytes(data: bytes) -> DecryptionShareSimple: ...
def __bytes__(self) -> bytes: ...

@final
class DecryptionSharePrecomputed:
@staticmethod
def from_bytes(data: bytes) -> DecryptionSharePrecomputed:
...

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

def from_bytes(data: bytes) -> DecryptionSharePrecomputed: ...
def __bytes__(self) -> bytes: ...

@final
class AggregatedTranscript:

def __init__(self, messages: Sequence[ValidatorMessage]):
...

def verify(self, shares_num: int, messages: Sequence[ValidatorMessage]) -> bool:
...

def __init__(self, messages: Sequence[ValidatorMessage]): ...
def verify(self, shares_num: int, messages: Sequence[ValidatorMessage]) -> bool: ...
def create_decryption_share_simple(
self,
dkg: Dkg,
ciphertext_header: CiphertextHeader,
aad: bytes,
validator_keypair: Keypair
) -> DecryptionShareSimple:
...

self,
dkg: Dkg,
ciphertext_header: CiphertextHeader,
aad: bytes,
validator_keypair: Keypair,
) -> DecryptionShareSimple: ...
def create_decryption_share_precomputed(
self,
dkg: Dkg,
ciphertext_header: CiphertextHeader,
aad: bytes,
validator_keypair: Keypair
) -> DecryptionSharePrecomputed:
...

self,
dkg: Dkg,
ciphertext_header: CiphertextHeader,
aad: bytes,
validator_keypair: Keypair,
) -> DecryptionSharePrecomputed: ...
@staticmethod
def from_bytes(data: bytes) -> AggregatedTranscript:
...

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

def from_bytes(data: bytes) -> AggregatedTranscript: ...
def __bytes__(self) -> bytes: ...

@final
class SharedSecret:

@staticmethod
def from_bytes(data: bytes) -> SharedSecret:
...

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

def from_bytes(data: bytes) -> SharedSecret: ...
def __bytes__(self) -> bytes: ...

@final
class FerveoVariant:
Simple: FerveoVariant
Precomputed: FerveoVariant

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

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


def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext:
...

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

def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext: ...
def combine_decryption_shares_simple(
decryption_shares: Sequence[DecryptionShareSimple],
) -> SharedSecret:
...


decryption_shares: Sequence[DecryptionShareSimple],
) -> SharedSecret: ...
def combine_decryption_shares_precomputed(
decryption_shares: Sequence[DecryptionSharePrecomputed],
) -> SharedSecret:
...


decryption_shares: Sequence[DecryptionSharePrecomputed],
) -> SharedSecret: ...
def decrypt_with_shared_secret(
ciphertext: Ciphertext,
aad: bytes,
shared_secret: SharedSecret,
) -> bytes:
...

ciphertext: Ciphertext,
aad: bytes,
shared_secret: SharedSecret,
) -> bytes: ...

class ThresholdEncryptionError(Exception):
pass


class InvalidDkgStateToDeal(Exception):
pass


class InvalidDkgStateToAggregate(Exception):
pass


class InvalidDkgStateToVerify(Exception):
pass


class InvalidDkgStateToIngest(Exception):
pass


class DealerNotInValidatorSet(Exception):
pass


class UnknownDealer(Exception):
pass


class DuplicateDealer(Exception):
pass


class InvalidPvssTranscript(Exception):
pass


class InsufficientTranscriptsForAggregate(Exception):
pass


class InvalidDkgPublicKey(Exception):
pass


class InsufficientValidators(Exception):
pass


class InvalidTranscriptAggregate(Exception):
pass


class ValidatorsNotSorted(Exception):
pass


class ValidatorPublicKeyMismatch(Exception):
pass


class SerializationError(Exception):
pass
Loading

0 comments on commit f4905e5

Please sign in to comment.