From 05e3708a745d66f7b512ddb7d7df63121e2a361c Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Mon, 10 Jul 2023 13:39:37 +0200 Subject: [PATCH 01/11] fix: python typings don't match runtime --- .github/workflows/nucypher-core.yml | 32 +++ .../nucypher_core/__init__.pyi | 195 ++++++++++-------- nucypher-core-python/nucypher_core/ferveo.py | 2 +- nucypher-core-python/nucypher_core/ferveo.pyi | 72 ++++--- nucypher-core-python/nucypher_core/umbral.pyi | 40 ++-- nucypher-core-python/src/lib.rs | 7 - 6 files changed, 211 insertions(+), 137 deletions(-) diff --git a/.github/workflows/nucypher-core.yml b/.github/workflows/nucypher-core.yml index 33fb1abe..d27b2931 100644 --- a/.github/workflows/nucypher-core.yml +++ b/.github/workflows/nucypher-core.yml @@ -96,6 +96,38 @@ jobs: with: cmd: --cwd nucypher-core-wasm/examples/node test + python-test: + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + python: + - "3.10" + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + + - name: Install nucypher-core Python package + run: pip install -e . + working-directory: nucypher-core-python + + - name: Install pip dependencies + run: pip install mypy + + - name: Run mypy.stubtest + run: python -m mypy.stubtest nucypher_core + working-directory: nucypher-core-python + trigger-wheels: runs-on: ubuntu-latest needs: test diff --git a/nucypher-core-python/nucypher_core/__init__.pyi b/nucypher-core-python/nucypher_core/__init__.pyi index fce1d08b..677d609f 100644 --- a/nucypher-core-python/nucypher_core/__init__.pyi +++ b/nucypher-core-python/nucypher_core/__init__.pyi @@ -1,4 +1,4 @@ -from typing import List, Dict, Sequence, Optional, Mapping, Tuple, Set +from typing import List, Dict, Sequence, Optional, Mapping, Tuple, Set, final from .umbral import ( SecretKey, @@ -10,12 +10,13 @@ from .umbral import ( RecoverableSignature ) -from .ferveo import ( +from .ferveo import ( FerveoPublicKey, Ciphertext ) +@final class Address: def __init__(self, address_bytes: bytes): @@ -31,32 +32,31 @@ class Address: ... +@final class Conditions: def __init__(self, conditions: str): ... - @classmethod - def from_string(cls, conditions: str) -> Conditions: + @staticmethod + def from_string(conditions: str) -> Conditions: ... def __str__(self) -> str: ... +@final class Context: def __init__(self, context: str): ... - @classmethod - def from_string(cls, context: str) -> Context: - ... - def __str__(self) -> str: ... +@final class MessageKit: @staticmethod @@ -64,10 +64,10 @@ class MessageKit: ... def __init__( - self, - policy_encrypting_key: PublicKey, - plaintext: bytes, - conditions: Optional[Conditions] + self, + policy_encrypting_key: PublicKey, + plaintext: bytes, + conditions: Optional[Conditions] ): ... @@ -75,25 +75,29 @@ class MessageKit: ... def decrypt_reencrypted( - self, - sk: SecretKey, - policy_encrypting_key: PublicKey, - vcfrags: Sequence[VerifiedCapsuleFrag] + self, + sk: SecretKey, + policy_encrypting_key: PublicKey, + vcfrags: Sequence[VerifiedCapsuleFrag] ) -> bytes: ... + def __bytes__(self) -> bytes: + ... + capsule: Capsule conditions: Optional[Conditions] +@final class HRAC: def __init__( - self, - publisher_verifying_key: PublicKey, - bob_verifying_key: PublicKey, - label: bytes, + self, + publisher_verifying_key: PublicKey, + bob_verifying_key: PublicKey, + label: bytes, ): ... @@ -105,22 +109,23 @@ class HRAC: ... +@final class EncryptedKeyFrag: def __init__( - self, - signer: Signer, - recipient_key: PublicKey, - hrac: HRAC, - verified_kfrag: VerifiedKeyFrag, + self, + signer: Signer, + recipient_key: PublicKey, + hrac: HRAC, + verified_kfrag: VerifiedKeyFrag, ): ... def decrypt( - self, - sk: SecretKey, - hrac: HRAC, - publisher_verifying_key: PublicKey, + self, + sk: SecretKey, + hrac: HRAC, + publisher_verifying_key: PublicKey, ) -> VerifiedKeyFrag: ... @@ -132,15 +137,16 @@ class EncryptedKeyFrag: ... +@final class TreasureMap: def __init__( - self, - signer: Signer, - hrac: HRAC, - policy_encrypting_key: PublicKey, - assigned_kfrags: Mapping[Address, Tuple[PublicKey, VerifiedKeyFrag]], - threshold: int, + self, + signer: Signer, + hrac: HRAC, + policy_encrypting_key: PublicKey, + assigned_kfrags: Mapping[Address, Tuple[PublicKey, VerifiedKeyFrag]], + threshold: int, ): ... @@ -168,12 +174,13 @@ class TreasureMap: ... +@final class EncryptedTreasureMap: def decrypt( - self, - sk: SecretKey, - publisher_verifying_key: PublicKey, + self, + sk: SecretKey, + publisher_verifying_key: PublicKey, ) -> TreasureMap: ... @@ -185,17 +192,18 @@ class EncryptedTreasureMap: ... +@final class ReencryptionRequest: def __init__( - self, - capsules: Sequence[Capsule], - hrac: HRAC, - encrypted_kfrag: EncryptedKeyFrag, - publisher_verifying_key: PublicKey, - bob_verifying_key: PublicKey, - conditions: Optional[Conditions], - context: Optional[Context], + self, + capsules: Sequence[Capsule], + hrac: HRAC, + encrypted_kfrag: EncryptedKeyFrag, + publisher_verifying_key: PublicKey, + bob_verifying_key: PublicKey, + conditions: Optional[Conditions], + context: Optional[Context], ): ... @@ -221,18 +229,19 @@ class ReencryptionRequest: ... +@final class ReencryptionResponse: def __init__(self, signer: Signer, capsules_and_vcfrags: Sequence[Tuple[Capsule, VerifiedCapsuleFrag]]): ... def verify( - self, - capsules: Sequence[Capsule], - alice_verifying_key: PublicKey, - ursula_verifying_key: PublicKey, - policy_encrypting_key: PublicKey, - bob_encrypting_key: PublicKey, + self, + capsules: Sequence[Capsule], + alice_verifying_key: PublicKey, + ursula_verifying_key: PublicKey, + policy_encrypting_key: PublicKey, + bob_encrypting_key: PublicKey, ) -> List[VerifiedCapsuleFrag]: ... @@ -244,6 +253,7 @@ class ReencryptionResponse: ... +@final class RetrievalKit: @staticmethod @@ -251,10 +261,10 @@ class RetrievalKit: ... def __init__( - self, - capsule: Capsule, - queried_addresses: Set[Address], - conditions: Optional[Conditions], + self, + capsule: Capsule, + queried_addresses: Set[Address], + conditions: Optional[Conditions], ): ... @@ -272,19 +282,20 @@ class RetrievalKit: ... +@final class RevocationOrder: def __init__( - self, - signer: Signer, - staking_provider_address: Address, - encrypted_kfrag: EncryptedKeyFrag, + self, + signer: Signer, + staking_provider_address: Address, + encrypted_kfrag: EncryptedKeyFrag, ): ... def verify( - self, - alice_verifying_key: PublicKey, + self, + alice_verifying_key: PublicKey, ) -> Tuple[Address, EncryptedKeyFrag]: ... @@ -296,20 +307,21 @@ class RevocationOrder: ... +@final class NodeMetadataPayload: def __init__( - self, - staking_provider_address: Address, - domain: str, - timestamp_epoch: int, - verifying_key: PublicKey, - encrypting_key: PublicKey, - ferveo_public_key: FerveoPublicKey, - certificate_der: bytes, - host: str, - port: int, - operator_signature: RecoverableSignature, + self, + staking_provider_address: Address, + domain: str, + timestamp_epoch: int, + verifying_key: PublicKey, + encrypting_key: PublicKey, + ferveo_public_key: FerveoPublicKey, + certificate_der: bytes, + host: str, + port: int, + operator_signature: RecoverableSignature, ): ... @@ -337,6 +349,7 @@ class NodeMetadataPayload: ... +@final class NodeMetadata: def __init__(self, signer: Signer, payload: NodeMetadataPayload): @@ -355,18 +368,23 @@ class NodeMetadata: ... +@final class FleetStateChecksum: def __init__(self, other_nodes: Sequence[NodeMetadata], this_node: Optional[NodeMetadata]): ... + def __bytes__(self) -> bytes: + ... + +@final class MetadataRequest: def __init__( - self, - fleet_state_checksum: FleetStateChecksum, - announce_nodes: Sequence[NodeMetadata], + self, + fleet_state_checksum: FleetStateChecksum, + announce_nodes: Sequence[NodeMetadata], ): ... @@ -382,6 +400,7 @@ class MetadataRequest: ... +@final class MetadataResponsePayload: def __init__(self, timestamp_epoch: int, announce_nodes: Sequence[NodeMetadata]): @@ -392,6 +411,7 @@ class MetadataResponsePayload: announce_nodes: List[NodeMetadata] +@final class MetadataResponse: def __init__(self, signer: Signer, payload: MetadataResponsePayload): @@ -408,9 +428,11 @@ class MetadataResponse: ... +@final class ThresholdDecryptionRequest: - def __init__(self, ritual_id: int, variant: int, ciphertext: Ciphertext, conditions: Optional[Conditions], context: Optional[Context]): + def __init__(self, ritual_id: int, variant: int, ciphertext: Ciphertext, conditions: Optional[Conditions], + context: Optional[Context]): ... ritual_id: int @@ -423,7 +445,8 @@ class ThresholdDecryptionRequest: ciphertext: Ciphertext - def encrypt(self, shared_secret: SessionSharedSecret, requester_public_key: SessionStaticKey) -> EncryptedThresholdDecryptionRequest: + def encrypt(self, shared_secret: SessionSharedSecret, + requester_public_key: SessionStaticKey) -> EncryptedThresholdDecryptionRequest: ... @staticmethod @@ -434,14 +457,15 @@ class ThresholdDecryptionRequest: ... +@final class EncryptedThresholdDecryptionRequest: ritual_id: int requester_public_key: SessionStaticKey def decrypt( - self, - shared_secret: SessionSharedSecret + self, + shared_secret: SessionSharedSecret ) -> ThresholdDecryptionRequest: ... @@ -453,6 +477,7 @@ class EncryptedThresholdDecryptionRequest: ... +@final class ThresholdDecryptionResponse: def __init__(self, ritual_id: int, decryption_share: bytes): @@ -473,13 +498,13 @@ class ThresholdDecryptionResponse: ... +@final class EncryptedThresholdDecryptionResponse: - ritual_id: int def decrypt( - self, - shared_secret: SessionSharedSecret + self, + shared_secret: SessionSharedSecret ) -> ThresholdDecryptionResponse: ... @@ -491,10 +516,12 @@ class EncryptedThresholdDecryptionResponse: ... +@final class SessionSharedSecret: ... +@final class SessionStaticKey: @staticmethod @@ -505,6 +532,7 @@ class SessionStaticKey: ... +@final class SessionStaticSecret: @staticmethod @@ -518,6 +546,7 @@ class SessionStaticSecret: ... +@final class SessionSecretFactory: @staticmethod diff --git a/nucypher-core-python/nucypher_core/ferveo.py b/nucypher-core-python/nucypher_core/ferveo.py index ac550a22..3593b4b2 100644 --- a/nucypher-core-python/nucypher_core/ferveo.py +++ b/nucypher-core-python/nucypher_core/ferveo.py @@ -18,8 +18,8 @@ AggregatedTranscript = _ferveo.AggregatedTranscript DkgPublicKey = _ferveo.DkgPublicKey SharedSecret = _ferveo.SharedSecret +FerveoVariant = _ferveo.FerveoVariant ThresholdEncryptionError = _ferveo.ThresholdEncryptionError -InvalidShareNumberParameter = _ferveo.InvalidShareNumberParameter InvalidDkgStateToDeal = _ferveo.InvalidDkgStateToDeal InvalidDkgStateToAggregate = _ferveo.InvalidDkgStateToAggregate InvalidDkgStateToVerify = _ferveo.InvalidDkgStateToVerify diff --git a/nucypher-core-python/nucypher_core/ferveo.pyi b/nucypher-core-python/nucypher_core/ferveo.pyi index b708fa56..4d540655 100644 --- a/nucypher-core-python/nucypher_core/ferveo.pyi +++ b/nucypher-core-python/nucypher_core/ferveo.pyi @@ -1,13 +1,13 @@ -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(bytes: bytes) -> Keypair: ... @staticmethod @@ -15,7 +15,7 @@ class Keypair: ... @staticmethod - def from_bytes(data: bytes) -> Keypair: + def from_bytes(bytes: bytes) -> Keypair: ... def __bytes__(self) -> bytes: @@ -24,10 +24,10 @@ class Keypair: def public_key(self) -> FerveoPublicKey: ... - +@final class FerveoPublicKey: @staticmethod - def from_bytes(data: bytes) -> FerveoPublicKey: + def from_bytes(bytes: bytes) -> FerveoPublicKey: ... def __bytes__(self) -> bytes: @@ -36,7 +36,11 @@ class FerveoPublicKey: def __hash__(self) -> int: ... + @staticmethod + def serialized_size() -> int: + ... +@final class Validator: def __init__(self, address: str, public_key: FerveoPublicKey): @@ -46,25 +50,29 @@ class Validator: public_key: FerveoPublicKey - +@final class Transcript: @staticmethod - def from_bytes(data: bytes) -> Transcript: + def from_bytes(bytes: bytes) -> Transcript: ... def __bytes__(self) -> bytes: ... - +@final class DkgPublicKey: @staticmethod - def from_bytes(data: bytes) -> DkgPublicKey: + def from_bytes(bytes: bytes) -> DkgPublicKey: ... def __bytes__(self) -> bytes: ... + @staticmethod + def serialized_size() -> int: + ... +@final class ValidatorMessage: def __init__( @@ -77,7 +85,7 @@ class ValidatorMessage: validator: Validator transcript: Transcript - +@final class Dkg: def __init__( @@ -98,34 +106,33 @@ class Dkg: def aggregate_transcripts(self, messages: Sequence[ValidatorMessage]) -> AggregatedTranscript: ... - +@final class Ciphertext: @staticmethod - def from_bytes(data: bytes) -> Ciphertext: + def from_bytes(bytes: bytes) -> Ciphertext: ... def __bytes__(self) -> bytes: ... - +@final class DecryptionShareSimple: @staticmethod - def from_bytes(data: bytes) -> DecryptionShareSimple: + def from_bytes(bytes: bytes) -> DecryptionShareSimple: ... def __bytes__(self) -> bytes: ... - - +@final class DecryptionSharePrecomputed: @staticmethod - def from_bytes(data: bytes) -> DecryptionSharePrecomputed: + def from_bytes(bytes: bytes) -> DecryptionSharePrecomputed: ... def __bytes__(self) -> bytes: ... - +@final class AggregatedTranscript: def __init__(self, messages: Sequence[ValidatorMessage]): @@ -153,35 +160,44 @@ class AggregatedTranscript: ... @staticmethod - def from_bytes(data: bytes) -> AggregatedTranscript: + def from_bytes(bytes: bytes) -> AggregatedTranscript: ... def __bytes__(self) -> bytes: ... - +@final class SharedSecret: @staticmethod - def from_bytes(data: bytes) -> SharedSecret: + def from_bytes(bytes: bytes) -> SharedSecret: ... def __bytes__(self) -> bytes: ... -def encrypt(message: bytes, add: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext: +@final +class FerveoVariant: + @staticmethod + def simple() -> str: ... + + @staticmethod + def precomputed() -> str: ... + + +def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext: ... def combine_decryption_shares_simple( - decryption_shares: Sequence[DecryptionShareSimple], + shares: Sequence[DecryptionShareSimple], ) -> bytes: ... def combine_decryption_shares_precomputed( - decryption_shares: Sequence[DecryptionSharePrecomputed], + shares: Sequence[DecryptionSharePrecomputed], ) -> SharedSecret: ... @@ -198,10 +214,6 @@ class ThresholdEncryptionError(Exception): pass -class InvalidShareNumberParameter(Exception): - pass - - class InvalidDkgStateToDeal(Exception): pass @@ -259,4 +271,4 @@ class ValidatorPublicKeyMismatch(Exception): class SerializationError(Exception): - pass \ No newline at end of file + pass diff --git a/nucypher-core-python/nucypher_core/umbral.pyi b/nucypher-core-python/nucypher_core/umbral.pyi index 0937d27d..0733cb74 100644 --- a/nucypher-core-python/nucypher_core/umbral.pyi +++ b/nucypher-core-python/nucypher_core/umbral.pyi @@ -1,6 +1,7 @@ -from typing import Optional, Tuple, List, Sequence +from typing import Optional, Tuple, List, final +@final class SecretKey: @staticmethod @@ -18,6 +19,7 @@ class SecretKey: ... +@final class SecretKeyFactory: @staticmethod @@ -28,10 +30,6 @@ class SecretKeyFactory: def seed_size() -> int: ... - @staticmethod - def from_secure_randomness(seed: bytes) -> SecretKeyFactory: - ... - def make_secret(self, label: bytes) -> bytes: ... @@ -42,10 +40,11 @@ class SecretKeyFactory: ... @staticmethod - def from_secure_randomness(data: bytes) -> SecretKeyFactory: + def from_secure_randomness(seed: bytes) -> SecretKeyFactory: ... +@final class PublicKey: @staticmethod @@ -60,6 +59,7 @@ class PublicKey: ... +@final class Signer: def __init__(self, secret_key: SecretKey): @@ -72,6 +72,7 @@ class Signer: ... +@final class Signature: def verify(self, verifying_pk: PublicKey, message: bytes) -> bool: @@ -92,6 +93,7 @@ class Signature: ... +@final class RecoverableSignature: @staticmethod @@ -102,6 +104,7 @@ class RecoverableSignature: ... +@final class Capsule: @staticmethod @@ -115,14 +118,15 @@ class Capsule: ... +@final class KeyFrag: def verify( self, verifying_pk: PublicKey, - delegating_pk: Optional[PublicKey], - receiving_pk: Optional[PublicKey], - ) -> VerifiedKeyFrag: + delegating_pk: Optional[PublicKey] = ..., + receiving_pk: Optional[PublicKey] = ..., + ) -> VerifiedKeyFrag: ... def skip_verification(self) -> VerifiedKeyFrag: @@ -136,6 +140,7 @@ class KeyFrag: ... +@final class VerifiedKeyFrag: def __bytes__(self) -> bytes: @@ -153,10 +158,11 @@ def generate_kfrags( shares: int, sign_delegating_key: bool, sign_receiving_key: bool, - ) -> List[VerifiedKeyFrag]: +) -> List[VerifiedKeyFrag]: ... +@final class CapsuleFrag: def verify( @@ -165,7 +171,7 @@ class CapsuleFrag: verifying_pk: PublicKey, delegating_pk: PublicKey, receiving_pk: PublicKey, - ) -> VerifiedCapsuleFrag: + ) -> VerifiedCapsuleFrag: ... def skip_verification(self) -> VerifiedCapsuleFrag: @@ -182,6 +188,7 @@ class CapsuleFrag: ... +@final class VerifiedCapsuleFrag: def __bytes__(self) -> bytes: @@ -198,20 +205,21 @@ def reencrypt(capsule: Capsule, kfrag: VerifiedKeyFrag) -> VerifiedCapsuleFrag: ... +@final class CurvePoint: - - def coordinates(self) -> Tuple[bytes, bytes]: - ... + coordinates: Tuple[bytes, bytes] +@final class Parameters: - def __init__(self) -> None: + def __init__(self, *args) -> None: ... u: CurvePoint +@final class ReencryptionEvidence: def __init__( @@ -221,7 +229,7 @@ class ReencryptionEvidence: verifying_pk: PublicKey, delegating_pk: PublicKey, receiving_pk: PublicKey, - ): + ): ... def __bytes__(self) -> bytes: diff --git a/nucypher-core-python/src/lib.rs b/nucypher-core-python/src/lib.rs index f6c34fce..723cf05b 100644 --- a/nucypher-core-python/src/lib.rs +++ b/nucypher-core-python/src/lib.rs @@ -141,13 +141,6 @@ impl Context { } } - #[staticmethod] - pub fn from_bytes(context: String) -> Self { - Self { - backend: context.into(), - } - } - fn __str__(&self) -> &str { self.backend.as_ref() } From 5e8811828b1a51f279082e8cea47fa244def6afe Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 11 Jul 2023 10:01:16 +0200 Subject: [PATCH 02/11] test with pre-released crates --- Cargo.lock | 15 +++++---------- nucypher-core-python/Cargo.toml | 4 ++-- nucypher-core-wasm/Cargo.toml | 4 ++-- nucypher-core/Cargo.toml | 4 ++-- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1d73bd5..6adbcae0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,8 +518,7 @@ dependencies = [ [[package]] name = "ferveo-common-pre-release" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b88f694e924a2878d4abf89b79df44cdee2e0670875aba885bb769ccd71be3" +source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" dependencies = [ "ark-ec", "ark-serialize", @@ -534,8 +533,7 @@ dependencies = [ [[package]] name = "ferveo-pre-release" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58661702af7320b5e643e34f41a1528db32ee7faa92b6294e93feff307f52e41" +source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" dependencies = [ "ark-bls12-381", "ark-ec", @@ -638,8 +636,7 @@ dependencies = [ [[package]] name = "group-threshold-cryptography-pre-release" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ade4859b58171e6815b0641e23f615f5dab030ecf2376b069d652f323fa760b" +source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" dependencies = [ "ark-bls12-381", "ark-ec", @@ -1395,8 +1392,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subproductdomain-pre-release" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7331c4e4ab9b7c9ed4ad2e950e8760826622c7ab110d9f1b3f350e2005017eab" +source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" dependencies = [ "anyhow", "ark-ec", @@ -1495,8 +1491,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "umbral-pre" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "594a478131f30b32cf28a822d95821ef32881e9773d567739c09df9f2accd692" +source = "git+https://github.com/piotr-roslaniec/rust-umbral.git#c7ff41296e26ae0696f84f4a62fd26d619479c52" dependencies = [ "base64 0.21.2", "chacha20poly1305", diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index 220f37b7..841ead9e 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -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"] } -ferveo = { package = "ferveo-pre-release", version = "0.2.0", features = ["bindings-python"] } +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", version = "0.2.0", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", ref = "4fcc7c0ad33c05b0d956378efed3858c2a389885" } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } [build-dependencies] diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index 151eaf64..d73e2c93 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -19,8 +19,8 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -umbral-pre = { version = "0.10.0", features = ["bindings-wasm"] } -ferveo = { package = "ferveo-pre-release", version = "0.2.0", features = ["bindings-wasm"] } +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", version = "0.2.0", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", ref = "4fcc7c0ad33c05b0d956378efed3858c2a389885" } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" js-sys = "0.3.63" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 74612f14..f0403f26 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -10,8 +10,8 @@ readme = "README.md" categories = ["cryptography", "no-std"] [dependencies] -umbral-pre = { version = "0.10.0", features = ["serde"] } -ferveo = { package = "ferveo-pre-release", version = "0.2.0" } +umbral-pre = { version = "0.10.0", features = ["serde"], git = "https://github.com/piotr-roslaniec/rust-umbral.git", ref = "4b28a85c494e4e2640abb131460da0680a74134d" } +ferveo = { package = "ferveo-pre-release", version = "0.2.0", git = "https://github.com/nucypher/ferveo.git", ref = "4fcc7c0ad33c05b0d956378efed3858c2a389885" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" From 2e7b98955ebf7b261d31e373a669c21efdc51994 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 11 Jul 2023 12:31:12 +0200 Subject: [PATCH 03/11] update ferveo typings --- nucypher-core-python/Cargo.toml | 2 +- nucypher-core-python/nucypher_core/ferveo.pyi | 27 +++++++++---------- nucypher-core-wasm/Cargo.toml | 2 +- nucypher-core/Cargo.toml | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index 841ead9e..55b601cb 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] 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", version = "0.2.0", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", ref = "4fcc7c0ad33c05b0d956378efed3858c2a389885" } +ferveo = { package = "ferveo-pre-release", version = "0.2.0", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", ref = "7cbe65def65a76043d21763723ce98787cbf8eed" } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } [build-dependencies] diff --git a/nucypher-core-python/nucypher_core/ferveo.pyi b/nucypher-core-python/nucypher_core/ferveo.pyi index 4d540655..9fc82342 100644 --- a/nucypher-core-python/nucypher_core/ferveo.pyi +++ b/nucypher-core-python/nucypher_core/ferveo.pyi @@ -7,7 +7,7 @@ class Keypair: ... @staticmethod - def from_secure_randomness(bytes: bytes) -> Keypair: + def from_secure_randomness(secure_randomness: bytes) -> Keypair: ... @staticmethod @@ -15,7 +15,7 @@ class Keypair: ... @staticmethod - def from_bytes(bytes: bytes) -> Keypair: + def from_bytes(data: bytes) -> Keypair: ... def __bytes__(self) -> bytes: @@ -27,7 +27,7 @@ class Keypair: @final class FerveoPublicKey: @staticmethod - def from_bytes(bytes: bytes) -> FerveoPublicKey: + def from_bytes(data: bytes) -> FerveoPublicKey: ... def __bytes__(self) -> bytes: @@ -53,7 +53,7 @@ class Validator: @final class Transcript: @staticmethod - def from_bytes(bytes: bytes) -> Transcript: + def from_bytes(data: bytes) -> Transcript: ... def __bytes__(self) -> bytes: @@ -62,7 +62,7 @@ class Transcript: @final class DkgPublicKey: @staticmethod - def from_bytes(bytes: bytes) -> DkgPublicKey: + def from_bytes(data: bytes) -> DkgPublicKey: ... def __bytes__(self) -> bytes: @@ -109,7 +109,7 @@ class Dkg: @final class Ciphertext: @staticmethod - def from_bytes(bytes: bytes) -> Ciphertext: + def from_bytes(data: bytes) -> Ciphertext: ... def __bytes__(self) -> bytes: @@ -118,7 +118,7 @@ class Ciphertext: @final class DecryptionShareSimple: @staticmethod - def from_bytes(bytes: bytes) -> DecryptionShareSimple: + def from_bytes(data: bytes) -> DecryptionShareSimple: ... def __bytes__(self) -> bytes: @@ -126,7 +126,7 @@ class DecryptionShareSimple: @final class DecryptionSharePrecomputed: @staticmethod - def from_bytes(bytes: bytes) -> DecryptionSharePrecomputed: + def from_bytes(data: bytes) -> DecryptionSharePrecomputed: ... def __bytes__(self) -> bytes: @@ -160,7 +160,7 @@ class AggregatedTranscript: ... @staticmethod - def from_bytes(bytes: bytes) -> AggregatedTranscript: + def from_bytes(data: bytes) -> AggregatedTranscript: ... def __bytes__(self) -> bytes: @@ -170,7 +170,7 @@ class AggregatedTranscript: class SharedSecret: @staticmethod - def from_bytes(bytes: bytes) -> SharedSecret: + def from_bytes(data: bytes) -> SharedSecret: ... def __bytes__(self) -> bytes: @@ -179,11 +179,8 @@ class SharedSecret: @final class FerveoVariant: - @staticmethod - def simple() -> str: ... - - @staticmethod - def precomputed() -> str: ... + simple: str + precomputed: str def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext: diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index d73e2c93..ba16fb89 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -20,7 +20,7 @@ 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", version = "0.2.0", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", ref = "4fcc7c0ad33c05b0d956378efed3858c2a389885" } +ferveo = { package = "ferveo-pre-release", version = "0.2.0", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", ref = "7cbe65def65a76043d21763723ce98787cbf8eed" } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" js-sys = "0.3.63" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index f0403f26..e11ad59d 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -11,7 +11,7 @@ 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", version = "0.2.0", git = "https://github.com/nucypher/ferveo.git", ref = "4fcc7c0ad33c05b0d956378efed3858c2a389885" } +ferveo = { package = "ferveo-pre-release", version = "0.2.0", git = "https://github.com/nucypher/ferveo.git", ref = "7cbe65def65a76043d21763723ce98787cbf8eed" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" From 5459efaaf3b8618997c0fe681537b9fe023d190d Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 11 Jul 2023 15:02:51 +0200 Subject: [PATCH 04/11] update FerveoVariant usage --- Cargo.lock | 46 ++++++++++++++++----------------- nucypher-core-python/Cargo.toml | 2 +- nucypher-core-python/src/lib.rs | 26 ++++--------------- nucypher-core-wasm/Cargo.toml | 2 +- nucypher-core/Cargo.toml | 2 +- 5 files changed, 31 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6adbcae0..1ac07297 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,9 +294,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6340df57935414636969091153f35f68d9f00bbc8fb4a9c6054706c213e6c6bc" +checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" [[package]] name = "core-foundation-sys" @@ -361,7 +361,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", ] [[package]] @@ -409,7 +409,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.23", + "syn 2.0.25", ] [[package]] @@ -431,7 +431,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core 0.20.1", "quote", - "syn 2.0.23", + "syn 2.0.25", ] [[package]] @@ -1011,9 +1011,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" dependencies = [ "unicode-ident", ] @@ -1258,9 +1258,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.167" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daf513456463b42aa1d94cff7e0c24d682b429f020b9afa4f5ba5c40a22b237" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] @@ -1276,13 +1276,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.167" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69b106b68bc8054f0e974e70d19984040f8a5cf9215ca82626ea4853f82c4b9" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", ] [[package]] @@ -1343,7 +1343,7 @@ dependencies = [ "darling 0.20.1", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", ] [[package]] @@ -1420,9 +1420,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.23" +version = "2.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" dependencies = [ "proc-macro2", "quote", @@ -1452,14 +1452,14 @@ checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", ] [[package]] name = "time" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" dependencies = [ "itoa", "serde", @@ -1475,9 +1475,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" dependencies = [ "time-core", ] @@ -1574,7 +1574,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", "wasm-bindgen-shared", ] @@ -1630,7 +1630,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1792,5 +1792,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.25", ] diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index 55b601cb..7aae50fd 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] 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", version = "0.2.0", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", ref = "7cbe65def65a76043d21763723ce98787cbf8eed" } +ferveo = { package = "ferveo-pre-release", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", ref = "fbb97be59d991a263233a0b876da982143b2cbf2" } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } [build-dependencies] diff --git a/nucypher-core-python/src/lib.rs b/nucypher-core-python/src/lib.rs index 723cf05b..42d4aaba 100644 --- a/nucypher-core-python/src/lib.rs +++ b/nucypher-core-python/src/lib.rs @@ -7,10 +7,7 @@ extern crate alloc; use alloc::collections::{BTreeMap, BTreeSet}; -use ferveo::{ - api::FerveoVariant, - bindings_python::{Ciphertext, FerveoPublicKey}, -}; +use ferveo::bindings_python::{Ciphertext, FerveoPublicKey, FerveoVariant}; use pyo3::class::basic::CompareOp; use pyo3::exceptions::{PyTypeError, PyValueError}; use pyo3::prelude::*; @@ -752,21 +749,11 @@ impl ThresholdDecryptionRequest { #[new] pub fn new( ritual_id: u32, - variant: u8, + variant: &str, ciphertext: &Ciphertext, conditions: Option<&Conditions>, context: Option<&Context>, ) -> PyResult { - let ferveo_variant = match variant { - 0 => FerveoVariant::Simple, - 1 => FerveoVariant::Precomputed, - _ => { - return Err(PyValueError::new_err( - "Invalid ThresholdDecryptionRequest variant", - )); - } - }; - Ok(Self { backend: nucypher_core::ThresholdDecryptionRequest::new( ritual_id, @@ -775,7 +762,7 @@ impl ThresholdDecryptionRequest { .map(|conditions| conditions.backend.clone()) .as_ref(), context.map(|context| context.backend.clone()).as_ref(), - ferveo_variant, + variant, ), }) } @@ -809,11 +796,8 @@ impl ThresholdDecryptionRequest { } #[getter] - pub fn variant(&self) -> u8 { - match self.backend.variant { - FerveoVariant::Simple => 0, - FerveoVariant::Precomputed => 1, - } + pub fn variant(&self) -> String { + self.backend.variant.to_string() } pub fn encrypt( diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index ba16fb89..70de7317 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -20,7 +20,7 @@ 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", version = "0.2.0", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", ref = "7cbe65def65a76043d21763723ce98787cbf8eed" } +ferveo = { package = "ferveo-pre-release", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", ref = "fbb97be59d991a263233a0b876da982143b2cbf2" } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" js-sys = "0.3.63" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index e11ad59d..dd08e8cd 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -11,7 +11,7 @@ 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", version = "0.2.0", git = "https://github.com/nucypher/ferveo.git", ref = "7cbe65def65a76043d21763723ce98787cbf8eed" } +ferveo = { package = "ferveo-pre-release", git = "https://github.com/nucypher/ferveo.git", ref = "fbb97be59d991a263233a0b876da982143b2cbf2" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" From 7f3a7f21f2f9bdc0395e256025ec9af0d53723aa Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Wed, 12 Jul 2023 12:24:54 +0200 Subject: [PATCH 05/11] update dependencies --- .github/workflows/nucypher-core.yml | 2 +- Cargo.lock | 10 +++---- nucypher-core-python/Cargo.toml | 4 +-- nucypher-core-python/README.md | 7 +++++ .../nucypher_core/__init__.pyi | 7 ++--- nucypher-core-python/nucypher_core/ferveo.pyi | 27 ++++++++++++++++--- nucypher-core-python/nucypher_core/umbral.pyi | 10 +++---- nucypher-core-python/src/lib.rs | 8 +++--- nucypher-core-python/stubtest-allowlist.txt | 1 + nucypher-core-wasm/Cargo.toml | 4 +-- nucypher-core-wasm/src/lib.rs | 19 ++++--------- nucypher-core-wasm/tests/wasm.rs | 4 +-- nucypher-core/Cargo.toml | 4 +-- 13 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 nucypher-core-python/stubtest-allowlist.txt diff --git a/.github/workflows/nucypher-core.yml b/.github/workflows/nucypher-core.yml index d27b2931..1c802a03 100644 --- a/.github/workflows/nucypher-core.yml +++ b/.github/workflows/nucypher-core.yml @@ -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: diff --git a/Cargo.lock b/Cargo.lock index 1ac07297..6caf4734 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "ferveo-common-pre-release" version = "0.1.0" -source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" +source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "ark-ec", "ark-serialize", @@ -533,7 +533,7 @@ dependencies = [ [[package]] name = "ferveo-pre-release" version = "0.2.0" -source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" +source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "ark-bls12-381", "ark-ec", @@ -636,7 +636,7 @@ dependencies = [ [[package]] name = "group-threshold-cryptography-pre-release" version = "0.1.0" -source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" +source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "ark-bls12-381", "ark-ec", @@ -1392,7 +1392,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subproductdomain-pre-release" version = "0.1.0" -source = "git+https://github.com/nucypher/ferveo.git#434fd5d07b54e72d120e9aa06cbc3e47848e6bcf" +source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "anyhow", "ark-ec", @@ -1491,7 +1491,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "umbral-pre" version = "0.10.0" -source = "git+https://github.com/piotr-roslaniec/rust-umbral.git#c7ff41296e26ae0696f84f4a62fd26d619479c52" +source = "git+https://github.com/piotr-roslaniec/rust-umbral.git?rev=fd2e16f9304b9dab85c9a8947a61d962ff136131#fd2e16f9304b9dab85c9a8947a61d962ff136131" dependencies = [ "base64 0.21.2", "chacha20poly1305", diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index 7aae50fd..429e3760 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -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] diff --git a/nucypher-core-python/README.md b/nucypher-core-python/README.md index 90db8b68..1163f9c1 100644 --- a/nucypher-core-python/README.md +++ b/nucypher-core-python/README.md @@ -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/ diff --git a/nucypher-core-python/nucypher_core/__init__.pyi b/nucypher-core-python/nucypher_core/__init__.pyi index 677d609f..96093475 100644 --- a/nucypher-core-python/nucypher_core/__init__.pyi +++ b/nucypher-core-python/nucypher_core/__init__.pyi @@ -12,7 +12,8 @@ from .umbral import ( from .ferveo import ( FerveoPublicKey, - Ciphertext + Ciphertext, + FerveoVariant ) @@ -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]): ... @@ -441,7 +442,7 @@ class ThresholdDecryptionRequest: context: Optional[Context] - variant: int + variant: FerveoVariant ciphertext: Ciphertext diff --git a/nucypher-core-python/nucypher_core/ferveo.pyi b/nucypher-core-python/nucypher_core/ferveo.pyi index 9fc82342..51f982a6 100644 --- a/nucypher-core-python/nucypher_core/ferveo.pyi +++ b/nucypher-core-python/nucypher_core/ferveo.pyi @@ -1,5 +1,6 @@ from typing import Sequence, final + @final class Keypair: @staticmethod @@ -24,6 +25,7 @@ class Keypair: def public_key(self) -> FerveoPublicKey: ... + @final class FerveoPublicKey: @staticmethod @@ -40,6 +42,10 @@ class FerveoPublicKey: def serialized_size() -> int: ... + def __eq__(self, other: object) -> bool: + ... + + @final class Validator: @@ -50,6 +56,7 @@ class Validator: public_key: FerveoPublicKey + @final class Transcript: @staticmethod @@ -59,6 +66,7 @@ class Transcript: def __bytes__(self) -> bytes: ... + @final class DkgPublicKey: @staticmethod @@ -72,6 +80,7 @@ class DkgPublicKey: def serialized_size() -> int: ... + @final class ValidatorMessage: @@ -85,6 +94,7 @@ class ValidatorMessage: validator: Validator transcript: Transcript + @final class Dkg: @@ -106,6 +116,7 @@ class Dkg: def aggregate_transcripts(self, messages: Sequence[ValidatorMessage]) -> AggregatedTranscript: ... + @final class Ciphertext: @staticmethod @@ -115,6 +126,7 @@ class Ciphertext: def __bytes__(self) -> bytes: ... + @final class DecryptionShareSimple: @staticmethod @@ -123,6 +135,8 @@ class DecryptionShareSimple: def __bytes__(self) -> bytes: ... + + @final class DecryptionSharePrecomputed: @staticmethod @@ -132,6 +146,7 @@ class DecryptionSharePrecomputed: def __bytes__(self) -> bytes: ... + @final class AggregatedTranscript: @@ -166,6 +181,7 @@ class AggregatedTranscript: def __bytes__(self) -> bytes: ... + @final class SharedSecret: @@ -179,8 +195,11 @@ 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: @@ -188,13 +207,13 @@ def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphert 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: ... diff --git a/nucypher-core-python/nucypher_core/umbral.pyi b/nucypher-core-python/nucypher_core/umbral.pyi index 0733cb74..c83e56a4 100644 --- a/nucypher-core-python/nucypher_core/umbral.pyi +++ b/nucypher-core-python/nucypher_core/umbral.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Tuple, List, final +from typing import Optional, Tuple, List, final, Sequence @final @@ -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: ... @@ -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 diff --git a/nucypher-core-python/src/lib.rs b/nucypher-core-python/src/lib.rs index 42d4aaba..b33e1ccf 100644 --- a/nucypher-core-python/src/lib.rs +++ b/nucypher-core-python/src/lib.rs @@ -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>, @@ -762,7 +762,7 @@ impl ThresholdDecryptionRequest { .map(|conditions| conditions.backend.clone()) .as_ref(), context.map(|context| context.backend.clone()).as_ref(), - variant, + variant.into(), ), }) } @@ -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( diff --git a/nucypher-core-python/stubtest-allowlist.txt b/nucypher-core-python/stubtest-allowlist.txt new file mode 100644 index 00000000..e7fbe133 --- /dev/null +++ b/nucypher-core-python/stubtest-allowlist.txt @@ -0,0 +1 @@ +nucypher_core.umbral.Parameters.__init__ diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index 70de7317..b4695f4e 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -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" diff --git a/nucypher-core-wasm/src/lib.rs b/nucypher-core-wasm/src/lib.rs index 13e8b913..623a024c 100644 --- a/nucypher-core-wasm/src/lib.rs +++ b/nucypher-core-wasm/src/lib.rs @@ -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, @@ -664,7 +664,7 @@ impl ThresholdDecryptionRequest { #[wasm_bindgen(constructor)] pub fn new( ritual_id: u32, - variant: u8, + variant: &FerveoVariant, ciphertext: &Ciphertext, conditions: &OptionConditions, context: &OptionContext, @@ -672,18 +672,12 @@ impl ThresholdDecryptionRequest { let typed_conditions = try_from_js_option::(conditions)?; let typed_context = try_from_js_option::(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(), ))) } @@ -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)] diff --git a/nucypher-core-wasm/tests/wasm.rs b/nucypher-core-wasm/tests/wasm.rs index 732319ee..b44e967e 100644 --- a/nucypher-core-wasm/tests/wasm.rs +++ b/nucypher-core-wasm/tests/wasm.rs @@ -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, @@ -704,7 +704,7 @@ fn threshold_decryption_request() { let request = ThresholdDecryptionRequest::new( ritual_id, - 0, + &FerveoVariant::simple(), &ciphertext, &conditions_js.unchecked_into::(), &context.unchecked_into::(), diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index dd08e8cd..c6e06bbc 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -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" From e97861d453ffc39d943db78777a739ad7b42df64 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Thu, 13 Jul 2023 15:24:37 +0200 Subject: [PATCH 06/11] update dkg test --- nucypher-core/src/dkg.rs | 117 +++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index f339baea..c6874f58 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -277,8 +277,10 @@ pub mod session { } } - type SessionSecretFactorySeedSize = U32; // the size of the seed material for key derivation - type SessionSecretFactoryDerivedKeySize = U32; // the size of the derived key + type SessionSecretFactorySeedSize = U32; + // the size of the seed material for key derivation + type SessionSecretFactoryDerivedKeySize = U32; + // the size of the derived key type SessionSecretFactorySeed = GenericArray; /// Error thrown when invalid random seed provided for creating key factory. @@ -716,60 +718,65 @@ mod tests { #[test] fn threshold_decryption_request() { - let ritual_id = 0; - - let service_secret = SessionStaticSecret::random(); - - let requester_secret = SessionStaticSecret::random(); - let requester_public_key = requester_secret.public_key(); - - let dkg_pk = DkgPublicKey::random(); - let message = "The Tyranny of Merit".as_bytes().to_vec(); - let aad = "my-add".as_bytes(); - let ciphertext = ferveo_encrypt(SecretBox::new(message), aad, &dkg_pk).unwrap(); - - let request = ThresholdDecryptionRequest::new( - ritual_id, - &ciphertext, - Some(&Conditions::new("abcd")), - Some(&Context::new("efgh")), - FerveoVariant::Simple, - ); - - // requester encrypts request to send to service - let service_public_key = service_secret.public_key(); - let requester_shared_secret = requester_secret.derive_shared_secret(&service_public_key); - let encrypted_request = request.encrypt(&requester_shared_secret, &requester_public_key); - - // mimic serialization/deserialization over the wire - let encrypted_request_bytes = encrypted_request.to_bytes(); - let encrypted_request_from_bytes = - EncryptedThresholdDecryptionRequest::from_bytes(&encrypted_request_bytes).unwrap(); - - assert_eq!(encrypted_request_from_bytes.ritual_id, ritual_id); - assert_eq!( - encrypted_request_from_bytes.requester_public_key, - requester_public_key - ); - - // service decrypts request - let service_shared_secret = - service_secret.derive_shared_secret(&encrypted_request_from_bytes.requester_public_key); - assert_eq!( - service_shared_secret.as_bytes(), - requester_shared_secret.as_bytes() - ); - let decrypted_request = encrypted_request_from_bytes - .decrypt(&service_shared_secret) - .unwrap(); - assert_eq!(decrypted_request, request); + for variant in [FerveoVariant::Simple, FerveoVariant::Precomputed] { + let ritual_id = 0; + + let service_secret = SessionStaticSecret::random(); + + let requester_secret = SessionStaticSecret::random(); + let requester_public_key = requester_secret.public_key(); + + let dkg_pk = DkgPublicKey::random(); + let message = "The Tyranny of Merit".as_bytes().to_vec(); + let aad = "my-add".as_bytes(); + let ciphertext = ferveo_encrypt(SecretBox::new(message), aad, &dkg_pk).unwrap(); + + let request = ThresholdDecryptionRequest::new( + ritual_id, + &ciphertext, + Some(&Conditions::new("abcd")), + Some(&Context::new("efgh")), + variant, + ); + + // requester encrypts request to send to service + let service_public_key = service_secret.public_key(); + let requester_shared_secret = + requester_secret.derive_shared_secret(&service_public_key); + let encrypted_request = + request.encrypt(&requester_shared_secret, &requester_public_key); + + // mimic serialization/deserialization over the wire + let encrypted_request_bytes = encrypted_request.to_bytes(); + let encrypted_request_from_bytes = + EncryptedThresholdDecryptionRequest::from_bytes(&encrypted_request_bytes).unwrap(); + + assert_eq!(encrypted_request_from_bytes.ritual_id, ritual_id); + assert_eq!( + encrypted_request_from_bytes.requester_public_key, + requester_public_key + ); + + // service decrypts request + let service_shared_secret = service_secret + .derive_shared_secret(&encrypted_request_from_bytes.requester_public_key); + assert_eq!( + service_shared_secret.as_bytes(), + requester_shared_secret.as_bytes() + ); + let decrypted_request = encrypted_request_from_bytes + .decrypt(&service_shared_secret) + .unwrap(); + assert_eq!(decrypted_request, request); - // wrong shared key used - let random_secret_key = SessionStaticSecret::random(); - let random_shared_secret = random_secret_key.derive_shared_secret(&requester_public_key); - assert!(encrypted_request_from_bytes - .decrypt(&random_shared_secret) - .is_err()); + // wrong shared key used + let random_secret_key = SessionStaticSecret::random(); + let random_shared_secret = + random_secret_key.derive_shared_secret(&requester_public_key); + assert!(encrypted_request_from_bytes + .decrypt(&random_shared_secret) + .is_err()); + } } #[test] From b3dbb5fc38a1a044dce5ea5d47cbda540a532227 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Fri, 14 Jul 2023 08:54:00 +0200 Subject: [PATCH 07/11] update ferveo --- Cargo.lock | 4 ---- nucypher-core-python/Cargo.toml | 2 +- nucypher-core-python/nucypher_core/ferveo.pyi | 7 +++++-- nucypher-core-wasm/Cargo.toml | 2 +- nucypher-core/Cargo.toml | 2 +- nucypher-core/src/dkg.rs | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6caf4734..d2c9af10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,7 +518,6 @@ dependencies = [ [[package]] name = "ferveo-common-pre-release" version = "0.1.0" -source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "ark-ec", "ark-serialize", @@ -533,7 +532,6 @@ dependencies = [ [[package]] name = "ferveo-pre-release" version = "0.2.0" -source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "ark-bls12-381", "ark-ec", @@ -636,7 +634,6 @@ dependencies = [ [[package]] name = "group-threshold-cryptography-pre-release" version = "0.1.0" -source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "ark-bls12-381", "ark-ec", @@ -1392,7 +1389,6 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subproductdomain-pre-release" version = "0.1.0" -source = "git+https://github.com/nucypher/ferveo.git?rev=cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4#cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" dependencies = [ "anyhow", "ark-ec", diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index 429e3760..a7d67a5e 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] 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", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" } -ferveo = { package = "ferveo-pre-release", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", rev = "cea467e0bd48a096f70dd1c7ca24a7e4bd88b3d4" } +ferveo = { package = "ferveo-pre-release", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", rev = "0e7c5615a0660a69077e7b431dd24c5bb3d0f10d" } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } [build-dependencies] diff --git a/nucypher-core-python/nucypher_core/ferveo.pyi b/nucypher-core-python/nucypher_core/ferveo.pyi index 51f982a6..1dfab2f0 100644 --- a/nucypher-core-python/nucypher_core/ferveo.pyi +++ b/nucypher-core-python/nucypher_core/ferveo.pyi @@ -195,12 +195,15 @@ class SharedSecret: @final class FerveoVariant: - simple: FerveoVariant - precomputed: 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: ... diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index b4695f4e..1f56aca8 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -20,7 +20,7 @@ default = ["console_error_panic_hook"] [dependencies] 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" } +ferveo = { package = "ferveo-pre-release", features = ["bindings-wasm"], git = "https://github.com/nucypher/ferveo.git", rev = "0e7c5615a0660a69077e7b431dd24c5bb3d0f10d" } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" js-sys = "0.3.63" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index c6e06bbc..0bfb999d 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -11,7 +11,7 @@ categories = ["cryptography", "no-std"] [dependencies] 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" } +ferveo = { package = "ferveo-pre-release", git = "https://github.com/nucypher/ferveo.git", rev = "0e7c5615a0660a69077e7b431dd24c5bb3d0f10d" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index c6874f58..cd4f86df 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -277,10 +277,10 @@ pub mod session { } } - type SessionSecretFactorySeedSize = U32; // the size of the seed material for key derivation - type SessionSecretFactoryDerivedKeySize = U32; + type SessionSecretFactorySeedSize = U32; // the size of the derived key + type SessionSecretFactoryDerivedKeySize = U32; type SessionSecretFactorySeed = GenericArray; /// Error thrown when invalid random seed provided for creating key factory. From b7d16ea0b5c27f2a3a037461c0ab43aff02ce350 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 1 Aug 2023 11:33:57 +0200 Subject: [PATCH 08/11] use ferveo crate @ 0.2.1 --- Cargo.lock | 10 +++++++++- nucypher-core-python/Cargo.toml | 2 +- nucypher-core-wasm/Cargo.toml | 2 +- nucypher-core/Cargo.toml | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2c9af10..d612d45c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,6 +518,8 @@ dependencies = [ [[package]] name = "ferveo-common-pre-release" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b88f694e924a2878d4abf89b79df44cdee2e0670875aba885bb769ccd71be3" dependencies = [ "ark-ec", "ark-serialize", @@ -531,7 +533,9 @@ dependencies = [ [[package]] name = "ferveo-pre-release" -version = "0.2.0" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34e97a82e328847d4abf9d5a4dfec06c693210fcb3e6e9feb78f225b8126464" dependencies = [ "ark-bls12-381", "ark-ec", @@ -634,6 +638,8 @@ dependencies = [ [[package]] name = "group-threshold-cryptography-pre-release" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ade4859b58171e6815b0641e23f615f5dab030ecf2376b069d652f323fa760b" dependencies = [ "ark-bls12-381", "ark-ec", @@ -1389,6 +1395,8 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "subproductdomain-pre-release" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7331c4e4ab9b7c9ed4ad2e950e8760826622c7ab110d9f1b3f350e2005017eab" dependencies = [ "anyhow", "ark-ec", diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index a7d67a5e..d414244a 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] 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", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" } -ferveo = { package = "ferveo-pre-release", features = ["bindings-python"], git = "https://github.com/nucypher/ferveo.git", rev = "0e7c5615a0660a69077e7b431dd24c5bb3d0f10d" } +ferveo = { version = "0.2.1", package = "ferveo-pre-release", features = ["bindings-python"] } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } [build-dependencies] diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index 1f56aca8..2326877a 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -20,7 +20,7 @@ default = ["console_error_panic_hook"] [dependencies] 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 = "0e7c5615a0660a69077e7b431dd24c5bb3d0f10d" } +ferveo = { version = "0.2.1", package = "ferveo-pre-release", features = ["bindings-wasm"] } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" js-sys = "0.3.63" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 0bfb999d..79370f5e 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -11,7 +11,7 @@ categories = ["cryptography", "no-std"] [dependencies] 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 = "0e7c5615a0660a69077e7b431dd24c5bb3d0f10d" } +ferveo = { version = "0.2.1", package = "ferveo-pre-release" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = { version = "0.14", features = ["zeroize"] } sha3 = "0.10" From e5dac28833fd7278645c9349ad79d32a06f54a14 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 1 Aug 2023 18:09:22 +0200 Subject: [PATCH 09/11] use released umbral-pre crate @ 0.11.0 --- Cargo.lock | 5 +++-- nucypher-core-python/Cargo.toml | 2 +- nucypher-core-wasm/Cargo.toml | 2 +- nucypher-core/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d612d45c..f2654251 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1494,8 +1494,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "umbral-pre" -version = "0.10.0" -source = "git+https://github.com/piotr-roslaniec/rust-umbral.git?rev=fd2e16f9304b9dab85c9a8947a61d962ff136131#fd2e16f9304b9dab85c9a8947a61d962ff136131" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7aa08487feab265cc169ef77650f3527664f6b945a06fbb233ef9a44d56ee11" dependencies = [ "base64 0.21.2", "chacha20poly1305", diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index d414244a..0343354d 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -10,7 +10,7 @@ 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", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" } +umbral-pre = { version = "0.11.0", features = ["bindings-python"] } ferveo = { version = "0.2.1", package = "ferveo-pre-release", features = ["bindings-python"] } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index 2326877a..08de0579 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -19,7 +19,7 @@ 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", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" } +umbral-pre = { version = "0.11.0", features = ["bindings-wasm"] } ferveo = { version = "0.2.1", package = "ferveo-pre-release", features = ["bindings-wasm"] } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 79370f5e..df2cd8df 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -10,7 +10,7 @@ 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", rev = "fd2e16f9304b9dab85c9a8947a61d962ff136131" } +umbral-pre = { version = "0.11.0", features = ["serde"] } ferveo = { version = "0.2.1", package = "ferveo-pre-release" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = { version = "0.14", features = ["zeroize"] } From a2a860d1f8e785faa6363f8732cc4c3f0955e5c0 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 1 Aug 2023 18:17:37 +0200 Subject: [PATCH 10/11] chore(ci): bump msrv to fix wasm-pack dependency --- .github/workflows/nucypher-core.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nucypher-core.yml b/.github/workflows/nucypher-core.yml index 1c802a03..b18fe2bd 100644 --- a/.github/workflows/nucypher-core.yml +++ b/.github/workflows/nucypher-core.yml @@ -29,7 +29,7 @@ jobs: matrix: include: - target: x86_64-unknown-linux-gnu - rust: 1.65 # MSRV + rust: 1.67 # MSRV - target: x86_64-unknown-linux-gnu rust: stable @@ -50,7 +50,7 @@ jobs: strategy: matrix: rust: - - 1.65 # MSRV + - 1.67 # MSRV - stable target: - wasm32-unknown-unknown From ae0175a2c39a1a55df1f4d27408bef1bf8c8833e Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 1 Aug 2023 18:34:09 +0200 Subject: [PATCH 11/11] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc0782c..b503db0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Changed + +- Bumped `umbral-pre` version to 0.11.0 and `ferveo-pre-release` version to 0.2.1 ([#72]) +- Bumped MSRV to 1.67. ([#72]) + +[#73]: https://github.com/nucypher/nucypher-core/pull/72 ## 0.10.0 - 2023-06-23