-
Notifications
You must be signed in to change notification settings - Fork 2
/
mod.rs
634 lines (556 loc) · 21 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
use single_step_avd::{
SingleStepAVD,
constraints::SingleStepAVDGadget,
};
use ark_crypto_primitives::{
snark::{SNARK},
};
use ark_groth16::{
Groth16,
verifier::prepare_verifying_key,
};
use ark_ff::{
ToConstraintField,
};
use ark_ec:: {
PairingEngine,
};
use ark_ip_proofs::{
tipa::{SRS},
};
use rand::{Rng, CryptoRng};
use digest::Digest as HashDigest;
use std::{
fmt::{Display, Formatter, Result as FmtResult},
marker::PhantomData,
error::Error as ErrorTrait,
};
use crate::{
FullHistoryAVD, Error,
get_checkpoint_epochs,
};
pub mod constraints;
use constraints::{SingleStepProofCircuit, SingleStepProofVerifierInput};
pub mod groth16_aggregation;
use groth16_aggregation::*;
pub trait AggregatedFullHistoryAVDParameters {
const MAX_EPOCH_LOG_2: u8;
fn is_valid() -> Result<bool, Error> {
//TODO: Only supports epoch in u64
if Self::MAX_EPOCH_LOG_2 < 1 || Self::MAX_EPOCH_LOG_2 > 63 {
return Err(Box::new(AggregatedFullHistoryAVDError::MaxEpochSize(Self::MAX_EPOCH_LOG_2)));
}
Ok(true)
}
}
//TODO: Double storing SSAVD_pp (also stored in MerkleTreeAVD) since need for update
pub struct AggregatedFullHistoryAVD<Params, SSAVD, SSAVDGadget, Pairing, FastH>
where
Params: AggregatedFullHistoryAVDParameters,
SSAVD: SingleStepAVD,
SSAVDGadget: SingleStepAVDGadget<SSAVD, Pairing::Fr>,
Pairing: PairingEngine,
FastH: HashDigest,
SSAVD::Digest: ToConstraintField<Pairing::Fr>,
{
ssavd: SSAVD,
proofs: Vec<<Groth16<Pairing> as SNARK<Pairing::Fr>>::Proof>,
aggregated_proofs: Vec<Vec<AggregateDigestProof<Pairing, FastH>>>,
digests: Vec<SSAVD::Digest>,
ssavd_pp: SSAVD::PublicParameters,
groth16_pp: <Groth16<Pairing> as SNARK<Pairing::Fr>>::ProvingKey,
ip_pp: SRS<Pairing>,
_params: PhantomData<Params>,
_ssavd_gadget: PhantomData<SSAVDGadget>,
}
//TODO: Can separate out verification parameters
//TODO: Can add genesis digest as constant to parameters instead of recalculating on verify
//TODO: Optimization: Groth16 and Inner Product public parameters may be shared
pub struct PublicParameters<SSAVD, Pairing>
where
SSAVD: SingleStepAVD,
Pairing: PairingEngine,
SSAVD::Digest: ToConstraintField<Pairing::Fr>,
{
ssavd_pp: SSAVD::PublicParameters,
groth16_pp: <Groth16<Pairing> as SNARK<Pairing::Fr>>::ProvingKey,
ip_pp: SRS<Pairing>,
}
impl<SSAVD, Pairing> Clone for PublicParameters<SSAVD, Pairing>
where
SSAVD: SingleStepAVD,
Pairing: PairingEngine,
SSAVD::Digest: ToConstraintField<Pairing::Fr>,
{
fn clone(&self) -> Self {
Self {
ssavd_pp: self.ssavd_pp.clone(),
groth16_pp: self.groth16_pp.clone(),
ip_pp: self.ip_pp.clone(),
}
}
}
pub enum CheckpointRangeProof<Pairing, FastH>
where
Pairing: PairingEngine,
FastH: HashDigest,
{
Single(<Groth16<Pairing> as SNARK<Pairing::Fr>>::Proof),
Range(AggregateDigestProof<Pairing, FastH>),
}
pub struct AuditProof<SSAVD, Pairing, FastH>
where
SSAVD: SingleStepAVD,
Pairing: PairingEngine,
FastH: HashDigest,
SSAVD::Digest: ToConstraintField<Pairing::Fr>,
{
aggregated_proofs: Vec<CheckpointRangeProof<Pairing, FastH>>,
checkpoint_digests: Vec<SSAVD::Digest>,
}
impl<Params, SSAVD, SSAVDGadget, Pairing, FastH> FullHistoryAVD for
AggregatedFullHistoryAVD<Params, SSAVD, SSAVDGadget, Pairing, FastH>
where
Params: AggregatedFullHistoryAVDParameters,
SSAVD: SingleStepAVD,
SSAVDGadget: SingleStepAVDGadget<SSAVD, Pairing::Fr>,
Pairing: PairingEngine,
FastH: HashDigest,
SSAVD::Digest: ToConstraintField<Pairing::Fr>,
{
type Digest = SSAVD::Digest;
type PublicParameters = PublicParameters<SSAVD, Pairing>;
type LookupProof = SSAVD::LookupProof;
type AuditProof = AuditProof<SSAVD, Pairing, FastH>;
fn setup<R: Rng + CryptoRng>(rng: &mut R) -> Result<Self::PublicParameters, Error> {
let ssavd_pp = SSAVD::setup(rng)?;
let blank_circuit = SingleStepProofCircuit::<SSAVD, SSAVDGadget, Pairing::Fr>::blank(
&ssavd_pp,
);
let (groth16_pp, _) = Groth16::<Pairing>::circuit_specific_setup::<
SingleStepProofCircuit<SSAVD, SSAVDGadget, Pairing::Fr>, _
>(blank_circuit, rng)?;
let ip_pp = Self::setup_inner_product(rng, (1_u64 << (Params::MAX_EPOCH_LOG_2 as u64)) as usize)?;
Ok(PublicParameters {
ssavd_pp,
groth16_pp,
ip_pp,
})
}
fn new<R: Rng + CryptoRng>(rng: &mut R, pp: &Self::PublicParameters) -> Result<Self, Error> {
let ssavd = SSAVD::new(rng, &pp.ssavd_pp)?;
let digests = vec![ssavd.digest()?];
Ok(Self {
ssavd: ssavd,
proofs: Vec::new(),
aggregated_proofs: Vec::new(),
digests: digests,
ssavd_pp: pp.ssavd_pp.clone(),
groth16_pp: pp.groth16_pp.clone(),
ip_pp: pp.ip_pp.clone(),
_params: PhantomData,
_ssavd_gadget: PhantomData,
})
}
fn digest(&self) -> Result<Self::Digest, Error> {
self.ssavd.digest()
}
fn lookup(&mut self, key: &[u8; 32]) -> Result<(Option<(u64, [u8; 32])>, Self::Digest, Self::LookupProof), Error> {
self.ssavd.lookup(key)
}
fn update<R: Rng + CryptoRng>(&mut self, rng: &mut R, key: &[u8; 32], value: &[u8; 32]) -> Result<Self::Digest, Error> {
if self.proofs.len() >= 1 << (Params::MAX_EPOCH_LOG_2 as u64) {
return Err(Box::new(AggregatedFullHistoryAVDError::MaxEpochExceeded));
}
// Compute new step proof
let (d, update) = self.ssavd.update(key, value)?;
self._update(rng, update)?;
Ok(d)
}
fn batch_update<R: Rng + CryptoRng>(&mut self, rng: &mut R, kvs: &Vec<([u8; 32], [u8; 32])>) -> Result<Self::Digest, Error> {
if self.proofs.len() >= 1 << (Params::MAX_EPOCH_LOG_2 as u64) {
return Err(Box::new(AggregatedFullHistoryAVDError::MaxEpochExceeded));
}
// Compute new step proof
let (d, update) = self.ssavd.batch_update(kvs)?;
self._update(rng, update)?;
Ok(d)
}
fn verify_lookup(pp: &Self::PublicParameters, key: &[u8; 32], value: &Option<(u64, [u8; 32])>, digest: &Self::Digest, proof: &Self::LookupProof) -> Result<bool, Error> {
SSAVD::verify_lookup(
&pp.ssavd_pp,
key,
value,
digest,
proof,
)
}
fn audit(
&self,
start_epoch: usize,
end_epoch: usize,
) -> Result<(Self::Digest, Self::AuditProof), Error> {
let (checkpoints, checkpoint_ranges) = get_checkpoint_epochs(start_epoch, end_epoch);
let checkpoint_digests = checkpoints.iter()
.map(|i| self.digests[*i].clone())
.collect::<Vec<_>>();
let range_proofs = checkpoints.iter().zip(&checkpoint_ranges)
.map(|(ckpt, ckpt_level)| {
match ckpt_level {
0 => CheckpointRangeProof::Single(self.proofs[*ckpt].clone()),
_ => CheckpointRangeProof::Range(self.aggregated_proofs[ckpt_level-1][ckpt >> ckpt_level].clone()),
}
}).collect::<Vec<_>>();
Ok((
self.digest()?,
AuditProof {
aggregated_proofs: range_proofs,
checkpoint_digests: checkpoint_digests,
},
))
}
fn verify_audit(
pp: &Self::PublicParameters,
start_epoch: usize,
end_epoch: usize,
_digest: &Self::Digest,
proof: &Self::AuditProof,
) -> Result<bool, Error> {
Ok(proof.aggregated_proofs.iter()
.zip(get_checkpoint_epochs(start_epoch, end_epoch).1)
.enumerate()
.map(|(i, (range_proof, ckpt_level))| {
match range_proof {
CheckpointRangeProof::Single(groth_proof) =>
Groth16::<Pairing>::verify_with_processed_vk(
&prepare_verifying_key(&pp.groth16_pp.vk),
&SingleStepProofVerifierInput::<SSAVD>{
prev_digest: proof.checkpoint_digests[i].clone(),
new_digest: proof.checkpoint_digests[i+1].clone(),
}.to_field_elements().unwrap(),
groth_proof,
).unwrap(),
CheckpointRangeProof::Range(agg_proof) =>
Self::verify_aggregate_proof(
&pp.ip_pp.get_verifier_key(),
&pp.groth16_pp.vk,
&proof.checkpoint_digests[i].clone(),
&proof.checkpoint_digests[i+1].clone(),
&agg_proof,
1 << ckpt_level,
).unwrap(),
}
}).all(|b| b)
)
}
}
impl<Params, SSAVD, SSAVDGadget, Pairing, FastH>
AggregatedFullHistoryAVD<Params, SSAVD, SSAVDGadget, Pairing, FastH>
where
Params: AggregatedFullHistoryAVDParameters,
SSAVD: SingleStepAVD,
SSAVDGadget: SingleStepAVDGadget<SSAVD, Pairing::Fr>,
Pairing: PairingEngine,
FastH: HashDigest,
SSAVD::Digest: ToConstraintField<Pairing::Fr>,
{
fn _update<R: Rng + CryptoRng>(&mut self, rng: &mut R, update: SSAVD::UpdateProof)
-> Result<(), Error> {
let prev_digest = self.digests.last().unwrap().clone();
let new_digest = self.digest()?;
self.digests.push(new_digest.clone());
let groth16_proof = Groth16::<Pairing>::prove(
&self.groth16_pp,
SingleStepProofCircuit::<SSAVD, SSAVDGadget, Pairing::Fr>::new(
&self.ssavd_pp, update,
SingleStepProofVerifierInput {
prev_digest: prev_digest,
new_digest: new_digest,
},
),
rng,
)?;
self.proofs.push(groth16_proof);
// Compute aggregated proofs if necessary
let new_epoch = self.proofs.len();
let mut aggr_level = new_epoch.trailing_zeros() as usize;
if aggr_level > self.aggregated_proofs.len() {
self.aggregated_proofs.push(vec![]);
}
while aggr_level > 0 { // Aggregate
let start_epoch = new_epoch - (1 << aggr_level);
let proof = self.aggregate_proofs(
start_epoch,
new_epoch,
)?;
self.aggregated_proofs[aggr_level - 1].push(proof);
aggr_level -= 1;
}
Ok(())
}
}
#[derive(Debug)]
pub enum AggregatedFullHistoryAVDError {
MaxEpochSize(u8),
MaxEpochExceeded,
Verification,
}
impl ErrorTrait for AggregatedFullHistoryAVDError {
fn source(self: &Self) -> Option<&(dyn ErrorTrait + 'static)> {
None
}
}
impl Display for AggregatedFullHistoryAVDError {
fn fmt(self: &Self, f: &mut Formatter<'_>) -> FmtResult {
let msg = match self {
AggregatedFullHistoryAVDError::MaxEpochSize(h) => format!("max num epochs is invalid: {}", h),
AggregatedFullHistoryAVDError::MaxEpochExceeded => "max num epochs exceeded".to_string(),
AggregatedFullHistoryAVDError::Verification => "unexpected proof format for verification".to_string(),
};
write!(f, "{}", msg)
}
}
#[cfg(test)]
mod tests {
use super::*;
use ark_ed_on_bls12_381::{EdwardsProjective as JubJub, Fq, constraints::EdwardsVar};
use ark_bls12_381::Bls12_381;
use rand::{rngs::StdRng, SeedableRng};
use ark_crypto_primitives::{
crh::pedersen::{constraints::CRHGadget, CRH, Window},
};
use blake2::Blake2b;
use single_step_avd::{
merkle_tree_avd::{
MerkleTreeAVDParameters,
MerkleTreeAVD,
constraints::MerkleTreeAVDGadget,
},
rsa_avd::{
RsaAVD, constraints::RsaAVDGadget,
}
};
use crypto_primitives::sparse_merkle_tree::{MerkleDepth, MerkleTreeParameters};
use rsa::{
bignat::constraints::BigNatCircuitParams,
kvac::RsaKVACParams,
poker::{PoKERParams},
hog::{RsaGroupParams},
hash::{
HasherFromDigest, PoseidonHasher, constraints::PoseidonHasherGadget,
},
};
use std::time::Instant;
#[derive(Clone)]
pub struct Window4x256;
impl Window for Window4x256 {
const WINDOW_SIZE: usize = 4;
const NUM_WINDOWS: usize = 256;
}
type H = CRH<JubJub, Window4x256>;
type HG = CRHGadget<JubJub, EdwardsVar, Window4x256>;
#[derive(Clone)]
pub struct MerkleTreeTestParameters;
impl MerkleTreeParameters for MerkleTreeTestParameters {
const DEPTH: MerkleDepth = 4;
type H = H;
}
#[derive(Clone)]
pub struct MerkleTreeAVDTestParameters;
impl MerkleTreeAVDParameters for MerkleTreeAVDTestParameters {
const MAX_UPDATE_BATCH_SIZE: u64 = 3;
const MAX_OPEN_ADDRESSING_PROBES: u8 = 2;
type MerkleTreeParameters = MerkleTreeTestParameters;
}
type TestMerkleTreeAVD = MerkleTreeAVD<MerkleTreeAVDTestParameters>;
type TestMerkleTreeAVDGadget = MerkleTreeAVDGadget<MerkleTreeAVDTestParameters, HG, Fq>;
#[derive(Clone)]
pub struct AggregatedFHAVDTestParameters;
impl AggregatedFullHistoryAVDParameters for AggregatedFHAVDTestParameters {
const MAX_EPOCH_LOG_2: u8 = 8;
}
type TestAggregatedFHAVD = AggregatedFullHistoryAVD<
AggregatedFHAVDTestParameters,
TestMerkleTreeAVD,
TestMerkleTreeAVDGadget,
Bls12_381,
Blake2b,
>;
// Parameters for RSA AVD
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct TestRsa64Params;
impl RsaGroupParams for TestRsa64Params {
const RAW_G: usize = 2;
const RAW_M: &'static str = "17839761582542106619";
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct BigNatTestParams;
impl BigNatCircuitParams for BigNatTestParams {
const LIMB_WIDTH: usize = 32;
const N_LIMBS: usize = 2;
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct TestPokerParams;
impl PoKERParams for TestPokerParams {
const HASH_TO_PRIME_ENTROPY: usize = 32;
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct TestKVACParams;
impl RsaKVACParams for TestKVACParams {
const KEY_LEN: usize = 64;
const VALUE_LEN: usize = 64;
const PRIME_LEN: usize = 72;
type RsaGroupParams = TestRsa64Params;
type PoKERParams = TestPokerParams;
}
pub type PoseidonH = PoseidonHasher<Fq>;
pub type PoseidonHG = PoseidonHasherGadget<Fq>;
pub type TestRsaAVD = RsaAVD<
TestKVACParams,
HasherFromDigest<Fq, blake3::Hasher>,
PoseidonH,
BigNatTestParams,
>;
pub type TestRsaAVDGadget = RsaAVDGadget<
Fq,
TestKVACParams,
HasherFromDigest<Fq, blake3::Hasher>,
PoseidonH,
PoseidonHG,
BigNatTestParams,
>;
type TestRsaAggregatedFHAVD = AggregatedFullHistoryAVD<
AggregatedFHAVDTestParameters,
TestRsaAVD,
TestRsaAVDGadget,
Bls12_381,
Blake2b,
>;
#[test]
#[ignore] // Expensive test, run with ``cargo test mt_update_and_verify_aggregated_full_history_test --release -- --ignored --nocapture``
fn mt_update_and_verify_aggregated_full_history_test() {
let mut rng = StdRng::seed_from_u64(0_u64);
let start = Instant::now();
let pp = TestAggregatedFHAVD::setup(&mut rng).unwrap();
let mut avd: TestAggregatedFHAVD = TestAggregatedFHAVD::new(&mut rng, &pp).unwrap();
let bench = start.elapsed().as_secs();
println!("\t setup time: {} s", bench);
let epoch1_update = &vec![
([1_u8; 32], [2_u8; 32]),
([11_u8; 32], [12_u8; 32]),
([21_u8; 32], [22_u8; 32]),
];
let epoch2_update = &vec![
([1_u8; 32], [3_u8; 32]),
([11_u8; 32], [13_u8; 32]),
([21_u8; 32], [23_u8; 32]),
];
let epoch3_update = &vec![
([1_u8; 32], [4_u8; 32]),
([11_u8; 32], [14_u8; 32]),
([21_u8; 32], [24_u8; 32]),
];
let epoch4_update = &vec![
([1_u8; 32], [5_u8; 32]),
([11_u8; 32], [15_u8; 32]),
([31_u8; 32], [35_u8; 32]),
];
let epoch5_update = &vec![
([1_u8; 32], [6_u8; 32]),
([11_u8; 32], [16_u8; 32]),
([31_u8; 32], [36_u8; 32]),
];
let start = Instant::now();
let d1 = avd.batch_update(&mut rng, &epoch1_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 1 proving time: {} s", bench);
let (_, audit_proof) = avd.audit(0, 1).unwrap();
let verify_audit = TestAggregatedFHAVD::verify_audit(&pp, 0, 1, &d1, &audit_proof).unwrap();
assert!(verify_audit);
let start = Instant::now();
let _d2 = avd.batch_update(&mut rng, &epoch2_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 2 proving time: {} s", bench);
let start = Instant::now();
let _d3 = avd.batch_update(&mut rng, &epoch3_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 3 proving time: {} s", bench);
let start = Instant::now();
let _d4 = avd.batch_update(&mut rng, &epoch4_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 4 proving time: {} s", bench);
let start = Instant::now();
let d5 = avd.batch_update(&mut rng, &epoch5_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 5 proving time: {} s", bench);
let (_, audit_proof) = avd.audit(2, 5).unwrap();
let verify_audit = TestAggregatedFHAVD::verify_audit(&pp, 2, 5, &d5, &audit_proof).unwrap();
assert!(verify_audit);
}
#[test]
#[ignore] // Expensive test, run with ``cargo test rsa_update_and_verify_aggregated_full_history_test --release -- --ignored --nocapture``
fn rsa_update_and_verify_aggregated_full_history_test() {
let mut rng = StdRng::seed_from_u64(0_u64);
let start = Instant::now();
let pp = TestRsaAggregatedFHAVD::setup(&mut rng).unwrap();
let mut avd = TestRsaAggregatedFHAVD::new(&mut rng, &pp).unwrap();
let bench = start.elapsed().as_secs();
println!("\t setup time: {} s", bench);
fn u8_to_array(n: u8) -> [u8; 32] {
let mut arr = [0_u8; 32];
arr[31] = n;
arr
}
let epoch1_update = &vec![
(u8_to_array(1), u8_to_array(2)),
(u8_to_array(11), u8_to_array(12)),
(u8_to_array(21), u8_to_array(22)),
];
let epoch2_update = &vec![
(u8_to_array(1), u8_to_array(3)),
(u8_to_array(11), u8_to_array(13)),
(u8_to_array(21), u8_to_array(23)),
];
let epoch3_update = &vec![
(u8_to_array(1), u8_to_array(4)),
(u8_to_array(11), u8_to_array(14)),
(u8_to_array(21), u8_to_array(24)),
];
let epoch4_update = &vec![
(u8_to_array(1), u8_to_array(5)),
(u8_to_array(11), u8_to_array(15)),
(u8_to_array(31), u8_to_array(35)),
];
let epoch5_update = &vec![
(u8_to_array(1), u8_to_array(6)),
(u8_to_array(11), u8_to_array(16)),
(u8_to_array(31), u8_to_array(36)),
];
let start = Instant::now();
let d1 = avd.batch_update(&mut rng, &epoch1_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 1 proving time: {} s", bench);
let (_, audit_proof) = avd.audit(0, 1).unwrap();
let verify_audit = TestRsaAggregatedFHAVD::verify_audit(&pp, 0, 1, &d1, &audit_proof).unwrap();
assert!(verify_audit);
let start = Instant::now();
let _d2 = avd.batch_update(&mut rng, &epoch2_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 2 proving time: {} s", bench);
let start = Instant::now();
let _d3 = avd.batch_update(&mut rng, &epoch3_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 3 proving time: {} s", bench);
let start = Instant::now();
let _d4 = avd.batch_update(&mut rng, &epoch4_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 4 proving time: {} s", bench);
let start = Instant::now();
let d5 = avd.batch_update(&mut rng, &epoch5_update).unwrap();
let bench = start.elapsed().as_secs();
println!("\t epoch 5 proving time: {} s", bench);
let (_, audit_proof) = avd.audit(1, 5).unwrap();
let verify_audit = TestRsaAggregatedFHAVD::verify_audit(&pp, 1, 5, &d5, &audit_proof).unwrap();
assert!(verify_audit);
}
}