Skip to content

Commit

Permalink
Impl eval_circuit hint
Browse files Browse the repository at this point in the history
  • Loading branch information
notlesh committed Sep 9, 2024
1 parent 40ebe36 commit e2198f0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions vm/src/hint_processor/cairo_1_hint_processor/hint_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ impl Cairo1HintProcessor {
t_or_k0,
t_or_k1,
),
Hint::Core(CoreHintBase::Core(CoreHint::EvalCircuit { n_add_mods, add_mod_builtin, n_mul_mods, mul_mod_builtin } )) => {
self.eval_circuit(vm, n_add_mods, add_mod_builtin, n_mul_mods, mul_mod_builtin)
},
Hint::Starknet(StarknetHint::Cheatcode { selector, .. }) => {
let selector = &selector.value.to_bytes_be().1;
let selector = crate::stdlib::str::from_utf8(selector).map_err(|_| {
Expand Down Expand Up @@ -1192,6 +1195,33 @@ impl Cairo1HintProcessor {
}
Ok(())
}

#[allow(clippy::too_many_arguments)]
fn eval_circuit(
&self,
vm: &mut VirtualMachine,
n_add_mods: &ResOperand,
add_mod_builtin: &ResOperand,
n_mul_mods: &ResOperand,
mul_mod_builtin: &ResOperand,
) -> Result<(), HintError> {
let n_add_mods: usize = get_val(vm, n_add_mods)?
.to_bigint()
.try_into()
.map_err(|_| HintError::BigintToU32Fail)?;
let add_mod_builtin = as_relocatable(vm, add_mod_builtin)?;
let n_mul_mods: usize = get_val(vm, n_mul_mods)?
.to_bigint()
.try_into()
.map_err(|_| HintError::BigintToU32Fail)?;
let mul_mod_builtin = as_relocatable(vm, mul_mod_builtin)?;

vm.mod_builtin_fill_memory(
Some((add_mod_builtin, n_add_mods)),
Some((mul_mod_builtin, n_mul_mods)),
None,
).map_err(HintError::from)
}
}

impl HintProcessorLogic for Cairo1HintProcessor {
Expand Down

0 comments on commit e2198f0

Please sign in to comment.