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

Function test_oblivious_transfer

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

Source from the content-addressed store, hash-verified

313
314 #[test]
315 fn test_oblivious_transfer() {
316 // test correct inputs
317 let roles_helper = |sender_id: u64, receiver_id: u64| -> Result<()> {
318 let helper_id = PARTIES as u64 - sender_id - receiver_id;
319 let c = simple_context(|g| {
320 let input_type = array_type(vec![2], INT32);
321 let bit_type = array_type(vec![2], BIT);
322
323 let i0 = g.input(input_type.clone())?;
324 let i1 = g.input(input_type.clone())?;
325
326 // Generate a selecting bit known by parties 0 and 2
327 let b = g
328 .input(bit_type.clone())?
329 .nop()?
330 .add_annotation(NodeAnnotation::Send(receiver_id, helper_id))?;
331
332 // Generate a PRF key known to the sender and helper
333 let key_t = array_type(vec![KEY_LENGTH], BIT);
334 let key = g
335 .random(key_t.clone())?
336 .nop()?
337 .add_annotation(NodeAnnotation::Send(helper_id, sender_id))?;
338
339 // Run the OT protocol with party 0 being a receiver and party 1 being a sender.
340 g.custom_op(
341 CustomOperation::new(ObliviousTransfer {
342 sender_id,
343 receiver_id,
344 }),
345 vec![i0, i1, b, key],
346 )
347 })?;
348
349 let instantiated_c = run_instantiation_pass(c)?.context;
350 let inlined_c = inline_operations(
351 instantiated_c,
352 InlineConfig {
353 default_mode: InlineMode::Simple,
354 ..Default::default()
355 },
356 )?;
357
358 let result_class = generate_equivalence_class(
359 inlined_c.clone(),
360 vec![vec![
361 IOStatus::Party(1),
362 IOStatus::Party(1),
363 IOStatus::Party(0),
364 ]],
365 )?;
366
367 let private_class = EquivalenceClasses::Atomic(vec![vec![0], vec![1], vec![2]]);
368 // data shared by the sender and helper
369 let share_r_sh =
370 EquivalenceClasses::Atomic(vec![vec![receiver_id], vec![sender_id, helper_id]]);
371 // data shared by the receiver and helper
372 let share_s_rh =

Callers

nothing calls this directly

Calls 13

simple_contextFunction · 0.85
run_instantiation_passFunction · 0.85
inline_operationsFunction · 0.85
random_evaluateFunction · 0.85
cloneMethod · 0.80
add_annotationMethod · 0.80
array_typeFunction · 0.50
inputMethod · 0.45
nopMethod · 0.45
randomMethod · 0.45
custom_opMethod · 0.45

Tested by

no test coverage detected