Skip to content

Commit

Permalink
Implement AsRef for EncodedPoint (ZenGo-X#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai authored Aug 22, 2022
1 parent daebb16 commit 8b3b7a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/elliptic/curves/wrappers/encoded_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ pub(super) enum EncodedPointChoice<E: Curve> {
impl<E: Curve> Deref for EncodedPoint<E> {
type Target = [u8];
fn deref(&self) -> &[u8] {
self.as_ref()
}
}

impl<E: Curve> AsRef<[u8]> for EncodedPoint<E> {
fn as_ref(&self) -> &[u8] {
match &self.0 {
EncodedPointChoice::Compressed(bytes) => bytes.as_ref(),
EncodedPointChoice::Uncompressed(bytes) => bytes.as_ref(),
}
}
}
}

0 comments on commit 8b3b7a5

Please sign in to comment.