Skip to content

Commit

Permalink
🔇 Make log more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
taskooh committed Apr 26, 2024
1 parent 16a6e17 commit e982521
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 14 additions & 9 deletions mpc-algebra/examples/algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,22 @@ fn test_interval_test_half_modulus() {
<<ark_ff::Fp256<ark_bls12_377::FrParameters> as ark_ff::PrimeField>::Params>::MODULUS;
half_modulus.div2();

for _ in 0..5 {
let n = 10;
let timer = start_timer!(|| format!("interval_test_half_modulus test x {}", n));
for _ in 0..n {
let shared = MF::rand(rng);
let timer = start_timer!(|| "interval_test_half_modulus");
let res = shared.interval_test_half_modulus();
assert_eq!(res.reveal(), if shared.reveal().into_repr() < half_modulus {F::one()} else {F::zero()});
end_timer!(timer);
}
end_timer!(timer);
}

fn test_less_than() {
let rng = &mut thread_rng();

for _ in 0..5 {
let timer = start_timer!(|| "less_than test");
let n = 10;
let timer = start_timer!(|| format!("less_than test x {}", n));
for _ in 0..n {
let a = MF::rand(rng);
let b = MF::rand(rng);

Expand All @@ -176,8 +178,8 @@ fn test_less_than() {
println!("res: {:?}", res.reveal());
assert_eq!(res.reveal().is_one(), a.reveal() < b.reveal());
}
end_timer!(timer)
}
end_timer!(timer);
}

fn test_and() {
Expand Down Expand Up @@ -209,7 +211,7 @@ fn test_and() {
}

fn test_or() {
let mut rng = ark_std::test_rng();
let mut rng = thread_rng();

let a00 = vec![MF::zero(), MF::zero()];
let a10 = vec![MF::one(), MF::zero()];
Expand All @@ -226,7 +228,7 @@ fn test_or() {

let res = a.unbounded_fan_in_or();

println!("unbounded or is {:?}", res.reveal());
// println!("unbounded or is {:?}", res.reveal());
if res.reveal().is_zero() {
counter[0] += 1;
} else if res.reveal().is_one() {
Expand All @@ -249,15 +251,18 @@ fn test_equality_zero() {
let res = a.is_zero_shared();
assert!(res.reveal().is_zero());

let n = 10;
let timer = start_timer!(|| format!("is_zero_shared test x {}", n));
// a is random number
for _ in 0..10 {
for _ in 0..n {
let a = MF::rand(&mut rng);

let res = a.is_zero_shared();

assert_eq!(a.reveal().is_zero(), res.reveal().is_one());
assert_eq!(!a.reveal().is_zero(), res.reveal().is_zero());
}
end_timer!(timer);
}

fn test_carries() {
Expand Down
2 changes: 0 additions & 2 deletions mpc-algebra/src/wire/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ impl<F: Field, S: FieldShare<F>> Zero for MpcField<F, S> {

impl<F: PrimeField + SquareRootField, S: FieldShare<F>> EqualityZero for MpcField<F, S> {
fn is_zero_shared(&self) -> Self {
let timer = start_timer!(|| "EqualityZero test");
let res = match self {
MpcField::Public(_) => {
panic!("public is not expected here");
Expand Down Expand Up @@ -685,7 +684,6 @@ impl<F: PrimeField + SquareRootField, S: FieldShare<F>> EqualityZero for MpcFiel
c_prime.unbounded_fan_in_and()
}
};
end_timer!(timer);
res
}
}
Expand Down

0 comments on commit e982521

Please sign in to comment.