Skip to content

Commit 9e2cd9a

Browse files
committed
Protocols for proving equality of committed values across groups
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent 4ae121a commit 9e2cd9a

30 files changed

+3863
-212
lines changed

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ members = [
2121
"smc_range_proof",
2222
"short_group_sig",
2323
"syra",
24-
"verifiable_encryption"]
24+
"verifiable_encryption",
25+
"equality_across_groups"
26+
]
2527
resolver = "2"
2628

2729
[workspace.package]

benches/Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ serde_with.workspace = true
1616
blake2 = { version = "0.10", default-features = false }
1717
itertools.workspace = true
1818
zeroize.workspace = true
19+
rayon = {workspace = true, optional = true}
1920
bbs_plus = { default-features = false, path = "../bbs_plus" }
2021
schnorr_pok = { default-features = false, path = "../schnorr_pok" }
2122
vb_accumulator = { default-features = false, path = "../vb_accumulator" }
@@ -93,4 +94,9 @@ harness = false
9394
[[bench]]
9495
name = "syra"
9596
path = "benches/syra.rs"
96-
harness = false
97+
harness = false
98+
99+
[features]
100+
default = [ "parallel" ]
101+
std = [ "ark-ff/std", "ark-ec/std", "ark-std/std", "schnorr_pok/std", "dock_crypto_utils/std", "serde/std", "oblivious_transfer_protocols/std", "secret_sharing_and_dkg/std", "bbs_plus/std", "vb_accumulator/std", "coconut-crypto/std", "syra/std"]
102+
parallel = [ "std", "ark-ff/parallel", "ark-ec/parallel", "rayon", "schnorr_pok/parallel", "dock_crypto_utils/parallel", "oblivious_transfer_protocols/parallel", "secret_sharing_and_dkg/parallel", "bbs_plus/parallel", "vb_accumulator/parallel", "coconut-crypto/parallel", "syra/parallel"]

benches/benches/syra.rs

+47-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use ark_bls12_381::{Bls12_381, Fr, G1Affine};
22
use ark_ff::Zero;
3+
use ark_serialize::{CanonicalSerialize, Compress};
34
use ark_std::{
45
collections::BTreeSet,
56
rand::{prelude::StdRng, SeedableRng},
@@ -399,21 +400,27 @@ fn pseudonym(c: &mut Criterion) {
399400
});
400401
}
401402

402-
criterion_group!(benches, threshold_issuance_with_known_user_id, pseudonym);
403-
criterion_main!(benches);
403+
// criterion_group!(benches, threshold_issuance_with_known_user_id, pseudonym);
404+
// criterion_main!(benches);
404405

405-
/*fn timing_info(mut times: Vec<std::time::Duration>) -> String {
406+
fn timing_info(mut times: Vec<std::time::Duration>) -> String {
406407
times.sort();
407408
let median = {
408409
let mid = times.len() / 2;
409410
if times.len() % 2 == 0 {
410-
(times[mid - 1] + times[mid]) / 2
411+
(times[mid - 1] + times[mid]) / 2
411412
} else {
412413
times[mid]
413414
}
414415
};
415416
let total = times.iter().sum::<std::time::Duration>();
416-
format!("{:.2?} | [{:.2?}, {:.2?}, {:.2?}]", total, times[0], median, times[times.len() - 1])
417+
format!(
418+
"{:.2?} | [{:.2?}, {:.2?}, {:.2?}]",
419+
total,
420+
times[0],
421+
median,
422+
times[times.len() - 1]
423+
)
417424
}
418425

419426
fn main() {
@@ -428,28 +435,51 @@ fn main() {
428435
);
429436

430437
const NUM_ITERATIONS: usize = 10;
438+
// let ps = [(5, 10), (10, 20)];
439+
// let ps = [(5, 10), (10, 20), (15, 30), (20, 40), (25, 50), (30, 60), (35, 70), (40, 80), (45, 90), (50, 100), (55, 110), (60, 120), (65, 130), (70, 140)];
440+
let ps = [(350, 700)];
441+
let max = ps.iter().map(|(t, _)| *t).max().unwrap();
442+
let start = Instant::now();
443+
// The signers run OT protocol instances. This is also a one time setup.
444+
let base_ot_outputs = test_utils::ot::do_pairwise_base_ot::<BASE_OT_KEY_SIZE>(
445+
&mut rng,
446+
OTE_PARAMS.num_base_ot(),
447+
max,
448+
(1..=max).into_iter().collect::<BTreeSet<_>>(),
449+
);
450+
println!("Time taken for {} base OT {:.2?}", max, start.elapsed());
451+
println!(
452+
"Uncompressed size of base OT {}",
453+
base_ot_outputs.serialized_size(Compress::No)
454+
);
455+
println!(
456+
"Compressed size of base OT {}",
457+
base_ot_outputs.serialized_size(Compress::Yes)
458+
);
431459

432-
for (threshold_signers, total_signers) in [(5, 10), (10, 20), (15, 30), (20, 40), (25, 50), (30, 60), (35, 70), (40, 80), (45, 90), (50, 100), (55, 110), (60, 120), (65, 130), (70, 140)] {
433-
println!("\nRunning {} iterations for {}-of-{}", NUM_ITERATIONS, threshold_signers, total_signers);
460+
for (threshold_signers, total_signers) in ps {
461+
println!(
462+
"\nRunning {} iterations for {}-of-{}",
463+
NUM_ITERATIONS, threshold_signers, total_signers
464+
);
434465
let all_party_set = (1..=total_signers).into_iter().collect::<BTreeSet<_>>();
435466

436467
// The signers do a keygen. This is a one time setup.
437-
let (sk, sk_shares) =
438-
trusted_party_keygen(&mut rng, threshold_signers, total_signers);
468+
let (sk, sk_shares) = trusted_party_keygen(&mut rng, threshold_signers, total_signers);
439469
let isk_shares = sk_shares
440470
.into_iter()
441471
.map(|s| IssuerSecretKey(s))
442472
.collect::<Vec<_>>();
443473
// Public key created by the trusted party using the secret key directly. In practice, this will be a result of a DKG
444474
let threshold_ipk = IssuerPublicKey::new(&mut rng, &IssuerSecretKey(sk), &params);
445475

446-
// The signers run OT protocol instances. This is also a one time setup.
447-
let base_ot_outputs = test_utils::ot::do_pairwise_base_ot::<BASE_OT_KEY_SIZE>(
448-
&mut rng,
449-
OTE_PARAMS.num_base_ot(),
450-
total_signers,
451-
all_party_set.clone(),
452-
);
476+
// // The signers run OT protocol instances. This is also a one time setup.
477+
// let base_ot_outputs = test_utils::ot::do_pairwise_base_ot::<BASE_OT_KEY_SIZE>(
478+
// &mut rng,
479+
// OTE_PARAMS.num_base_ot(),
480+
// total_signers,
481+
// all_party_set.clone(),
482+
// );
453483

454484
let mut phase1_time = vec![];
455485
let mut phase2_time = vec![];
@@ -492,4 +522,4 @@ fn main() {
492522
println!("Phase2 time: {:?}", timing_info(phase2_time));
493523
println!("Aggregation time: {:?}", timing_info(aggr_time));
494524
}
495-
}*/
525+
}

benches/src/ot.rs

+27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use ark_bls12_381::Bls12_381;
22
use ark_ec::pairing::Pairing;
33
use ark_std::{
4+
cfg_into_iter,
45
collections::{BTreeMap, BTreeSet},
56
rand::prelude::StdRng,
67
UniformRand,
@@ -15,6 +16,9 @@ use oblivious_transfer_protocols::{
1516
Bit, ParticipantId,
1617
};
1718

19+
#[cfg(feature = "parallel")]
20+
use rayon::prelude::*;
21+
1822
pub fn check_base_ot_keys(
1923
choices: &[Bit],
2024
receiver_keys: &ROTReceiverKeys,
@@ -91,26 +95,49 @@ pub fn do_pairwise_base_ot<const KEY_SIZE: u16>(
9195
.unwrap();
9296
challenges.insert((receiver, sender), chal);
9397
}
98+
// let challenges = cfg_into_iter!(receiver_pks).map(|((sender, receiver), pk)| {
99+
// let chal = base_ots[receiver as usize - 1]
100+
// .receive_receiver_pubkey::<KEY_SIZE>(sender, pk)
101+
// .unwrap();
102+
// ((receiver, sender), chal)
103+
// }).collect::<BTreeMap<_, _>>();
94104

95105
for ((sender, receiver), chal) in challenges {
96106
let resp = base_ots[receiver as usize - 1]
97107
.receive_challenges(sender, chal)
98108
.unwrap();
99109
responses.insert((receiver, sender), resp);
100110
}
111+
// let responses = cfg_into_iter!(challenges).map(|((sender, receiver), chal)| {
112+
// let resp = base_ots[receiver as usize - 1]
113+
// .receive_challenges(sender, chal)
114+
// .unwrap();
115+
// ((receiver, sender), resp)
116+
// }).collect::<BTreeMap<_, _>>();
101117

102118
for ((sender, receiver), resp) in responses {
103119
let hk = base_ots[receiver as usize - 1]
104120
.receive_responses(sender, resp)
105121
.unwrap();
106122
hashed_keys.insert((receiver, sender), hk);
107123
}
124+
// let hashed_keys = cfg_into_iter!(responses).map(|((sender, receiver), resp)| {
125+
// let hk = base_ots[receiver as usize - 1]
126+
// .receive_responses(sender, resp)
127+
// .unwrap();
128+
// ((receiver, sender), hk)
129+
// }).collect::<BTreeMap<_, _>>();
108130

109131
for ((sender, receiver), hk) in hashed_keys {
110132
base_ots[receiver as usize - 1]
111133
.receive_hashed_keys(sender, hk)
112134
.unwrap()
113135
}
136+
// cfg_into_iter!(hashed_keys).for_each(|((sender, receiver), hk)| {
137+
// base_ots[receiver as usize - 1]
138+
// .receive_hashed_keys(sender, hk)
139+
// .unwrap()
140+
// });
114141

115142
let mut base_ot_outputs = vec![];
116143
for b in base_ots {

bulletproofs_plus_plus/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
#![allow(non_snake_case)]
33

44
pub mod error;
5+
pub mod range_proof;
56
pub mod range_proof_arbitrary_range;
6-
pub mod rangeproof;
77
pub mod setup;
88
pub mod util;
99
pub mod weighted_norm_linear_argument;
1010

1111
pub mod prelude {
1212
pub use crate::{
1313
error::BulletproofsPlusPlusError,
14+
range_proof::{Proof, Prover},
1415
range_proof_arbitrary_range::ProofArbitraryRange,
15-
rangeproof::{Proof, Prover},
1616
setup::SetupParams,
1717
};
1818
}

0 commit comments

Comments
 (0)