Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACP/ThresholdMessageKit Work #74

Merged
merged 14 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
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).


## [0.12.0] - Unreleased

### Changed

- Modified `ThresholdDecryptionResponse` to use `CiphertextHeader` and `AccessControlPolicy` to utilize encapsulation now provided by `ferveo`. ([#74])

### Added

- Added `ThresholdMessageKit` which is the representation of data encrypted via `ferveo` that utilizes data encapsulation and ephemeral symmetric key. ([#74])
- Added `AccessControlPolicy` which contains access metadata (conditions, public key, authorization etc.) which forms part of the `ThresholdMessageKit`. ([#74])
- Added `AuthenticatedData` which forms part of the `AccessControlPolicy` and is needed to ensure that the aad is consistent during encryption process and during decryption process. ([#74])
- Added `encrypt_for_dkg` method for generation of `ferveo` `Ciphertext` and `AuthenticatedData`. ([#74])


[#74]: https://github.com/nucypher/nucypher-core/pull/74


## [0.11.0] - 2023-08-01

### Changed
Expand Down
34 changes: 10 additions & 24 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion nucypher-core-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
pyo3 = "0.18"
nucypher-core = { path = "../nucypher-core" }
umbral-pre = { version = "0.11.0", features = ["bindings-python"] }
ferveo = { version = "0.2.1", package = "ferveo-pre-release", features = ["bindings-python"] }
ferveo = { package = "ferveo-pre-release", git = "https://github.com/derekpierre/nucypher-ferveo.git", branch = "acp", features = ["bindings-python"] }
derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] }

[build-dependencies]
Expand Down
4 changes: 4 additions & 0 deletions nucypher-core-python/nucypher_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
MetadataRequest,
MetadataResponse,
MetadataResponsePayload,
AccessControlPolicy,
AuthenticatedData,
ThresholdMessageKit,
ThresholdDecryptionRequest,
ThresholdDecryptionResponse,
EncryptedThresholdDecryptionRequest,
Expand All @@ -25,4 +28,5 @@
SessionStaticKey,
SessionStaticSecret,
SessionSecretFactory,
encrypt_for_dkg,
)
81 changes: 75 additions & 6 deletions nucypher-core-python/nucypher_core/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ from .umbral import (
)

from .ferveo import (
FerveoPublicKey,
Ciphertext,
FerveoVariant
CiphertextHeader,
DkgPublicKey,
FerveoPublicKey,
FerveoVariant, SharedSecret,
)


Expand Down Expand Up @@ -429,22 +431,89 @@ class MetadataResponse:
...


@final
class AuthenticatedData:

def __init__(self, public_key: DkgPublicKey, conditions: Optional[Conditions]):
Copy link
Contributor

@piotr-roslaniec piotr-roslaniec Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekpierre I just recalled your comment on Optional<&Condition> in DKG structures. Are conditions supposed to be optional here? Or is it just downstream of that optionality in the DKG structures?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is downstream.

This is something that came to me last night, but it pervades many types in nucypher-core (ThresholdDecryptionRequest, ... etc.) and I didn't have time to fix it across all of them. I think we should fix it in a separate PR. Basically for DKG types Conditions should not be Optional but should be specified. Hence I filed #76 .

...

public_key: DkgPublicKey

conditions: Optional[Conditions]

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

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

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


def encrypt_for_dkg(data: bytes, public_key: DkgPublicKey, conditions: Optional[Conditions]) -> Tuple[Ciphertext, AuthenticatedData]:
...


@final
class AccessControlPolicy:

def __init__(self, auth_data: AuthenticatedData, authorization: bytes):
...

public_key: DkgPublicKey

conditions: Optional[Conditions]

authorization: bytes

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

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

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

@final
class ThresholdMessageKit:

def __init__(self, ciphertext: Ciphertext, acp: AccessControlPolicy):
...

acp: AccessControlPolicy

ciphertext_header: CiphertextHeader

def decrypt_with_shared_secret(self, shared_secret: SharedSecret):
...

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

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


@final
class ThresholdDecryptionRequest:

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

ritual_id: int

conditions: Optional[Conditions]
acp: AccessControlPolicy

context: Optional[Context]

variant: FerveoVariant

ciphertext: Ciphertext
ciphertext_header: CiphertextHeader

def encrypt(self, shared_secret: SessionSharedSecret,
requester_public_key: SessionStaticKey) -> EncryptedThresholdDecryptionRequest:
Expand Down
1 change: 1 addition & 0 deletions nucypher-core-python/nucypher_core/ferveo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
ValidatorsNotSorted = _ferveo.ValidatorsNotSorted
ValidatorPublicKeyMismatch = _ferveo.ValidatorPublicKeyMismatch
SerializationError = _ferveo.SerializationError
CiphertextHeader = _ferveo.CiphertextHeader
17 changes: 15 additions & 2 deletions nucypher-core-python/nucypher_core/ferveo.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class Dkg:

@final
class Ciphertext:
header: CiphertextHeader
payload: bytes

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


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

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


@final
class DecryptionShareSimple:
@staticmethod
Expand Down Expand Up @@ -159,7 +172,7 @@ class AggregatedTranscript:
def create_decryption_share_simple(
self,
dkg: Dkg,
ciphertext: Ciphertext,
ciphertext_header: CiphertextHeader,
aad: bytes,
validator_keypair: Keypair
) -> DecryptionShareSimple:
Expand All @@ -168,7 +181,7 @@ class AggregatedTranscript:
def create_decryption_share_precomputed(
self,
dkg: Dkg,
ciphertext: Ciphertext,
ciphertext_header: CiphertextHeader,
aad: bytes,
validator_keypair: Keypair
) -> DecryptionSharePrecomputed:
Expand Down
Loading
Loading