Skip to content

Commit

Permalink
refactor: Refactor trait imports in provider/traits.rs
Browse files Browse the repository at this point in the history
- Refactored `provider/traits.rs` to remove local definitions of helper traits.
- Incorporated `GroupOps`, `GroupOpsOwned`, and `ScalarMulOwned` from `group` module into `provider/traits.rs` to maintain functionality.
  • Loading branch information
huitseeker committed Dec 23, 2023
1 parent c3d81da commit 1585c84
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/provider/traits.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::traits::{commitment::ScalarMul, Group, TranscriptReprTrait};
use core::{
fmt::Debug,
ops::{Add, AddAssign, Sub, SubAssign},
};
use core::fmt::Debug;
use group::{GroupOps, GroupOpsOwned, ScalarMulOwned};
use serde::{Deserialize, Serialize};

/// Represents a compressed version of a group element
Expand All @@ -25,25 +23,6 @@ pub trait CompressedGroup:
fn decompress(&self) -> Option<Self::GroupElement>;
}

/// A helper trait for types with a group operation.
pub trait GroupOps<Rhs = Self, Output = Self>:
Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>
{
}

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T where
T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>
{
}

/// A helper trait for references with a group operation.
pub trait GroupOpsOwned<Rhs = Self, Output = Self>: for<'r> GroupOps<&'r Rhs, Output> {}
impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T where T: for<'r> GroupOps<&'r Rhs, Output> {}

/// A helper trait for references implementing group scalar multiplication.
pub trait ScalarMulOwned<Rhs, Output = Self>: for<'r> ScalarMul<&'r Rhs, Output> {}
impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T where T: for<'r> ScalarMul<&'r Rhs, Output> {}

/// A trait that defines extensions to the Group trait
pub trait DlogGroup:
Group
Expand Down

0 comments on commit 1585c84

Please sign in to comment.