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

Tracking changes for [email protected] update #69

Merged
merged 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
363 changes: 145 additions & 218 deletions Cargo.lock

Large diffs are not rendered by default.

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.10.0", features = ["bindings-python"] }
ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.10", features = ["bindings-python"] }
ferveo = { package = "ferveo-pre-release", version = "0.2.0", features = ["bindings-python"] }
derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] }

[build-dependencies]
Expand Down
14 changes: 8 additions & 6 deletions nucypher-core-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ extern crate alloc;

use alloc::collections::{BTreeMap, BTreeSet};

use ferveo::bindings_python::{Ciphertext, FerveoPublicKey};
use ferveo::{
api::FerveoVariant,
bindings_python::{Ciphertext, FerveoPublicKey},
};
use pyo3::class::basic::CompareOp;
use pyo3::exceptions::{PyTypeError, PyValueError};
use pyo3::prelude::*;
Expand All @@ -18,7 +21,6 @@ use umbral_pre::bindings_python::{
VerifiedCapsuleFrag, VerifiedKeyFrag,
};

use nucypher_core::FerveoVariant;
use nucypher_core::ProtocolObject;

fn to_bytes<'a, T, U>(obj: &T) -> PyObject
Expand Down Expand Up @@ -763,8 +765,8 @@ impl ThresholdDecryptionRequest {
context: Option<&Context>,
) -> PyResult<Self> {
let ferveo_variant = match variant {
0 => FerveoVariant::SIMPLE,
1 => FerveoVariant::PRECOMPUTED,
0 => FerveoVariant::Simple,
1 => FerveoVariant::Precomputed,
_ => {
return Err(PyValueError::new_err(
"Invalid ThresholdDecryptionRequest variant",
Expand Down Expand Up @@ -816,8 +818,8 @@ impl ThresholdDecryptionRequest {
#[getter]
pub fn variant(&self) -> u8 {
match self.backend.variant {
FerveoVariant::SIMPLE => 0,
FerveoVariant::PRECOMPUTED => 1,
FerveoVariant::Simple => 0,
FerveoVariant::Precomputed => 1,
}
}

Expand Down
2 changes: 1 addition & 1 deletion nucypher-core-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default = ["console_error_panic_hook"]

[dependencies]
umbral-pre = { version = "0.10.0", features = ["bindings-wasm"] }
ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.10", features = ["bindings-wasm"] }
ferveo = { package = "ferveo-pre-release", version = "0.2.0", features = ["bindings-wasm"] }
nucypher-core = { path = "../nucypher-core" }
wasm-bindgen = "0.2.86"
js-sys = "0.3.63"
Expand Down
12 changes: 6 additions & 6 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::bindings_wasm::Ciphertext;
use ferveo::{api::FerveoVariant, bindings_wasm::Ciphertext};
use js_sys::Error;
use umbral_pre::bindings_wasm::{
Capsule, PublicKey, RecoverableSignature, SecretKey, Signer, VerifiedCapsuleFrag,
Expand All @@ -22,7 +22,7 @@ use wasm_bindgen::prelude::{wasm_bindgen, JsValue};
use wasm_bindgen::JsCast;
use wasm_bindgen_derive::TryFromJsValue;

use nucypher_core::{FerveoVariant, ProtocolObject};
use nucypher_core::ProtocolObject;

// Re-export certain types so they can be used from `nucypher-core` WASM bindings directly.
pub use ferveo::bindings_wasm::{FerveoPublicKey, Keypair};
Expand Down Expand Up @@ -673,8 +673,8 @@ impl ThresholdDecryptionRequest {
let typed_context = try_from_js_option::<Context>(context)?;

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

Expand All @@ -695,8 +695,8 @@ impl ThresholdDecryptionRequest {
#[wasm_bindgen(getter)]
pub fn variant(&self) -> u8 {
match self.0.variant {
FerveoVariant::SIMPLE => 0,
FerveoVariant::PRECOMPUTED => 1,
FerveoVariant::Simple => 0,
FerveoVariant::Precomputed => 1,
}
}

Expand Down
2 changes: 1 addition & 1 deletion nucypher-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ categories = ["cryptography", "no-std"]

[dependencies]
umbral-pre = { version = "0.10.0", features = ["serde"] }
ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.10" }
ferveo = { package = "ferveo-pre-release", version = "0.2.0" }
serde = { version = "1", default-features = false, features = ["derive"] }
generic-array = { version = "0.14", features = ["zeroize"] }
sha3 = "0.10"
Expand Down
17 changes: 4 additions & 13 deletions nucypher-core/src/dkg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloc::boxed::Box;
use alloc::string::String;
use core::fmt;
use ferveo::api::Ciphertext;
use ferveo::api::{Ciphertext, FerveoVariant};
use generic_array::typenum::Unsigned;

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -100,15 +100,6 @@ fn decrypt_with_shared_secret(
Ok(plaintext.into_boxed_slice())
}

/// The ferveo variant to use for the decryption share derivation.
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Copy, Clone)]
pub enum FerveoVariant {
/// The simple variant requires m of n shares to decrypt
SIMPLE,
/// The precomputed variant requires n of n shares to decrypt
PRECOMPUTED,
}

/// Module for session key objects.
pub mod session {
use alloc::boxed::Box;
Expand Down Expand Up @@ -601,11 +592,11 @@ impl<'a> ProtocolObject<'a> for EncryptedThresholdDecryptionResponse {}

#[cfg(test)]
mod tests {
use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, SecretBox};
use ferveo::api::{encrypt as ferveo_encrypt, DkgPublicKey, FerveoVariant, SecretBox};

use crate::{
Conditions, Context, EncryptedThresholdDecryptionRequest,
EncryptedThresholdDecryptionResponse, FerveoVariant, ProtocolObject, SessionSecretFactory,
EncryptedThresholdDecryptionResponse, ProtocolObject, SessionSecretFactory,
SessionStaticKey, ThresholdDecryptionRequest, ThresholdDecryptionResponse,
};

Expand Down Expand Up @@ -742,7 +733,7 @@ mod tests {
&ciphertext,
Some(&Conditions::new("abcd")),
Some(&Context::new("efgh")),
FerveoVariant::SIMPLE,
FerveoVariant::Simple,
Copy link
Member

Choose a reason for hiding this comment

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

Is there an equivalent test case for a request that uses Precomputed? You could do one within this same test.

);

// requester encrypts request to send to service
Expand Down
2 changes: 1 addition & 1 deletion nucypher-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use conditions::{Conditions, Context};
pub use dkg::{
session::{SessionSecretFactory, SessionSharedSecret, SessionStaticKey, SessionStaticSecret},
DecryptionError, EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse,
EncryptionError, FerveoVariant, ThresholdDecryptionRequest, ThresholdDecryptionResponse,
EncryptionError, ThresholdDecryptionRequest, ThresholdDecryptionResponse,
};
pub use fleet_state::FleetStateChecksum;
pub use hrac::HRAC;
Expand Down
Loading