MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / test_simple_share

Function test_simple_share

ciphercore-base/src/mpc/utils.rs:288–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

286
287 #[test]
288 fn test_simple_share() {
289 || -> Result<()> {
290 let data = vec![12, 34, 56];
291 let mut prng = PRNG::new(None)?;
292 let shares = share_vector(&mut prng, &data, UINT32)?;
293 let shares0 = shares[0].to_vector()?;
294 let shares1 = shares[1].to_vector()?;
295 let shares2 = shares[2].to_vector()?;
296 assert_eq!(shares0[0], shares2[0]);
297 assert_eq!(shares0[1], shares1[1]);
298 assert_eq!(shares1[2], shares2[2]);
299 let t = array_type(vec![3], UINT32);
300 let v0 = shares0[0].to_flattened_array_u128(t.clone())?;
301 let v1 = shares1[1].to_flattened_array_u128(t.clone())?;
302 let v2 = shares2[2].to_flattened_array_u128(t.clone())?;
303 let new_data = add_vectors_u128(
304 &add_vectors_u128(&v0, &v1, UINT32.get_modulus())?,
305 &v2,
306 UINT32.get_modulus(),
307 )?;
308 assert_eq!(new_data, data);
309 Ok(())
310 }()
311 .unwrap();
312 }
313
314 #[test]
315 fn test_oblivious_transfer() {

Callers

nothing calls this directly

Calls 7

share_vectorFunction · 0.85
add_vectors_u128Function · 0.85
cloneMethod · 0.80
get_modulusMethod · 0.80
array_typeFunction · 0.50
to_vectorMethod · 0.45

Tested by

no test coverage detected