openvm_ecc_circuit/weierstrass_chip/
add_ne.rsuse std::{cell::RefCell, rc::Rc};
use openvm_circuit_primitives::var_range::VariableRangeCheckerBus;
use openvm_mod_circuit_builder::{ExprBuilder, ExprBuilderConfig, FieldExpr};
pub fn ec_add_ne_expr(
config: ExprBuilderConfig, range_bus: VariableRangeCheckerBus,
) -> FieldExpr {
config.check_valid();
let builder = ExprBuilder::new(config, range_bus.range_max_bits);
let builder = Rc::new(RefCell::new(builder));
let x1 = ExprBuilder::new_input(builder.clone());
let y1 = ExprBuilder::new_input(builder.clone());
let x2 = ExprBuilder::new_input(builder.clone());
let y2 = ExprBuilder::new_input(builder.clone());
let mut lambda = (y2 - y1.clone()) / (x2.clone() - x1.clone());
let mut x3 = lambda.square() - x1.clone() - x2;
x3.save_output();
let mut y3 = lambda * (x1 - x3.clone()) - y1;
y3.save_output();
let builder = builder.borrow().clone();
FieldExpr::new(builder, range_bus, true)
}