From 097245e25b2b7eb7c1f8e1c7cc3f7767e87faa12 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Mon, 18 Nov 2024 02:22:07 +0100 Subject: [PATCH] add execute_big_calculation --- zkvm/src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index f6da9ce..035204b 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -50,6 +50,7 @@ mod tests { use super::*; use test_methods::{MULTIPLICATION_ELF, MULTIPLICATION_ID}; use test_methods::{SUMMATION_ELF, SUMMATION_ID}; + use test_methods::{BIG_CALCULATION_ELF, BIG_CALCULATION_ID}; #[test] fn prove_simple_sum() { @@ -112,4 +113,24 @@ mod tests { let result = execute(vec![message, message_2], SUMMATION_ELF); assert_eq!(result, message + message_2); } + + #[test] + fn execute_big_calculation() { + let message: u128 = 1; + let message_2: u128 = 2; + + let result = execute(vec![message, message_2], BIG_CALCULATION_ELF); + assert_eq!(result, big_calculation(message, message_2)); + } + + + fn big_calculation(lhs: u128, rhs: u128) -> u128 { + let mut res = 1_u128; + for _ in 0..lhs { + res *= rhs; + res += lhs; + } + + res + } }