Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
kevjue committed Feb 9, 2024
1 parent 11795af commit 8c73158
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions baby-bear/src/baby_bear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,40 +340,40 @@ impl Add for BabyBear {
// *func_counts
// .entry("add".to_string())
// .or_insert(0) += 1;
// #[cfg(target_os = "zkvm")]
// {
// // unconstrained!
// {
// let mut sum = self.value + rhs.value;
// let (corr_sum, over) = sum.overflowing_sub(P);
// if !over {
// sum = corr_sum;
// }

// io::hint_slice(&sum.to_le_bytes());
// }
#[cfg(target_os = "zkvm")]
{
// unconstrained!
{
let mut sum = self.value + rhs.value;
let (corr_sum, over) = sum.overflowing_sub(P);
if !over {
sum = corr_sum;
}

io::hint_slice(&sum.to_le_bytes());
}

// let mut bytes: [u8; 4] = [0; 4];
// io::read_hint_slice(&mut bytes);
// BabyBear::from_canonical_u32(u32::from_le_bytes(bytes))
// }
let mut bytes: [u8; 4] = [0; 4];
io::read_hint_slice(&mut bytes);
Sum { value: u32::from_le_bytes(bytes) }
}

// if !*in_hash {
// println!("cycle-tracker-end: BabyBear_add");
// }
// drop(in_hash);
// drop(func_counts);

// #[cfg(not(target_os = "zkvm"))]
// {
#[cfg(not(target_os = "zkvm"))]
{
let mut sum = self.value + rhs.value;
let (corr_sum, over) = sum.overflowing_sub(P);
if !over {
sum = corr_sum;
}

Self { value: sum }
// }
}
}
}

Expand Down

0 comments on commit 8c73158

Please sign in to comment.