Skip to content

Commit

Permalink
comment out everything
Browse files Browse the repository at this point in the history
  • Loading branch information
kevjue committed Feb 9, 2024
1 parent 1f03be8 commit 11795af
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 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());
}

let mut bytes: [u8; 4] = [0; 4];
io::read_hint_slice(&mut bytes);
BabyBear::from_canonical_u32(u32::from_le_bytes(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))
// }

// 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 Expand Up @@ -405,36 +405,36 @@ impl Sub for BabyBear {
// .entry("sub".to_string())
// .or_insert(0) += 1;

#[cfg(target_os = "zkvm")]
{
// unconstrained!
{
let (mut diff, over) = self.value.overflowing_sub(rhs.value);
let corr = if over { P } else { 0 };
diff = diff.wrapping_add(corr);
// #[cfg(target_os = "zkvm")]
// {
// // unconstrained!
// {
// let (mut diff, over) = self.value.overflowing_sub(rhs.value);
// let corr = if over { P } else { 0 };
// diff = diff.wrapping_add(corr);

io::hint_slice(&diff.to_le_bytes());
}
// io::hint_slice(&diff.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);
// BabyBear::from_canonical_u32(u32::from_le_bytes(bytes))
// }

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

#[cfg(not(target_os = "zkvm"))]
{
// #[cfg(not(target_os = "zkvm"))]
// {
let (mut diff, over) = self.value.overflowing_sub(rhs.value);
let corr = if over { P } else { 0 };
diff = diff.wrapping_add(corr);

Self { value: diff }
}
// }
}
}

Expand Down Expand Up @@ -471,33 +471,33 @@ impl Mul for BabyBear {
#[cfg(target_os = "zkvm")]
{
// unconstrained!
{
let long_prod = self.value as u64 * rhs.value as u64;
let ret = Self {
value: monty_reduce(long_prod),
};

io::hint_slice(&ret.as_canonical_u32().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 long_prod = self.value as u64 * rhs.value as u64;
// let ret = Self {
// value: monty_reduce(long_prod),
// };

// io::hint_slice(&ret.as_canonical_u32().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))
}
// if !*in_hash {
// println!("cycle-tracker-end: BabyBear_mul");
// }
// drop(in_hash);
// drop(func_counts);

#[cfg(not(target_os = "zkvm"))]
{
// #[cfg(not(target_os = "zkvm"))]
// {
let long_prod = self.value as u64 * rhs.value as u64;
let ret = Self {
value: monty_reduce(long_prod),
};
ret
}
// }
}
}

Expand Down

0 comments on commit 11795af

Please sign in to comment.