Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ColoCarletti committed Oct 4, 2024
1 parent 10636f9 commit 876459d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion math/src/circle/cosets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod tests {

#[test]
fn coset_generator_has_right_order() {
let coset = Coset::new(2, CirclePoint::generator().mul(3));
let coset = Coset::new(2, CirclePoint::generator().scalar_mul(3));
let generator_n = coset.get_generator();
assert_eq!(generator_n.repeated_double(2), CirclePoint::zero());
}
Expand Down
9 changes: 5 additions & 4 deletions math/src/circle/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ impl<F: IsField + HasCircleParams<F>> CirclePoint<F> {
}

/// Computes (a0, a1) + (b0, b1) = (a0 * b0 - a1 * b1, a0 * b1 + a1 * b0)
#[allow(clippy::should_implement_trait)]
pub fn add(a: Self, b: Self) -> Self {
let x = &a.x * &b.x - &a.y * &b.y;
let y = a.x * b.y + a.y * b.x;
CirclePoint { x, y }
}

/// Computes n * (x, y) = (x ,y) + ... + (x, y) n-times.
pub fn mul(self, mut scalar: u128) -> Self {
pub fn scalar_mul(self, mut scalar: u128) -> Self {
let mut res = Self::zero();
let mut cur = self;
loop {
Expand Down Expand Up @@ -224,13 +225,13 @@ mod tests {
#[test]
fn double_equals_mul_two() {
let g = G::generator();
assert_eq!(g.clone().double(), G::mul(g, 2))
assert_eq!(g.clone().double(), G::scalar_mul(g, 2))
}

#[test]
fn mul_eight_equals_double_three_times() {
let g = G::generator();
assert_eq!(g.clone().repeated_double(3), G::mul(g, 8))
assert_eq!(g.clone().repeated_double(3), G::scalar_mul(g, 8))
}

#[test]
Expand All @@ -243,7 +244,7 @@ mod tests {
#[test]
fn generator_g4_has_the_order_of_the_group() {
let g = G4::generator();
assert_eq!(g.mul(G4::group_order()), G4::zero())
assert_eq!(g.scalar_mul(G4::group_order()), G4::zero())
}

#[test]
Expand Down

0 comments on commit 876459d

Please sign in to comment.