MCPcopy Create free account
hub / github.com/docknetwork/crypto / check_compression

Function check_compression

compressed_sigma/src/compressed_linear_form.rs:434–504  ·  view source on GitHub ↗
(size: u32)

Source from the content-addressed store, hash-verified

432 #[test]
433 fn compression() {
434 fn check_compression(size: u32) {
435 let mut rng = StdRng::seed_from_u64(0u64);
436 let mut linear_form = TestLinearForm {
437 constants: (0..size).map(|_| Fr::rand(&mut rng)).collect::<Vec<_>>(),
438 };
439 linear_form.constants.push(Fr::zero());
440
441 let x = (0..size).map(|_| Fr::rand(&mut rng)).collect::<Vec<_>>();
442 let gamma = Fr::rand(&mut rng);
443 let g = (0..size)
444 .map(|_| <Bls12_381 as Pairing>::G1::rand(&mut rng).into_affine())
445 .collect::<Vec<_>>();
446 let h = <Bls12_381 as Pairing>::G1::rand(&mut rng).into_affine();
447 let k = <Bls12_381 as Pairing>::G1::rand(&mut rng).into_affine();
448
449 let P = (<Bls12_381 as Pairing>::G1::msm_unchecked(&g, &x)
450 + h.mul_bigint(gamma.into_bigint()))
451 .into_affine();
452 let y = linear_form.eval(&x);
453
454 let rand_comm = RandomCommitment::new(&mut rng, &g, &h, &linear_form, None).unwrap();
455
456 let c_0 = Fr::rand(&mut rng);
457 let c_1 = Fr::rand(&mut rng);
458
459 let response = rand_comm
460 .response::<Blake2b512, _>(&g, &h, &k, &linear_form, &x, &gamma, &c_0, &c_1)
461 .unwrap();
462
463 let start = Instant::now();
464 response
465 .is_valid_recursive::<Blake2b512, _>(
466 &g,
467 &h,
468 &k,
469 &P,
470 &y,
471 &linear_form,
472 &rand_comm.A_hat,
473 &rand_comm.t,
474 &c_0,
475 &c_1,
476 )
477 .unwrap();
478 println!(
479 "Recursive verification for compressed linear form of size {} takes: {:?}",
480 size,
481 start.elapsed()
482 );
483
484 let start = Instant::now();
485 response
486 .is_valid::<Blake2b512, _>(
487 &g,
488 &h,
489 &k,
490 &P,
491 &y,

Callers 1

compressionFunction · 0.70

Calls 3

randFunction · 0.85
mapMethod · 0.80
evalMethod · 0.45

Tested by 1

compressionFunction · 0.56