Skip to content

Commit

Permalink
Merge pull request #139 from nucypher/fix-typings
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec authored Aug 1, 2023
2 parents f2bcb35 + 0e7c561 commit dc9d81a
Show file tree
Hide file tree
Showing 18 changed files with 195 additions and 207 deletions.
104 changes: 0 additions & 104 deletions .github/workflows/maturin.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,17 @@ jobs:
run: python examples/server_api_simple.py
working-directory: ferveo-python

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

- name: Run pytest
run: pytest
working-directory: ferveo-python

- name: Run mypy.stubtest
run: python -m mypy.stubtest ferveo
working-directory: ferveo-python

codecov:
runs-on: ubuntu-latest
needs: [ test ]
Expand Down
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.10"
8 changes: 0 additions & 8 deletions ferveo-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ publish = false

[lib]
crate-type = ["cdylib"]
name = "ferveo_py"

[features]
extension-module = ["pyo3/extension-module"]
Expand All @@ -18,12 +17,5 @@ default = ["extension-module"]
ferveo = { package = "ferveo-pre-release", path = "../ferveo", features = ["bindings-python"] }
pyo3 = "0.18.2"

# We avoid declaring "pyo3/extension-module" in `dependencies` since it causes compile-time issues:
# https://github.com/PyO3/pyo3/issues/340
# Instead, we expose it in certain cases:
# https://github.com/PyO3/maturin/issues/325
[tool.maturin]
features = ["pyo3/extension-module"]

[build-dependencies]
pyo3-build-config = "*"
11 changes: 11 additions & 0 deletions ferveo-python/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.10"
7 changes: 0 additions & 7 deletions ferveo-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,3 @@
## Build

You will need to have `setuptools-rust` installed. Then, for development, you can just do `pip install -e .` as usual.

## Publish

```bash
maturin build --release
maturin publish
```
2 changes: 1 addition & 1 deletion ferveo-python/examples/exception.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ferveo_py import (
from ferveo import (
Keypair,
Validator,
Dkg,
Expand Down
2 changes: 1 addition & 1 deletion ferveo-python/examples/server_api_precomputed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ferveo_py import (
from ferveo import (
encrypt,
combine_decryption_shares_precomputed,
decrypt_with_shared_secret,
Expand Down
2 changes: 1 addition & 1 deletion ferveo-python/examples/server_api_simple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ferveo_py import (
from ferveo import (
encrypt,
combine_decryption_shares_simple,
decrypt_with_shared_secret,
Expand Down
2 changes: 1 addition & 1 deletion ferveo-python/ferveo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .ferveo_py import (
from ._ferveo import (
encrypt,
combine_decryption_shares_simple,
combine_decryption_shares_precomputed,
Expand Down
46 changes: 33 additions & 13 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from typing import Sequence
from typing import Sequence, final


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

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

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

@staticmethod
Expand All @@ -25,6 +26,7 @@ class Keypair:
...


@final
class FerveoPublicKey:
@staticmethod
def from_bytes(data: bytes) -> FerveoPublicKey:
Expand All @@ -36,10 +38,15 @@ class FerveoPublicKey:
def __hash__(self) -> int:
...

def __richcmp__(self, other: FerveoPublicKey, op: int) -> bool:
@staticmethod
def serialized_size() -> int:
...

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


@final
class Validator:

def __init__(self, address: str, public_key: FerveoPublicKey):
Expand All @@ -50,6 +57,7 @@ class Validator:
public_key: FerveoPublicKey


@final
class Transcript:
@staticmethod
def from_bytes(data: bytes) -> Transcript:
Expand All @@ -59,6 +67,7 @@ class Transcript:
...


@final
class DkgPublicKey:
@staticmethod
def from_bytes(data: bytes) -> DkgPublicKey:
Expand All @@ -67,7 +76,12 @@ class DkgPublicKey:
def __bytes__(self) -> bytes:
...

@staticmethod
def serialized_size() -> int:
...


@final
class ValidatorMessage:

def __init__(
Expand All @@ -81,6 +95,7 @@ class ValidatorMessage:
transcript: Transcript


@final
class Dkg:

def __init__(
Expand All @@ -102,6 +117,7 @@ class Dkg:
...


@final
class Ciphertext:
@staticmethod
def from_bytes(data: bytes) -> Ciphertext:
Expand All @@ -111,6 +127,7 @@ class Ciphertext:
...


@final
class DecryptionShareSimple:
@staticmethod
def from_bytes(data: bytes) -> DecryptionShareSimple:
Expand All @@ -120,6 +137,7 @@ class DecryptionShareSimple:
...


@final
class DecryptionSharePrecomputed:
@staticmethod
def from_bytes(data: bytes) -> DecryptionSharePrecomputed:
Expand All @@ -129,6 +147,7 @@ class DecryptionSharePrecomputed:
...


@final
class AggregatedTranscript:

def __init__(self, messages: Sequence[ValidatorMessage]):
Expand Down Expand Up @@ -163,6 +182,7 @@ class AggregatedTranscript:
...


@final
class SharedSecret:

@staticmethod
Expand All @@ -173,15 +193,19 @@ class SharedSecret:
...


@final
class FerveoVariant:
@staticmethod
def simple() -> str: ...
Simple: FerveoVariant
Precomputed: FerveoVariant

@staticmethod
def precomputed() -> str: ...
def __eq__(self, other: object) -> bool:
...

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


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


Expand Down Expand Up @@ -267,7 +291,3 @@ class ValidatorPublicKeyMismatch(Exception):

class SerializationError(Exception):
pass


class InvalidVariant(Exception):
pass
12 changes: 1 addition & 11 deletions ferveo-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
build-backend = "maturin"

[project]
name = "ferveo"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
requires = ["setuptools", "wheel", "setuptools-rust"]


2 changes: 1 addition & 1 deletion ferveo-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ use ferveo::bindings_python::*;
use pyo3::prelude::*;

#[pymodule]
fn ferveo_py(py: Python, m: &PyModule) -> PyResult<()> {
fn _ferveo(py: Python, m: &PyModule) -> PyResult<()> {
make_ferveo_py_module(py, m)
}
Loading

0 comments on commit dc9d81a

Please sign in to comment.