From 124a8a2bb21c21990ca843d8e0bf22b497d12cb9 Mon Sep 17 00:00:00 2001 From: derekpierre Date: Tue, 16 May 2023 20:23:22 -0400 Subject: [PATCH] Respond to RFCs for #52. --- nucypher-core-wasm/tests/wasm.rs | 2 ++ nucypher-core/src/dkg.rs | 28 +++++----------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/nucypher-core-wasm/tests/wasm.rs b/nucypher-core-wasm/tests/wasm.rs index 54491ab9..b3eea31f 100644 --- a/nucypher-core-wasm/tests/wasm.rs +++ b/nucypher-core-wasm/tests/wasm.rs @@ -691,10 +691,12 @@ fn threshold_decryption_request() { let encrypted_request = request.encrypt(&request_encrypting_key, &response_encrypting_key); + // mimic encrypted request going over the wire let encrypted_request_bytes = encrypted_request.to_bytes(); let encrypted_request_from_bytes = EncryptedThresholdDecryptionRequest::from_bytes(&encrypted_request_bytes).unwrap(); + assert_eq!(encrypted_request_from_bytes, encrypted_request); assert_eq!(encrypted_request_from_bytes.id(), ritual_id); let e2e_request = encrypted_request_from_bytes diff --git a/nucypher-core/src/dkg.rs b/nucypher-core/src/dkg.rs index ab56782e..422c41c6 100644 --- a/nucypher-core/src/dkg.rs +++ b/nucypher-core/src/dkg.rs @@ -2,9 +2,7 @@ use alloc::boxed::Box; use alloc::string::String; use serde::{Deserialize, Serialize}; -use umbral_pre::{ - decrypt_original, encrypt, serde_bytes, Capsule, EncryptionError, PublicKey, SecretKey, -}; +use umbral_pre::{decrypt_original, encrypt, serde_bytes, Capsule, PublicKey, SecretKey}; use crate::conditions::{Conditions, Context}; use crate::key_frag::DecryptionError; @@ -161,16 +159,8 @@ impl EncryptedThresholdDecryptionRequest { E2EEThresholdDecryptionRequest::new(request, response_encrypting_key); // TODO: using Umbral for encryption to avoid introducing more crypto primitives. let (capsule, ciphertext) = - match encrypt(request_encrypting_key, &e2e_decryption_request.to_bytes()) { - Ok(result) => result, - Err(err) => match err { - // For now this is the only error that can happen during encryption, - // and there's really no point in propagating it. - EncryptionError::PlaintextTooLarge => { - panic!("encryption failed - out of memory?") - } - }, - }; + encrypt(request_encrypting_key, &e2e_decryption_request.to_bytes()) + .expect("encryption failed - out of memory?"); let ritual_id = request.ritual_id; Self { ritual_id, @@ -279,16 +269,8 @@ impl EncryptedThresholdDecryptionResponse { ) -> Self { // TODO: using Umbral for encryption to avoid introducing more crypto primitives. let (capsule, ciphertext) = - match encrypt(encrypting_key, &threshold_decryption_response.to_bytes()) { - Ok(result) => result, - Err(err) => match err { - // For now this is the only error that can happen during encryption, - // and there's really no point in propagating it. - EncryptionError::PlaintextTooLarge => { - panic!("encryption failed - out of memory?") - } - }, - }; + encrypt(encrypting_key, &threshold_decryption_response.to_bytes()) + .expect("encryption failed - out of memory?"); Self { capsule, ciphertext,