Skip to content

Commit

Permalink
Conversion helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Sep 13, 2024
1 parent ccb4779 commit 6867897
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,6 @@ impl<S: Suite> Secret<S> {
#[derive(Debug, Copy, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct Public<S: Suite>(pub AffinePoint<S>);

impl<S: Suite> Public<S> {
pub fn from(value: AffinePoint<S>) -> Self {
Public(value)
}
}

/// VRF input point generic over the cipher suite.
#[derive(Debug, Clone, Copy, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct Input<S: Suite>(pub AffinePoint<S>);
Expand All @@ -261,7 +255,7 @@ impl<S: Suite> Input<S> {
}

/// Construct from inner affine point.
pub fn from(value: <S as Suite>::Affine) -> Self {
pub fn from(value: AffinePoint<S>) -> Self {
Input(value)
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,41 @@ macro_rules! suite_types {
#[cfg(feature = "ring")]
#[allow(dead_code)]
pub type RingProof = $crate::ring::Proof<$suite>;

impl From<AffinePoint> for Public {
fn from(p: AffinePoint) -> Self {
Self(p)
}
}

impl From<Public> for AffinePoint {
fn from(p: Public) -> Self {
p.0
}
}

impl From<AffinePoint> for Input {
fn from(p: AffinePoint) -> Self {
Self(p)
}
}

impl From<Input> for AffinePoint {
fn from(p: Input) -> Self {
p.0
}
}

impl From<AffinePoint> for Output {
fn from(p: AffinePoint) -> Self {
Self(p)
}
}

impl From<Output> for AffinePoint {
fn from(p: Output) -> Self {
p.0
}
}
};
}

0 comments on commit 6867897

Please sign in to comment.