Skip to content

Commit 5080094

Browse files
authored
Merge pull request #66 from cyjseagull/dev-1.6.0
sync code from dev-1.6.0
2 parents a051184 + aae88cc commit 5080094

File tree

39 files changed

+6591
-490
lines changed

39 files changed

+6591
-490
lines changed

.github/workflows/default_test.yml

-19
This file was deleted.

.github/workflows/workflow.yml

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: WeDPR-Lab-Core GitHub Actions
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "docs/**"
7+
- "Changelog.md"
8+
- "README.md"
9+
pull_request:
10+
paths-ignore:
11+
- "docs/**"
12+
- "Changelog.md"
13+
- "README.md"
14+
release:
15+
types: [published, created, edited]
16+
env:
17+
CCACHE_DIR: ${{ github.workspace }}/ccache
18+
19+
jobs:
20+
build_with_macos:
21+
name: build_with_macos
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix:
25+
os: [macos-latest]
26+
steps:
27+
- uses: actions/checkout@v2
28+
with:
29+
fetch-depth: 5
30+
- name: Nightly default
31+
run: rustup default nightly
32+
- name: install macOS dependencies
33+
if: runner.os == 'macOS'
34+
run: brew install ccache
35+
- name: build
36+
run: cargo build --all --all-targets --verbose --release
37+
- name: run test and bench
38+
run: cargo test && cargo bench
39+
- uses: actions/upload-artifact@v2
40+
with:
41+
name: libffi_java_acv.dylib.tar.gz
42+
path: target/release/libffi_java_acv.dylib
43+
- uses: actions/upload-artifact@v2
44+
with:
45+
name: libffi_java_vcl.dylib.tar.gz
46+
path: target/release/libffi_java_vcl.dylib
47+
- uses: actions/upload-artifact@v2
48+
with:
49+
name: libffi_java_scd.dylib.tar.gz
50+
path: target/release/libffi_java_scd.dylib
51+
- uses: actions/upload-artifact@v2
52+
with:
53+
name: libffi_java_ktb.dylib.tar.gz
54+
path: target/release/libffi_java_ktb.dylib
55+
- uses: actions/upload-artifact@v2
56+
with:
57+
name: libffi_c_scd.dylib.tar.gz
58+
path: target/release/libffi_c_scd.dylib
59+
- uses: actions/upload-artifact@v2
60+
with:
61+
name: libffi_c_vcl.dylib.tar.gz
62+
path: target/release/libffi_c_vcl.dylib
63+
- uses: actions/upload-artifact@v2
64+
with:
65+
name: libffi_c_hdk.dylib.tar.gz
66+
path: target/release/libffi_c_hdk.dylib
67+
- name: build sm-acv
68+
run: cd ffi/ffi_java/ffi_java_acv && cargo clean && cargo build --release --no-default-features --features sm
69+
- name: rename libffi_java_acv
70+
run: mv target/release/libffi_java_acv.dylib target/release/libffi_java_sm_acv.dylib
71+
- uses: actions/upload-artifact@v2
72+
with:
73+
name: libffi_java_sm_acv.dylib.tar.gz
74+
path: target/release/libffi_java_sm_acv.dylib
75+
76+
build_with_centos:
77+
name: build_with_centos
78+
runs-on: ubuntu-latest
79+
container:
80+
image: docker.io/centos:7
81+
steps:
82+
- uses: actions/checkout@v2
83+
with:
84+
fetch-depth: 5
85+
- name: install rust language
86+
uses: actions-rs/toolchain@v1
87+
with:
88+
toolchain: nightly-2021-06-17
89+
override: true
90+
- name: install CentOS dependencies
91+
run: |
92+
yum install -y epel-release centos-release-scl
93+
yum install -y openssl openssl-devel git make gcc gcc-c++ glibc-static glibc-devel cmake3 ccache devtoolset-7 libzstd-devel zlib-devel flex bison python-devel python3-devel && source /opt/rh/devtoolset-7/enable
94+
- name: configure and compile
95+
run: |
96+
cargo build --all --all-targets --verbose --release
97+
cargo test
98+
cargo bench
99+
- uses: actions/upload-artifact@v2
100+
with:
101+
name: libffi_java_acv.so.tar.gz
102+
path: target/release/libffi_java_acv.so
103+
- uses: actions/upload-artifact@v2
104+
with:
105+
name: libffi_java_vcl.so.tar.gz
106+
path: target/release/libffi_java_vcl.so
107+
- uses: actions/upload-artifact@v2
108+
with:
109+
name: libffi_java_scd.so.tar.gz
110+
path: target/release/libffi_java_scd.so
111+
- uses: actions/upload-artifact@v2
112+
with:
113+
name: libffi_java_ktb.so.tar.gz
114+
path: target/release/libffi_java_ktb.so
115+
- uses: actions/upload-artifact@v2
116+
with:
117+
name: libffi_c_scd.so.tar.gz
118+
path: target/release/libffi_c_scd.so
119+
- uses: actions/upload-artifact@v2
120+
with:
121+
name: libffi_c_vcl.so.tar.gz
122+
path: target/release/libffi_c_vcl.so
123+
- uses: actions/upload-artifact@v2
124+
with:
125+
name: libffi_c_hdk.so.tar.gz
126+
path: target/release/libffi_c_hdk.so
127+
- name: build sm-acv
128+
run: cd ffi/ffi_java/ffi_java_acv && cargo clean && cargo build --release --no-default-features --features sm
129+
- name: rename libffi_java_acv
130+
run: mv target/release/libffi_java_acv.so target/release/libffi_java_sm_acv.so
131+
- uses: actions/upload-artifact@v2
132+
with:
133+
name: libffi_java_sm_acv.so.tar.gz
134+
path: target/release/libffi_java_sm_acv.so
135+
build_with_windows:
136+
name: build_with_windows
137+
runs-on: ${{ matrix.os }}
138+
strategy:
139+
matrix:
140+
os: [windows-2019]
141+
steps:
142+
- uses: actions/checkout@v2
143+
with:
144+
fetch-depth: 5
145+
- run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
146+
- run: vcpkg install openssl:x64-windows-static-md
147+
- name: build and test
148+
run: |
149+
cargo build --all --all-targets --verbose --release
150+
cargo test
151+
cargo bench
152+
- uses: actions/upload-artifact@v2
153+
with:
154+
name: ffi_java_acv.dll.zip
155+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_acv.dll
156+
- uses: actions/upload-artifact@v2
157+
with:
158+
name: ffi_java_vcl.dll.zip
159+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_vcl.dll
160+
- uses: actions/upload-artifact@v2
161+
with:
162+
name: ffi_java_scd.dll.zip
163+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_scd.dll
164+
- uses: actions/upload-artifact@v2
165+
with:
166+
name: ffi_java_ktb.dll.zip
167+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_ktb.dll
168+
- uses: actions/upload-artifact@v2
169+
with:
170+
name: ffi_c_scd.dll.zip
171+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_c_scd.dll
172+
- uses: actions/upload-artifact@v2
173+
with:
174+
name: ffi_c_vcl.dll.zip
175+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_c_vcl.dll
176+
- uses: actions/upload-artifact@v2
177+
with:
178+
name: ffi_c_hdk.dll.zip
179+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_c_hdk.dll
180+
- name: build sm-acv
181+
run: cd ffi/ffi_java/ffi_java_acv && cargo clean && cargo build --release --no-default-features --features sm
182+
- name: rename libffi_java_acv
183+
run: mv D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_acv.dll D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_sm_acv.dll
184+
- uses: actions/upload-artifact@v2
185+
with:
186+
name: ffi_java_sm_acv.dll.zip
187+
path: D:\a\WeDPR-Lab-Core\WeDPR-Lab-Core\target\release\ffi_java_sm_acv.dll

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[workspace]
2-
32
members = [
43
"bounty",
54
"ffi/ffi_c/ffi_c_ktb",
@@ -8,6 +7,7 @@ members = [
87
"ffi/ffi_java/ffi_java_ktb",
98
"ffi/ffi_java/ffi_java_scd",
109
"ffi/ffi_java/ffi_java_vcl",
10+
"ffi/ffi_java/ffi_java_acv",
1111
"protos",
1212
"solution/key_tool_box/hierarchical_deterministic_key",
1313
"solution/selective_certificate_disclosure",

bounty/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ curve25519-dalek = { version = "1", features = [ "serde" ] }
1212
protobuf = "2.22.1"
1313
rand = "0.3.17"
1414
sha3 = "0.8"
15-
wedpr_l_crypto_zkp_discrete_logarithm_proof = "1.0.0"
15+
wedpr_l_crypto_zkp_discrete_logarithm_proof = {version = "1.3.0", git = "https://github.com/WeBankBlockchain/WeDPR-Lab-Crypto", branch = "dev-1.3.0"}
1616
wedpr_l_crypto_zkp_range_proof = "1.2.0"
17-
wedpr_l_crypto_zkp_utils = "1.0.0"
17+
wedpr_l_crypto_zkp_utils ={version = "1.3.0", git = "https://github.com/WeBankBlockchain/WeDPR-Lab-Crypto", branch = "dev-1.3.0"}
1818
wedpr_l_macros = "1.0.0"
19-
wedpr_l_protos = "1.0.0"
2019
wedpr_l_utils = "1.0.0"
2120
wedpr_s_protos = { path = "../protos" }
2221
wedpr_s_selective_certificate_disclosure = { path = "../solution/selective_certificate_disclosure" }
23-
2422
wedpr_s_verifiable_confidential_ledger = { path = "../solution/verifiable_confidential_ledger" }
2523

2624
[dev-dependencies]

bounty/src/vcl.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use super::utils;
66
extern crate wedpr_s_verifiable_confidential_ledger;
77
use wedpr_s_verifiable_confidential_ledger::vcl;
88
extern crate wedpr_l_crypto_zkp_range_proof;
9-
109
/// UI flow of VCL bounty playground.
1110
pub fn flow_vcl() {
1211
utils::print_highlight(
@@ -223,15 +222,16 @@ mod tests {
223222
};
224223
extern crate wedpr_l_common_coder_base64;
225224
extern crate wedpr_l_crypto_zkp_range_proof;
226-
extern crate wedpr_l_protos;
227225
extern crate wedpr_s_verifiable_confidential_ledger;
228226
use crate::vcl_data::{
229227
TARGET_SIZE, VCL_C1_VEC, VCL_C2_VEC, VCL_C3_VEC, VCL_PROOF_VEC,
230228
};
231229
use protobuf::Message;
232230
use wedpr_l_common_coder_base64::WedprBase64;
233-
use wedpr_l_protos::generated::zkp::BalanceProof;
234231
use wedpr_l_utils::traits::Coder;
232+
use wedpr_s_protos::{
233+
generated::zkp::PBBalanceProof, pb_to_arithmetric_proof,
234+
};
235235

236236
#[test]
237237
fn test_vcl_bounty_data_validity() {
@@ -249,16 +249,20 @@ mod tests {
249249
bytes_to_point(&base64.decode(&VCL_C3_VEC[i]).unwrap())
250250
.expect("failed to decode point");
251251

252-
let proof = <BalanceProof>::parse_from_bytes(
252+
let pb_proof = <PBBalanceProof>::parse_from_bytes(
253253
&base64.decode(&VCL_PROOF_VEC[i]).unwrap(),
254254
)
255255
.expect("failed to parse proof PB");
256-
256+
let arithmetric_proof_result = pb_to_arithmetric_proof(&pb_proof);
257+
let arithmetric_proof = match arithmetric_proof_result {
258+
Ok(v) => v,
259+
Err(_) => panic!("invalid arithmetric_proof"),
260+
};
257261
assert!(wedpr_l_crypto_zkp_discrete_logarithm_proof::verify_sum_relationship(
258262
&c1_point,
259263
&c2_point,
260264
&c3_point,
261-
&proof,
265+
&arithmetric_proof,
262266
&value_basepoint,
263267
&blinding_basepoint
264268
).unwrap());

ffi/ffi_c/ffi_c_vcl/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ protobuf = "2.22.1"
1616
wedpr_ffi_common = "1.0.0"
1717
wedpr_ffi_macros = "1.1.0"
1818
wedpr_l_macros = "1.0.0"
19-
wedpr_l_protos = "1.1.0"
2019
wedpr_s_protos = { path = "../../../protos" }
2120
wedpr_s_verifiable_confidential_ledger = { path = "../../../solution/verifiable_confidential_ledger" }
2221

ffi/ffi_c/ffi_c_vcl/src/lib.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ use wedpr_ffi_common::utils::{
1616
};
1717
use wedpr_s_verifiable_confidential_ledger;
1818

19-
use wedpr_l_protos::generated::zkp::BalanceProof;
20-
use wedpr_s_protos::generated::vcl::{
21-
BatchCreditBalanceProof, EncodedConfidentialCredit, EncodedOwnerSecret,
22-
VclResult,
19+
use wedpr_s_protos::generated::{
20+
vcl::{
21+
BatchCreditBalanceProof, EncodedConfidentialCredit, EncodedOwnerSecret,
22+
VclResult,
23+
},
24+
zkp::PBBalanceProof,
2325
};
2426

2527
use libc::{c_char, c_ulong};
@@ -110,7 +112,7 @@ pub extern "C" fn wedpr_vcl_verify_sum_balance(
110112
let result = panic::catch_unwind(|| {
111113
let proof = c_safe_c_char_pointer_to_proto_with_error_value!(
112114
proof_cstring,
113-
BalanceProof,
115+
PBBalanceProof,
114116
FAILURE
115117
);
116118
let c1_credit =
@@ -160,7 +162,7 @@ pub extern "C" fn wedpr_vcl_verify_sum_balance_in_batch(
160162
let mut c1_credits: Vec<ConfidentialCredit> = vec![];
161163
let mut c2_credits: Vec<ConfidentialCredit> = vec![];
162164
let mut c3_credits: Vec<ConfidentialCredit> = vec![];
163-
let mut proofs: Vec<BalanceProof> = vec![];
165+
let mut proofs: Vec<PBBalanceProof> = vec![];
164166
for credit_balance_proof in batch_proof.credit_balance_proof {
165167
c1_credits.push(decode_credit!(
166168
c_safe_bytes_to_proto_with_error_value!(
@@ -197,7 +199,7 @@ pub extern "C" fn wedpr_vcl_verify_sum_balance_in_batch(
197199
credit_balance_proof.proof,
198200
FAILURE
199201
),
200-
BalanceProof,
202+
PBBalanceProof,
201203
FAILURE
202204
));
203205
}
@@ -257,7 +259,7 @@ pub extern "C" fn wedpr_vcl_verify_product_balance(
257259
let result = panic::catch_unwind(|| {
258260
let proof = c_safe_c_char_pointer_to_proto_with_error_value!(
259261
proof_cstring,
260-
BalanceProof,
262+
PBBalanceProof,
261263
FAILURE
262264
);
263265
let c1_credit =
@@ -307,7 +309,7 @@ pub extern "C" fn wedpr_vcl_verify_product_balance_in_batch(
307309
let mut c1_credits: Vec<ConfidentialCredit> = vec![];
308310
let mut c2_credits: Vec<ConfidentialCredit> = vec![];
309311
let mut c3_credits: Vec<ConfidentialCredit> = vec![];
310-
let mut proofs: Vec<BalanceProof> = vec![];
312+
let mut proofs: Vec<PBBalanceProof> = vec![];
311313
for credit_balance_proof in batch_proof.credit_balance_proof {
312314
c1_credits.push(decode_credit!(
313315
c_safe_bytes_to_proto_with_error_value!(
@@ -344,7 +346,7 @@ pub extern "C" fn wedpr_vcl_verify_product_balance_in_batch(
344346
credit_balance_proof.proof,
345347
FAILURE
346348
),
347-
BalanceProof,
349+
PBBalanceProof,
348350
FAILURE
349351
));
350352
}

0 commit comments

Comments
 (0)