mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-05 23:43:11 +00:00
Use decode response in decrypt
This commit is contained in:
parent
65d1e538b4
commit
fbb2317997
@ -1,12 +1,13 @@
|
|||||||
//! Symmetric and asymmetric waku messages [decrypting](https://rfc.vac.dev/spec/36/#decrypting-messages) methods
|
//! Symmetric and asymmetric waku messages [decrypting](https://rfc.vac.dev/spec/36/#decrypting-messages) methods
|
||||||
|
|
||||||
// std
|
// std
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::CString;
|
||||||
// crates
|
// crates
|
||||||
use aes_gcm::{Aes256Gcm, Key};
|
use aes_gcm::{Aes256Gcm, Key};
|
||||||
use secp256k1::SecretKey;
|
use secp256k1::SecretKey;
|
||||||
// internal
|
// internal
|
||||||
use crate::general::{DecodedPayload, JsonResponse, Result, WakuMessage};
|
use crate::general::{DecodedPayload, Result, WakuMessage};
|
||||||
|
use crate::utils::decode_and_free_response;
|
||||||
|
|
||||||
/// Decrypt a message using a symmetric key
|
/// Decrypt a message using a symmetric key
|
||||||
///
|
///
|
||||||
@ -34,16 +35,7 @@ pub fn waku_decode_symmetric(
|
|||||||
res
|
res
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = unsafe { CStr::from_ptr(result_ptr) }
|
decode_and_free_response(result_ptr)
|
||||||
.to_str()
|
|
||||||
.expect("Response should always succeed to load to a &str");
|
|
||||||
|
|
||||||
let response: JsonResponse<DecodedPayload> =
|
|
||||||
serde_json::from_str(result).map_err(|e| format!("{e}"))?;
|
|
||||||
|
|
||||||
unsafe { waku_sys::waku_utils_free(result_ptr) };
|
|
||||||
|
|
||||||
response.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decrypt a message using a symmetric key
|
/// Decrypt a message using a symmetric key
|
||||||
@ -72,14 +64,5 @@ pub fn waku_decode_asymmetric(
|
|||||||
res
|
res
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = unsafe { CStr::from_ptr(result_ptr) }
|
decode_and_free_response(result_ptr)
|
||||||
.to_str()
|
|
||||||
.expect("Response should always succeed to load to a &str");
|
|
||||||
|
|
||||||
let response: JsonResponse<DecodedPayload> =
|
|
||||||
serde_json::from_str(result).map_err(|e| format!("{e}"))?;
|
|
||||||
|
|
||||||
unsafe { waku_sys::waku_utils_free(result_ptr) };
|
|
||||||
|
|
||||||
response.into()
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user