Skip to content

Commit

Permalink
fix edwards ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
Shareong authored and HaoXuan40404 committed Oct 10, 2023
1 parent a5c39b2 commit 34d9485
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions crypto/ecc/ecc_edwards25519/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 3 additions & 5 deletions ffi/ffi_c/ffi_c_ecc_edwards25519/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

0 comments on commit 34d9485

Please sign in to comment.