From 16a8ce3a4562487acb6cef911c7a74c2aadfe138 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 26 Jul 2024 21:53:19 -0400 Subject: [PATCH] Add * point from bytes --- src/fcmp/fcmp_rust/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fcmp/fcmp_rust/src/lib.rs b/src/fcmp/fcmp_rust/src/lib.rs index 6e48ed5e6..60197349f 100644 --- a/src/fcmp/fcmp_rust/src/lib.rs +++ b/src/fcmp/fcmp_rust/src/lib.rs @@ -78,6 +78,22 @@ pub extern "C" fn selene_point_to_bytes(selene_point: SelenePoint) -> *const u8 c_u8_32(selene_point.to_bytes()) } +#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[no_mangle] +pub extern "C" fn helios_point_from_bytes(helios_point: *const u8) -> HeliosPoint { + let mut helios_point = unsafe { core::slice::from_raw_parts(helios_point, 32) }; + // TODO: Return an error here (instead of unwrapping) + ::read_G(&mut helios_point).unwrap() +} + +#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[no_mangle] +pub extern "C" fn selene_point_from_bytes(selene_point: *const u8) -> SelenePoint { + let mut selene_point = unsafe { core::slice::from_raw_parts(selene_point, 32) }; + // TODO: Return an error here (instead of unwrapping) + ::read_G(&mut selene_point).unwrap() +} + // Get the x coordinate of the ed25519 point #[allow(clippy::not_unsafe_ptr_arg_deref)] #[no_mangle]