From 5459efaaf3b8618997c0fe681537b9fe023d190d Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 11 Jul 2023 15:02:51 +0200
Subject: [PATCH] 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"