From 6b6a338c3e781309ad849712f0bc8a6ed02fce12 Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Wed, 20 Sep 2023 17:22:09 +0800 Subject: [PATCH] add ffi c edwards25519 --- Cargo.lock | 20 ++++++++++++++----- Cargo.toml | 7 ++++--- .../Cargo.toml | 2 +- .../src/lib.rs | 0 .../ffi_java_ecc_edwards25519}/Cargo.toml | 6 +++--- .../ffi_java_ecc_edwards25519}/src/lib.rs | 4 +--- .../ffi_wasm_ecc_edwards25519}/Cargo.toml | 6 +++--- .../ffi_wasm_ecc_edwards25519}/readme.md | 0 .../ffi_wasm_ecc_edwards25519}/src/lib.rs | 4 +--- 9 files changed, 28 insertions(+), 21 deletions(-) rename crypto/ecc/{ecc_ed25519 => ecc_edwards25519}/Cargo.toml (91%) rename crypto/ecc/{ecc_ed25519 => ecc_edwards25519}/src/lib.rs (100%) rename {crypto/ecc/ffi_java_ecc_ed25519 => ffi/ffi_java/ffi_java_ecc_edwards25519}/Cargo.toml (61%) rename {crypto/ecc/ffi_java_ecc_ed25519 => ffi/ffi_java/ffi_java_ecc_edwards25519}/src/lib.rs (96%) rename {crypto/ecc/ffi_wasm_ecc_ed25519 => ffi/ffi_wasm/ffi_wasm_ecc_edwards25519}/Cargo.toml (65%) rename {crypto/ecc/ffi_wasm_ecc_ed25519 => ffi/ffi_wasm/ffi_wasm_ecc_edwards25519}/readme.md (100%) rename {crypto/ecc/ffi_wasm_ecc_ed25519 => ffi/ffi_wasm/ffi_wasm_ecc_edwards25519}/src/lib.rs (83%) diff --git a/Cargo.lock b/Cargo.lock index a50c7ec..800a6f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -619,7 +619,7 @@ dependencies = [ ] [[package]] -name = "ecc_ed25519" +name = "ecc_edwards25519" version = "0.1.0" dependencies = [ "curve25519-dalek 4.0.0", @@ -811,18 +811,18 @@ dependencies = [ ] [[package]] -name = "ffi_java_ecc_ed25519" +name = "ffi_java_ecc_edwards25519" version = "0.1.0" dependencies = [ - "ecc_ed25519", + "ecc_edwards25519", "jni", ] [[package]] -name = "ffi_wasm_ecc_ed25519" +name = "ffi_wasm_ecc_edwards25519" version = "0.1.0" dependencies = [ - "ecc_ed25519", + "ecc_edwards25519", "getrandom 0.2.2", "wasm-bindgen", ] @@ -2233,6 +2233,16 @@ dependencies = [ "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wedpr_ffi_c_edwards25519" +version = "1.0.0" +dependencies = [ + "cbindgen", + "ecc_edwards25519", + "libc", + "wedpr_ffi_common 1.1.0", +] + [[package]] name = "wedpr_ffi_c_fisco_bcos" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 40e4310..da2c03a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ members = [ "ffi/ffi_c/ffi_c_crypto_binary", "ffi/ffi_c/ffi_c_fisco_bcos", "ffi/ffi_c/ffi_c_zkp", + "ffi/ffi_c/ffi_c_ecc_edwards25519", "ffi/ffi_common", "ffi/ffi_java/ffi_java_crypto", "ffi/ffi_java/ffi_java_crypto_binary", @@ -34,7 +35,7 @@ members = [ "protos", "third_party/fisco_bcos", "third_party/fisco_bcos_java_sdk", - "crypto/ecc/ecc_ed25519", - "crypto/ecc/ffi_java_ecc_ed25519", - "crypto/ecc/ffi_wasm_ecc_ed25519", + "crypto/ecc/ecc_edwards25519", + "ffi/ffi_java/ffi_java_ecc_edwards25519", + "ffi/ffi_wasm/ffi_wasm_ecc_edwards25519", ] diff --git a/crypto/ecc/ecc_ed25519/Cargo.toml b/crypto/ecc/ecc_edwards25519/Cargo.toml similarity index 91% rename from crypto/ecc/ecc_ed25519/Cargo.toml rename to crypto/ecc/ecc_edwards25519/Cargo.toml index dbcdf8e..efdaa6b 100644 --- a/crypto/ecc/ecc_ed25519/Cargo.toml +++ b/crypto/ecc/ecc_edwards25519/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ecc_ed25519" +name = "ecc_edwards25519" version = "0.1.0" edition = "2021" diff --git a/crypto/ecc/ecc_ed25519/src/lib.rs b/crypto/ecc/ecc_edwards25519/src/lib.rs similarity index 100% rename from crypto/ecc/ecc_ed25519/src/lib.rs rename to crypto/ecc/ecc_edwards25519/src/lib.rs diff --git a/crypto/ecc/ffi_java_ecc_ed25519/Cargo.toml b/ffi/ffi_java/ffi_java_ecc_edwards25519/Cargo.toml similarity index 61% rename from crypto/ecc/ffi_java_ecc_ed25519/Cargo.toml rename to ffi/ffi_java/ffi_java_ecc_edwards25519/Cargo.toml index e6b9013..1f42919 100644 --- a/crypto/ecc/ffi_java_ecc_ed25519/Cargo.toml +++ b/ffi/ffi_java/ffi_java_ecc_edwards25519/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "ffi_java_ecc_ed25519" +name = "ffi_java_ecc_edwards25519" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "ffi_java_ecc_ed25519" +name = "ffi_java_ecc_edwards25519" crate-type = [ "cdylib", "staticlib" ] [dependencies] jni = "0.13.0" -ecc_ed25519 = { path = "../ecc_ed25519"} \ No newline at end of file +ecc_edwards25519 = { path = "../../../crypto/ecc/ecc_edwards25519" } \ No newline at end of file diff --git a/crypto/ecc/ffi_java_ecc_ed25519/src/lib.rs b/ffi/ffi_java/ffi_java_ecc_edwards25519/src/lib.rs similarity index 96% rename from crypto/ecc/ffi_java_ecc_ed25519/src/lib.rs rename to ffi/ffi_java/ffi_java_ecc_edwards25519/src/lib.rs index 981dc30..f07a4c1 100644 --- a/crypto/ecc/ffi_java_ecc_ed25519/src/lib.rs +++ b/ffi/ffi_java/ffi_java_ecc_edwards25519/src/lib.rs @@ -1,8 +1,6 @@ extern crate jni; -use ecc_ed25519::{ - hash_to_curve, point_scalar_multi, random_scalar, -}; +use ecc_edwards25519::{hash_to_curve, point_scalar_multi, random_scalar}; use jni::{objects::JClass, sys::jbyteArray, JNIEnv}; diff --git a/crypto/ecc/ffi_wasm_ecc_ed25519/Cargo.toml b/ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/Cargo.toml similarity index 65% rename from crypto/ecc/ffi_wasm_ecc_ed25519/Cargo.toml rename to ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/Cargo.toml index 89e608a..d866981 100644 --- a/crypto/ecc/ffi_wasm_ecc_ed25519/Cargo.toml +++ b/ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "ffi_wasm_ecc_ed25519" +name = "ffi_wasm_ecc_edwards25519" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "ffi_wasm_ecc_ed25519" +name = "ffi_wasm_ecc_edwards25519" crate-type = ["rlib", "cdylib"] [dependencies] wasm-bindgen = "0.2" getrandom = { version = "0.2", features = ["js"] } -ecc_ed25519 = { path = "../ecc_ed25519"} +ecc_edwards25519 = { path = "../../../crypto/ecc/ecc_edwards25519" } diff --git a/crypto/ecc/ffi_wasm_ecc_ed25519/readme.md b/ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/readme.md similarity index 100% rename from crypto/ecc/ffi_wasm_ecc_ed25519/readme.md rename to ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/readme.md diff --git a/crypto/ecc/ffi_wasm_ecc_ed25519/src/lib.rs b/ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/src/lib.rs similarity index 83% rename from crypto/ecc/ffi_wasm_ecc_ed25519/src/lib.rs rename to ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/src/lib.rs index 904f9c8..a305055 100644 --- a/crypto/ecc/ffi_wasm_ecc_ed25519/src/lib.rs +++ b/ffi/ffi_wasm/ffi_wasm_ecc_edwards25519/src/lib.rs @@ -1,8 +1,6 @@ extern crate wasm_bindgen; -use ecc_ed25519::{ - hash_to_curve, point_scalar_multi, random_scalar, -}; +use ecc_edwards25519::{hash_to_curve, point_scalar_multi, random_scalar}; use wasm_bindgen::prelude::wasm_bindgen; #[wasm_bindgen]