mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +00:00
fixes to use references
This commit is contained in:
parent
ffc90e902b
commit
57da32fb82
@ -35,7 +35,7 @@ pub trait Frobenius<const D: usize>: OEF<D> {
|
|||||||
}
|
}
|
||||||
let arr = self.to_basefield_array();
|
let arr = self.to_basefield_array();
|
||||||
let k = (Self::BaseField::order() - 1u32) / (D as u64);
|
let k = (Self::BaseField::order() - 1u32) / (D as u64);
|
||||||
let z0 = Self::W.exp_biguint(k * count as u64);
|
let z0 = Self::W.exp_biguint(&(k * count as u64));
|
||||||
let mut res = [Self::BaseField::ZERO; D];
|
let mut res = [Self::BaseField::ZERO; D];
|
||||||
for (i, z) in z0.powers().take(D).enumerate() {
|
for (i, z) in z0.powers().take(D).enumerate() {
|
||||||
res[i] = arr[i] * z;
|
res[i] = arr[i] * z;
|
||||||
|
|||||||
@ -261,7 +261,7 @@ mod tests {
|
|||||||
type F = QuadraticCrandallField;
|
type F = QuadraticCrandallField;
|
||||||
let x = F::rand();
|
let x = F::rand();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
x.exp_biguint(<F as FieldExtension<2>>::BaseField::order()),
|
x.exp_biguint(&<F as FieldExtension<2>>::BaseField::order()),
|
||||||
x.frobenius()
|
x.frobenius()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -342,7 +342,7 @@ mod tests {
|
|||||||
const D: usize = 4;
|
const D: usize = 4;
|
||||||
let x = F::rand();
|
let x = F::rand();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
x.exp_biguint(<F as FieldExtension<D>>::BaseField::order()),
|
x.exp_biguint(&<F as FieldExtension<D>>::BaseField::order()),
|
||||||
x.frobenius()
|
x.frobenius()
|
||||||
);
|
);
|
||||||
for count in 2..D {
|
for count in 2..D {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ impl<const D: usize> ExtensionTarget<D> {
|
|||||||
}
|
}
|
||||||
let arr = self.to_target_array();
|
let arr = self.to_target_array();
|
||||||
let k = (F::order() - 1u32) / (D as u64);
|
let k = (F::order() - 1u32) / (D as u64);
|
||||||
let z0 = F::Extension::W.exp_biguint(k * count as u64);
|
let z0 = F::Extension::W.exp_biguint(&(k * count as u64));
|
||||||
let zs = z0
|
let zs = z0
|
||||||
.powers()
|
.powers()
|
||||||
.take(D)
|
.take(D)
|
||||||
|
|||||||
@ -220,7 +220,7 @@ pub trait Field:
|
|||||||
self.exp(power as u64)
|
self.exp(power as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exp_biguint(&self, power: BigUint) -> Self {
|
fn exp_biguint(&self, power: &BigUint) -> Self {
|
||||||
let digits = power.to_u32_digits();
|
let digits = power.to_u32_digits();
|
||||||
let radix = 1u64 << 32;
|
let radix = 1u64 << 32;
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ pub trait Field:
|
|||||||
let numerator = p.clone() + &p_minus_1 * n;
|
let numerator = p.clone() + &p_minus_1 * n;
|
||||||
if numerator.clone() % k == BigUint::zero() {
|
if numerator.clone() % k == BigUint::zero() {
|
||||||
let power = (numerator / k) % p_minus_1;
|
let power = (numerator / k) % p_minus_1;
|
||||||
return self.exp_biguint(power);
|
return self.exp_biguint(&power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic!(
|
panic!(
|
||||||
|
|||||||
@ -242,8 +242,8 @@ macro_rules! test_field_arithmetic {
|
|||||||
let big_pow = &pow + &mul_group_order * cycles;
|
let big_pow = &pow + &mul_group_order * cycles;
|
||||||
let big_pow_wrong = &pow + &mul_group_order * cycles + 1u32;
|
let big_pow_wrong = &pow + &mul_group_order * cycles + 1u32;
|
||||||
|
|
||||||
assert_eq!(base.exp_biguint(pow.clone()), base.exp_biguint(big_pow));
|
assert_eq!(base.exp_biguint(&pow), base.exp_biguint(&big_pow));
|
||||||
assert_ne!(base.exp_biguint(pow), base.exp_biguint(big_pow_wrong));
|
assert_ne!(base.exp_biguint(&pow), base.exp_biguint(&big_pow_wrong));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user