diff --git a/CHANGELOG.md b/CHANGELOG.md index ebd62211..131c786a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `EncryptedThresholdDecryptionRequest`/`EncryptedThresholdDecryptionResponse` types and bindings. ([#52])` +### Changed + +- Bumped MSRV to 1.65. ([#52]) + + [#52]: https://github.com/nucypher/nucypher-core/pull/52 diff --git a/nucypher-core-python/nucypher_core/__init__.py b/nucypher-core-python/nucypher_core/__init__.py index 9c967d27..501c856f 100644 --- a/nucypher-core-python/nucypher_core/__init__.py +++ b/nucypher-core-python/nucypher_core/__init__.py @@ -18,7 +18,7 @@ MetadataResponse, MetadataResponsePayload, ThresholdDecryptionRequest, - E2EEThresholdDecryptionRequest, + E2EThresholdDecryptionRequest, ThresholdDecryptionResponse, EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse, diff --git a/nucypher-core-python/nucypher_core/__init__.pyi b/nucypher-core-python/nucypher_core/__init__.pyi index 236a61b4..0ec56072 100644 --- a/nucypher-core-python/nucypher_core/__init__.pyi +++ b/nucypher-core-python/nucypher_core/__init__.pyi @@ -408,20 +408,15 @@ class ThresholdDecryptionRequest: def __init__(self, ritual_id: int, variant: int, ciphertext: bytes, conditions: Optional[Conditions], context: Optional[Context]): ... - def id(self) -> int: - ... + ritual_id: int - def conditions(self) -> Optional[Conditions]: - ... + conditions: Optional[Conditions] - def context(self) -> Optional[Context]: - ... + context: Optional[Context] - def variant(self) -> int: - ... + variant: int - def ciphertext(self) -> bytes: - ... + ciphertext: bytes def encrypt(self, request_encrypting_key: PublicKey, response_encrypting_key: PublicKey) -> EncryptedThresholdDecryptionRequest: ... @@ -434,16 +429,14 @@ class ThresholdDecryptionRequest: ... -class E2EEThresholdDecryptionRequest: +class E2EThresholdDecryptionRequest: - def decryption_request(self) -> ThresholdDecryptionRequest: - ... + decryption_request: ThresholdDecryptionRequest - def response_encrypting_key(self) -> PublicKey: - ... + response_encrypting_key: PublicKey @staticmethod - def from_bytes(data: bytes) -> E2EEThresholdDecryptionRequest: + def from_bytes(data: bytes) -> E2EThresholdDecryptionRequest: ... def __bytes__(self) -> bytes: @@ -451,13 +444,12 @@ class E2EEThresholdDecryptionRequest: class EncryptedThresholdDecryptionRequest: - def id(self) -> int: - ... + ritual_id: int def decrypt( self, sk: SecretKey - ) -> E2EEThresholdDecryptionRequest: + ) -> E2EThresholdDecryptionRequest: ... @staticmethod @@ -473,8 +465,7 @@ class ThresholdDecryptionResponse: def __init__(self, decryption_share: bytes): ... - def decryption_share(self) -> bytes: - ... + decryption_share: bytes def encrypt(self, encrypting_key: PublicKey) -> EncryptedThresholdDecryptionResponse: ... @@ -487,7 +478,6 @@ class ThresholdDecryptionResponse: ... - class EncryptedThresholdDecryptionResponse: def decrypt( diff --git a/nucypher-core-python/src/lib.rs b/nucypher-core-python/src/lib.rs index 87fa3248..1f10a42c 100644 --- a/nucypher-core-python/src/lib.rs +++ b/nucypher-core-python/src/lib.rs @@ -645,7 +645,7 @@ pub struct ThresholdDecryptionRequest { impl ThresholdDecryptionRequest { #[new] pub fn new( - id: u16, + ritual_id: u16, variant: u8, ciphertext: &[u8], // TODO use ferveo Ciphertext type conditions: Option<&Conditions>, @@ -663,7 +663,7 @@ impl ThresholdDecryptionRequest { Ok(Self { backend: nucypher_core::ThresholdDecryptionRequest::new( - id, + ritual_id, ciphertext, conditions .map(|conditions| conditions.backend.clone()) @@ -675,7 +675,7 @@ impl ThresholdDecryptionRequest { } #[getter] - pub fn id(&self) -> u16 { + pub fn ritual_id(&self) -> u16 { self.backend.ritual_id } @@ -734,16 +734,16 @@ impl ThresholdDecryptionRequest { } // -// E2EEThresholdDecryptionRequest +// E2EThresholdDecryptionRequest // #[pyclass(module = "nucypher_core")] #[derive(derive_more::From, derive_more::AsRef)] -pub struct E2EEThresholdDecryptionRequest { - backend: nucypher_core::E2EEThresholdDecryptionRequest, +pub struct E2EThresholdDecryptionRequest { + backend: nucypher_core::E2EThresholdDecryptionRequest, } #[pymethods] -impl E2EEThresholdDecryptionRequest { +impl E2EThresholdDecryptionRequest { #[getter] pub fn decryption_request(&self) -> ThresholdDecryptionRequest { self.backend.decryption_request.clone().into() @@ -756,7 +756,7 @@ impl E2EEThresholdDecryptionRequest { #[staticmethod] pub fn from_bytes(data: &[u8]) -> PyResult { - from_bytes::<_, nucypher_core::E2EEThresholdDecryptionRequest>(data) + from_bytes::<_, nucypher_core::E2EThresholdDecryptionRequest>(data) } fn __bytes__(&self) -> PyObject { @@ -777,14 +777,14 @@ pub struct EncryptedThresholdDecryptionRequest { #[pymethods] impl EncryptedThresholdDecryptionRequest { #[getter] - pub fn id(&self) -> u16 { + pub fn ritual_id(&self) -> u16 { self.backend.ritual_id } - pub fn decrypt(&self, sk: &SecretKey) -> PyResult { + pub fn decrypt(&self, sk: &SecretKey) -> PyResult { self.backend .decrypt(sk.as_ref()) - .map(E2EEThresholdDecryptionRequest::from) + .map(E2EThresholdDecryptionRequest::from) .map_err(|err| PyValueError::new_err(format!("{}", err))) } @@ -1333,7 +1333,7 @@ fn _nucypher_core(py: Python, m: &PyModule) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; - m.add_class::()?; + m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; diff --git a/nucypher-core-wasm/src/lib.rs b/nucypher-core-wasm/src/lib.rs index 3c59633e..e8ecec14 100644 --- a/nucypher-core-wasm/src/lib.rs +++ b/nucypher-core-wasm/src/lib.rs @@ -572,8 +572,8 @@ impl ThresholdDecryptionRequest { ))) } - #[wasm_bindgen(getter)] - pub fn id(&self) -> u16 { + #[wasm_bindgen(getter, js_name = ritualId)] + pub fn ritual_id(&self) -> u16 { self.0.ritual_id } @@ -613,18 +613,18 @@ impl ThresholdDecryptionRequest { } // -// E2EEThresholdDecryptionRequest +// E2EThresholdDecryptionRequest // #[wasm_bindgen] #[derive(PartialEq, Debug, derive_more::From, derive_more::AsRef)] -pub struct E2EEThresholdDecryptionRequest(nucypher_core::E2EEThresholdDecryptionRequest); +pub struct E2EThresholdDecryptionRequest(nucypher_core::E2EThresholdDecryptionRequest); #[wasm_bindgen] -impl E2EEThresholdDecryptionRequest { +impl E2EThresholdDecryptionRequest { #[wasm_bindgen(js_name = fromBytes)] - pub fn from_bytes(data: &[u8]) -> Result { - from_bytes::<_, nucypher_core::E2EEThresholdDecryptionRequest>(data) + pub fn from_bytes(data: &[u8]) -> Result { + from_bytes::<_, nucypher_core::E2EThresholdDecryptionRequest>(data) } #[wasm_bindgen(js_name = toBytes)] @@ -632,7 +632,7 @@ impl E2EEThresholdDecryptionRequest { to_bytes(self) } - #[wasm_bindgen(getter, js_name=decryption_request)] + #[wasm_bindgen(getter, js_name=decryptionRequest)] pub fn decryption_request(&self) -> ThresholdDecryptionRequest { ThresholdDecryptionRequest::from(self.0.decryption_request.clone()) } @@ -653,16 +653,16 @@ pub struct EncryptedThresholdDecryptionRequest(nucypher_core::EncryptedThreshold #[wasm_bindgen] impl EncryptedThresholdDecryptionRequest { - #[wasm_bindgen(getter)] - pub fn id(&self) -> u16 { + #[wasm_bindgen(getter, js_name = ritualId)] + pub fn ritual_id(&self) -> u16 { self.0.ritual_id } - pub fn decrypt(&self, sk: &SecretKey) -> Result { + pub fn decrypt(&self, sk: &SecretKey) -> Result { self.0 .decrypt(sk.as_ref()) .map_err(map_js_err) - .map(E2EEThresholdDecryptionRequest) + .map(E2EThresholdDecryptionRequest) } #[wasm_bindgen(js_name = fromBytes)] diff --git a/nucypher-core-wasm/tests/wasm.rs b/nucypher-core-wasm/tests/wasm.rs index b3eea31f..3255bd12 100644 --- a/nucypher-core-wasm/tests/wasm.rs +++ b/nucypher-core-wasm/tests/wasm.rs @@ -697,7 +697,7 @@ fn threshold_decryption_request() { EncryptedThresholdDecryptionRequest::from_bytes(&encrypted_request_bytes).unwrap(); assert_eq!(encrypted_request_from_bytes, encrypted_request); - assert_eq!(encrypted_request_from_bytes.id(), ritual_id); + assert_eq!(encrypted_request_from_bytes.ritual_id(), ritual_id); let e2e_request = encrypted_request_from_bytes .decrypt(&request_secret) diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index 422c41c6..90f6e684 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -94,14 +94,14 @@ impl<'a> ProtocolObject<'a> for ThresholdDecryptionRequest {} /// A request for an Ursula to derive a decryption share that specifies the key to encrypt Ursula's response. #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] -pub struct E2EEThresholdDecryptionRequest { +pub struct E2EThresholdDecryptionRequest { /// The decryption request. pub decryption_request: ThresholdDecryptionRequest, /// The key to encrypt the corresponding decryption response. pub response_encrypting_key: PublicKey, } -impl E2EEThresholdDecryptionRequest { +impl E2EThresholdDecryptionRequest { /// Create E2E decryption request. pub fn new( decryption_request: &ThresholdDecryptionRequest, @@ -114,7 +114,7 @@ impl E2EEThresholdDecryptionRequest { } } -impl<'a> ProtocolObjectInner<'a> for E2EEThresholdDecryptionRequest { +impl<'a> ProtocolObjectInner<'a> for E2EThresholdDecryptionRequest { fn version() -> (u16, u16) { (1, 0) } @@ -136,7 +136,7 @@ impl<'a> ProtocolObjectInner<'a> for E2EEThresholdDecryptionRequest { } } -impl<'a> ProtocolObject<'a> for E2EEThresholdDecryptionRequest {} +impl<'a> ProtocolObject<'a> for E2EThresholdDecryptionRequest {} /// An encrypted request for an Ursula to derive a decryption share. #[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] @@ -156,7 +156,7 @@ impl EncryptedThresholdDecryptionRequest { response_encrypting_key: &PublicKey, ) -> Self { let e2e_decryption_request = - E2EEThresholdDecryptionRequest::new(request, response_encrypting_key); + E2EThresholdDecryptionRequest::new(request, response_encrypting_key); // TODO: using Umbral for encryption to avoid introducing more crypto primitives. let (capsule, ciphertext) = encrypt(request_encrypting_key, &e2e_decryption_request.to_bytes()) @@ -173,11 +173,11 @@ impl EncryptedThresholdDecryptionRequest { pub fn decrypt( &self, sk: &SecretKey, - ) -> Result { + ) -> Result { let decryption_request_bytes = decrypt_original(sk, &self.capsule, &self.ciphertext) .map_err(DecryptionError::DecryptionFailed)?; let decryption_request = - E2EEThresholdDecryptionRequest::from_bytes(&decryption_request_bytes) + E2EThresholdDecryptionRequest::from_bytes(&decryption_request_bytes) .map_err(DecryptionError::DeserializationFailed)?; Ok(decryption_request) } diff --git a/nucypher-core/src/lib.rs b/nucypher-core/src/lib.rs index 70422159..8da9564b 100644 --- a/nucypher-core/src/lib.rs +++ b/nucypher-core/src/lib.rs @@ -27,7 +27,7 @@ pub struct VerificationError; pub use address::Address; pub use conditions::{Conditions, Context}; pub use dkg::{ - E2EEThresholdDecryptionRequest, EncryptedThresholdDecryptionRequest, + E2EThresholdDecryptionRequest, EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse, FerveoVariant, ThresholdDecryptionRequest, ThresholdDecryptionResponse, };