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

Function batch_commitment_verification

saver/src/encryption.rs:1181–1222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1179
1180 #[test]
1181 fn batch_commitment_verification() {
1182 fn check(chunk_bit_size: u8, count: u8) {
1183 let mut rng = StdRng::seed_from_u64(0u64);
1184 let (gens, g_i, _, ek, _) = enc_setup(chunk_bit_size, &mut rng);
1185
1186 let mut cts = vec![];
1187
1188 let mut total_ver_com = Duration::default();
1189
1190 for _ in 0..count {
1191 let m = Fr::rand(&mut rng);
1192 let (ct, _) = Encryption::encrypt(&mut rng, &m, &ek, &g_i, chunk_bit_size).unwrap();
1193
1194 let start = Instant::now();
1195 ct.verify_commitment(ek.clone(), gens.clone()).unwrap();
1196 total_ver_com += start.elapsed();
1197
1198 cts.push(ct);
1199 }
1200
1201 let r = Fr::rand(&mut rng);
1202 let mut r_powers = vec![Fr::one(); count as usize];
1203 for i in 1..count as usize {
1204 r_powers[i] = r_powers[i - 1] * &r;
1205 }
1206
1207 let start = Instant::now();
1208 Encryption::verify_commitments_in_batch(&cts, &r_powers, ek.clone(), gens).unwrap();
1209 let t = start.elapsed();
1210
1211 println!(
1212 "Time taken for {} iterations and {}-bit chunk size:",
1213 count, chunk_bit_size
1214 );
1215 println!("Verifying commitment {:?}", total_ver_com);
1216 println!("Verifying commitments in batch {:?}", t);
1217 }
1218
1219 check(4, 10);
1220 check(8, 10);
1221 check(16, 10);
1222 }
1223}

Callers

nothing calls this directly

Calls 1

checkFunction · 0.70

Tested by

no test coverage detected