Skip to content

Commit 4ae121a

Browse files
committed
Add benchmark for SyRA and some docs
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent 4c23fa2 commit 4ae121a

File tree

32 files changed

+1067
-396
lines changed

32 files changed

+1067
-396
lines changed

bbs_plus/Cargo.toml

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[package]
22
name = "bbs_plus"
3-
version = "0.22.0"
3+
version = "0.23.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
77
repository.workspace = true
8-
description = "BBS and BBS+ signatures and protocols for proof of knowledge of signature"
8+
description = "BBS, BBS+, threshold BBS+ signatures and protocols for proof of knowledge of signature"
9+
keywords = ["BBS", "BBS-plus", "threshold-BBS", "threshold-BBS-plus"]
910

1011
[lib]
1112
doctest = false
@@ -22,10 +23,10 @@ itertools.workspace = true
2223
serde.workspace = true
2324
serde_with.workspace = true
2425
zeroize.workspace = true
25-
schnorr_pok = { version = "0.20.0", default-features = false, path = "../schnorr_pok" }
26-
dock_crypto_utils = { version = "0.20.0", default-features = false, path = "../utils" }
27-
oblivious_transfer_protocols = { version = "0.9.0", default-features = false, path = "../oblivious_transfer" }
28-
secret_sharing_and_dkg = { version = "0.13.0", default-features = false, path = "../secret_sharing_and_dkg" }
26+
schnorr_pok = { version = "0.21.0", default-features = false, path = "../schnorr_pok" }
27+
dock_crypto_utils = { version = "0.21.0", default-features = false, path = "../utils" }
28+
oblivious_transfer_protocols = { version = "0.10.0", default-features = false, path = "../oblivious_transfer" }
29+
secret_sharing_and_dkg = { version = "0.14.0", default-features = false, path = "../secret_sharing_and_dkg" }
2930

3031
[dev-dependencies]
3132
blake2.workspace = true

benches/Cargo.toml

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ license.workspace = true
77
publish = false
88

99
[dependencies]
10-
bbs_plus = { default-features = false, path = "../bbs_plus" }
11-
schnorr_pok = { default-features = false, path = "../schnorr_pok" }
12-
vb_accumulator = { default-features = false, path = "../vb_accumulator" }
13-
test_utils = { default-features = false, path = "../test_utils" }
1410
ark-ff.workspace = true
1511
ark-ec.workspace = true
1612
ark-std.workspace = true
@@ -19,10 +15,16 @@ serde.workspace = true
1915
serde_with.workspace = true
2016
blake2 = { version = "0.10", default-features = false }
2117
itertools.workspace = true
18+
zeroize.workspace = true
19+
bbs_plus = { default-features = false, path = "../bbs_plus" }
20+
schnorr_pok = { default-features = false, path = "../schnorr_pok" }
21+
vb_accumulator = { default-features = false, path = "../vb_accumulator" }
2222
coconut-crypto = { default-features = false, path = "../coconut" }
2323
oblivious_transfer_protocols = { default-features = false, path = "../oblivious_transfer" }
2424
dock_crypto_utils = { default-features = false, path = "../utils" }
25-
zeroize.workspace = true
25+
secret_sharing_and_dkg = { default-features = false, path = "../secret_sharing_and_dkg" }
26+
syra = { default-features = false, path = "../syra" }
27+
test_utils = { default-features = false, path = "../test_utils" }
2628

2729
[dev-dependencies]
2830
criterion = "0.4.0"
@@ -86,4 +88,9 @@ harness = false
8688
[[bench]]
8789
name = "dkls19_batch_mul_2p"
8890
path = "benches/dkls19_batch_mul_2p.rs"
91+
harness = false
92+
93+
[[bench]]
94+
name = "syra"
95+
path = "benches/syra.rs"
8996
harness = false

benches/README.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,31 @@ For universal accumulator
3535

3636
For witness update (both using and without secret key)
3737

38-
`cargo bench --bench=accum_witness_updates`
38+
`cargo bench --bench=accum_witness_updates`
39+
40+
## PS signatures
41+
To run benchmarks for signing and verifying (both groups G1 and G2), run
42+
43+
`cargo bench --bench=ps_signature`
44+
45+
For proof of knowledge (signature in G1 only)
46+
47+
`cargo bench --bench=ps_proof`
48+
49+
## Oblivious transfer and multiplication based on it
50+
51+
For KOS OT extension
52+
53+
`cargo bench --bench=kos_ote`
54+
55+
For 2-party batch multiplication
56+
57+
`cargo bench --bench=dkls19_batch_mul_2p`
58+
59+
## SyRA
60+
61+
`cargo bench --bench=syra`
62+
63+
Since threshold issuance benchmarks can take long, a reduced sample size can be tried like of 10.
64+
65+
`cargo bench --bench=syra -- --sample-size=10`

benches/benches/dkls19_batch_mul_2p.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,30 @@ fn batch_multiplication(c: &mut Criterion) {
4848

4949
c.bench_function(format!("Party1 init {}", otc).as_str(), |b| {
5050
b.iter(|| {
51-
Party1::new::<StdRng>(
51+
let p = Party1::new::<StdRng>(
5252
&mut rng,
5353
black_box(alpha.clone()),
5454
black_box(base_ot_choices.clone()),
5555
black_box(base_ot_receiver_keys.clone()),
5656
black_box(ote_params),
5757
)
58-
.unwrap()
58+
.unwrap();
59+
black_box(p)
5960
})
6061
});
6162

6263
c.bench_function(format!("Party2 init {}", otc).as_str(), |b| {
6364
b.iter(|| {
64-
Party2::new(
65+
let p = Party2::new(
6566
&mut rng,
6667
black_box(beta.clone()),
6768
black_box(base_ot_sender_keys.clone()),
68-
&mut party2_transcript,
69+
&mut party2_transcript.clone(),
6970
black_box(ote_params),
7071
&gadget_vector,
7172
)
72-
.unwrap()
73+
.unwrap();
74+
black_box(p)
7375
})
7476
});
7577

@@ -94,16 +96,17 @@ fn batch_multiplication(c: &mut Criterion) {
9496

9597
c.bench_function(format!("Party1 creates shares for {}", otc).as_str(), |b| {
9698
b.iter(|| {
97-
party1
99+
let m = party1
98100
.clone()
99101
.receive::<Blake2b512>(
100102
black_box(U.clone()),
101103
black_box(kos_rlc.clone()),
102104
black_box(gamma_b.clone()),
103-
&mut party1_transcript,
105+
&mut party1_transcript.clone(),
104106
&gadget_vector,
105107
)
106-
.unwrap()
108+
.unwrap();
109+
black_box(m)
107110
})
108111
});
109112

@@ -113,18 +116,30 @@ fn batch_multiplication(c: &mut Criterion) {
113116

114117
c.bench_function(format!("Party2 creates shares for {}", otc).as_str(), |b| {
115118
b.iter(|| {
116-
party2
119+
let m = party2
117120
.clone()
118121
.receive::<Blake2b512>(
119122
black_box(tau.clone()),
120123
black_box(rlc.clone()),
121124
black_box(gamma_a.clone()),
122-
&mut party2_transcript,
125+
&mut party2_transcript.clone(),
123126
&gadget_vector,
124127
)
125-
.unwrap()
128+
.unwrap();
129+
black_box(m)
126130
})
127131
});
132+
133+
party2
134+
.clone()
135+
.receive::<Blake2b512>(
136+
tau.clone(),
137+
rlc.clone(),
138+
gamma_a.clone(),
139+
&mut party2_transcript,
140+
&gadget_vector,
141+
)
142+
.unwrap();
128143
}
129144
}
130145

benches/benches/kos_ote.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ fn kos_ote(c: &mut Criterion) {
5454
format!("OT extension receiver setup {}", otc).as_str(),
5555
|b| {
5656
b.iter(|| {
57-
OTExtensionReceiverSetup::new::<_, SSP>(
57+
let r = OTExtensionReceiverSetup::new::<_, SSP>(
5858
&mut rng,
5959
black_box(ote_config),
6060
black_box(ot_ext_choices.clone()),
6161
black_box(base_ot_sender_keys.clone()),
6262
)
6363
.unwrap();
64+
black_box(r)
6465
})
6566
},
6667
);
@@ -81,14 +82,15 @@ fn kos_ote(c: &mut Criterion) {
8182
format!("OT extension receiver setup {}", otc).as_str(),
8283
|b| {
8384
b.iter(|| {
84-
OTExtensionSenderSetup::new::<SSP>(
85+
let r = OTExtensionSenderSetup::new::<SSP>(
8586
black_box(ote_config),
8687
black_box(u.clone()),
8788
black_box(rlc.clone()),
8889
black_box(base_ot_choices.clone()),
8990
black_box(base_ot_receiver_keys.clone()),
9091
)
91-
.unwrap()
92+
.unwrap();
93+
black_box(r)
9294
})
9395
},
9496
);
@@ -104,10 +106,11 @@ fn kos_ote(c: &mut Criterion) {
104106

105107
c.bench_function(format!("Encrypt chosen messages {}", otc).as_str(), |b| {
106108
b.iter(|| {
107-
ext_sender_setup
109+
let r = ext_sender_setup
108110
.clone()
109111
.encrypt(black_box(messages.clone()), black_box(message_size as u32))
110-
.unwrap()
112+
.unwrap();
113+
black_box(r)
111114
})
112115
});
113116

@@ -117,13 +120,14 @@ fn kos_ote(c: &mut Criterion) {
117120

118121
c.bench_function(format!("Decrypt chosen messages {}", otc).as_str(), |b| {
119122
b.iter(|| {
120-
ext_receiver_setup
123+
let r = ext_receiver_setup
121124
.clone()
122125
.decrypt(
123126
black_box(encryptions.clone()),
124127
black_box(message_size as u32),
125128
)
126-
.unwrap()
129+
.unwrap();
130+
black_box(r)
127131
})
128132
});
129133

@@ -133,9 +137,10 @@ fn kos_ote(c: &mut Criterion) {
133137

134138
c.bench_function(format!("Encrypt correlations {}", otc).as_str(), |b| {
135139
b.iter(|| {
136-
ext_sender_setup
140+
let r = ext_sender_setup
137141
.transfer::<Fr, Blake2b512>(alpha.clone())
138-
.unwrap()
142+
.unwrap();
143+
black_box(r)
139144
})
140145
});
141146

@@ -145,9 +150,10 @@ fn kos_ote(c: &mut Criterion) {
145150

146151
c.bench_function(format!("Decrypt correlations {}", otc).as_str(), |b| {
147152
b.iter(|| {
148-
ext_receiver_setup
153+
let r = ext_receiver_setup
149154
.receive::<Fr, Blake2b512>(black_box(tau.clone()))
150-
.unwrap()
155+
.unwrap();
156+
black_box(r)
151157
})
152158
});
153159
}

0 commit comments

Comments
 (0)