Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 13, 2023
1 parent 5459efa commit 7f3a7f2
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nucypher-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
run: pip install mypy

- name: Run mypy.stubtest
run: python -m mypy.stubtest nucypher_core
run: python -m mypy.stubtest nucypher_core --allowlist stubtest-allowlist.txt
working-directory: nucypher-core-python

trigger-wheels:
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nucypher-core-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ crate-type = ["cdylib"]
[dependencies]
pyo3 = "0.18"
nucypher-core = { path = "../nucypher-core" }
umbral-pre = { version = "0.10.0", features = ["bindings-python"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", ref = "4b28a85c494e4e2640abb131460da0680a74134d" }
ferveo = { package = "ferveo-pre-release", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", ref = "fbb97be59d991a263233a0b876da982143b2cbf2" }
umbral-pre = { version = "0.10.0", features = ["bindings-python"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" }
ferveo = { package = "ferveo-pre-release", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", rev = "cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" }
derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] }

[build-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions nucypher-core-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ This repo contains the Python bindings for the [main Rust project][nucypher-core

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

## Development

Update `nucypher-core-python/stubtest-allowlist.txt` with:
```bash
cd umbral-pre-python
python -m mypy.stubtest nucypher_core --generate-allowlist > stubtest-allowlist.txt
```

[pypi-image]: https://img.shields.io/pypi/v/nucypher-core
[pypi-link]: https://pypi.org/project/nucypher-core/
Expand Down
7 changes: 4 additions & 3 deletions nucypher-core-python/nucypher_core/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ from .umbral import (

from .ferveo import (
FerveoPublicKey,
Ciphertext
Ciphertext,
FerveoVariant
)


Expand Down Expand Up @@ -431,7 +432,7 @@ class MetadataResponse:
@final
class ThresholdDecryptionRequest:

def __init__(self, ritual_id: int, variant: int, ciphertext: Ciphertext, conditions: Optional[Conditions],
def __init__(self, ritual_id: int, variant: FerveoVariant, ciphertext: Ciphertext, conditions: Optional[Conditions],
context: Optional[Context]):
...

Expand All @@ -441,7 +442,7 @@ class ThresholdDecryptionRequest:

context: Optional[Context]

variant: int
variant: FerveoVariant

ciphertext: Ciphertext

Expand Down
27 changes: 23 additions & 4 deletions nucypher-core-python/nucypher_core/ferveo.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,10 @@ class FerveoPublicKey:
def serialized_size() -> int:
...

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


@final
class Validator:

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

public_key: FerveoPublicKey


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


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


@final
class ValidatorMessage:

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


@final
class Dkg:

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


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


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

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


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


@final
class AggregatedTranscript:

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


@final
class SharedSecret:

Expand All @@ -179,22 +195,25 @@ class SharedSecret:

@final
class FerveoVariant:
simple: str
precomputed: str
simple: FerveoVariant
precomputed: FerveoVariant

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


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


def combine_decryption_shares_simple(
shares: Sequence[DecryptionShareSimple],
decryption_shares: Sequence[DecryptionShareSimple],
) -> bytes:
...


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

Expand Down
10 changes: 5 additions & 5 deletions nucypher-core-python/nucypher_core/umbral.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Tuple, List, final
from typing import Optional, Tuple, List, final, Sequence


@final
Expand Down Expand Up @@ -124,8 +124,8 @@ class KeyFrag:
def verify(
self,
verifying_pk: PublicKey,
delegating_pk: Optional[PublicKey] = ...,
receiving_pk: Optional[PublicKey] = ...,
delegating_pk: Optional[PublicKey] = None,
receiving_pk: Optional[PublicKey] = None,
) -> VerifiedKeyFrag:
...

Expand Down Expand Up @@ -207,13 +207,13 @@ def reencrypt(capsule: Capsule, kfrag: VerifiedKeyFrag) -> VerifiedCapsuleFrag:

@final
class CurvePoint:
coordinates: Tuple[bytes, bytes]
coordinates: Optional[Tuple[bytes, bytes]]


@final
class Parameters:

def __init__(self, *args) -> None:
def __init__(self) -> None:
...

u: CurvePoint
Expand Down
8 changes: 4 additions & 4 deletions nucypher-core-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ impl ThresholdDecryptionRequest {
#[new]
pub fn new(
ritual_id: u32,
variant: &str,
variant: FerveoVariant,
ciphertext: &Ciphertext,
conditions: Option<&Conditions>,
context: Option<&Context>,
Expand All @@ -762,7 +762,7 @@ impl ThresholdDecryptionRequest {
.map(|conditions| conditions.backend.clone())
.as_ref(),
context.map(|context| context.backend.clone()).as_ref(),
variant,
variant.into(),
),
})
}
Expand Down Expand Up @@ -796,8 +796,8 @@ impl ThresholdDecryptionRequest {
}

#[getter]
pub fn variant(&self) -> String {
self.backend.variant.to_string()
pub fn variant(&self) -> FerveoVariant {
self.backend.variant.into()
}

pub fn encrypt(
Expand Down
1 change: 1 addition & 0 deletions nucypher-core-python/stubtest-allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nucypher_core.umbral.Parameters.__init__
4 changes: 2 additions & 2 deletions nucypher-core-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ crate-type = ["cdylib", "rlib"]
default = ["console_error_panic_hook"]

[dependencies]
umbral-pre = { version = "0.10.0", features = ["bindings-wasm"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", ref = "4b28a85c494e4e2640abb131460da0680a74134d" }
ferveo = { package = "ferveo-pre-release", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", ref = "fbb97be59d991a263233a0b876da982143b2cbf2" }
umbral-pre = { version = "0.10.0", features = ["bindings-wasm"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" }
ferveo = { package = "ferveo-pre-release", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", rev = "cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" }
nucypher-core = { path = "../nucypher-core" }
wasm-bindgen = "0.2.86"
js-sys = "0.3.63"
Expand Down
19 changes: 5 additions & 14 deletions nucypher-core-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use alloc::{
};
use core::fmt;

use ferveo::{api::FerveoVariant, bindings_wasm::Ciphertext};
use ferveo::bindings_wasm::{Ciphertext, FerveoVariant};
use js_sys::Error;
use umbral_pre::bindings_wasm::{
Capsule, PublicKey, RecoverableSignature, SecretKey, Signer, VerifiedCapsuleFrag,
Expand Down Expand Up @@ -664,26 +664,20 @@ impl ThresholdDecryptionRequest {
#[wasm_bindgen(constructor)]
pub fn new(
ritual_id: u32,
variant: u8,
variant: &FerveoVariant,
ciphertext: &Ciphertext,
conditions: &OptionConditions,
context: &OptionContext,
) -> Result<ThresholdDecryptionRequest, Error> {
let typed_conditions = try_from_js_option::<Conditions>(conditions)?;
let typed_context = try_from_js_option::<Context>(context)?;

let ferveo_variant = match variant {
0 => FerveoVariant::Simple,
1 => FerveoVariant::Precomputed,
_ => return Err(Error::new("Invalid variant")),
};

Ok(Self(nucypher_core::ThresholdDecryptionRequest::new(
ritual_id,
ciphertext.as_ref(),
typed_conditions.as_ref().map(|conditions| &conditions.0),
typed_context.as_ref().map(|context| &context.0),
ferveo_variant,
variant.clone().into(),
)))
}

Expand All @@ -693,11 +687,8 @@ impl ThresholdDecryptionRequest {
}

#[wasm_bindgen(getter)]
pub fn variant(&self) -> u8 {
match self.0.variant {
FerveoVariant::Simple => 0,
FerveoVariant::Precomputed => 1,
}
pub fn variant(&self) -> FerveoVariant {
self.0.variant.into()
}

#[wasm_bindgen(getter)]
Expand Down
4 changes: 2 additions & 2 deletions nucypher-core-wasm/tests/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use nucypher_core_wasm::*;

use ferveo::bindings_wasm::{ferveo_encrypt, DkgPublicKey, Keypair};
use ferveo::bindings_wasm::{ferveo_encrypt, DkgPublicKey, FerveoVariant, Keypair};
use umbral_pre::bindings_wasm::{
generate_kfrags, reencrypt, Capsule, RecoverableSignature, SecretKey, Signer,
VerifiedCapsuleFrag, VerifiedKeyFrag,
Expand Down Expand Up @@ -704,7 +704,7 @@ fn threshold_decryption_request() {

let request = ThresholdDecryptionRequest::new(
ritual_id,
0,
&FerveoVariant::simple(),
&ciphertext,
&conditions_js.unchecked_into::<OptionConditions>(),
&context.unchecked_into::<OptionContext>(),
Expand Down
4 changes: 2 additions & 2 deletions nucypher-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ readme = "README.md"
categories = ["cryptography", "no-std"]

[dependencies]
umbral-pre = { version = "0.10.0", features = ["serde"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", ref = "4b28a85c494e4e2640abb131460da0680a74134d" }
ferveo = { package = "ferveo-pre-release", git = "https://github.com/nucypher/ferveo.git", ref = "fbb97be59d991a263233a0b876da982143b2cbf2" }
umbral-pre = { version = "0.10.0", features = ["serde"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" }
ferveo = { package = "ferveo-pre-release", git = "https://github.com/nucypher/ferveo.git", rev = "cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" }
serde = { version = "1", default-features = false, features = ["derive"] }
generic-array = { version = "0.14", features = ["zeroize"] }
sha3 = "0.10"
Expand Down

0 comments on commit 7f3a7f2

Please sign in to comment.