From f40697817a16b5fbace944249c617e75ff378227 Mon Sep 17 00:00:00 2001 From: asherli <444649358@qq.com> Date: Tue, 29 Oct 2024 15:49:12 +0800 Subject: [PATCH 1/9] add secp256k1 vrf rust part --- Cargo.lock | 254 +++++++++++++++++++++- Cargo.toml | 2 +- Changelog.md | 7 + crypto/vrf/secp256k1/Cargo.toml | 17 ++ crypto/vrf/secp256k1/src/lib.rs | 362 ++++++++++++++++++++++++++++++++ release_note.txt | 2 +- 6 files changed, 636 insertions(+), 8 deletions(-) create mode 100644 crypto/vrf/secp256k1/Cargo.toml create mode 100644 crypto/vrf/secp256k1/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 07006cb..438c47a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,6 +129,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.12.3" @@ -141,6 +147,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bitflags" version = "1.3.2" @@ -195,6 +207,15 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "block-modes" version = "0.7.0" @@ -360,6 +381,12 @@ dependencies = [ "unreachable", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "cpufeatures" version = "0.2.12" @@ -436,6 +463,28 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.7", + "typenum", +] + [[package]] name = "crypto-mac" version = "0.8.0" @@ -493,9 +542,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", "digest 0.9.0", @@ -504,6 +553,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "digest" version = "0.6.1" @@ -531,13 +590,40 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "serdect", + "signature 2.2.0", + "spki", +] + [[package]] name = "ed25519" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", ] [[package]] @@ -546,7 +632,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.2.1", + "curve25519-dalek 3.2.0", "ed25519", "rand 0.7.3", "serde", @@ -566,6 +652,26 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562cc8504a01eb20c10fb154abd7c4baeb9beba2329cf85838ee2bd48a468b18" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array 0.14.7", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "serdect", + "subtle", + "zeroize", +] + [[package]] name = "errno" version = "0.3.8" @@ -700,6 +806,16 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "ffi_c_crypto_binary" version = "1.0.0" @@ -783,6 +899,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -815,6 +932,17 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "half" version = "1.8.2" @@ -866,6 +994,15 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "hmac-drbg" version = "0.3.0" @@ -930,6 +1067,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "serdect", + "sha2 0.10.8", + "signature 2.2.0", +] + [[package]] name = "keccak" version = "0.1.4" @@ -1167,6 +1319,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.28" @@ -1529,6 +1691,16 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + [[package]] name = "ripemd160" version = "0.6.0" @@ -1592,6 +1764,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array 0.14.7", + "pkcs8", + "serdect", + "subtle", + "zeroize", +] + [[package]] name = "secp256k1" version = "0.26.0" @@ -1666,6 +1853,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serdect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" +dependencies = [ + "base16ct", + "serde", +] + [[package]] name = "sha2" version = "0.6.0" @@ -1692,6 +1889,17 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha3" version = "0.6.0" @@ -1723,6 +1931,16 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "sm4" version = "0.3.0" @@ -1734,6 +1952,16 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "sputnikvm" version = "0.10.1" @@ -2464,6 +2692,20 @@ dependencies = [ "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wedpr_l_crypto_vrf_secp256k1" +version = "1.4.0" +dependencies = [ + "k256", + "rand 0.6.5", + "serde", + "sha2 0.10.8", + "wedpr_l_crypto_hash_keccak256 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wedpr_l_crypto_zkp_utils 1.2.0", + "wedpr_l_macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wedpr_l_crypto_zkp_discrete_logarithm_proof" version = "1.3.0" @@ -2726,9 +2968,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.3.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] diff --git a/Cargo.toml b/Cargo.toml index 767d4d4..942011b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ "crypto/signature/ed25519", "crypto/signature/secp256k1", "crypto/signature/sm2", - "crypto/vrf/curve25519", + "crypto/vrf/curve25519", "crypto/vrf/secp256k1", "crypto/zkp/discrete_logarithm_proof", "crypto/zkp/range_proof", "crypto/zkp/utils", diff --git a/Changelog.md b/Changelog.md index 0e1bc8b..1bb5ba0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +## v1.4.0 +(2024-10-28) + +**新增** + +- 新增基于secp256k1曲线的ecvrf + ## v1.3.0 (2022-08-22) diff --git a/crypto/vrf/secp256k1/Cargo.toml b/crypto/vrf/secp256k1/Cargo.toml new file mode 100644 index 0000000..de01fa1 --- /dev/null +++ b/crypto/vrf/secp256k1/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "wedpr_l_crypto_vrf_secp256k1" +version = "1.4.0" +authors = ["WeDPR "] +edition = "2018" +license = "Apache-2.0" +description = "Library of WeDPR shared VRF Function implement by secp256k1." + +[dependencies] +k256 = { version = "0.13.4", features = ["serde", "arithmetic"] } +rand = "0.6" +sha2 = "0.10.8" +wedpr_l_crypto_hash_keccak256 = "1.1.0" +wedpr_l_crypto_zkp_utils = "1.2.0" +wedpr_l_macros = "1.0.0" +wedpr_l_utils = "1.1.0" +serde = { version = "1.0", features = ["derive"] } diff --git a/crypto/vrf/secp256k1/src/lib.rs b/crypto/vrf/secp256k1/src/lib.rs new file mode 100644 index 0000000..d5cedfe --- /dev/null +++ b/crypto/vrf/secp256k1/src/lib.rs @@ -0,0 +1,362 @@ +// Copyright 2024 WeDPR Lab Project Authors. Licensed under Apache-2.0. + +//! secp256k1 VRF functions. + +extern crate k256; + +use k256::{ + elliptic_curve::{ + generic_array::GenericArray, rand_core::OsRng, sec1::FromEncodedPoint, + PrimeField, + }, + AffinePoint, EncodedPoint, Scalar, +}; +use wedpr_l_utils::traits::Vrf; + +use crate::k256::elliptic_curve::{ + group::{prime::PrimeCurveAffine, GroupEncoding}, + Field, +}; +use sha2::{Digest, Sha256}; +use wedpr_l_utils::error::WedprError; + +const SECP256K1_POINT_LENGTH: usize = 33; +const SECP256K1_SCALAR_LENGTH: usize = 32; + +/// Implements secp256k1 as a VRF instance. +#[derive(PartialEq, Debug, Clone, Default)] +pub struct WedprSecp256k1Vrf { + // 33 bytes + pub gamma_param: Vec, + // 32 bytes + pub c_param: Vec, + // 32 bytes + pub s_param: Vec, +} + +fn hash_to_scalar(hash_vec: &Vec) -> Result { + let mut hasher = Sha256::new(); + hasher.update(hash_vec); + let hash_vec = hasher.finalize().to_vec(); + + let array: GenericArray = + GenericArray::clone_from_slice(hash_vec.as_slice()); + + let scalar_option = k256::Scalar::from_repr(array); + + if scalar_option.is_some().into() { + return Ok(scalar_option.unwrap()); + } else { + return Err(WedprError::FormatError); + }; +} + +fn bytes_to_affine(bytes: &[u8]) -> Result { + let encoded_point = EncodedPoint::from_bytes(bytes); + match encoded_point { + Ok(encoded_point) => { + let affine_point = AffinePoint::from_encoded_point(&encoded_point); + if affine_point.is_some().into() { + return Ok(affine_point.unwrap()); + } else { + return Err(WedprError::FormatError); + } + }, + Err(_) => Err(WedprError::FormatError), + } +} + +fn bytes_to_scalar(bytes: &[u8]) -> Result { + let scalar_option = + k256::Scalar::from_repr(GenericArray::clone_from_slice(bytes)); + if scalar_option.is_some().into() { + return Ok(scalar_option.unwrap()); + } else { + return Err(WedprError::FormatError); + } +} + +impl Vrf for WedprSecp256k1Vrf { + fn encode_proof(&self) -> Vec { + let mut proof = Vec::new(); + proof.append(&mut self.gamma_param.to_vec()); + proof.append(&mut self.c_param.to_vec()); + proof.append(&mut self.s_param.to_vec()); + proof + } + + fn decode_proof>( + proof: &T, + ) -> Result { + if proof.as_ref().len() + != (SECP256K1_POINT_LENGTH + + SECP256K1_SCALAR_LENGTH + + SECP256K1_SCALAR_LENGTH) + { + return Err(WedprError::FormatError); + } + let mut gamma = [0u8; SECP256K1_POINT_LENGTH]; + gamma.copy_from_slice(&proof.as_ref()[0..SECP256K1_POINT_LENGTH]); + + let mut c = [0u8; SECP256K1_SCALAR_LENGTH]; + c.copy_from_slice( + &proof.as_ref()[SECP256K1_POINT_LENGTH + ..SECP256K1_POINT_LENGTH + SECP256K1_SCALAR_LENGTH], + ); + + let mut s = [0u8; SECP256K1_SCALAR_LENGTH]; + s.copy_from_slice( + &proof.as_ref()[SECP256K1_POINT_LENGTH + SECP256K1_SCALAR_LENGTH + ..SECP256K1_POINT_LENGTH + + SECP256K1_SCALAR_LENGTH + + SECP256K1_SCALAR_LENGTH], + ); + Ok(WedprSecp256k1Vrf { + gamma_param: gamma.to_vec(), + c_param: c.to_vec(), + s_param: s.to_vec(), + }) + } + + fn prove>( + private_key: &T, + message: &T, + ) -> Result + where + Self: Sized, + { + let private_key_result = + k256::SecretKey::from_slice(private_key.as_ref()); + + let private_key = match private_key_result { + Ok(private_key) => private_key, + Err(_) => return Err(WedprError::FormatError), + }; + + let private_key_scalar: Scalar = + private_key.as_scalar_primitive().into(); + + let public_key = private_key.public_key(); + + let public_key_bytes = public_key.as_affine().to_bytes().to_vec(); + + let message = message.as_ref(); + + let mut hash_vec = Vec::new(); + hash_vec.append(&mut public_key_bytes.clone()); + hash_vec.append(&mut message.to_vec()); + + let h_scalar_result = hash_to_scalar(&hash_vec); + let h_scalar = match h_scalar_result { + Ok(h_scalar_result) => h_scalar_result, + Err(_) => return Err(WedprError::FormatError), + }; + + let base_point = k256::AffinePoint::generator(); + let h_point = base_point * h_scalar; + + let gamma = h_point * private_key_scalar; + + let blinding_k = k256::Scalar::random(&mut OsRng); + + let scalar_k = private_key_scalar * blinding_k; + + let point_k = base_point * scalar_k; + + let point_kh = h_point * scalar_k; + + let mut c_vec = Vec::new(); + c_vec.append(&mut h_point.to_bytes().to_vec()); + c_vec.append(&mut gamma.to_bytes().to_vec()); + c_vec.append(&mut point_k.to_bytes().to_vec()); + c_vec.append(&mut point_kh.to_bytes().to_vec()); + + let c_scalar_result = hash_to_scalar(&c_vec); + let c_scalar = match c_scalar_result { + Ok(c_scalar_result) => c_scalar_result, + Err(_) => return Err(WedprError::FormatError), + }; + + let s = scalar_k + (c_scalar * private_key_scalar); + + // println!("gamma : {:?}", gamma.to_bytes().to_vec()); + // println!("c : {:?}", c_scalar.to_bytes().to_vec()); + // println!("s : {:?}", s.to_bytes().to_vec()); + + return Ok(WedprSecp256k1Vrf { + gamma_param: gamma.to_bytes().to_vec(), + c_param: c_scalar.to_bytes().to_vec(), + s_param: s.to_bytes().to_vec(), + }); + } + + fn prove_fast>( + private_key: &T, + public_key: &T, + message: &T, + ) -> Result + where + Self: Sized, + { + // TODO: We found use input public key directly is slower than derive + // public key from private key + Self::prove(private_key, message) + } + + fn verify>( + &self, + public_key: &T, + message: &T, + ) -> bool { + let public_key_bytes = public_key.as_ref().to_vec(); + + let public_key_point = match bytes_to_affine(&public_key_bytes) { + Ok(public_key_point) => public_key_point, + Err(_) => return false, + }; + + let message = message.as_ref(); + + let mut hash_vec = Vec::new(); + hash_vec.append(&mut public_key_bytes.clone()); + hash_vec.append(&mut message.to_vec()); + + let base_point = k256::AffinePoint::generator(); + + let h_scalar = hash_to_scalar(&hash_vec).unwrap(); + let h_point = base_point * h_scalar; + + let gamma = match bytes_to_affine(&self.gamma_param) { + Ok(gamma) => gamma, + Err(_) => return false, + }; + + let c = match bytes_to_scalar(&self.c_param) { + Ok(c) => c, + Err(_) => return false, + }; + + let s = match bytes_to_scalar(&self.s_param) { + Ok(s) => s, + Err(_) => return false, + }; + + let u = (base_point * s) - (public_key_point * c); + let v = (h_point * s) - (gamma * c); + + let mut c_vec = Vec::new(); + c_vec.append(&mut h_point.to_bytes().to_vec()); + c_vec.append(&mut self.gamma_param.clone()); + c_vec.append(&mut u.to_bytes().to_vec()); + c_vec.append(&mut v.to_bytes().to_vec()); + + let c_scalar_result = hash_to_scalar(&c_vec); + let c_scalar = match c_scalar_result { + Ok(c_scalar_result) => c_scalar_result, + Err(_) => return false, + }; + + return c_scalar.to_bytes().to_vec().eq(self.c_param.as_slice()); + } + + fn derive_public_key>(private_key: &T) -> Vec { + let private_key_result = + k256::SecretKey::from_slice(private_key.as_ref()); + + let private_key = match private_key_result { + Ok(private_key) => private_key, + Err(_) => return Vec::new(), + }; + + let public_key = private_key.public_key(); + + public_key.as_affine().to_bytes().to_vec() + } + + fn is_valid_public_key>(public_key: &T) -> bool { + let public_key_bytes = public_key.as_ref().to_vec(); + match bytes_to_affine(&public_key_bytes) { + Ok(_) => return true, + Err(_) => return false, + }; + } + + fn proof_to_hash(&self) -> Result, WedprError> { + let gamma = match bytes_to_affine(&self.gamma_param) { + Ok(gamma) => gamma, + Err(_) => return Err(WedprError::FormatError), + }; + + let base_order = Scalar::from_u128(8); + let base = gamma * base_order; + + let mut hasher = Sha256::new(); + hasher.update(base.to_bytes().as_slice()); + let hash_vec = hasher.finalize().to_vec(); + + Ok(hash_vec) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_secp256k1_vrf() { + let private_key = k256::SecretKey::random(&mut OsRng); + let public_key = private_key.public_key(); + let message = "hello world".as_bytes().to_vec(); + + let proof = WedprSecp256k1Vrf::prove( + &private_key.to_bytes().to_vec(), + &message, + ) + .unwrap(); + + assert_eq!( + proof.verify(&public_key.as_affine().to_bytes().to_vec(), &message), + true + ); + // println!("proof hash : {:?}", proof.proof_to_hash().unwrap()); + } + + #[test] + fn test_encode_proof() { + let private_key = k256::SecretKey::random(&mut OsRng); + // let public_key = private_key.public_key(); + let message = "hello world".as_bytes().to_vec(); + + let proof = WedprSecp256k1Vrf::prove( + &private_key.to_bytes().to_vec(), + &message, + ) + .unwrap(); + let encoded_proof = proof.encode_proof(); + // println!("encoded_proof : {:?}, length: {}", encoded_proof, + // encoded_proof.len()); + let decoded_proof = + WedprSecp256k1Vrf::decode_proof(&encoded_proof).unwrap(); + assert_eq!(decoded_proof, proof); + + assert_eq!( + proof.verify( + &private_key.public_key().as_affine().to_bytes().to_vec(), + &message + ), + true + ); + } + + #[test] + fn test_utils() { + let private_key = k256::SecretKey::random(&mut OsRng); + let public_key = private_key.public_key(); + let expected_pk = WedprSecp256k1Vrf::derive_public_key( + &private_key.to_bytes().to_vec(), + ); + assert_eq!(public_key.as_affine().to_bytes().to_vec(), expected_pk); + + assert_eq!(WedprSecp256k1Vrf::is_valid_public_key(&expected_pk), true); + } +} diff --git a/release_note.txt b/release_note.txt index 8b3a022..ec7b967 100644 --- a/release_note.txt +++ b/release_note.txt @@ -1 +1 @@ -v1.3.0 \ No newline at end of file +v1.4.0 \ No newline at end of file From f924db914726fd97b4c285f0d62667ac8c0fc076 Mon Sep 17 00:00:00 2001 From: asherli <444649358@qq.com> Date: Wed, 30 Oct 2024 14:15:44 +0800 Subject: [PATCH 2/9] remove rand private key --- crypto/vrf/secp256k1/src/lib.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crypto/vrf/secp256k1/src/lib.rs b/crypto/vrf/secp256k1/src/lib.rs index d5cedfe..cffa8bd 100644 --- a/crypto/vrf/secp256k1/src/lib.rs +++ b/crypto/vrf/secp256k1/src/lib.rs @@ -6,7 +6,7 @@ extern crate k256; use k256::{ elliptic_curve::{ - generic_array::GenericArray, rand_core::OsRng, sec1::FromEncodedPoint, + generic_array::GenericArray, sec1::FromEncodedPoint, PrimeField, }, AffinePoint, EncodedPoint, Scalar, @@ -119,14 +119,14 @@ impl Vrf for WedprSecp256k1Vrf { } fn prove>( - private_key: &T, + private_key_vec: &T, message: &T, ) -> Result where Self: Sized, { let private_key_result = - k256::SecretKey::from_slice(private_key.as_ref()); + k256::SecretKey::from_slice(private_key_vec.as_ref()); let private_key = match private_key_result { Ok(private_key) => private_key, @@ -157,9 +157,11 @@ impl Vrf for WedprSecp256k1Vrf { let gamma = h_point * private_key_scalar; - let blinding_k = k256::Scalar::random(&mut OsRng); - - let scalar_k = private_key_scalar * blinding_k; + // let blinding_k = k256::Scalar::random(&mut OsRng); + let scalar_k = match hash_to_scalar(&private_key_vec.as_ref().to_vec()) { + Ok(scalar_k) => scalar_k, + Err(_) => return Err(WedprError::FormatError), + }; let point_k = base_point * scalar_k; @@ -300,6 +302,8 @@ impl Vrf for WedprSecp256k1Vrf { #[cfg(test)] mod tests { + use k256::elliptic_curve::rand_core::OsRng; + use super::*; #[test] @@ -318,7 +322,7 @@ mod tests { proof.verify(&public_key.as_affine().to_bytes().to_vec(), &message), true ); - // println!("proof hash : {:?}", proof.proof_to_hash().unwrap()); + println!("proof hash : {:?}", proof.proof_to_hash().unwrap()); } #[test] From 27c38ecbfa132151e4ca22b58f5f70897551daad Mon Sep 17 00:00:00 2001 From: asherli <444649358@qq.com> Date: Mon, 4 Nov 2024 18:00:47 +0800 Subject: [PATCH 3/9] add k1 vrf ffi --- Cargo.lock | 1 + ffi/ffi_c/ffi_c_crypto/Cargo.toml | 4 +- ffi/ffi_c/ffi_c_crypto/src/lib.rs | 1 + ffi/ffi_c/ffi_c_crypto/src/vrf_secp256k1.rs | 168 ++++++++++++++++++++ 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 ffi/ffi_c/ffi_c_crypto/src/vrf_secp256k1.rs diff --git a/Cargo.lock b/Cargo.lock index 438c47a..1fa54a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2274,6 +2274,7 @@ dependencies = [ "wedpr_l_crypto_signature_secp256k1", "wedpr_l_crypto_signature_sm2", "wedpr_l_crypto_vrf_curve25519", + "wedpr_l_crypto_vrf_secp256k1", "wedpr_l_macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_protos 1.2.0", "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ffi/ffi_c/ffi_c_crypto/Cargo.toml b/ffi/ffi_c/ffi_c_crypto/Cargo.toml index 00413e0..267fef4 100644 --- a/ffi/ffi_c/ffi_c_crypto/Cargo.toml +++ b/ffi/ffi_c/ffi_c_crypto/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = [ "wedpr_f_base64", "wedpr_f_ecies_secp256k1", "wedpr_f_signature_secp256k1", "wedpr_f_hash_keccak256", "wedpr_f_signature_sm2", "wedpr_f_hash_sm3", "wedpr_f_vrf_curve25519", "wedpr_f_crypto_block_cipher_aes", "wedpr_f_crypto_block_cipher_sm4", "wedpr_f_hash_ripemd160", "wedpr_f_hash_sha3", "wedpr_f_hash_blake2b", "wedpr_f_signature_ed25519" ] +default = [ "wedpr_f_base64", "wedpr_f_ecies_secp256k1", "wedpr_f_signature_secp256k1", "wedpr_f_hash_keccak256", "wedpr_f_signature_sm2", "wedpr_f_hash_sm3", "wedpr_f_vrf_curve25519", "wedpr_f_vrf_secp256k1", "wedpr_f_crypto_block_cipher_aes", "wedpr_f_crypto_block_cipher_sm4", "wedpr_f_hash_ripemd160", "wedpr_f_hash_sha3", "wedpr_f_hash_blake2b", "wedpr_f_signature_ed25519" ] wedpr_f_base64 = [ "wedpr_ffi_common_base64" ] wedpr_f_hex = [ "wedpr_ffi_common_hex" ] wedpr_f_ecies_secp256k1 = [ "wedpr_l_crypto_ecies_secp256k1" ] @@ -19,6 +19,7 @@ wedpr_f_hash_ripemd160 = [ "wedpr_l_crypto_hash_ripemd160" ] wedpr_f_hash_sha3 = [ "wedpr_l_crypto_hash_sha3" ] wedpr_f_hash_blake2b = [ "wedpr_l_crypto_hash_blake2b" ] wedpr_f_vrf_curve25519 = [ "wedpr_l_crypto_vrf_curve25519" ] +wedpr_f_vrf_secp256k1 = [ "wedpr_l_crypto_vrf_secp256k1" ] wedpr_f_crypto_block_cipher_aes = [ "wedpr_l_crypto_block_cipher_aes" ] wedpr_f_crypto_block_cipher_sm4 = [ "wedpr_l_crypto_block_cipher_sm4" ] @@ -46,6 +47,7 @@ wedpr_l_crypto_signature_ed25519 = { path = "../../../crypto/signature/ed25519", wedpr_l_crypto_signature_secp256k1 = { path = "../../../crypto/signature/secp256k1", optional = true } wedpr_l_crypto_signature_sm2 = { path = "../../../crypto/signature/sm2", optional = true } wedpr_l_crypto_vrf_curve25519 = { path = "../../../crypto/vrf/curve25519", optional = true } +wedpr_l_crypto_vrf_secp256k1 = { path = "../../../crypto/vrf/secp256k1", optional = true } wedpr_l_macros = "1.0.0" wedpr_l_protos = { path = "../../../protos" } wedpr_l_utils = "1.1.0" diff --git a/ffi/ffi_c/ffi_c_crypto/src/lib.rs b/ffi/ffi_c/ffi_c_crypto/src/lib.rs index 559b103..78651b9 100644 --- a/ffi/ffi_c/ffi_c_crypto/src/lib.rs +++ b/ffi/ffi_c/ffi_c_crypto/src/lib.rs @@ -31,5 +31,6 @@ pub mod ecies; pub mod hash; pub mod signature; pub mod vrf; +pub mod vrf_secp256k1; // C/C++ FFI: C-style interfaces will be generated. diff --git a/ffi/ffi_c/ffi_c_crypto/src/vrf_secp256k1.rs b/ffi/ffi_c/ffi_c_crypto/src/vrf_secp256k1.rs new file mode 100644 index 0000000..ab871b3 --- /dev/null +++ b/ffi/ffi_c/ffi_c_crypto/src/vrf_secp256k1.rs @@ -0,0 +1,168 @@ +// Copyright 2020 WeDPR Lab Project Authors. Licensed under Apache-2.0. + +//! VRF function wrappers. + +#![cfg(not(tarpaulin_include))] +#![cfg(feature = "wedpr_f_vrf_secp256k1")] + +use libc::c_char; +use std::{ffi::CString, panic, ptr}; + +#[cfg(feature = "wedpr_f_base64")] +use wedpr_ffi_common_base64::utils::{ + bytes_to_string, c_char_pointer_to_string, string_to_bytes, FAILURE, + SUCCESS, +}; + +#[cfg(feature = "wedpr_f_hex")] +use wedpr_ffi_common_hex::utils::{ + bytes_to_string, c_char_pointer_to_string, string_to_bytes, FAILURE, + SUCCESS, +}; + +#[cfg(feature = "wedpr_f_vrf_secp256k1")] +use wedpr_l_crypto_vrf_secp256k1::WedprSecp256k1Vrf; +use wedpr_l_utils::{tool::string_to_bytes_utf8, traits::Vrf}; + +// secp256k1 implementation. + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_derive_public_key'. +pub extern "C" fn wedpr_secp256k1_vrf_derive_public_key( + encoded_private_key: *const c_char, +) -> *mut c_char { + let result = panic::catch_unwind(|| { + let private_key = c_safe_c_char_pointer_to_bytes!(encoded_private_key); + + let encrypt_data = WedprSecp256k1Vrf::derive_public_key(&private_key); + c_safe_bytes_to_c_char_pointer!(&encrypt_data) + }); + c_safe_return!(result) +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_prove_utf8'. +pub extern "C" fn wedpr_secp256k1_vrf_prove_utf8( + encoded_private_key: *const c_char, + utf8_message: *const c_char, +) -> *mut c_char { + let result = panic::catch_unwind(|| { + let private_key = c_safe_c_char_pointer_to_bytes!(encoded_private_key); + let message = c_safe_c_char_pointer_to_bytes_utf8!(utf8_message); + + let proof = match WedprSecp256k1Vrf::prove(&private_key, &message) { + Ok(v) => v, + Err(_) => { + return ptr::null_mut(); + }, + }; + c_safe_bytes_to_c_char_pointer!(&proof.encode_proof()) + }); + c_safe_return!(result) +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_prove_fast_utf8'. +pub extern "C" fn wedpr_secp256k1_vrf_prove_fast_utf8( + encoded_private_key: *const c_char, + encoded_public_key: *const c_char, + utf8_message: *const c_char, +) -> *mut c_char { + let result = panic::catch_unwind(|| { + let private_key = c_safe_c_char_pointer_to_bytes!(encoded_private_key); + let public_key = c_safe_c_char_pointer_to_bytes!(encoded_public_key); + let message = c_safe_c_char_pointer_to_bytes_utf8!(utf8_message); + + let proof = match WedprSecp256k1Vrf::prove_fast( + &private_key, + &public_key, + &message, + ) { + Ok(v) => v, + Err(_) => { + return ptr::null_mut(); + }, + }; + c_safe_bytes_to_c_char_pointer!(&proof.encode_proof()) + }); + c_safe_return!(result) +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_verify_utf8'. +pub extern "C" fn wedpr_secp256k1_vrf_verify_utf8( + encoded_public_key: *const c_char, + utf8_message: *const c_char, + encoded_proof: *const c_char, +) -> i8 { + let result = panic::catch_unwind(|| { + let public_key = c_safe_c_char_pointer_to_bytes_with_error_value!( + encoded_public_key, + FAILURE + ); + let message = c_safe_c_char_pointer_to_bytes_utf8_with_error_value!( + utf8_message, + FAILURE + ); + let proof_bytes = c_safe_c_char_pointer_to_bytes_with_error_value!( + encoded_proof, + FAILURE + ); + + let proof = match WedprSecp256k1Vrf::decode_proof(&proof_bytes) { + Ok(v) => v, + Err(_) => { + return FAILURE; + }, + }; + match proof.verify(&public_key, &message) { + true => SUCCESS, + false => FAILURE, + } + }); + c_safe_return_with_error_value!(result, FAILURE) +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_proof_to_hash'. +pub extern "C" fn wedpr_secp256k1_vrf_proof_to_hash( + encoded_proof: *const c_char, +) -> *mut c_char { + let result = panic::catch_unwind(|| { + let proof_bytes = c_safe_c_char_pointer_to_bytes!(encoded_proof); + let proof = match WedprSecp256k1Vrf::decode_proof(&proof_bytes) { + Ok(v) => v, + Err(_) => { + return ptr::null_mut(); + }, + }; + + let hash_bytes = match proof.proof_to_hash() { + Ok(v) => v, + Err(_) => { + return ptr::null_mut(); + }, + }; + c_safe_bytes_to_c_char_pointer!(&hash_bytes) + }); + c_safe_return!(result) +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_is_valid_public_key'. +pub extern "C" fn wedpr_secp256k1_vrf_is_valid_public_key( + encoded_public_key: *const c_char, +) -> i8 { + let result = panic::catch_unwind(|| { + let public_key = c_safe_c_char_pointer_to_bytes_with_error_value!( + encoded_public_key, + FAILURE + ); + + match WedprSecp256k1Vrf::is_valid_public_key(&public_key) { + true => SUCCESS, + false => FAILURE, + } + }); + c_safe_return_with_error_value!(result, FAILURE) +} From a250924b29a4e1a268623b4394aaa130433b9e61 Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Mon, 18 Nov 2024 15:02:36 +0800 Subject: [PATCH 4/9] add secp256k1 vrf c interface --- Cargo.lock | 446 ++++++++++++++++-------------- third_party/include/WedprCrypto.h | 25 ++ 2 files changed, 267 insertions(+), 204 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fa54a5..7854ff7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aes" @@ -35,7 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" dependencies = [ "cipher", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] @@ -45,14 +45,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" dependencies = [ "cipher", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -105,28 +105,28 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" dependencies = [ - "autocfg 1.1.0", + "autocfg 1.4.0", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -161,9 +161,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "blake2" @@ -173,7 +173,7 @@ checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" dependencies = [ "crypto-mac 0.8.0", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-tools" @@ -307,11 +307,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" dependencies = [ - "libc", + "shlex", ] [[package]] @@ -389,9 +389,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -408,7 +408,7 @@ dependencies = [ "criterion-plot", "csv", "itertools", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "num-traits", "oorandom", "plotters", @@ -453,9 +453,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -507,9 +507,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -642,9 +642,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elastic-array-plus" @@ -674,12 +674,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -758,7 +758,7 @@ dependencies = [ "byteorder", "elastic-array-plus", "etcommon-hexutil", - "lazy_static 1.4.0", + "lazy_static 1.5.0", ] [[package]] @@ -802,9 +802,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fastrand" -version = "2.0.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "ff" @@ -821,7 +821,7 @@ name = "ffi_c_crypto_binary" version = "1.0.0" dependencies = [ "cbindgen", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "libc", "protobuf", "wedpr_ffi_c_common 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -917,9 +917,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -928,9 +928,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "group" @@ -945,9 +945,9 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" [[package]] name = "hermit-abi" @@ -1020,7 +1020,7 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1034,9 +1034,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jni" @@ -1060,9 +1060,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -1084,9 +1084,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -1099,15 +1099,15 @@ checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libsecp256k1" @@ -1159,21 +1159,21 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "merlin" @@ -1189,11 +1189,11 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -1208,35 +1208,34 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.1.0", + "autocfg 1.4.0", "num-integer", "num-traits", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg 1.1.0", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "autocfg 1.1.0", + "autocfg 1.4.0", ] [[package]] name = "object" -version = "0.32.2" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] @@ -1249,15 +1248,15 @@ checksum = "4eae0151b9dacf24fcc170d9995e511669a082856a91f958a2fe380bfab3fb22" [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "opaque-debug" @@ -1267,17 +1266,17 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -1294,23 +1293,23 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] name = "openssl-src" -version = "300.2.1+3.2.0" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -1331,15 +1330,15 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -1350,30 +1349,33 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -1417,9 +1419,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1550,7 +1552,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.15", ] [[package]] @@ -1626,9 +1628,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -1636,9 +1638,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -1653,20 +1655,11 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "regex" -version = "1.10.2" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -1676,9 +1669,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1687,9 +1680,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rfc6979" @@ -1721,14 +1714,14 @@ checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" dependencies = [ "block-buffer 0.9.0", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-serialize" @@ -1738,22 +1731,22 @@ checksum = "fe834bc780604f4674073badbad26d7219cadfb4a2275802db12cbae17498401" [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1814,9 +1807,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -1833,22 +1826,23 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1886,7 +1880,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] @@ -1925,6 +1919,12 @@ dependencies = [ "opaque-debug 0.2.3", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "1.6.4" @@ -1949,7 +1949,7 @@ checksum = "9e7069c464471f2ee94ce925f479887d2e4546d18e9b7a7ba888f8694bae3f8d" dependencies = [ "byteorder", "cipher", - "opaque-debug 0.3.0", + "opaque-debug 0.3.1", ] [[package]] @@ -2015,9 +2015,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -2038,15 +2038,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "once_cell", "rustix", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -2085,21 +2085,21 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unreachable" @@ -2124,9 +2124,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "void" @@ -2136,9 +2136,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -2158,34 +2158,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2193,28 +2194,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -2256,7 +2257,7 @@ name = "wedpr_ffi_c_crypto" version = "1.0.0" dependencies = [ "cbindgen", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "libc", "protobuf", "wedpr_ffi_c_common 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2312,7 +2313,7 @@ name = "wedpr_ffi_common" version = "1.1.0" dependencies = [ "jni", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "libc", "wedpr_ffi_macros 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_common_coder_base64 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2328,7 +2329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b6141b0a1032aeade65bec5da74cd7fd169972695a8245beffb2c93a8bc55d" dependencies = [ "jni", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "libc", "wedpr_ffi_macros 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_common_coder_base64 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2342,7 +2343,7 @@ name = "wedpr_ffi_java_crypto" version = "1.0.0" dependencies = [ "jni", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "openssl-sys", "wedpr_ffi_common 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_ffi_macros 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2367,7 +2368,7 @@ name = "wedpr_ffi_java_crypto_binary" version = "1.0.0" dependencies = [ "jni", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "openssl-sys", "wedpr_ffi_common 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_ffi_macros 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2638,7 +2639,7 @@ version = "0.2.0" dependencies = [ "criterion", "curve25519-dalek 1.2.6", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "rand 0.6.5", "rand_core 0.5.1", "sha3 0.8.2", @@ -2653,7 +2654,7 @@ version = "1.1.0" dependencies = [ "ed25519", "ed25519-dalek", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "rand 0.7.3", "wedpr_l_macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2664,7 +2665,7 @@ name = "wedpr_l_crypto_signature_secp256k1" version = "1.1.0" dependencies = [ "criterion", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "secp256k1", "wedpr_l_macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2674,7 +2675,7 @@ dependencies = [ name = "wedpr_l_crypto_signature_sm2" version = "1.1.1" dependencies = [ - "lazy_static 1.4.0", + "lazy_static 1.5.0", "wedpr_l_libsm", "wedpr_l_macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2740,7 +2741,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a65819bf4f253e5659d7999607444f157e27e980d9d2d2081f52b1d32c3cba1" dependencies = [ "curve25519-dalek 1.2.6", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "rand 0.6.5", "rand_core 0.5.1", "sha3 0.8.2", @@ -2754,7 +2755,7 @@ name = "wedpr_l_crypto_zkp_utils" version = "1.3.0" dependencies = [ "curve25519-dalek 1.2.6", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "rand 0.6.5", "rand_core 0.5.1", "serde", @@ -2771,7 +2772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "860e8c9ede976ffb26f9470cdaf0ac7135b0eb8ab70baea0d2bb88cb0a44e4f6" dependencies = [ "byteorder", - "lazy_static 1.4.0", + "lazy_static 1.5.0", "num-bigint", "num-integer", "num-traits", @@ -2879,11 +2880,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -2901,15 +2902,25 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -2918,45 +2929,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "yasna" @@ -2967,6 +2984,27 @@ dependencies = [ "num-bigint", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -2984,5 +3022,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] diff --git a/third_party/include/WedprCrypto.h b/third_party/include/WedprCrypto.h index a7a7d3e..d31f27c 100644 --- a/third_party/include/WedprCrypto.h +++ b/third_party/include/WedprCrypto.h @@ -117,6 +117,31 @@ int8_t wedpr_curve25519_vrf_proof_to_hash( /// C interface for 'wedpr_curve25519_vrf_is_valid_public_key'. int8_t wedpr_curve25519_vrf_is_valid_public_key(const CInputBuffer* raw_public_key); +/// C interface for 'wedpr_secp256k1_vrf_derive_public_key'. +int8_t wedpr_secp256k1_vrf_derive_public_key( + const CInputBuffer* raw_private_key, COutputBuffer* output_public_key); + +/// C interface for 'wedpr_secp256k1_vrf_prove_utf8'. +int8_t wedpr_secp256k1_vrf_prove_utf8(const CInputBuffer* raw_private_key, + const CInputBuffer* raw_utf8_message, COutputBuffer* output_proof); + +/// C interface for 'wedpr_secp256k1_vrf_prove_fast_utf8'. +int8_t wedpr_secp256k1_vrf_prove_fast_utf8(const CInputBuffer* raw_private_key, + const CInputBuffer* raw_public_key, const CInputBuffer* raw_utf8_message, + COutputBuffer* output_proof); + +/// C interface for 'wedpr_secp256k1_vrf_verify_utf8'. +int8_t wedpr_secp256k1_vrf_verify_utf8(const CInputBuffer* raw_public_key, + const CInputBuffer* raw_utf8_message, const CInputBuffer* raw_proof); + +/// C interface for 'wedpr_secp256k1_vrf_proof_to_hash'. +int8_t wedpr_secp256k1_vrf_proof_to_hash( + const CInputBuffer* raw_proof, COutputBuffer* output_hash); + +/// C interface for 'wedpr_secp256k1_vrf_is_valid_public_key'. +int8_t wedpr_secp256k1_vrf_is_valid_public_key(const CInputBuffer* raw_public_key); + + } // extern "C" #endif From 029329aad500cfd31c0025feda279c54d499949c Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Mon, 18 Nov 2024 16:32:27 +0800 Subject: [PATCH 5/9] add vrf feature to binary --- Cargo.lock | 1 + ffi/ffi_c/ffi_c_crypto_binary/Cargo.toml | 4 +- ffi/ffi_c/ffi_c_crypto_binary/src/lib.rs | 1 + .../ffi_c_crypto_binary/src/vrf_secp256k1.rs | 150 ++++++++++++++++++ 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 ffi/ffi_c/ffi_c_crypto_binary/src/vrf_secp256k1.rs diff --git a/Cargo.lock b/Cargo.lock index 7854ff7..45c280a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -840,6 +840,7 @@ dependencies = [ "wedpr_l_crypto_signature_secp256k1", "wedpr_l_crypto_signature_sm2", "wedpr_l_crypto_vrf_curve25519", + "wedpr_l_crypto_vrf_secp256k1", "wedpr_l_macros 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wedpr_l_protos 1.2.0", "wedpr_l_utils 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ffi/ffi_c/ffi_c_crypto_binary/Cargo.toml b/ffi/ffi_c/ffi_c_crypto_binary/Cargo.toml index b2d68b1..ceb058b 100644 --- a/ffi/ffi_c/ffi_c_crypto_binary/Cargo.toml +++ b/ffi/ffi_c/ffi_c_crypto_binary/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = [ "wedpr_f_ecies_secp256k1", "wedpr_f_signature_secp256k1", "wedpr_f_hash_keccak256", "wedpr_f_signature_sm2", "wedpr_f_hash_sm3", "wedpr_f_vrf_curve25519", "wedpr_f_crypto_block_cipher_aes", "wedpr_f_crypto_block_cipher_sm4", "wedpr_f_hash_ripemd160", "wedpr_f_hash_sha2", "wedpr_f_hash_sha3", "wedpr_f_hash_blake2b", "wedpr_f_signature_ed25519" ] +default = [ "wedpr_f_ecies_secp256k1", "wedpr_f_signature_secp256k1", "wedpr_f_hash_keccak256", "wedpr_f_signature_sm2", "wedpr_f_hash_sm3", "wedpr_f_vrf_curve25519", "wedpr_f_vrf_secp256k1", "wedpr_f_crypto_block_cipher_aes", "wedpr_f_crypto_block_cipher_sm4", "wedpr_f_hash_ripemd160", "wedpr_f_hash_sha2", "wedpr_f_hash_sha3", "wedpr_f_hash_blake2b", "wedpr_f_signature_ed25519" ] wedpr_f_ecies_secp256k1 = [ "wedpr_l_crypto_ecies_secp256k1" ] wedpr_f_signature_secp256k1 = [ "wedpr_l_crypto_signature_secp256k1" ] wedpr_f_hash_keccak256 = [ "wedpr_l_crypto_hash_keccak256" ] @@ -18,6 +18,7 @@ wedpr_f_hash_sha2 = [ "wedpr_l_crypto_hash_sha2" ] wedpr_f_hash_sha3 = [ "wedpr_l_crypto_hash_sha3" ] wedpr_f_hash_blake2b = [ "wedpr_l_crypto_hash_blake2b" ] wedpr_f_vrf_curve25519 = [ "wedpr_l_crypto_vrf_curve25519" ] +wedpr_f_vrf_secp256k1 = [ "wedpr_l_crypto_vrf_secp256k1" ] wedpr_f_crypto_block_cipher_aes = [ "wedpr_l_crypto_block_cipher_aes" ] wedpr_f_crypto_block_cipher_sm4 = [ "wedpr_l_crypto_block_cipher_sm4" ] @@ -45,6 +46,7 @@ wedpr_l_crypto_signature_ed25519 = { path = "../../../crypto/signature/ed25519", wedpr_l_crypto_signature_secp256k1 = { path = "../../../crypto/signature/secp256k1", optional = true } wedpr_l_crypto_signature_sm2 = { path = "../../../crypto/signature/sm2", optional = true } wedpr_l_crypto_vrf_curve25519 = { path = "../../../crypto/vrf/curve25519", optional = true } +wedpr_l_crypto_vrf_secp256k1 = { path = "../../../crypto/vrf/secp256k1", optional = true } wedpr_l_macros = "1.0.0" wedpr_l_protos = { path = "../../../protos" } wedpr_l_utils = "1.1.0" diff --git a/ffi/ffi_c/ffi_c_crypto_binary/src/lib.rs b/ffi/ffi_c/ffi_c_crypto_binary/src/lib.rs index c20ff4f..162d31b 100644 --- a/ffi/ffi_c/ffi_c_crypto_binary/src/lib.rs +++ b/ffi/ffi_c/ffi_c_crypto_binary/src/lib.rs @@ -20,5 +20,6 @@ pub mod ecies; pub mod hash; pub mod signature; pub mod vrf; +pub mod vrf_secp256k1; // C/C++ FFI: C-style interfaces will be generated. diff --git a/ffi/ffi_c/ffi_c_crypto_binary/src/vrf_secp256k1.rs b/ffi/ffi_c/ffi_c_crypto_binary/src/vrf_secp256k1.rs new file mode 100644 index 0000000..57409fe --- /dev/null +++ b/ffi/ffi_c/ffi_c_crypto_binary/src/vrf_secp256k1.rs @@ -0,0 +1,150 @@ +// Copyright 2020 WeDPR Lab Project Authors. Licensed under Apache-2.0. + +//! VRF function wrappers. + +#![cfg(not(tarpaulin_include))] +#![cfg(feature = "wedpr_f_vrf_secp256k1")] + +use wedpr_ffi_common::utils::{ + c_read_raw_pointer, c_write_raw_pointer, CInputBuffer, COutputBuffer, + FAILURE, SUCCESS, +}; + +#[cfg(feature = "wedpr_f_vrf_secp256k1")] +use wedpr_l_crypto_vrf_secp256k1::WedprSecp256k1Vrf; +use wedpr_l_utils::traits::Vrf; + +// secp256k1 implementation. + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_derive_public_key'. +pub unsafe extern "C" fn wedpr_secp256k1_vrf_derive_public_key( + raw_private_key: &CInputBuffer, + output_public_key: &mut COutputBuffer, +) -> i8 { + let private_key = c_read_raw_pointer(raw_private_key); + + let public_key = WedprSecp256k1Vrf::derive_public_key(&private_key); + std::mem::forget(private_key); + c_write_raw_pointer(&public_key, output_public_key); + SUCCESS +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_prove_utf8'. +pub unsafe extern "C" fn wedpr_secp256k1_vrf_prove_utf8( + raw_private_key: &CInputBuffer, + raw_utf8_message: &CInputBuffer, + output_proof: &mut COutputBuffer, +) -> i8 { + let private_key = c_read_raw_pointer(raw_private_key); + let message = c_read_raw_pointer(raw_utf8_message); + + let result = WedprSecp256k1Vrf::prove(&private_key, &message); + std::mem::forget(private_key); + std::mem::forget(message); + let proof = match result { + Ok(v) => v, + Err(_) => return FAILURE, + }; + c_write_raw_pointer(&proof.encode_proof(), output_proof); + SUCCESS +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_prove_fast_utf8'. +pub unsafe extern "C" fn wedpr_secp256k1_vrf_prove_fast_utf8( + raw_private_key: &CInputBuffer, + raw_public_key: &CInputBuffer, + raw_utf8_message: &CInputBuffer, + output_proof: &mut COutputBuffer, +) -> i8 { + let private_key = c_read_raw_pointer(raw_private_key); + let public_key = c_read_raw_pointer(raw_public_key); + let message = c_read_raw_pointer(raw_utf8_message); + + let result = + WedprSecp256k1Vrf::prove_fast(&private_key, &public_key, &message); + std::mem::forget(private_key); + std::mem::forget(public_key); + std::mem::forget(message); + let proof = match result { + Ok(v) => v, + Err(_) => return FAILURE, + }; + c_write_raw_pointer(&proof.encode_proof(), output_proof); + SUCCESS +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_verify_utf8'. +pub unsafe extern "C" fn wedpr_secp256k1_vrf_verify_utf8( + raw_public_key: &CInputBuffer, + raw_utf8_message: &CInputBuffer, + raw_proof: &CInputBuffer, +) -> i8 { + let proof_bytes = c_read_raw_pointer(raw_proof); + let public_key = c_read_raw_pointer(raw_public_key); + let message = c_read_raw_pointer(raw_utf8_message); + + let proof = match WedprSecp256k1Vrf::decode_proof(&proof_bytes) { + Ok(v) => v, + Err(_) => { + std::mem::forget(proof_bytes); + std::mem::forget(public_key); + std::mem::forget(message); + return FAILURE; + }, + }; + + let result = proof.verify(&public_key, &message); + std::mem::forget(proof_bytes); + std::mem::forget(public_key); + std::mem::forget(message); + match result { + true => SUCCESS, + false => FAILURE, + } +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_proof_to_hash'. +pub unsafe extern "C" fn wedpr_secp256k1_vrf_proof_to_hash( + raw_proof: &CInputBuffer, + output_hash: &mut COutputBuffer, +) -> i8 { + let proof_bytes = c_read_raw_pointer(raw_proof); + let proof = match WedprSecp256k1Vrf::decode_proof(&proof_bytes) { + Ok(v) => v, + Err(_) => { + std::mem::forget(proof_bytes); + return FAILURE; + }, + }; + + let result = proof.proof_to_hash(); + std::mem::forget(proof_bytes); + let hash = match result { + Ok(v) => v, + Err(_) => { + return FAILURE; + }, + }; + c_write_raw_pointer(&hash, output_hash); + SUCCESS +} + +#[no_mangle] +/// C interface for 'wedpr_secp256k1_vrf_is_valid_public_key'. +pub unsafe extern "C" fn wedpr_secp256k1_vrf_is_valid_public_key( + raw_public_key: &CInputBuffer, +) -> i8 { + let public_key = c_read_raw_pointer(raw_public_key); + + let result = WedprSecp256k1Vrf::is_valid_public_key(&public_key); + std::mem::forget(public_key); + match result { + true => SUCCESS, + false => FAILURE, + } +} From 70136d0824f96bf40b15e04369f74c1d098d7863 Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Mon, 18 Nov 2024 19:00:07 +0800 Subject: [PATCH 6/9] adapt bcos wasm and tikv --- Cargo.lock | 25 ++++++++++++------------- crypto/vrf/secp256k1/Cargo.toml | 2 +- rust-toolchain | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 45c280a..935f004 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "shlex", ] @@ -1106,9 +1106,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libsecp256k1" @@ -1299,9 +1299,9 @@ dependencies = [ [[package]] name = "openssl-src" -version = "300.4.0+3.4.0" +version = "300.4.1+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" +checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" dependencies = [ "cc", ] @@ -1808,9 +1808,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] @@ -1827,9 +1827,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", @@ -1838,12 +1838,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" dependencies = [ "itoa", - "memchr", "ryu", "serde", ] diff --git a/crypto/vrf/secp256k1/Cargo.toml b/crypto/vrf/secp256k1/Cargo.toml index de01fa1..adfe83e 100644 --- a/crypto/vrf/secp256k1/Cargo.toml +++ b/crypto/vrf/secp256k1/Cargo.toml @@ -14,4 +14,4 @@ wedpr_l_crypto_hash_keccak256 = "1.1.0" wedpr_l_crypto_zkp_utils = "1.2.0" wedpr_l_macros = "1.0.0" wedpr_l_utils = "1.1.0" -serde = { version = "1.0", features = ["derive"] } +serde = { version = "=1.0.171", features = ["derive"] } diff --git a/rust-toolchain b/rust-toolchain index cbfe4d8..c60dcf7 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2024-01-10 \ No newline at end of file +nightly-2024-02-25 \ No newline at end of file From 5daad654663b2cc7ff94d83a65d6e18fa0e828c9 Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Tue, 19 Nov 2024 17:49:25 +0800 Subject: [PATCH 7/9] fix action upload --- .github/workflows/release.yml | 54 ++++++++++++++++++---------------- .github/workflows/workflow.yml | 48 +++++++++++++++--------------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85eac48..b0ba366 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: - name: build run: cargo build --all --all-targets --verbose --release - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_crypto.dylib @@ -33,7 +33,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_zkp.dylib @@ -41,7 +41,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_java_crypto_binary.dylib @@ -49,7 +49,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_crypto_binary.dylib @@ -57,7 +57,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_fisco_bcos_sdk.dylib @@ -65,7 +65,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_fisco_bcos.dylib @@ -73,7 +73,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_java_crypto.dylib @@ -85,7 +85,7 @@ jobs: - name: rename to ffi_java_sdk lib run: mv target/release/libffi_java_crypto.dylib target/release/libffi_java_sdk.dylib - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_java_sdk.dylib @@ -95,11 +95,15 @@ jobs: build_with_centos: name: build_with_centos + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION: "node16" + ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: "node16" runs-on: ubuntu-latest container: image: docker.io/centos:7 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 5 - name: install rust language @@ -115,7 +119,7 @@ jobs: run: | cargo build --all --all-targets --verbose --release - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_crypto.so @@ -123,7 +127,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_zkp.so @@ -131,7 +135,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_java_crypto_binary.so @@ -139,7 +143,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_crypto_binary.so @@ -147,7 +151,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_fisco_bcos_sdk.so @@ -155,7 +159,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_c_fisco_bcos.so @@ -163,7 +167,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_java_crypto.so @@ -175,7 +179,7 @@ jobs: - name: rename to ffi_java_sdk lib run: mv target/release/libffi_java_crypto.so target/release/libffi_java_sdk.so - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: libffi_java_sdk.so @@ -199,7 +203,7 @@ jobs: run: | cargo build --all --all-targets --verbose --release - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_c_crypto.dll @@ -207,7 +211,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_c_zkp.dll @@ -215,7 +219,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_java_crypto_binary.dll @@ -223,7 +227,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_c_crypto_binary.dll @@ -231,7 +235,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_fisco_bcos_sdk.dll @@ -239,7 +243,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_c_fisco_bcos.dll @@ -247,7 +251,7 @@ jobs: tag: ${{ github.ref }} overwrite: true - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_java_crypto.dll @@ -259,7 +263,7 @@ jobs: - name: rename to vrf lib run: mv D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_crypto.dll D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_sdk.dll - name: Upload wedpr-lab-crypto binaries to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@v4-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} asset_name: ffi_java_sdk.dll diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 80c0eb8..4a66d24 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -38,31 +38,31 @@ jobs: run: cargo test - name: bench run: cargo bench - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_crypto.dylib path: target/release/libffi_c_crypto.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_zkp.dylib path: target/release/libffi_c_zkp.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_java_crypto_binary.dylib path: target/release/libffi_java_crypto_binary.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_crypto_binary.dylib path: target/release/libffi_c_crypto_binary.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_fisco_bcos_sdk.dylib path: target/release/libffi_fisco_bcos_sdk.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_fisco_bcos.dylib path: target/release/libffi_c_fisco_bcos.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_java_crypto.dylib path: target/release/libffi_java_crypto.dylib @@ -70,7 +70,7 @@ jobs: run: cargo clean && cd ffi/ffi_java/ffi_java_crypto && cargo build --release --no-default-features --features "wedpr_f_hex wedpr_f_signature_secp256k1 wedpr_f_hash_keccak256 wedpr_f_signature_sm2 wedpr_f_hash_sm3 wedpr_f_vrf_curve25519" - name: rename to ffi_java_sdk lib run: mv target/release/libffi_java_crypto.dylib target/release/libffi_java_sdk.dylib - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_java_sdk.dylib path: target/release/libffi_java_sdk.dylib @@ -98,31 +98,31 @@ jobs: cargo build --all --all-targets --verbose --release cargo test cargo bench - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_crypto.so path: target/release/libffi_c_crypto.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_zkp.so path: target/release/libffi_c_zkp.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_java_crypto_binary.so path: target/release/libffi_java_crypto_binary.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_crypto_binary.so path: target/release/libffi_c_crypto_binary.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_fisco_bcos_sdk.so path: target/release/libffi_fisco_bcos_sdk.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_c_fisco_bcos.so path: target/release/libffi_c_fisco_bcos.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_java_crypto.so path: target/release/libffi_java_crypto.so @@ -130,7 +130,7 @@ jobs: run: cargo clean && cd ffi/ffi_java/ffi_java_crypto && cargo build --release --no-default-features --features "wedpr_f_hex wedpr_f_signature_secp256k1 wedpr_f_hash_keccak256 wedpr_f_signature_sm2 wedpr_f_hash_sm3 wedpr_f_vrf_curve25519" - name: rename to ffi_java_sdk lib run: mv target/release/libffi_java_crypto.so target/release/libffi_java_sdk.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: libffi_java_sdk.so path: target/release/libffi_java_sdk.so @@ -152,31 +152,31 @@ jobs: cargo build --all --all-targets --verbose --release cargo test cargo bench - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_c_crypto.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_c_crypto.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_c_zkp.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_c_zkp.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_java_crypto_binary.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_crypto_binary.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_c_crypto_binary.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_c_crypto_binary.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_fisco_bcos_sdk.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_fisco_bcos_sdk.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_c_fisco_bcos.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_c_fisco_bcos.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_java_crypto.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_crypto.dll @@ -184,7 +184,7 @@ jobs: run: cargo clean && cd ffi/ffi_java/ffi_java_crypto && cargo build --release --no-default-features --features "wedpr_f_hex wedpr_f_signature_secp256k1 wedpr_f_hash_keccak256 wedpr_f_signature_sm2 wedpr_f_hash_sm3 wedpr_f_vrf_curve25519" - name: rename to vrf lib run: mv D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_crypto.dll D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_sdk.dll - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ffi_java_sdk.dll path: D:\a\WeDPR-Lab-Crypto\WeDPR-Lab-Crypto\target\release\ffi_java_sdk.dll From 7b16e5248e5fdc866abe511903c5901e4db1cf9d Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Tue, 19 Nov 2024 19:45:58 +0800 Subject: [PATCH 8/9] update action v3 --- .github/workflows/release.yml | 4 ++-- .github/workflows/workflow.yml | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0ba366..af6c3ab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [macos-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 5 - name: Nightly default @@ -194,7 +194,7 @@ jobs: matrix: os: [windows-2019] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 5 - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4a66d24..dfd8a22 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -77,11 +77,15 @@ jobs: build_with_centos: name: build_with_centos + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION: "node16" + ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: "node16" runs-on: ubuntu-latest container: image: docker.io/centos:7 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 5 - name: install rust language @@ -89,10 +93,10 @@ jobs: with: toolchain: nightly-2024-01-10 override: true - - name: install CentOS dependencies - run: | - yum install -y epel-release centos-release-scl - yum install -y java-11-openjdk-devel git make gcc gcc-c++ glibc-static glibc-devel openssl openssl-devel cmake3 ccache devtoolset-7 libzstd-devel zlib-devel flex bison python-devel python3-devel perl-IPC-Cmd && source /opt/rh/devtoolset-7/enable + # - name: install CentOS dependencies + # run: | + # yum install -y epel-release centos-release-scl + # yum install -y java-11-openjdk-devel git make gcc gcc-c++ glibc-static glibc-devel openssl openssl-devel cmake3 ccache devtoolset-7 libzstd-devel zlib-devel flex bison python-devel python3-devel perl-IPC-Cmd && source /opt/rh/devtoolset-7/enable - name: configure and compile run: | cargo build --all --all-targets --verbose --release From 619f565219dc5b15628e5a1c94d11803f935f6d4 Mon Sep 17 00:00:00 2001 From: HaoXuan40404 <444649358@qq.com> Date: Wed, 20 Nov 2024 11:26:08 +0800 Subject: [PATCH 9/9] fix cargo lock --- Cargo.lock | 8 ++++---- crypto/vrf/secp256k1/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 935f004..39ce56f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1808,9 +1808,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.171" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -1827,9 +1827,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", diff --git a/crypto/vrf/secp256k1/Cargo.toml b/crypto/vrf/secp256k1/Cargo.toml index adfe83e..0638acd 100644 --- a/crypto/vrf/secp256k1/Cargo.toml +++ b/crypto/vrf/secp256k1/Cargo.toml @@ -14,4 +14,4 @@ wedpr_l_crypto_hash_keccak256 = "1.1.0" wedpr_l_crypto_zkp_utils = "1.2.0" wedpr_l_macros = "1.0.0" wedpr_l_utils = "1.1.0" -serde = { version = "=1.0.171", features = ["derive"] } +serde = { version = "=1.0.195", features = ["derive"] }