This commit is contained in:
Srinath Setty 2024-09-19 11:30:00 -07:00
Родитель 1e60918472
Коммит a77c558047
3 изменённых файлов: 2 добавлений и 15 удалений

Просмотреть файл

@ -416,7 +416,7 @@ mod tests {
// compute n = 2^\ell
let n = ell.pow2();
// compute m = sqrt(n) = 2^{\ell/2}
let m = n.square_root();
let m = (n as f64).sqrt() as usize;
// compute vector-matrix product between L and Z viewed as a matrix
let LZ = (0..m)
@ -455,7 +455,7 @@ mod tests {
let ell = r.len();
assert!(ell % 2 == 0); // ensure ell is even
let n = ell.pow2();
let m = n.square_root();
let m = (n as f64).sqrt() as usize;
// compute row vector L
for i in 0..m {

Просмотреть файл

@ -1,16 +1,10 @@
pub trait Math {
fn square_root(self) -> usize;
fn pow2(self) -> usize;
fn get_bits(self, num_bits: usize) -> Vec<bool>;
fn log_2(self) -> usize;
}
impl Math for usize {
#[inline]
fn square_root(self) -> usize {
(self as f64).sqrt() as usize
}
#[inline]
fn pow2(self) -> usize {
let base: usize = 2;

Просмотреть файл

@ -27,17 +27,10 @@ impl ScalarFromPrimitives for bool {
pub trait ScalarBytesFromScalar {
fn decompress_scalar(s: &Scalar) -> ScalarBytes;
fn decompress_vector(s: &[Scalar]) -> Vec<ScalarBytes>;
}
impl ScalarBytesFromScalar for Scalar {
fn decompress_scalar(s: &Scalar) -> ScalarBytes {
ScalarBytes::from_bytes_mod_order(s.to_bytes())
}
fn decompress_vector(s: &[Scalar]) -> Vec<ScalarBytes> {
(0..s.len())
.map(|i| Scalar::decompress_scalar(&s[i]))
.collect::<Vec<ScalarBytes>>()
}
}