Skip to content

Commit

Permalink
update FerveoVariant usage
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 11, 2023
1 parent 2e7b989 commit 5459efa
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 47 deletions.
46 changes: 23 additions & 23 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.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]
Expand Down
26 changes: 5 additions & 21 deletions nucypher-core-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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<Self> {
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,
Expand All @@ -775,7 +762,7 @@ impl ThresholdDecryptionRequest {
.map(|conditions| conditions.backend.clone())
.as_ref(),
context.map(|context| context.backend.clone()).as_ref(),
ferveo_variant,
variant,
),
})
}
Expand Down Expand Up @@ -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(
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"], 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"
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"], 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"
Expand Down

0 comments on commit 5459efa

Please sign in to comment.