Skip to content

Commit

Permalink
feat: provide conversions in both directions for keys, sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Mar 29, 2020
1 parent 57290b2 commit 757687e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,23 @@ impl From<G1> for PublicKey {
PublicKey(val)
}
}
impl From<PublicKey> for G1 {
fn from(val: PublicKey) -> Self {
val.0
}
}

impl From<Fr> for PrivateKey {
fn from(val: Fr) -> Self {
PrivateKey(val)
}
}

impl From<PrivateKey> for Fr {
fn from(val: PrivateKey) -> Self {
val.0
}
}
impl From<PrivateKey> for FrRepr {
fn from(val: PrivateKey) -> Self {
val.0.into_repr()
Expand Down
5 changes: 5 additions & 0 deletions src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ impl From<G2> for Signature {
Signature(val.into_affine())
}
}
impl From<Signature> for G2 {
fn from(val: Signature) -> Self {
val.0.into_projective()
}
}

impl From<G2Affine> for Signature {
fn from(val: G2Affine) -> Self {
Expand Down

0 comments on commit 757687e

Please sign in to comment.