Skip to content

Commit

Permalink
v1.4.0 refine part1
Browse files Browse the repository at this point in the history
  • Loading branch information
qyan-dev authored and HaoXuan40404 committed Mar 30, 2021
1 parent ae18283 commit 24784fd
Show file tree
Hide file tree
Showing 27 changed files with 665 additions and 402 deletions.
12 changes: 8 additions & 4 deletions bounty/src/scd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ fn generate_predicate_proof(
template_private_key: TemplatePrivateKey,
value: u64,
rule_set: &mut VerificationRuleSet,
) -> Result<VerifyRequest, WedprError> {
) -> Result<VerifyRequest, WedprError>
{
user_fill_certificate_attribute(certificate_attribute_dict, value);
let (
sign_certificate_request,
Expand Down Expand Up @@ -352,7 +353,8 @@ fn issuer_make_certificate_template(
fn user_fill_certificate_attribute(
certificate_attribute_dict: &mut AttributeDict,
attribute: u64,
) {
)
{
let mut attribute_kv = StringToStringPair::new();
attribute_kv.set_key(TARGET_ATTRIBUTE.to_string());
attribute_kv.set_value(attribute.to_string());
Expand All @@ -365,7 +367,8 @@ fn user_prove_rule_set(
certificate_template: &CertificateTemplate,
user_private_key_str: &str,
rule_set: &mut VerificationRuleSet,
) -> Result<VerifyRequest, WedprError> {
) -> Result<VerifyRequest, WedprError>
{
// In most cases, this nonce should be provided by the verifier to prevent
// replaying attacks.
let verification_nonce_str = verifier::get_verification_nonce().unwrap();
Expand All @@ -382,6 +385,7 @@ fn user_prove_rule_set(
fn verifier_verify_rule_set(
rule_set: &mut VerificationRuleSet,
request: &VerifyRequest,
) -> bool {
) -> bool
{
verifier::verify_selective_disclosure(&rule_set, &request).unwrap()
}
3 changes: 2 additions & 1 deletion bounty/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ pub fn print_alert5(
message3: &str,
message4: &str,
message5: &str,
) {
)
{
println!(
"{}\n{}\n{}\n{}\n{}\n",
message1.yellow(),
Expand Down
18 changes: 10 additions & 8 deletions ffi/ffi_c/ffi_c_ktb/src/hdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use std::{ffi::CString, panic, ptr};

// Local macros and functions section.

/// C interface for 'wedpr_hdk_create_mnemonic_en'.
/// C interface for 'wedpr_ktb_hdk_create_mnemonic_en'.
#[no_mangle]
pub extern "C" fn wedpr_hdk_create_mnemonic_en(
pub extern "C" fn wedpr_ktb_hdk_create_mnemonic_en(
word_count: c_uchar,
) -> *mut c_char {
let result = panic::catch_unwind(|| {
Expand All @@ -37,12 +37,13 @@ pub extern "C" fn wedpr_hdk_create_mnemonic_en(
c_safe_return!(result)
}

/// C interface for 'wedpr_hdk_create_master_key_en'.
/// C interface for 'wedpr_ktb_hdk_create_master_key_en'.
#[no_mangle]
pub extern "C" fn wedpr_hdk_create_master_key_en(
pub extern "C" fn wedpr_ktb_hdk_create_master_key_en(
password_cstring: *mut c_char,
mnemonic_cstring: *mut c_char,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let passwd = c_safe_c_char_pointer_to_string!(password_cstring);
let mnemonic = c_safe_c_char_pointer_to_string!(mnemonic_cstring);
Expand All @@ -61,16 +62,17 @@ pub extern "C" fn wedpr_hdk_create_master_key_en(
c_safe_return!(result)
}

/// C interface for 'wedpr_hdk_derive_extended_key'.
/// C interface for 'wedpr_ktb_hdk_derive_extended_key'.
#[no_mangle]
pub extern "C" fn wedpr_hdk_derive_extended_key(
pub extern "C" fn wedpr_ktb_hdk_derive_extended_key(
master_key_cstring: *mut c_char,
purpose_type: c_int,
asset_type: c_int,
account: c_int,
change: c_int,
address_index: c_int,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let master_key = c_safe_c_char_pointer_to_bytes!(master_key_cstring);

Expand Down
3 changes: 2 additions & 1 deletion ffi/ffi_c/ffi_c_scd/src/issuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ pub extern "C" fn wedpr_scd_sign_certificate(
sign_request_cstring: *mut c_char,
user_id_cstring: *mut c_char,
user_nonce_cstring: *mut c_char,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let certificate_template_pb = c_safe_c_char_pointer_to_proto!(
certificate_template_cstring,
Expand Down
9 changes: 6 additions & 3 deletions ffi/ffi_c/ffi_c_scd/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use wedpr_ffi_common::utils::{
pub extern "C" fn wedpr_scd_fill_certificate(
attribute_dict_cstring: *mut c_char,
certificate_template_cstring: *mut c_char,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let attribute_dict_pb = c_safe_c_char_pointer_to_proto!(
attribute_dict_cstring,
Expand Down Expand Up @@ -66,7 +67,8 @@ pub extern "C" fn wedpr_scd_blind_certificate_signature(
user_private_key_cstring: *mut c_char,
certificate_secrets_blinding_factors_cstring: *mut c_char,
issuer_nonce_cstring: *mut c_char,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let certificate_signature_pb = c_safe_c_char_pointer_to_proto!(
certificate_signature_cstring,
Expand Down Expand Up @@ -116,7 +118,8 @@ pub extern "C" fn wedpr_scd_prove_selective_disclosure(
certificate_template_cstring: *mut c_char,
user_private_key_cstring: *mut c_char,
verification_nonce_cstring: *mut c_char,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let certificate_signature_pb = c_safe_c_char_pointer_to_proto!(
certificate_signature_cstring,
Expand Down
3 changes: 2 additions & 1 deletion ffi/ffi_c/ffi_c_scd/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ pub extern "C" fn wedpr_scd_get_revealed_attributes(
pub extern "C" fn wedpr_scd_verify_selective_disclosure(
rule_set_cstring: *mut c_char,
verify_request_cstring: *mut c_char,
) -> *mut c_char {
) -> *mut c_char
{
let result = panic::catch_unwind(|| {
let verify_request_pb = c_safe_c_char_pointer_to_proto!(
verify_request_cstring,
Expand Down
4 changes: 2 additions & 2 deletions ffi/ffi_c/ffi_c_vcl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ libc = "0.2.60"
protobuf = "2.22.1"
wedpr_s_verifiable_confidential_ledger = { path = "../../../solution/verifiable_confidential_ledger"}
wedpr_ffi_common = "1.0.0"
wedpr_ffi_macros = { git = "https://github.com/WeBankBlockchain/WeDPR-Lab-Crypto.git", branch = "v1.1.0" }
wedpr_ffi_macros = { git = "https://gitee.com/WeBankBlockchain/WeDPR-Lab-Crypto.git", branch = "v1.1.0" }
wedpr_s_protos = { path = "../../../protos"}
wedpr_l_protos = { git = "https://github.com/WeBankBlockchain/WeDPR-Lab-Crypto.git", branch = "v1.1.0" }
wedpr_l_protos = { git = "https://gitee.com/WeBankBlockchain/WeDPR-Lab-Crypto.git", branch = "v1.1.0" }
wedpr_l_macros = "1.0.0"

# This is required to generate C/C++ header files.
Expand Down
Loading

0 comments on commit 24784fd

Please sign in to comment.