Skip to content

Commit

Permalink
add remaining conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
dknopik committed Jan 21, 2025
1 parent 273616b commit 19e5f34
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions bindings/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,24 @@ macro_rules! sig_variant_impl {
}
}

impl From<PublicKey> for $pk_aff {
fn from(pk: PublicKey) -> Self {
pk.point
}
}

impl<'a> From<&'a PublicKey> for &'a $pk_aff {
fn from(pk: &'a PublicKey) -> Self {
&pk.point
}
}

impl From<$pk_aff> for PublicKey {
fn from(point: $pk_aff) -> Self {
Self { point }
}
}

#[repr(transparent)]
#[derive(Debug, Clone, Copy)]
pub struct AggregatePublicKey {
Expand Down Expand Up @@ -1043,6 +1061,24 @@ macro_rules! sig_variant_impl {
}
}

impl From<AggregatePublicKey> for $pk {
fn from(pk: AggregatePublicKey) -> Self {
pk.point
}
}

impl<'a> From<&'a AggregatePublicKey> for &'a $pk {
fn from(pk: &'a AggregatePublicKey) -> Self {
&pk.point
}
}

impl From<$pk> for AggregatePublicKey {
fn from(point: $pk) -> Self {
Self { point }
}
}

#[repr(transparent)]
#[derive(Debug, Clone, Copy)]
pub struct Signature {
Expand Down Expand Up @@ -1653,6 +1689,24 @@ macro_rules! sig_variant_impl {
}
}

impl From<AggregateSignature> for $sig {
fn from(sig: AggregateSignature) -> Self {
sig.point
}
}

impl<'a> From<&'a AggregateSignature> for &'a $sig {
fn from(sig: &'a AggregateSignature) -> Self {
&sig.point
}
}

impl From<$sig> for AggregateSignature {
fn from(point: $sig) -> Self {
Self { point }
}
}

impl MultiPoint for [PublicKey] {
type Output = AggregatePublicKey;

Expand Down

0 comments on commit 19e5f34

Please sign in to comment.