Skip to content

Commit

Permalink
constrained
Browse files Browse the repository at this point in the history
  • Loading branch information
kevjue committed Feb 9, 2024
1 parent d99ff8a commit 99fb6ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions baby-bear/src/baby_bear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Add for BabyBear {
// .or_insert(0) += 1;
#[cfg(target_os = "zkvm")]
{
unconstrained!
// unconstrained!
{
let mut sum = self.value + rhs.value;
let (corr_sum, over) = sum.overflowing_sub(P);
Expand Down Expand Up @@ -410,7 +410,7 @@ impl Sub for BabyBear {

#[cfg(target_os = "zkvm")]
{
unconstrained!
// unconstrained!
{
let (mut diff, over) = self.value.overflowing_sub(rhs.value);
let corr = if over { P } else { 0 };
Expand All @@ -424,7 +424,7 @@ impl Sub for BabyBear {

let mut bytes: [u8; 4] = [0; 4];
io::read_hint_slice(&mut bytes);
Self {value: diff}
Self {value: u32::from_le_bytes(bytes)}
}

// if !*in_hash {
Expand Down Expand Up @@ -476,13 +476,13 @@ impl Mul for BabyBear {

#[cfg(target_os = "zkvm")]
{
unconstrained!
// unconstrained!
{
let long_prod = self.value as u64 * rhs.value as u64;
let value = monty_reduce(long_prod);
// unconstrained!
{
io::hint_slice(&value.as_canonical_u32().to_le_bytes());
io::hint_slice(&value.to_le_bytes());
}
}

Expand Down

0 comments on commit 99fb6ba

Please sign in to comment.