From 815b640a2749c0beece1ad1375b897426d4c3b89 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Fri, 6 Jun 2025 11:23:20 +0200 Subject: [PATCH] [bug] don't stringify value before encryption --- src/api.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api.rs b/src/api.rs index 8383144..af1499c 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1186,8 +1186,7 @@ pub fn create_new_process( for (field, plain_value) in private_data.iter() { let hash = pcd_commitment.get(field).ok_or(anyhow::Error::msg("Missing commitment"))?; let key = generate_key(&mut rng); - let serialized = serde_json::to_string(plain_value)?; - let cipher = encrypt_with_key(&key, serialized.as_bytes())?; + let cipher = encrypt_with_key(&key, plain_value.as_slice())?; new_state.keys.insert(field.to_owned(), key); encrypted_data.insert(hash.to_lower_hex_string(), cipher.to_lower_hex_string()); } @@ -1674,7 +1673,7 @@ pub fn is_child_role(parent_roles: String, child_roles: String) -> ApiResult<()> } #[wasm_bindgen] -pub fn decrypt_data(key: &[u8], data: &[u8]) -> ApiResult { +pub fn decrypt_data(key: &[u8], data: &[u8]) -> ApiResult> { let mut key_buf = [0u8; 32]; if key.len() != 32 {