Skip to content

Commit

Permalink
Respond to RFCs for #52.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre committed May 17, 2023
1 parent 827b07e commit 124a8a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 2 additions & 0 deletions nucypher-core-wasm/tests/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 5 additions & 23 deletions nucypher-core/src/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 124a8a2

Please sign in to comment.