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

Function add_with_overflow_helper

ciphercore-base/src/ops/adder.rs:396–415  ·  view source on GitHub ↗
(first: u64, second: u64, st: ScalarType)

Source from the content-addressed store, hash-verified

394 }
395
396 fn add_with_overflow_helper(first: u64, second: u64, st: ScalarType) -> Result<(u64, u64)> {
397 let bits = st.size_in_bits();
398 let c = simple_context(|g| {
399 let i1 = g.input(array_type(vec![bits], BIT))?;
400 let i2 = g.input(array_type(vec![bits], BIT))?;
401 g.custom_op(
402 CustomOperation::new(BinaryAdd { overflow_bit: true }),
403 vec![i1, i2],
404 )
405 })?;
406 let mapped_c = run_instantiation_pass(c)?;
407 let input0 = Value::from_scalar(first, st)?;
408 let input1 = Value::from_scalar(second, st)?;
409 let results = random_evaluate(
410 mapped_c.get_context().get_main_graph()?,
411 vec![input0, input1],
412 )?
413 .to_vector()?;
414 Ok((results[0].to_u64(st)?, results[1].to_u64(BIT)?))
415 }
416
417 #[test]
418 fn test_add_with_overflow_bit() -> Result<()> {

Callers 1

Calls 11

simple_contextFunction · 0.85
run_instantiation_passFunction · 0.85
random_evaluateFunction · 0.85
array_typeFunction · 0.50
size_in_bitsMethod · 0.45
inputMethod · 0.45
custom_opMethod · 0.45
to_vectorMethod · 0.45
get_main_graphMethod · 0.45
get_contextMethod · 0.45
to_u64Method · 0.45

Tested by 1