From 34d9485fc1bc9909ac8d2a0ead69b734e3332ba5 Mon Sep 17 00:00:00 2001 From: shareong <740310627@qq.com> Date: Tue, 10 Oct 2023 17:33:51 +0800 Subject: [PATCH] fix edwards ffi --- crypto/ecc/ecc_edwards25519/Cargo.toml | 3 +++ ffi/ffi_c/ffi_c_ecc_edwards25519/src/lib.rs | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crypto/ecc/ecc_edwards25519/Cargo.toml b/crypto/ecc/ecc_edwards25519/Cargo.toml index efdaa6b..19b5fbd 100644 --- a/crypto/ecc/ecc_edwards25519/Cargo.toml +++ b/crypto/ecc/ecc_edwards25519/Cargo.toml @@ -11,3 +11,6 @@ sha2 = "0.10.7" rand = "0.8.4" rand_core = "0.6.3" curve25519-dalek = { version = "4", features = [ "digest" , "rand_core"] } + +[lib] +crate-type = ["cdylib", "rlib"] diff --git a/ffi/ffi_c/ffi_c_ecc_edwards25519/src/lib.rs b/ffi/ffi_c/ffi_c_ecc_edwards25519/src/lib.rs index 9e20389..af2c31b 100644 --- a/ffi/ffi_c/ffi_c_ecc_edwards25519/src/lib.rs +++ b/ffi/ffi_c/ffi_c_ecc_edwards25519/src/lib.rs @@ -26,10 +26,8 @@ pub unsafe extern "C" fn wedpr_hash_to_curve( output_ciphertext: &mut COutputBuffer, ) -> i8 { let plaintext = c_read_raw_pointer(raw_message); - let message = hash_to_curve(&plaintext); - std::mem::forget(raw_message); - + std::mem::forget(plaintext); c_write_raw_pointer(&message, output_ciphertext); SUCCESS } @@ -44,8 +42,8 @@ pub unsafe extern "C" fn wedpr_point_scalar_multi( let num_point = c_read_raw_pointer(raw_point); let num_scalar = c_read_raw_pointer(raw_scalar); let result = point_scalar_multi(&num_point, &num_scalar); - std::mem::forget(raw_point); - std::mem::forget(raw_scalar); + std::mem::forget(num_point); + std::mem::forget(num_scalar); c_write_raw_pointer(&result, output_ciphertext); SUCCESS }