Skip to content

Commit cf9cfc8

Browse files
committed
Add zero-knowledge inequality predicate
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent 6d63ad6 commit cf9cfc8

40 files changed

+1152
-154
lines changed

bbs_plus/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bbs_plus"
3-
version = "0.17.0"
3+
version = "0.18.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -19,10 +19,10 @@ ark-std.workspace = true
1919
digest.workspace = true
2020
rayon = {workspace = true, optional = true}
2121
itertools.workspace = true
22-
schnorr_pok = { version = "0.15.0", default-features = false, path = "../schnorr_pok" }
22+
schnorr_pok = { version = "0.16.0", default-features = false, path = "../schnorr_pok" }
2323
dock_crypto_utils = { version = "0.16.0", default-features = false, path = "../utils" }
24-
oblivious_transfer_protocols = { version = "0.4.0", default-features = false, path = "../oblivious_transfer" }
25-
secret_sharing_and_dkg = { version = "0.8.0", default-features = false, path = "../secret_sharing_and_dkg" }
24+
oblivious_transfer_protocols = { version = "0.5.0", default-features = false, path = "../oblivious_transfer" }
25+
secret_sharing_and_dkg = { version = "0.9.0", default-features = false, path = "../secret_sharing_and_dkg" }
2626
sha3 = { version = "0.10.6", default-features = false }
2727
serde.workspace = true
2828
serde_with.workspace = true

benches/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ authors.workspace = true
66
license.workspace = true
77

88
[dependencies]
9-
bbs_plus = { version = "0.17.0", default-features = false, path = "../bbs_plus" }
10-
schnorr_pok = { version = "0.15.0", default-features = false, path = "../schnorr_pok" }
11-
vb_accumulator = { version = "0.18.0", default-features = false, path = "../vb_accumulator" }
9+
bbs_plus = { default-features = false, path = "../bbs_plus" }
10+
schnorr_pok = { default-features = false, path = "../schnorr_pok" }
11+
vb_accumulator = { default-features = false, path = "../vb_accumulator" }
1212
test_utils = { default-features = false, path = "../test_utils" }
1313
ark-ff.workspace = true
1414
ark-ec.workspace = true
@@ -18,8 +18,8 @@ serde.workspace = true
1818
serde_with.workspace = true
1919
blake2 = { version = "0.10", default-features = false }
2020
itertools.workspace = true
21-
coconut-crypto = { version = "0.6.0", default-features = false, path = "../coconut" }
22-
oblivious_transfer_protocols = { version = "0.4.0", default-features = false, path = "../oblivious_transfer" }
21+
coconut-crypto = { default-features = false, path = "../coconut" }
22+
oblivious_transfer_protocols = { default-features = false, path = "../oblivious_transfer" }
2323
dock_crypto_utils = { default-features = false, path = "../utils" }
2424
zeroize.workspace = true
2525

benches/benches/dkls19_batch_mul_2p.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn batch_multiplication(c: &mut Criterion) {
8282
)
8383
.unwrap();
8484

85-
let (party2, _, kos_rlc, gamma_b) = Party2::new(
85+
let (party2, U, kos_rlc, gamma_b) = Party2::new(
8686
&mut rng,
8787
beta.clone(),
8888
base_ot_sender_keys.clone(),

bulletproofs_plus_plus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bulletproofs_plus_plus"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true

bulletproofs_plus_plus/src/rangeproof.rs

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//!
77
//! Notation follows the bulletproofs++ paper.
88
9-
use ark_ec::{AffineRepr, CurveGroup, VariableBaseMSM};
9+
use ark_ec::AffineRepr;
1010
use ark_ff::{batch_inversion, Field, PrimeField, Zero};
1111
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
1212
use ark_std::{
@@ -750,13 +750,13 @@ impl<G: AffineRepr> Proof<G> {
750750
&self,
751751
alpha_r: &[G::ScalarField],
752752
alpha_r2: &[G::ScalarField],
753-
t3: &G::ScalarField,
753+
t_cube: &G::ScalarField,
754754
q_pows: &[G::ScalarField],
755755
alpha_d_q_inv_pows: &[G::ScalarField],
756756
alpha_d: &[G::ScalarField],
757757
total_num_digits: usize,
758758
) -> G::ScalarField {
759-
let two_t_3 = t3.double();
759+
let two_t_3 = t_cube.double();
760760
let two_t_3_v = vec![two_t_3; total_num_digits];
761761

762762
let v_hat_1 = inner_product(&two_t_3_v, q_pows);
@@ -790,7 +790,7 @@ impl<G: AffineRepr> Proof<G> {
790790
let t_pows = TPowers::new(t, setup_params.H_vec.len() as u32);
791791

792792
let c_vec = create_c_vec(y, &t_pows);
793-
let (t_inv, t2, t3) = (
793+
let (t_inv, t_sqr, t_cube) = (
794794
t_pows.nth_power(-1),
795795
t_pows.nth_power(2),
796796
t_pows.nth_power(3),
@@ -815,13 +815,13 @@ impl<G: AffineRepr> Proof<G> {
815815
let g_offset = self.g_offset(
816816
&alpha_r,
817817
&alpha_r2,
818-
t3,
818+
t_cube,
819819
&q_pows,
820820
&alpha_d_q_inv_pow,
821821
&alpha_d,
822822
total_num_digits,
823823
);
824-
let g_vec_pub_offsets = self.g_vec_pub_offsets(
824+
let mut g_vec_pub_offsets = self.g_vec_pub_offsets(
825825
e,
826826
x,
827827
&alpha_r_q_inv_pows,
@@ -830,26 +830,45 @@ impl<G: AffineRepr> Proof<G> {
830830
&alpha_d_q_inv_pow,
831831
);
832832

833-
// let (r1_comm, r2_comm, r3_comm, norm_proof) =
834-
// (self.r1_comm, self.r2_comm, self.r3_comm, self.norm_proof);
835-
let (S, M, D, R) = (
836-
self.r3_comm.S,
837-
self.r1_comm.M,
838-
self.r1_comm.D,
839-
self.r2_comm.R,
840-
);
833+
let two_t_cube = t_cube.double();
834+
835+
// C = <V, lambda_powers> * t^3 * 2 + S * t_inv + M * delta + D * t + R * t^2 + <G_vec, g_vec_pub_offsets> + G * g_offset
836+
837+
// RHS of above can be created using an MSM
838+
let msm_size = 5 + V.len() + g_vec_pub_offsets.len();
839+
let mut bases = Vec::with_capacity(msm_size);
840+
let mut scalars = Vec::with_capacity(msm_size);
841+
842+
// For <V, lambda_powers> * t^3 * 2
843+
bases.extend_from_slice(V);
844+
scalars.append(&mut scale(&lambda_powers, &two_t_cube));
845+
846+
// For S * t_inv + M * delta + D * t + R * t^2
847+
bases.push(self.r3_comm.S);
848+
bases.push(self.r1_comm.M);
849+
bases.push(self.r1_comm.D);
850+
bases.push(self.r2_comm.R);
851+
scalars.push(*t_inv);
852+
scalars.push(delta);
853+
scalars.push(t);
854+
scalars.push(*t_sqr);
841855

842-
let two_t3 = t3.double();
856+
// For <G_vec, g_vec_pub_offsets>
857+
bases.extend_from_slice(&setup_params.G_vec[0..g_vec_pub_offsets.len()]);
858+
scalars.append(&mut g_vec_pub_offsets);
843859

844-
// \sum_i(V_i * lambda_powers_i * t3 * 2)
845-
let V = G::Group::msm_unchecked(V, &scale(&lambda_powers, &two_t3));
846-
// TODO: C can be created using an MSM
847-
let C = S * t_inv + M * delta + D * t + R * t2 + V;
848-
let P = G::Group::msm_unchecked(&setup_params.G_vec, &g_vec_pub_offsets);
849-
let C = C + P + (setup_params.G * g_offset);
860+
// For G * g_offset
861+
bases.push(setup_params.G);
862+
scalars.push(g_offset);
850863

851-
self.norm_proof
852-
.verify(c_vec, r, &C.into_affine(), setup_params, transcript)
864+
self.norm_proof.verify_given_commitment_multiplicands(
865+
c_vec,
866+
r,
867+
bases,
868+
scalars,
869+
setup_params,
870+
transcript,
871+
)
853872
}
854873
}
855874

0 commit comments

Comments
 (0)