Skip to content

Commit 166e21d

Browse files
committed
add jni interface
1 parent dd9b8b3 commit 166e21d

File tree

11 files changed

+1453
-47
lines changed

11 files changed

+1453
-47
lines changed

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ members = [
2929
"ffi/ffi_common",
3030
"ffi/ffi_java/ffi_java_crypto",
3131
"ffi/ffi_java/ffi_java_crypto_binary",
32-
"ffi/ffi_java/ffi_java_fisco_bcos_sdk",
32+
"ffi/ffi_java/ffi_java_fisco_bcos_sdk", "ffi/ffi_java/ffi_java_zkp",
3333
"ffi/ffi_macros",
3434
"protos",
3535
"third_party/fisco_bcos",

crypto/zkp/discrete_logarithm_proof/src/lib.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use curve25519_dalek::{
88
};
99
use rand::Rng;
1010
use wedpr_l_crypto_zkp_utils::{
11-
get_random_scalar, hash_to_scalar, point_to_bytes, ArithmeticProof, BalanceProof, EqualityProof, FormatProof, KnowledgeProof, ReceiverRelationshipProofFinalPublic, ReceiverRelationshipProofSetupPrivate, ReceiverRelationshipProofSetupPublic, RelationshipProof, SenderRelationshipProofFinalPublic, SenderRelationshipProofSetupPrivate, SenderRelationshipProofSetupPublic, ValueQualityProof
11+
get_random_scalar, hash_to_scalar, point_to_bytes, ArithmeticProof, BalanceProof, EqualityProof, FormatProof, KnowledgeProof, ReceiverRelationshipProofFinalPublic, ReceiverRelationshipProofSetupPrivate, ReceiverRelationshipProofSetupPublic, RelationshipProof, SenderRelationshipProofFinalPublic, SenderRelationshipProofSetupPrivate, SenderRelationshipProofSetupPublic, ValueEqualityProof
1212
};
1313

1414
use wedpr_l_utils::error::WedprError;
@@ -28,7 +28,7 @@ pub fn prove_value_equality_relationship_proof(
2828
c_blinding: &Scalar,
2929
c_basepoint: &RistrettoPoint,
3030
blinding_basepoint: &RistrettoPoint,
31-
) -> ValueQualityProof {
31+
) -> ValueEqualityProof {
3232
let blinding_a = get_random_scalar();
3333
let blinding_b = get_random_scalar();
3434
let t1 = blinding_a * c_basepoint;
@@ -46,7 +46,7 @@ pub fn prove_value_equality_relationship_proof(
4646
let check = hash_to_scalar(&hash_vec);
4747
let m1 = blinding_a - (check * c_value_scalar);
4848
let m2 = blinding_b - (check * c_blinding);
49-
return ValueQualityProof { check, m1, m2 };
49+
return ValueEqualityProof { check, m1, m2 };
5050
}
5151

5252
/// Verifies a commitment satisfying an equality relationship, i.e.
@@ -56,7 +56,7 @@ pub fn prove_value_equality_relationship_proof(
5656
pub fn verify_value_equality_relationship_proof(
5757
c_value: u64,
5858
c_point: &RistrettoPoint,
59-
proof: &ValueQualityProof,
59+
proof: &ValueEqualityProof,
6060
c_basepoint: &RistrettoPoint,
6161
blinding_basepoint: &RistrettoPoint,
6262
) -> Result<bool, WedprError> {
@@ -551,6 +551,15 @@ pub fn sender_prove_multi_sum_relationship_setup(
551551
);
552552
}
553553

554+
pub fn sender_prove_multi_sum_relationship_final(input_value: u64, input_blinding: &Scalar, proof_secret: &SenderRelationshipProofSetupPrivate, check: &Scalar) -> SenderRelationshipProofFinalPublic {
555+
let m = proof_secret.blinding_a - check * Scalar::from(input_value);
556+
let n = proof_secret.blinding_b - check * input_blinding;
557+
return SenderRelationshipProofFinalPublic {
558+
m: m,
559+
n: n,
560+
};
561+
}
562+
554563
pub fn receiver_prove_multi_sum_relationship_setup(
555564
output_value: u64,
556565
output_blinding: &Scalar,
@@ -575,6 +584,13 @@ pub fn receiver_prove_multi_sum_relationship_setup(
575584
);
576585
}
577586

587+
pub fn receiver_prove_multi_sum_relationship_final(output_blinding: &Scalar, proof_secret: &ReceiverRelationshipProofSetupPrivate, check: &Scalar) -> ReceiverRelationshipProofFinalPublic {
588+
let t_commit_share = proof_secret.f_blinding - check * output_blinding;
589+
return ReceiverRelationshipProofFinalPublic {
590+
t_commit_share: t_commit_share,
591+
};
592+
}
593+
578594
pub fn coordinator_prove_multi_sum_relationship_setup(
579595
sender_setup_lists: &[SenderRelationshipProofSetupPublic],
580596
receiver_setup_lists: &[ReceiverRelationshipProofSetupPublic],
@@ -602,22 +618,6 @@ pub fn coordinator_prove_multi_sum_relationship_setup(
602618
return hash_to_scalar(&hash_vec);
603619
}
604620

605-
pub fn sender_prove_multi_sum_relationship_final(input_value: u64, input_blinding: &Scalar, proof_secret: &SenderRelationshipProofSetupPrivate, check: &Scalar) -> SenderRelationshipProofFinalPublic {
606-
let m = proof_secret.blinding_a - check * Scalar::from(input_value);
607-
let n = proof_secret.blinding_b - check * input_blinding;
608-
return SenderRelationshipProofFinalPublic {
609-
m: m,
610-
n: n,
611-
};
612-
}
613-
614-
pub fn receiver_prove_multi_sum_relationship_final(output_blinding: &Scalar, proof_secret: &ReceiverRelationshipProofSetupPrivate, check: &Scalar) -> ReceiverRelationshipProofFinalPublic {
615-
let t_commit_share = proof_secret.f_blinding - check * output_blinding;
616-
return ReceiverRelationshipProofFinalPublic {
617-
t_commit_share: t_commit_share,
618-
};
619-
}
620-
621621
pub fn coordinator_prove_multi_sum_relationship_final(check: &Scalar, sender_proofs: &[SenderRelationshipProofFinalPublic], receiver_proofs: &[ReceiverRelationshipProofFinalPublic]) -> RelationshipProof {
622622
let mut left_commit = Scalar::from(0u64);
623623
let mut m_list = Vec::new();

0 commit comments

Comments
 (0)