Address review comments

This commit is contained in:
therealyingtong 2021-04-09 21:01:26 +08:00
parent 17b66e1c6a
commit ce6e59bdb8
4 changed files with 56 additions and 50 deletions

View File

@ -240,11 +240,11 @@ impl<C: CurveAffine> FixedBase<C> for OrchardFixedBase<C> {
let z_for_single_y = |y: C::Base, z: u64| {
let sum_y_is_square: bool = (y + C::Base::from_u64(z)).sqrt().is_some().into();
let sum_neg_y_is_square: bool = (-y + C::Base::from_u64(z)).sqrt().is_some().into();
(sum_y_is_square && !sum_neg_y_is_square) as usize
sum_y_is_square && !sum_neg_y_is_square
};
for z in 0..(1000 * (1 << (2 * H))) {
if ys.iter().map(|y| z_for_single_y(*y, z)).sum::<usize>() == H {
if ys.iter().all(|y| z_for_single_y(*y, z)) {
return Some(z);
}
}

View File

@ -3735,21 +3735,23 @@ mod tests {
}
}
// #[test]
// fn z() {
// let base = super::generator::<pallas::Affine>();
// match base {
// OrchardFixedBases::CommitIvkR(inner) => inner.test_z(&Z, &U, NUM_WINDOWS),
// _ => unreachable!(),
// }
// }
#[test]
fn z() {
let base = super::generator::<pallas::Affine>();
match base {
OrchardFixedBases::CommitIvkR(inner) => inner.test_z(&Z, &U, NUM_WINDOWS),
_ => unreachable!(),
}
}
// #[test]
// fn z_short() {
// let base = super::generator::<pallas::Affine>();
// match base {
// OrchardFixedBases::CommitIvkR(inner) => inner.test_z(&Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT),
// _ => unreachable!(),
// }
// }
#[test]
fn z_short() {
let base = super::generator::<pallas::Affine>();
match base {
OrchardFixedBases::CommitIvkR(inner) => {
inner.test_z(&Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT)
}
_ => unreachable!(),
}
}
}

View File

@ -3733,21 +3733,23 @@ mod tests {
}
}
// #[test]
// fn z() {
// let base = super::generator::<pallas::Affine>();
// match base {
// OrchardFixedBases::NullifierK(inner) => inner.test_z(&Z, &U, NUM_WINDOWS),
// _ => unreachable!(),
// }
// }
#[test]
fn z() {
let base = super::generator::<pallas::Affine>();
match base {
OrchardFixedBases::NullifierK(inner) => inner.test_z(&Z, &U, NUM_WINDOWS),
_ => unreachable!(),
}
}
// #[test]
// fn z_short() {
// let base = super::generator::<pallas::Affine>();
// match base {
// OrchardFixedBases::NullifierK(inner) => inner.test_z(&Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT),
// _ => unreachable!(),
// }
// }
#[test]
fn z_short() {
let base = super::generator::<pallas::Affine>();
match base {
OrchardFixedBases::NullifierK(inner) => {
inner.test_z(&Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT)
}
_ => unreachable!(),
}
}
}

View File

@ -3735,21 +3735,23 @@ mod tests {
}
}
// #[test]
// fn z() {
// let base = super::generator::<pallas::Affine>();
// match base {
// OrchardFixedBases::ValueCommitR(inner) => inner.test_z(&Z, &U, NUM_WINDOWS),
// _ => unreachable!(),
// }
// }
#[test]
fn z() {
let base = super::generator::<pallas::Affine>();
match base {
OrchardFixedBases::ValueCommitR(inner) => inner.test_z(&Z, &U, NUM_WINDOWS),
_ => unreachable!(),
}
}
// #[test]
// fn z_short() {
// let base = super::generator::<pallas::Affine>();
// match base {
// OrchardFixedBases::ValueCommitR(inner) => inner.test_z(&Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT),
// _ => unreachable!(),
// }
// }
#[test]
fn z_short() {
let base = super::generator::<pallas::Affine>();
match base {
OrchardFixedBases::ValueCommitR(inner) => {
inner.test_z(&Z_SHORT, &U_SHORT, NUM_WINDOWS_SHORT)
}
_ => unreachable!(),
}
}
}